documentation.d.ts 3.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511
  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. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** 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 */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** 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 */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** 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 */
  689. static readonly GEQUAL: number;
  690. /** 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 */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  823. static readonly SCALEMODE_FLOOR: number;
  824. /** Defines that texture rescaling will look for the nearest power of 2 size */
  825. static readonly SCALEMODE_NEAREST: number;
  826. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  827. static readonly SCALEMODE_CEILING: number;
  828. /**
  829. * The dirty texture flag value
  830. */
  831. static readonly MATERIAL_TextureDirtyFlag: number;
  832. /**
  833. * The dirty light flag value
  834. */
  835. static readonly MATERIAL_LightDirtyFlag: number;
  836. /**
  837. * The dirty fresnel flag value
  838. */
  839. static readonly MATERIAL_FresnelDirtyFlag: number;
  840. /**
  841. * The dirty attribute flag value
  842. */
  843. static readonly MATERIAL_AttributesDirtyFlag: number;
  844. /**
  845. * The dirty misc flag value
  846. */
  847. static readonly MATERIAL_MiscDirtyFlag: number;
  848. /**
  849. * The all dirty flag value
  850. */
  851. static readonly MATERIAL_AllDirtyFlag: number;
  852. /**
  853. * Returns the triangle fill mode
  854. */
  855. static readonly MATERIAL_TriangleFillMode: number;
  856. /**
  857. * Returns the wireframe mode
  858. */
  859. static readonly MATERIAL_WireFrameFillMode: number;
  860. /**
  861. * Returns the point fill mode
  862. */
  863. static readonly MATERIAL_PointFillMode: number;
  864. /**
  865. * Returns the point list draw mode
  866. */
  867. static readonly MATERIAL_PointListDrawMode: number;
  868. /**
  869. * Returns the line list draw mode
  870. */
  871. static readonly MATERIAL_LineListDrawMode: number;
  872. /**
  873. * Returns the line loop draw mode
  874. */
  875. static readonly MATERIAL_LineLoopDrawMode: number;
  876. /**
  877. * Returns the line strip draw mode
  878. */
  879. static readonly MATERIAL_LineStripDrawMode: number;
  880. /**
  881. * Returns the triangle strip draw mode
  882. */
  883. static readonly MATERIAL_TriangleStripDrawMode: number;
  884. /**
  885. * Returns the triangle fan draw mode
  886. */
  887. static readonly MATERIAL_TriangleFanDrawMode: number;
  888. /**
  889. * Stores the clock-wise side orientation
  890. */
  891. static readonly MATERIAL_ClockWiseSideOrientation: number;
  892. /**
  893. * Stores the counter clock-wise side orientation
  894. */
  895. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  896. /**
  897. * Nothing
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_NothingTrigger: number;
  901. /**
  902. * On pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickTrigger: number;
  906. /**
  907. * On left pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLeftPickTrigger: number;
  911. /**
  912. * On right pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnRightPickTrigger: number;
  916. /**
  917. * On center pick
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnCenterPickTrigger: number;
  921. /**
  922. * On pick down
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnPickDownTrigger: number;
  926. /**
  927. * On double pick
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnDoublePickTrigger: number;
  931. /**
  932. * On pick up
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnPickUpTrigger: number;
  936. /**
  937. * On pick out.
  938. * This trigger will only be raised if you also declared a OnPickDown
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickOutTrigger: number;
  942. /**
  943. * On long press
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnLongPressTrigger: number;
  947. /**
  948. * On pointer over
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOverTrigger: number;
  952. /**
  953. * On pointer out
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPointerOutTrigger: number;
  957. /**
  958. * On every frame
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnEveryFrameTrigger: number;
  962. /**
  963. * On intersection enter
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionEnterTrigger: number;
  967. /**
  968. * On intersection exit
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnIntersectionExitTrigger: number;
  972. /**
  973. * On key down
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyDownTrigger: number;
  977. /**
  978. * On key up
  979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnKeyUpTrigger: number;
  982. /**
  983. * Billboard mode will only apply to Y axis
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  986. /**
  987. * Billboard mode will apply to all axes
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  990. /**
  991. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  994. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  995. * Test order :
  996. * Is the bounding sphere outside the frustum ?
  997. * If not, are the bounding box vertices outside the frustum ?
  998. * It not, then the cullable object is in the frustum.
  999. */
  1000. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1001. /** Culling strategy : Bounding Sphere Only.
  1002. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1003. * It's also less accurate than the standard because some not visible objects can still be selected.
  1004. * Test : is the bounding sphere outside the frustum ?
  1005. * If not, then the cullable object is in the frustum.
  1006. */
  1007. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1008. /** Culling strategy : Optimistic Inclusion.
  1009. * This in an inclusion test first, then the standard exclusion test.
  1010. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1011. * 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.
  1012. * Anyway, it's as accurate as the standard strategy.
  1013. * Test :
  1014. * Is the cullable object bounding sphere center in the frustum ?
  1015. * If not, apply the default culling strategy.
  1016. */
  1017. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1018. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1019. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1020. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1021. * 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.
  1022. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1023. * Test :
  1024. * Is the cullable object bounding sphere center in the frustum ?
  1025. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1026. */
  1027. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1028. /**
  1029. * No logging while loading
  1030. */
  1031. static readonly SCENELOADER_NO_LOGGING: number;
  1032. /**
  1033. * Minimal logging while loading
  1034. */
  1035. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1036. /**
  1037. * Summary logging while loading
  1038. */
  1039. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1040. /**
  1041. * Detailled logging while loading
  1042. */
  1043. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1044. }
  1045. }
  1046. declare module BABYLON {
  1047. /**
  1048. * This represents the required contract to create a new type of texture loader.
  1049. */
  1050. export interface IInternalTextureLoader {
  1051. /**
  1052. * Defines wether the loader supports cascade loading the different faces.
  1053. */
  1054. supportCascades: boolean;
  1055. /**
  1056. * This returns if the loader support the current file information.
  1057. * @param extension defines the file extension of the file being loaded
  1058. * @returns true if the loader can load the specified file
  1059. */
  1060. canLoad(extension: string): boolean;
  1061. /**
  1062. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1063. * @param data contains the texture data
  1064. * @param texture defines the BabylonJS internal texture
  1065. * @param createPolynomials will be true if polynomials have been requested
  1066. * @param onLoad defines the callback to trigger once the texture is ready
  1067. * @param onError defines the callback to trigger in case of error
  1068. */
  1069. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1070. /**
  1071. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1072. * @param data contains the texture data
  1073. * @param texture defines the BabylonJS internal texture
  1074. * @param callback defines the method to call once ready to upload
  1075. */
  1076. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1077. }
  1078. }
  1079. declare module BABYLON {
  1080. /**
  1081. * Class used to store and describe the pipeline context associated with an effect
  1082. */
  1083. export interface IPipelineContext {
  1084. /**
  1085. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1086. */
  1087. isAsync: boolean;
  1088. /**
  1089. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1090. */
  1091. isReady: boolean;
  1092. /** @hidden */
  1093. _getVertexShaderCode(): string | null;
  1094. /** @hidden */
  1095. _getFragmentShaderCode(): string | null;
  1096. /** @hidden */
  1097. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1098. }
  1099. }
  1100. declare module BABYLON {
  1101. /**
  1102. * Class used to store gfx data (like WebGLBuffer)
  1103. */
  1104. export class DataBuffer {
  1105. /**
  1106. * Gets or sets the number of objects referencing this buffer
  1107. */
  1108. references: number;
  1109. /** Gets or sets the size of the underlying buffer */
  1110. capacity: number;
  1111. /**
  1112. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1113. */
  1114. is32Bits: boolean;
  1115. /**
  1116. * Gets the underlying buffer
  1117. */
  1118. get underlyingResource(): any;
  1119. }
  1120. }
  1121. declare module BABYLON {
  1122. /** @hidden */
  1123. export interface IShaderProcessor {
  1124. attributeProcessor?: (attribute: string) => string;
  1125. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1126. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1127. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1128. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1129. lineProcessor?: (line: string, isFragment: boolean) => string;
  1130. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1131. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface ProcessingOptions {
  1137. defines: string[];
  1138. indexParameters: any;
  1139. isFragment: boolean;
  1140. shouldUseHighPrecisionShader: boolean;
  1141. supportsUniformBuffers: boolean;
  1142. shadersRepository: string;
  1143. includesShadersStore: {
  1144. [key: string]: string;
  1145. };
  1146. processor?: IShaderProcessor;
  1147. version: string;
  1148. platformName: string;
  1149. lookForClosingBracketForUniformBuffer?: boolean;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /** @hidden */
  1154. export class ShaderCodeNode {
  1155. line: string;
  1156. children: ShaderCodeNode[];
  1157. additionalDefineKey?: string;
  1158. additionalDefineValue?: string;
  1159. isValid(preprocessors: {
  1160. [key: string]: string;
  1161. }): boolean;
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderCodeCursor {
  1170. private _lines;
  1171. lineIndex: number;
  1172. get currentLine(): string;
  1173. get canRead(): boolean;
  1174. set lines(value: string[]);
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1180. process(preprocessors: {
  1181. [key: string]: string;
  1182. }, options: ProcessingOptions): string;
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderDefineExpression {
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. private static _OperatorPriority;
  1192. private static _Stack;
  1193. static postfixToInfix(postfix: string[]): string;
  1194. static infixToPostfix(infix: string): string[];
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderCodeTestNode extends ShaderCodeNode {
  1200. testExpression: ShaderDefineExpression;
  1201. isValid(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1209. define: string;
  1210. not: boolean;
  1211. constructor(define: string, not?: boolean);
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1220. leftOperand: ShaderDefineExpression;
  1221. rightOperand: ShaderDefineExpression;
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module BABYLON {
  1228. /** @hidden */
  1229. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1230. leftOperand: ShaderDefineExpression;
  1231. rightOperand: ShaderDefineExpression;
  1232. isTrue(preprocessors: {
  1233. [key: string]: string;
  1234. }): boolean;
  1235. }
  1236. }
  1237. declare module BABYLON {
  1238. /** @hidden */
  1239. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1240. define: string;
  1241. operand: string;
  1242. testValue: string;
  1243. constructor(define: string, operand: string, testValue: string);
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to enable access to offline support
  1252. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1253. */
  1254. export interface IOfflineProvider {
  1255. /**
  1256. * Gets a boolean indicating if scene must be saved in the database
  1257. */
  1258. enableSceneOffline: boolean;
  1259. /**
  1260. * Gets a boolean indicating if textures must be saved in the database
  1261. */
  1262. enableTexturesOffline: boolean;
  1263. /**
  1264. * Open the offline support and make it available
  1265. * @param successCallback defines the callback to call on success
  1266. * @param errorCallback defines the callback to call on error
  1267. */
  1268. open(successCallback: () => void, errorCallback: () => void): void;
  1269. /**
  1270. * Loads an image from the offline support
  1271. * @param url defines the url to load from
  1272. * @param image defines the target DOM image
  1273. */
  1274. loadImage(url: string, image: HTMLImageElement): void;
  1275. /**
  1276. * Loads a file from offline support
  1277. * @param url defines the URL to load from
  1278. * @param sceneLoaded defines a callback to call on success
  1279. * @param progressCallBack defines a callback to call when progress changed
  1280. * @param errorCallback defines a callback to call on error
  1281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1282. */
  1283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1284. }
  1285. }
  1286. declare module BABYLON {
  1287. /**
  1288. * Class used to help managing file picking and drag'n'drop
  1289. * File Storage
  1290. */
  1291. export class FilesInputStore {
  1292. /**
  1293. * List of files ready to be loaded
  1294. */
  1295. static FilesToLoad: {
  1296. [key: string]: File;
  1297. };
  1298. }
  1299. }
  1300. declare module BABYLON {
  1301. /**
  1302. * Class used to define a retry strategy when error happens while loading assets
  1303. */
  1304. export class RetryStrategy {
  1305. /**
  1306. * Function used to defines an exponential back off strategy
  1307. * @param maxRetries defines the maximum number of retries (3 by default)
  1308. * @param baseInterval defines the interval between retries
  1309. * @returns the strategy function to use
  1310. */
  1311. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /**
  1316. * @ignore
  1317. * Application error to support additional information when loading a file
  1318. */
  1319. export abstract class BaseError extends Error {
  1320. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /** @ignore */
  1325. export class LoadFileError extends BaseError {
  1326. request?: WebRequest;
  1327. file?: File;
  1328. /**
  1329. * Creates a new LoadFileError
  1330. * @param message defines the message of the error
  1331. * @param request defines the optional web request
  1332. * @param file defines the optional file
  1333. */
  1334. constructor(message: string, object?: WebRequest | File);
  1335. }
  1336. /** @ignore */
  1337. export class RequestFileError extends BaseError {
  1338. request: WebRequest;
  1339. /**
  1340. * Creates a new LoadFileError
  1341. * @param message defines the message of the error
  1342. * @param request defines the optional web request
  1343. */
  1344. constructor(message: string, request: WebRequest);
  1345. }
  1346. /** @ignore */
  1347. export class ReadFileError extends BaseError {
  1348. file: File;
  1349. /**
  1350. * Creates a new ReadFileError
  1351. * @param message defines the message of the error
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, file: File);
  1355. }
  1356. /**
  1357. * @hidden
  1358. */
  1359. export class FileTools {
  1360. /**
  1361. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1362. */
  1363. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1364. /**
  1365. * Gets or sets the base URL to use to load assets
  1366. */
  1367. static BaseUrl: string;
  1368. /**
  1369. * Default behaviour for cors in the application.
  1370. * It can be a string if the expected behavior is identical in the entire app.
  1371. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1372. */
  1373. static CorsBehavior: string | ((url: string | string[]) => string);
  1374. /**
  1375. * Gets or sets a function used to pre-process url before using them to load assets
  1376. */
  1377. static PreprocessUrl: (url: string) => string;
  1378. /**
  1379. * Removes unwanted characters from an url
  1380. * @param url defines the url to clean
  1381. * @returns the cleaned url
  1382. */
  1383. private static _CleanUrl;
  1384. /**
  1385. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1386. * @param url define the url we are trying
  1387. * @param element define the dom element where to configure the cors policy
  1388. */
  1389. static SetCorsBehavior(url: string | string[], element: {
  1390. crossOrigin: string | null;
  1391. }): void;
  1392. /**
  1393. * Loads an image as an HTMLImageElement.
  1394. * @param input url string, ArrayBuffer, or Blob to load
  1395. * @param onLoad callback called when the image successfully loads
  1396. * @param onError callback called when the image fails to load
  1397. * @param offlineProvider offline provider for caching
  1398. * @param mimeType optional mime type
  1399. * @returns the HTMLImageElement of the loaded image
  1400. */
  1401. 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>;
  1402. /**
  1403. * Reads a file from a File object
  1404. * @param file defines the file to load
  1405. * @param onSuccess defines the callback to call when data is loaded
  1406. * @param onProgress defines the callback to call during loading process
  1407. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1408. * @param onError defines the callback to call when an error occurs
  1409. * @returns a file request object
  1410. */
  1411. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1412. /**
  1413. * Loads a file from a url
  1414. * @param url url to load
  1415. * @param onSuccess callback called when the file successfully loads
  1416. * @param onProgress callback called while file is loading (if the server supports this mode)
  1417. * @param offlineProvider defines the offline provider for caching
  1418. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1419. * @param onError callback called when the file fails to load
  1420. * @returns a file request object
  1421. */
  1422. 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;
  1423. /**
  1424. * Loads a file
  1425. * @param url url to load
  1426. * @param onSuccess callback called when the file successfully loads
  1427. * @param onProgress callback called while file is loading (if the server supports this mode)
  1428. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1429. * @param onError callback called when the file fails to load
  1430. * @param onOpened callback called when the web request is opened
  1431. * @returns a file request object
  1432. */
  1433. 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;
  1434. /**
  1435. * Checks if the loaded document was accessed via `file:`-Protocol.
  1436. * @returns boolean
  1437. */
  1438. static IsFileURL(): boolean;
  1439. }
  1440. }
  1441. declare module BABYLON {
  1442. /** @hidden */
  1443. export class ShaderProcessor {
  1444. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1445. private static _ProcessPrecision;
  1446. private static _ExtractOperation;
  1447. private static _BuildSubExpression;
  1448. private static _BuildExpression;
  1449. private static _MoveCursorWithinIf;
  1450. private static _MoveCursor;
  1451. private static _EvaluatePreProcessors;
  1452. private static _PreparePreProcessors;
  1453. private static _ProcessShaderConversion;
  1454. private static _ProcessIncludes;
  1455. /**
  1456. * Loads a file from a url
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param offlineProvider defines the offline provider for caching
  1461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1462. * @param onError callback called when the file fails to load
  1463. * @returns a file request object
  1464. * @hidden
  1465. */
  1466. 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;
  1467. }
  1468. }
  1469. declare module BABYLON {
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor4Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. a: float;
  1478. }
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor3Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector4Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. w: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector3Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector2Like {
  1508. x: float;
  1509. y: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IMatrixLike {
  1515. toArray(): DeepImmutable<Float32Array>;
  1516. updateFlag: int;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IViewportLike {
  1522. x: float;
  1523. y: float;
  1524. width: float;
  1525. height: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IPlaneLike {
  1531. normal: IVector3Like;
  1532. d: float;
  1533. normalize(): void;
  1534. }
  1535. }
  1536. declare module BABYLON {
  1537. /**
  1538. * Interface used to define common properties for effect fallbacks
  1539. */
  1540. export interface IEffectFallbacks {
  1541. /**
  1542. * Removes the defines that should be removed when falling back.
  1543. * @param currentDefines defines the current define statements for the shader.
  1544. * @param effect defines the current effect we try to compile
  1545. * @returns The resulting defines with defines of the current rank removed.
  1546. */
  1547. reduce(currentDefines: string, effect: Effect): string;
  1548. /**
  1549. * Removes the fallback from the bound mesh.
  1550. */
  1551. unBindMesh(): void;
  1552. /**
  1553. * Checks to see if more fallbacks are still availible.
  1554. */
  1555. hasMoreFallbacks: boolean;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to evalaute queries containing `and` and `or` operators
  1561. */
  1562. export class AndOrNotEvaluator {
  1563. /**
  1564. * Evaluate a query
  1565. * @param query defines the query to evaluate
  1566. * @param evaluateCallback defines the callback used to filter result
  1567. * @returns true if the query matches
  1568. */
  1569. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1570. private static _HandleParenthesisContent;
  1571. private static _SimplifyNegation;
  1572. }
  1573. }
  1574. declare module BABYLON {
  1575. /**
  1576. * Class used to store custom tags
  1577. */
  1578. export class Tags {
  1579. /**
  1580. * Adds support for tags on the given object
  1581. * @param obj defines the object to use
  1582. */
  1583. static EnableFor(obj: any): void;
  1584. /**
  1585. * Removes tags support
  1586. * @param obj defines the object to use
  1587. */
  1588. static DisableFor(obj: any): void;
  1589. /**
  1590. * Gets a boolean indicating if the given object has tags
  1591. * @param obj defines the object to use
  1592. * @returns a boolean
  1593. */
  1594. static HasTags(obj: any): boolean;
  1595. /**
  1596. * Gets the tags available on a given object
  1597. * @param obj defines the object to use
  1598. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1599. * @returns the tags
  1600. */
  1601. static GetTags(obj: any, asString?: boolean): any;
  1602. /**
  1603. * Adds tags to an object
  1604. * @param obj defines the object to use
  1605. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1606. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1607. */
  1608. static AddTagsTo(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _AddTagTo(obj: any, tag: string): void;
  1613. /**
  1614. * Removes specific tags from a specific object
  1615. * @param obj defines the object to use
  1616. * @param tagsString defines the tags to remove
  1617. */
  1618. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1619. /**
  1620. * @hidden
  1621. */
  1622. static _RemoveTagFrom(obj: any, tag: string): void;
  1623. /**
  1624. * Defines if tags hosted on an object match a given query
  1625. * @param obj defines the object to use
  1626. * @param tagsQuery defines the tag query
  1627. * @returns a boolean
  1628. */
  1629. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1630. }
  1631. }
  1632. declare module BABYLON {
  1633. /**
  1634. * Scalar computation library
  1635. */
  1636. export class Scalar {
  1637. /**
  1638. * Two pi constants convenient for computation.
  1639. */
  1640. static TwoPi: number;
  1641. /**
  1642. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1643. * @param a number
  1644. * @param b number
  1645. * @param epsilon (default = 1.401298E-45)
  1646. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1647. */
  1648. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1649. /**
  1650. * Returns a string : the upper case translation of the number i to hexadecimal.
  1651. * @param i number
  1652. * @returns the upper case translation of the number i to hexadecimal.
  1653. */
  1654. static ToHex(i: number): string;
  1655. /**
  1656. * Returns -1 if value is negative and +1 is value is positive.
  1657. * @param value the value
  1658. * @returns the value itself if it's equal to zero.
  1659. */
  1660. static Sign(value: number): number;
  1661. /**
  1662. * Returns the value itself if it's between min and max.
  1663. * Returns min if the value is lower than min.
  1664. * Returns max if the value is greater than max.
  1665. * @param value the value to clmap
  1666. * @param min the min value to clamp to (default: 0)
  1667. * @param max the max value to clamp to (default: 1)
  1668. * @returns the clamped value
  1669. */
  1670. static Clamp(value: number, min?: number, max?: number): number;
  1671. /**
  1672. * the log2 of value.
  1673. * @param value the value to compute log2 of
  1674. * @returns the log2 of value.
  1675. */
  1676. static Log2(value: number): number;
  1677. /**
  1678. * Loops the value, so that it is never larger than length and never smaller than 0.
  1679. *
  1680. * This is similar to the modulo operator but it works with floating point numbers.
  1681. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1682. * With t = 5 and length = 2.5, the result would be 0.0.
  1683. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1684. * @param value the value
  1685. * @param length the length
  1686. * @returns the looped value
  1687. */
  1688. static Repeat(value: number, length: number): number;
  1689. /**
  1690. * Normalize the value between 0.0 and 1.0 using min and max values
  1691. * @param value value to normalize
  1692. * @param min max to normalize between
  1693. * @param max min to normalize between
  1694. * @returns the normalized value
  1695. */
  1696. static Normalize(value: number, min: number, max: number): number;
  1697. /**
  1698. * Denormalize the value from 0.0 and 1.0 using min and max values
  1699. * @param normalized value to denormalize
  1700. * @param min max to denormalize between
  1701. * @param max min to denormalize between
  1702. * @returns the denormalized value
  1703. */
  1704. static Denormalize(normalized: number, min: number, max: number): number;
  1705. /**
  1706. * Calculates the shortest difference between two given angles given in degrees.
  1707. * @param current current angle in degrees
  1708. * @param target target angle in degrees
  1709. * @returns the delta
  1710. */
  1711. static DeltaAngle(current: number, target: number): number;
  1712. /**
  1713. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1714. * @param tx value
  1715. * @param length length
  1716. * @returns The returned value will move back and forth between 0 and length
  1717. */
  1718. static PingPong(tx: number, length: number): number;
  1719. /**
  1720. * Interpolates between min and max with smoothing at the limits.
  1721. *
  1722. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1723. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1724. * @param from from
  1725. * @param to to
  1726. * @param tx value
  1727. * @returns the smooth stepped value
  1728. */
  1729. static SmoothStep(from: number, to: number, tx: number): number;
  1730. /**
  1731. * Moves a value current towards target.
  1732. *
  1733. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1734. * Negative values of maxDelta pushes the value away from target.
  1735. * @param current current value
  1736. * @param target target value
  1737. * @param maxDelta max distance to move
  1738. * @returns resulting value
  1739. */
  1740. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1741. /**
  1742. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1743. *
  1744. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1745. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1746. * @param current current value
  1747. * @param target target value
  1748. * @param maxDelta max distance to move
  1749. * @returns resulting angle
  1750. */
  1751. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1752. /**
  1753. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1754. * @param start start value
  1755. * @param end target value
  1756. * @param amount amount to lerp between
  1757. * @returns the lerped value
  1758. */
  1759. static Lerp(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1762. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static LerpAngle(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1771. * @param a start value
  1772. * @param b target value
  1773. * @param value value between a and b
  1774. * @returns the inverseLerp value
  1775. */
  1776. static InverseLerp(a: number, b: number, value: number): number;
  1777. /**
  1778. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1779. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1780. * @param value1 spline value
  1781. * @param tangent1 spline value
  1782. * @param value2 spline value
  1783. * @param tangent2 spline value
  1784. * @param amount input value
  1785. * @returns hermite result
  1786. */
  1787. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1788. /**
  1789. * Returns a random float number between and min and max values
  1790. * @param min min value of random
  1791. * @param max max value of random
  1792. * @returns random value
  1793. */
  1794. static RandomRange(min: number, max: number): number;
  1795. /**
  1796. * This function returns percentage of a number in a given range.
  1797. *
  1798. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1799. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1800. * @param number to convert to percentage
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the percentage
  1804. */
  1805. static RangeToPercent(number: number, min: number, max: number): number;
  1806. /**
  1807. * This function returns number that corresponds to the percentage in a given range.
  1808. *
  1809. * PercentToRange(0.34,0,100) will return 34.
  1810. * @param percent to convert to number
  1811. * @param min min range
  1812. * @param max max range
  1813. * @returns the number
  1814. */
  1815. static PercentToRange(percent: number, min: number, max: number): number;
  1816. /**
  1817. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1818. * @param angle The angle to normalize in radian.
  1819. * @return The converted angle.
  1820. */
  1821. static NormalizeRadians(angle: number): number;
  1822. }
  1823. }
  1824. declare module BABYLON {
  1825. /**
  1826. * Constant used to convert a value to gamma space
  1827. * @ignorenaming
  1828. */
  1829. export const ToGammaSpace: number;
  1830. /**
  1831. * Constant used to convert a value to linear space
  1832. * @ignorenaming
  1833. */
  1834. export const ToLinearSpace = 2.2;
  1835. /**
  1836. * Constant used to define the minimal number value in Babylon.js
  1837. * @ignorenaming
  1838. */
  1839. let Epsilon: number;
  1840. }
  1841. declare module BABYLON {
  1842. /**
  1843. * Class used to represent a viewport on screen
  1844. */
  1845. export class Viewport {
  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 Viewport object located at (x, y) and sized (width, height)
  1856. * @param x defines viewport left coordinate
  1857. * @param y defines viewport top coordinate
  1858. * @param width defines the viewport width
  1859. * @param height defines the viewport height
  1860. */
  1861. constructor(
  1862. /** viewport left coordinate */
  1863. x: number,
  1864. /** viewport top coordinate */
  1865. y: number,
  1866. /**viewport width */
  1867. width: number,
  1868. /** viewport height */
  1869. height: number);
  1870. /**
  1871. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1872. * @param renderWidth defines the rendering width
  1873. * @param renderHeight defines the rendering height
  1874. * @returns a new Viewport
  1875. */
  1876. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1877. /**
  1878. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1879. * @param renderWidth defines the rendering width
  1880. * @param renderHeight defines the rendering height
  1881. * @param ref defines the target viewport
  1882. * @returns the current viewport
  1883. */
  1884. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1885. /**
  1886. * Returns a new Viewport copied from the current one
  1887. * @returns a new Viewport
  1888. */
  1889. clone(): Viewport;
  1890. }
  1891. }
  1892. declare module BABYLON {
  1893. /**
  1894. * Class containing a set of static utilities functions for arrays.
  1895. */
  1896. export class ArrayTools {
  1897. /**
  1898. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1899. * @param size the number of element to construct and put in the array
  1900. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1901. * @returns a new array filled with new objects
  1902. */
  1903. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1904. }
  1905. }
  1906. declare module BABYLON {
  1907. /**
  1908. * Represens a plane by the equation ax + by + cz + d = 0
  1909. */
  1910. export class Plane {
  1911. private static _TmpMatrix;
  1912. /**
  1913. * Normal of the plane (a,b,c)
  1914. */
  1915. normal: Vector3;
  1916. /**
  1917. * d component of the plane
  1918. */
  1919. d: number;
  1920. /**
  1921. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1922. * @param a a component of the plane
  1923. * @param b b component of the plane
  1924. * @param c c component of the plane
  1925. * @param d d component of the plane
  1926. */
  1927. constructor(a: number, b: number, c: number, d: number);
  1928. /**
  1929. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1930. */
  1931. asArray(): number[];
  1932. /**
  1933. * @returns a new plane copied from the current Plane.
  1934. */
  1935. clone(): Plane;
  1936. /**
  1937. * @returns the string "Plane".
  1938. */
  1939. getClassName(): string;
  1940. /**
  1941. * @returns the Plane hash code.
  1942. */
  1943. getHashCode(): number;
  1944. /**
  1945. * Normalize the current Plane in place.
  1946. * @returns the updated Plane.
  1947. */
  1948. normalize(): Plane;
  1949. /**
  1950. * Applies a transformation the plane and returns the result
  1951. * @param transformation the transformation matrix to be applied to the plane
  1952. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1953. */
  1954. transform(transformation: DeepImmutable<Matrix>): Plane;
  1955. /**
  1956. * Compute the dot product between the point and the plane normal
  1957. * @param point point to calculate the dot product with
  1958. * @returns the dot product (float) of the point coordinates and the plane normal.
  1959. */
  1960. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1961. /**
  1962. * Updates the current Plane from the plane defined by the three given points.
  1963. * @param point1 one of the points used to contruct the plane
  1964. * @param point2 one of the points used to contruct the plane
  1965. * @param point3 one of the points used to contruct the plane
  1966. * @returns the updated Plane.
  1967. */
  1968. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1969. /**
  1970. * Checks if the plane is facing a given direction
  1971. * @param direction the direction to check if the plane is facing
  1972. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1973. * @returns True is the vector "direction" is the same side than the plane normal.
  1974. */
  1975. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1976. /**
  1977. * Calculates the distance to a point
  1978. * @param point point to calculate distance to
  1979. * @returns the signed distance (float) from the given point to the Plane.
  1980. */
  1981. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1982. /**
  1983. * Creates a plane from an array
  1984. * @param array the array to create a plane from
  1985. * @returns a new Plane from the given array.
  1986. */
  1987. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1988. /**
  1989. * Creates a plane from three points
  1990. * @param point1 point used to create the plane
  1991. * @param point2 point used to create the plane
  1992. * @param point3 point used to create the plane
  1993. * @returns a new Plane defined by the three given points.
  1994. */
  1995. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1996. /**
  1997. * Creates a plane from an origin point and a normal
  1998. * @param origin origin of the plane to be constructed
  1999. * @param normal normal of the plane to be constructed
  2000. * @returns a new Plane the normal vector to this plane at the given origin point.
  2001. * Note : the vector "normal" is updated because normalized.
  2002. */
  2003. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2004. /**
  2005. * Calculates the distance from a plane and a point
  2006. * @param origin origin of the plane to be constructed
  2007. * @param normal normal of the plane to be constructed
  2008. * @param point point to calculate distance to
  2009. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2010. */
  2011. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2012. }
  2013. }
  2014. declare module BABYLON {
  2015. /**
  2016. * Class representing a vector containing 2 coordinates
  2017. */
  2018. export class Vector2 {
  2019. /** defines the first coordinate */
  2020. x: number;
  2021. /** defines the second coordinate */
  2022. y: number;
  2023. /**
  2024. * Creates a new Vector2 from the given x and y coordinates
  2025. * @param x defines the first coordinate
  2026. * @param y defines the second coordinate
  2027. */
  2028. constructor(
  2029. /** defines the first coordinate */
  2030. x?: number,
  2031. /** defines the second coordinate */
  2032. y?: number);
  2033. /**
  2034. * Gets a string with the Vector2 coordinates
  2035. * @returns a string with the Vector2 coordinates
  2036. */
  2037. toString(): string;
  2038. /**
  2039. * Gets class name
  2040. * @returns the string "Vector2"
  2041. */
  2042. getClassName(): string;
  2043. /**
  2044. * Gets current vector hash code
  2045. * @returns the Vector2 hash code as a number
  2046. */
  2047. getHashCode(): number;
  2048. /**
  2049. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2050. * @param array defines the source array
  2051. * @param index defines the offset in source array
  2052. * @returns the current Vector2
  2053. */
  2054. toArray(array: FloatArray, index?: number): Vector2;
  2055. /**
  2056. * Copy the current vector to an array
  2057. * @returns a new array with 2 elements: the Vector2 coordinates.
  2058. */
  2059. asArray(): number[];
  2060. /**
  2061. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2062. * @param source defines the source Vector2
  2063. * @returns the current updated Vector2
  2064. */
  2065. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2066. /**
  2067. * Sets the Vector2 coordinates with the given floats
  2068. * @param x defines the first coordinate
  2069. * @param y defines the second coordinate
  2070. * @returns the current updated Vector2
  2071. */
  2072. copyFromFloats(x: number, y: number): Vector2;
  2073. /**
  2074. * Sets the Vector2 coordinates with the given floats
  2075. * @param x defines the first coordinate
  2076. * @param y defines the second coordinate
  2077. * @returns the current updated Vector2
  2078. */
  2079. set(x: number, y: number): Vector2;
  2080. /**
  2081. * Add another vector with the current one
  2082. * @param otherVector defines the other vector
  2083. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2084. */
  2085. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2086. /**
  2087. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2088. * @param otherVector defines the other vector
  2089. * @param result defines the target vector
  2090. * @returns the unmodified current Vector2
  2091. */
  2092. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2093. /**
  2094. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2095. * @param otherVector defines the other vector
  2096. * @returns the current updated Vector2
  2097. */
  2098. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2099. /**
  2100. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2101. * @param otherVector defines the other vector
  2102. * @returns a new Vector2
  2103. */
  2104. addVector3(otherVector: Vector3): Vector2;
  2105. /**
  2106. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2107. * @param otherVector defines the other vector
  2108. * @returns a new Vector2
  2109. */
  2110. subtract(otherVector: Vector2): Vector2;
  2111. /**
  2112. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2113. * @param otherVector defines the other vector
  2114. * @param result defines the target vector
  2115. * @returns the unmodified current Vector2
  2116. */
  2117. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2118. /**
  2119. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2120. * @param otherVector defines the other vector
  2121. * @returns the current updated Vector2
  2122. */
  2123. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2124. /**
  2125. * Multiplies in place the current Vector2 coordinates by the given ones
  2126. * @param otherVector defines the other vector
  2127. * @returns the current updated Vector2
  2128. */
  2129. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2130. /**
  2131. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2132. * @param otherVector defines the other vector
  2133. * @returns a new Vector2
  2134. */
  2135. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2136. /**
  2137. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2138. * @param otherVector defines the other vector
  2139. * @param result defines the target vector
  2140. * @returns the unmodified current Vector2
  2141. */
  2142. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2143. /**
  2144. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2145. * @param x defines the first coordinate
  2146. * @param y defines the second coordinate
  2147. * @returns a new Vector2
  2148. */
  2149. multiplyByFloats(x: number, y: number): Vector2;
  2150. /**
  2151. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2152. * @param otherVector defines the other vector
  2153. * @returns a new Vector2
  2154. */
  2155. divide(otherVector: Vector2): Vector2;
  2156. /**
  2157. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2158. * @param otherVector defines the other vector
  2159. * @param result defines the target vector
  2160. * @returns the unmodified current Vector2
  2161. */
  2162. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2163. /**
  2164. * Divides the current Vector2 coordinates by the given ones
  2165. * @param otherVector defines the other vector
  2166. * @returns the current updated Vector2
  2167. */
  2168. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Gets a new Vector2 with current Vector2 negated coordinates
  2171. * @returns a new Vector2
  2172. */
  2173. negate(): Vector2;
  2174. /**
  2175. * Negate this vector in place
  2176. * @returns this
  2177. */
  2178. negateInPlace(): Vector2;
  2179. /**
  2180. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2181. * @param result defines the Vector3 object where to store the result
  2182. * @returns the current Vector2
  2183. */
  2184. negateToRef(result: Vector2): Vector2;
  2185. /**
  2186. * Multiply the Vector2 coordinates by scale
  2187. * @param scale defines the scaling factor
  2188. * @returns the current updated Vector2
  2189. */
  2190. scaleInPlace(scale: number): Vector2;
  2191. /**
  2192. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2193. * @param scale defines the scaling factor
  2194. * @returns a new Vector2
  2195. */
  2196. scale(scale: number): Vector2;
  2197. /**
  2198. * Scale the current Vector2 values by a factor to a given Vector2
  2199. * @param scale defines the scale factor
  2200. * @param result defines the Vector2 object where to store the result
  2201. * @returns the unmodified current Vector2
  2202. */
  2203. scaleToRef(scale: number, result: Vector2): Vector2;
  2204. /**
  2205. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2206. * @param scale defines the scale factor
  2207. * @param result defines the Vector2 object where to store the result
  2208. * @returns the unmodified current Vector2
  2209. */
  2210. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2211. /**
  2212. * Gets a boolean if two vectors are equals
  2213. * @param otherVector defines the other vector
  2214. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2215. */
  2216. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2217. /**
  2218. * Gets a boolean if two vectors are equals (using an epsilon value)
  2219. * @param otherVector defines the other vector
  2220. * @param epsilon defines the minimal distance to consider equality
  2221. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2222. */
  2223. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2224. /**
  2225. * Gets a new Vector2 from current Vector2 floored values
  2226. * @returns a new Vector2
  2227. */
  2228. floor(): Vector2;
  2229. /**
  2230. * Gets a new Vector2 from current Vector2 floored values
  2231. * @returns a new Vector2
  2232. */
  2233. fract(): Vector2;
  2234. /**
  2235. * Gets the length of the vector
  2236. * @returns the vector length (float)
  2237. */
  2238. length(): number;
  2239. /**
  2240. * Gets the vector squared length
  2241. * @returns the vector squared length (float)
  2242. */
  2243. lengthSquared(): number;
  2244. /**
  2245. * Normalize the vector
  2246. * @returns the current updated Vector2
  2247. */
  2248. normalize(): Vector2;
  2249. /**
  2250. * Gets a new Vector2 copied from the Vector2
  2251. * @returns a new Vector2
  2252. */
  2253. clone(): Vector2;
  2254. /**
  2255. * Gets a new Vector2(0, 0)
  2256. * @returns a new Vector2
  2257. */
  2258. static Zero(): Vector2;
  2259. /**
  2260. * Gets a new Vector2(1, 1)
  2261. * @returns a new Vector2
  2262. */
  2263. static One(): Vector2;
  2264. /**
  2265. * Gets a new Vector2 set from the given index element of the given array
  2266. * @param array defines the data source
  2267. * @param offset defines the offset in the data source
  2268. * @returns a new Vector2
  2269. */
  2270. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2271. /**
  2272. * Sets "result" from the given index element of the given array
  2273. * @param array defines the data source
  2274. * @param offset defines the offset in the data source
  2275. * @param result defines the target vector
  2276. */
  2277. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2278. /**
  2279. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2280. * @param value1 defines 1st point of control
  2281. * @param value2 defines 2nd point of control
  2282. * @param value3 defines 3rd point of control
  2283. * @param value4 defines 4th point of control
  2284. * @param amount defines the interpolation factor
  2285. * @returns a new Vector2
  2286. */
  2287. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2288. /**
  2289. * 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".
  2290. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2291. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2292. * @param value defines the value to clamp
  2293. * @param min defines the lower limit
  2294. * @param max defines the upper limit
  2295. * @returns a new Vector2
  2296. */
  2297. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2298. /**
  2299. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2300. * @param value1 defines the 1st control point
  2301. * @param tangent1 defines the outgoing tangent
  2302. * @param value2 defines the 2nd control point
  2303. * @param tangent2 defines the incoming tangent
  2304. * @param amount defines the interpolation factor
  2305. * @returns a new Vector2
  2306. */
  2307. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2308. /**
  2309. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2310. * @param start defines the start vector
  2311. * @param end defines the end vector
  2312. * @param amount defines the interpolation factor
  2313. * @returns a new Vector2
  2314. */
  2315. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2316. /**
  2317. * Gets the dot product of the vector "left" and the vector "right"
  2318. * @param left defines first vector
  2319. * @param right defines second vector
  2320. * @returns the dot product (float)
  2321. */
  2322. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2323. /**
  2324. * Returns a new Vector2 equal to the normalized given vector
  2325. * @param vector defines the vector to normalize
  2326. * @returns a new Vector2
  2327. */
  2328. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2329. /**
  2330. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2331. * @param left defines 1st vector
  2332. * @param right defines 2nd vector
  2333. * @returns a new Vector2
  2334. */
  2335. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2336. /**
  2337. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2338. * @param left defines 1st vector
  2339. * @param right defines 2nd vector
  2340. * @returns a new Vector2
  2341. */
  2342. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2343. /**
  2344. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2345. * @param vector defines the vector to transform
  2346. * @param transformation defines the matrix to apply
  2347. * @returns a new Vector2
  2348. */
  2349. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2350. /**
  2351. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2352. * @param vector defines the vector to transform
  2353. * @param transformation defines the matrix to apply
  2354. * @param result defines the target vector
  2355. */
  2356. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2357. /**
  2358. * Determines if a given vector is included in a triangle
  2359. * @param p defines the vector to test
  2360. * @param p0 defines 1st triangle point
  2361. * @param p1 defines 2nd triangle point
  2362. * @param p2 defines 3rd triangle point
  2363. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2364. */
  2365. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2366. /**
  2367. * Gets the distance between the vectors "value1" and "value2"
  2368. * @param value1 defines first vector
  2369. * @param value2 defines second vector
  2370. * @returns the distance between vectors
  2371. */
  2372. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2373. /**
  2374. * Returns the squared distance between the vectors "value1" and "value2"
  2375. * @param value1 defines first vector
  2376. * @param value2 defines second vector
  2377. * @returns the squared distance between vectors
  2378. */
  2379. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2380. /**
  2381. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2382. * @param value1 defines first vector
  2383. * @param value2 defines second vector
  2384. * @returns a new Vector2
  2385. */
  2386. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2387. /**
  2388. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2389. * @param p defines the middle point
  2390. * @param segA defines one point of the segment
  2391. * @param segB defines the other point of the segment
  2392. * @returns the shortest distance
  2393. */
  2394. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2395. }
  2396. /**
  2397. * Class used to store (x,y,z) vector representation
  2398. * A Vector3 is the main object used in 3D geometry
  2399. * It can represent etiher the coordinates of a point the space, either a direction
  2400. * Reminder: js uses a left handed forward facing system
  2401. */
  2402. export class Vector3 {
  2403. /**
  2404. * Defines the first coordinates (on X axis)
  2405. */
  2406. x: number;
  2407. /**
  2408. * Defines the second coordinates (on Y axis)
  2409. */
  2410. y: number;
  2411. /**
  2412. * Defines the third coordinates (on Z axis)
  2413. */
  2414. z: number;
  2415. private static _UpReadOnly;
  2416. private static _ZeroReadOnly;
  2417. /**
  2418. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2419. * @param x defines the first coordinates (on X axis)
  2420. * @param y defines the second coordinates (on Y axis)
  2421. * @param z defines the third coordinates (on Z axis)
  2422. */
  2423. constructor(
  2424. /**
  2425. * Defines the first coordinates (on X axis)
  2426. */
  2427. x?: number,
  2428. /**
  2429. * Defines the second coordinates (on Y axis)
  2430. */
  2431. y?: number,
  2432. /**
  2433. * Defines the third coordinates (on Z axis)
  2434. */
  2435. z?: number);
  2436. /**
  2437. * Creates a string representation of the Vector3
  2438. * @returns a string with the Vector3 coordinates.
  2439. */
  2440. toString(): string;
  2441. /**
  2442. * Gets the class name
  2443. * @returns the string "Vector3"
  2444. */
  2445. getClassName(): string;
  2446. /**
  2447. * Creates the Vector3 hash code
  2448. * @returns a number which tends to be unique between Vector3 instances
  2449. */
  2450. getHashCode(): number;
  2451. /**
  2452. * Creates an array containing three elements : the coordinates of the Vector3
  2453. * @returns a new array of numbers
  2454. */
  2455. asArray(): number[];
  2456. /**
  2457. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2458. * @param array defines the destination array
  2459. * @param index defines the offset in the destination array
  2460. * @returns the current Vector3
  2461. */
  2462. toArray(array: FloatArray, index?: number): Vector3;
  2463. /**
  2464. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2465. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2466. */
  2467. toQuaternion(): Quaternion;
  2468. /**
  2469. * Adds the given vector to the current Vector3
  2470. * @param otherVector defines the second operand
  2471. * @returns the current updated Vector3
  2472. */
  2473. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2474. /**
  2475. * Adds the given coordinates to the current Vector3
  2476. * @param x defines the x coordinate of the operand
  2477. * @param y defines the y coordinate of the operand
  2478. * @param z defines the z coordinate of the operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2482. /**
  2483. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2484. * @param otherVector defines the second operand
  2485. * @returns the resulting Vector3
  2486. */
  2487. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2488. /**
  2489. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2490. * @param otherVector defines the second operand
  2491. * @param result defines the Vector3 object where to store the result
  2492. * @returns the current Vector3
  2493. */
  2494. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2495. /**
  2496. * Subtract the given vector from the current Vector3
  2497. * @param otherVector defines the second operand
  2498. * @returns the current updated Vector3
  2499. */
  2500. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2501. /**
  2502. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2503. * @param otherVector defines the second operand
  2504. * @returns the resulting Vector3
  2505. */
  2506. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2507. /**
  2508. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2509. * @param otherVector defines the second operand
  2510. * @param result defines the Vector3 object where to store the result
  2511. * @returns the current Vector3
  2512. */
  2513. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2514. /**
  2515. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2516. * @param x defines the x coordinate of the operand
  2517. * @param y defines the y coordinate of the operand
  2518. * @param z defines the z coordinate of the operand
  2519. * @returns the resulting Vector3
  2520. */
  2521. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2522. /**
  2523. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2524. * @param x defines the x coordinate of the operand
  2525. * @param y defines the y coordinate of the operand
  2526. * @param z defines the z coordinate of the operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2531. /**
  2532. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2533. * @returns a new Vector3
  2534. */
  2535. negate(): Vector3;
  2536. /**
  2537. * Negate this vector in place
  2538. * @returns this
  2539. */
  2540. negateInPlace(): Vector3;
  2541. /**
  2542. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2543. * @param result defines the Vector3 object where to store the result
  2544. * @returns the current Vector3
  2545. */
  2546. negateToRef(result: Vector3): Vector3;
  2547. /**
  2548. * Multiplies the Vector3 coordinates by the float "scale"
  2549. * @param scale defines the multiplier factor
  2550. * @returns the current updated Vector3
  2551. */
  2552. scaleInPlace(scale: number): Vector3;
  2553. /**
  2554. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2555. * @param scale defines the multiplier factor
  2556. * @returns a new Vector3
  2557. */
  2558. scale(scale: number): Vector3;
  2559. /**
  2560. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2561. * @param scale defines the multiplier factor
  2562. * @param result defines the Vector3 object where to store the result
  2563. * @returns the current Vector3
  2564. */
  2565. scaleToRef(scale: number, result: Vector3): Vector3;
  2566. /**
  2567. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2568. * @param scale defines the scale factor
  2569. * @param result defines the Vector3 object where to store the result
  2570. * @returns the unmodified current Vector3
  2571. */
  2572. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2573. /**
  2574. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2575. * @param origin defines the origin of the projection ray
  2576. * @param plane defines the plane to project to
  2577. * @returns the projected vector3
  2578. */
  2579. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2580. /**
  2581. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2582. * @param origin defines the origin of the projection ray
  2583. * @param plane defines the plane to project to
  2584. * @param result defines the Vector3 where to store the result
  2585. */
  2586. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2587. /**
  2588. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2589. * @param otherVector defines the second operand
  2590. * @returns true if both vectors are equals
  2591. */
  2592. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2593. /**
  2594. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2595. * @param otherVector defines the second operand
  2596. * @param epsilon defines the minimal distance to define values as equals
  2597. * @returns true if both vectors are distant less than epsilon
  2598. */
  2599. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2600. /**
  2601. * Returns true if the current Vector3 coordinates equals the given floats
  2602. * @param x defines the x coordinate of the operand
  2603. * @param y defines the y coordinate of the operand
  2604. * @param z defines the z coordinate of the operand
  2605. * @returns true if both vectors are equals
  2606. */
  2607. equalsToFloats(x: number, y: number, z: number): boolean;
  2608. /**
  2609. * Multiplies the current Vector3 coordinates by the given ones
  2610. * @param otherVector defines the second operand
  2611. * @returns the current updated Vector3
  2612. */
  2613. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2614. /**
  2615. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2616. * @param otherVector defines the second operand
  2617. * @returns the new Vector3
  2618. */
  2619. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2620. /**
  2621. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2622. * @param otherVector defines the second operand
  2623. * @param result defines the Vector3 object where to store the result
  2624. * @returns the current Vector3
  2625. */
  2626. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2627. /**
  2628. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2629. * @param x defines the x coordinate of the operand
  2630. * @param y defines the y coordinate of the operand
  2631. * @param z defines the z coordinate of the operand
  2632. * @returns the new Vector3
  2633. */
  2634. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2635. /**
  2636. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2637. * @param otherVector defines the second operand
  2638. * @returns the new Vector3
  2639. */
  2640. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2643. * @param otherVector defines the second operand
  2644. * @param result defines the Vector3 object where to store the result
  2645. * @returns the current Vector3
  2646. */
  2647. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2648. /**
  2649. * Divides the current Vector3 coordinates by the given ones.
  2650. * @param otherVector defines the second operand
  2651. * @returns the current updated Vector3
  2652. */
  2653. divideInPlace(otherVector: Vector3): Vector3;
  2654. /**
  2655. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2656. * @param other defines the second operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2660. /**
  2661. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2662. * @param other defines the second operand
  2663. * @returns the current updated Vector3
  2664. */
  2665. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2666. /**
  2667. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2668. * @param x defines the x coordinate of the operand
  2669. * @param y defines the y coordinate of the operand
  2670. * @param z defines the z coordinate of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2674. /**
  2675. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the current updated Vector3
  2680. */
  2681. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2684. * Check if is non uniform within a certain amount of decimal places to account for this
  2685. * @param epsilon the amount the values can differ
  2686. * @returns if the the vector is non uniform to a certain number of decimal places
  2687. */
  2688. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2689. /**
  2690. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2691. */
  2692. get isNonUniform(): boolean;
  2693. /**
  2694. * Gets a new Vector3 from current Vector3 floored values
  2695. * @returns a new Vector3
  2696. */
  2697. floor(): Vector3;
  2698. /**
  2699. * Gets a new Vector3 from current Vector3 floored values
  2700. * @returns a new Vector3
  2701. */
  2702. fract(): Vector3;
  2703. /**
  2704. * Gets the length of the Vector3
  2705. * @returns the length of the Vector3
  2706. */
  2707. length(): number;
  2708. /**
  2709. * Gets the squared length of the Vector3
  2710. * @returns squared length of the Vector3
  2711. */
  2712. lengthSquared(): number;
  2713. /**
  2714. * Normalize the current Vector3.
  2715. * Please note that this is an in place operation.
  2716. * @returns the current updated Vector3
  2717. */
  2718. normalize(): Vector3;
  2719. /**
  2720. * Reorders the x y z properties of the vector in place
  2721. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2722. * @returns the current updated vector
  2723. */
  2724. reorderInPlace(order: string): this;
  2725. /**
  2726. * Rotates the vector around 0,0,0 by a quaternion
  2727. * @param quaternion the rotation quaternion
  2728. * @param result vector to store the result
  2729. * @returns the resulting vector
  2730. */
  2731. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2732. /**
  2733. * Rotates a vector around a given point
  2734. * @param quaternion the rotation quaternion
  2735. * @param point the point to rotate around
  2736. * @param result vector to store the result
  2737. * @returns the resulting vector
  2738. */
  2739. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2740. /**
  2741. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2742. * The cross product is then orthogonal to both current and "other"
  2743. * @param other defines the right operand
  2744. * @returns the cross product
  2745. */
  2746. cross(other: Vector3): Vector3;
  2747. /**
  2748. * Normalize the current Vector3 with the given input length.
  2749. * Please note that this is an in place operation.
  2750. * @param len the length of the vector
  2751. * @returns the current updated Vector3
  2752. */
  2753. normalizeFromLength(len: number): Vector3;
  2754. /**
  2755. * Normalize the current Vector3 to a new vector
  2756. * @returns the new Vector3
  2757. */
  2758. normalizeToNew(): Vector3;
  2759. /**
  2760. * Normalize the current Vector3 to the reference
  2761. * @param reference define the Vector3 to update
  2762. * @returns the updated Vector3
  2763. */
  2764. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2765. /**
  2766. * Creates a new Vector3 copied from the current Vector3
  2767. * @returns the new Vector3
  2768. */
  2769. clone(): Vector3;
  2770. /**
  2771. * Copies the given vector coordinates to the current Vector3 ones
  2772. * @param source defines the source Vector3
  2773. * @returns the current updated Vector3
  2774. */
  2775. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2776. /**
  2777. * Copies the given floats to the current Vector3 coordinates
  2778. * @param x defines the x coordinate of the operand
  2779. * @param y defines the y coordinate of the operand
  2780. * @param z defines the z coordinate of the operand
  2781. * @returns the current updated Vector3
  2782. */
  2783. copyFromFloats(x: number, y: number, z: number): Vector3;
  2784. /**
  2785. * Copies the given floats to the current Vector3 coordinates
  2786. * @param x defines the x coordinate of the operand
  2787. * @param y defines the y coordinate of the operand
  2788. * @param z defines the z coordinate of the operand
  2789. * @returns the current updated Vector3
  2790. */
  2791. set(x: number, y: number, z: number): Vector3;
  2792. /**
  2793. * Copies the given float to the current Vector3 coordinates
  2794. * @param v defines the x, y and z coordinates of the operand
  2795. * @returns the current updated Vector3
  2796. */
  2797. setAll(v: number): Vector3;
  2798. /**
  2799. * Get the clip factor between two vectors
  2800. * @param vector0 defines the first operand
  2801. * @param vector1 defines the second operand
  2802. * @param axis defines the axis to use
  2803. * @param size defines the size along the axis
  2804. * @returns the clip factor
  2805. */
  2806. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2807. /**
  2808. * Get angle between two vectors
  2809. * @param vector0 angle between vector0 and vector1
  2810. * @param vector1 angle between vector0 and vector1
  2811. * @param normal direction of the normal
  2812. * @return the angle between vector0 and vector1
  2813. */
  2814. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2815. /**
  2816. * Returns a new Vector3 set from the index "offset" of the given array
  2817. * @param array defines the source array
  2818. * @param offset defines the offset in the source array
  2819. * @returns the new Vector3
  2820. */
  2821. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2822. /**
  2823. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2824. * @param array defines the source array
  2825. * @param offset defines the offset in the source array
  2826. * @returns the new Vector3
  2827. * @deprecated Please use FromArray instead.
  2828. */
  2829. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2830. /**
  2831. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2832. * @param array defines the source array
  2833. * @param offset defines the offset in the source array
  2834. * @param result defines the Vector3 where to store the result
  2835. */
  2836. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2837. /**
  2838. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2839. * @param array defines the source array
  2840. * @param offset defines the offset in the source array
  2841. * @param result defines the Vector3 where to store the result
  2842. * @deprecated Please use FromArrayToRef instead.
  2843. */
  2844. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the given floats.
  2847. * @param x defines the x coordinate of the source
  2848. * @param y defines the y coordinate of the source
  2849. * @param z defines the z coordinate of the source
  2850. * @param result defines the Vector3 where to store the result
  2851. */
  2852. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2853. /**
  2854. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2855. * @returns a new empty Vector3
  2856. */
  2857. static Zero(): Vector3;
  2858. /**
  2859. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2860. * @returns a new unit Vector3
  2861. */
  2862. static One(): Vector3;
  2863. /**
  2864. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2865. * @returns a new up Vector3
  2866. */
  2867. static Up(): Vector3;
  2868. /**
  2869. * Gets a up Vector3 that must not be updated
  2870. */
  2871. static get UpReadOnly(): DeepImmutable<Vector3>;
  2872. /**
  2873. * Gets a zero Vector3 that must not be updated
  2874. */
  2875. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2876. /**
  2877. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2878. * @returns a new down Vector3
  2879. */
  2880. static Down(): Vector3;
  2881. /**
  2882. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2883. * @param rightHandedSystem is the scene right-handed (negative z)
  2884. * @returns a new forward Vector3
  2885. */
  2886. static Forward(rightHandedSystem?: boolean): Vector3;
  2887. /**
  2888. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2889. * @param rightHandedSystem is the scene right-handed (negative-z)
  2890. * @returns a new forward Vector3
  2891. */
  2892. static Backward(rightHandedSystem?: boolean): Vector3;
  2893. /**
  2894. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2895. * @returns a new right Vector3
  2896. */
  2897. static Right(): Vector3;
  2898. /**
  2899. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2900. * @returns a new left Vector3
  2901. */
  2902. static Left(): Vector3;
  2903. /**
  2904. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2905. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2906. * @param vector defines the Vector3 to transform
  2907. * @param transformation defines the transformation matrix
  2908. * @returns the transformed Vector3
  2909. */
  2910. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2911. /**
  2912. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2913. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2914. * @param vector defines the Vector3 to transform
  2915. * @param transformation defines the transformation matrix
  2916. * @param result defines the Vector3 where to store the result
  2917. */
  2918. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2919. /**
  2920. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2921. * This method computes tranformed coordinates only, not transformed direction vectors
  2922. * @param x define the x coordinate of the source vector
  2923. * @param y define the y coordinate of the source vector
  2924. * @param z define the z coordinate of the source vector
  2925. * @param transformation defines the transformation matrix
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2929. /**
  2930. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2931. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2932. * @param vector defines the Vector3 to transform
  2933. * @param transformation defines the transformation matrix
  2934. * @returns the new Vector3
  2935. */
  2936. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2937. /**
  2938. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2939. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2940. * @param vector defines the Vector3 to transform
  2941. * @param transformation defines the transformation matrix
  2942. * @param result defines the Vector3 where to store the result
  2943. */
  2944. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2945. /**
  2946. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2947. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2948. * @param x define the x coordinate of the source vector
  2949. * @param y define the y coordinate of the source vector
  2950. * @param z define the z coordinate of the source vector
  2951. * @param transformation defines the transformation matrix
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2955. /**
  2956. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2957. * @param value1 defines the first control point
  2958. * @param value2 defines the second control point
  2959. * @param value3 defines the third control point
  2960. * @param value4 defines the fourth control point
  2961. * @param amount defines the amount on the spline to use
  2962. * @returns the new Vector3
  2963. */
  2964. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2965. /**
  2966. * 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"
  2967. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2968. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2969. * @param value defines the current value
  2970. * @param min defines the lower range value
  2971. * @param max defines the upper range value
  2972. * @returns the new Vector3
  2973. */
  2974. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2975. /**
  2976. * 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"
  2977. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2978. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2979. * @param value defines the current value
  2980. * @param min defines the lower range value
  2981. * @param max defines the upper range value
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2985. /**
  2986. * Checks if a given vector is inside a specific range
  2987. * @param v defines the vector to test
  2988. * @param min defines the minimum range
  2989. * @param max defines the maximum range
  2990. */
  2991. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2992. /**
  2993. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2994. * @param value1 defines the first control point
  2995. * @param tangent1 defines the first tangent vector
  2996. * @param value2 defines the second control point
  2997. * @param tangent2 defines the second tangent vector
  2998. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2999. * @returns the new Vector3
  3000. */
  3001. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3004. * @param start defines the start value
  3005. * @param end defines the end value
  3006. * @param amount max defines amount between both (between 0 and 1)
  3007. * @returns the new Vector3
  3008. */
  3009. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3010. /**
  3011. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3012. * @param start defines the start value
  3013. * @param end defines the end value
  3014. * @param amount max defines amount between both (between 0 and 1)
  3015. * @param result defines the Vector3 where to store the result
  3016. */
  3017. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3018. /**
  3019. * Returns the dot product (float) between the vectors "left" and "right"
  3020. * @param left defines the left operand
  3021. * @param right defines the right operand
  3022. * @returns the dot product
  3023. */
  3024. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3025. /**
  3026. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3027. * The cross product is then orthogonal to both "left" and "right"
  3028. * @param left defines the left operand
  3029. * @param right defines the right operand
  3030. * @returns the cross product
  3031. */
  3032. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3033. /**
  3034. * Sets the given vector "result" with the cross product of "left" and "right"
  3035. * The cross product is then orthogonal to both "left" and "right"
  3036. * @param left defines the left operand
  3037. * @param right defines the right operand
  3038. * @param result defines the Vector3 where to store the result
  3039. */
  3040. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3041. /**
  3042. * Returns a new Vector3 as the normalization of the given vector
  3043. * @param vector defines the Vector3 to normalize
  3044. * @returns the new Vector3
  3045. */
  3046. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3047. /**
  3048. * Sets the given vector "result" with the normalization of the given first vector
  3049. * @param vector defines the Vector3 to normalize
  3050. * @param result defines the Vector3 where to store the result
  3051. */
  3052. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3053. /**
  3054. * Project a Vector3 onto screen space
  3055. * @param vector defines the Vector3 to project
  3056. * @param world defines the world matrix to use
  3057. * @param transform defines the transform (view x projection) matrix to use
  3058. * @param viewport defines the screen viewport to use
  3059. * @returns the new Vector3
  3060. */
  3061. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3062. /** @hidden */
  3063. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3064. /**
  3065. * Unproject from screen space to object space
  3066. * @param source defines the screen space Vector3 to use
  3067. * @param viewportWidth defines the current width of the viewport
  3068. * @param viewportHeight defines the current height of the viewport
  3069. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3070. * @param transform defines the transform (view x projection) matrix to use
  3071. * @returns the new Vector3
  3072. */
  3073. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3074. /**
  3075. * Unproject from screen space to object space
  3076. * @param source defines the screen space Vector3 to use
  3077. * @param viewportWidth defines the current width of the viewport
  3078. * @param viewportHeight defines the current height of the viewport
  3079. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3080. * @param view defines the view matrix to use
  3081. * @param projection defines the projection matrix to use
  3082. * @returns the new Vector3
  3083. */
  3084. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3085. /**
  3086. * Unproject from screen space to object space
  3087. * @param source defines the screen space Vector3 to use
  3088. * @param viewportWidth defines the current width of the viewport
  3089. * @param viewportHeight defines the current height of the viewport
  3090. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3091. * @param view defines the view matrix to use
  3092. * @param projection defines the projection matrix to use
  3093. * @param result defines the Vector3 where to store the result
  3094. */
  3095. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3096. /**
  3097. * Unproject from screen space to object space
  3098. * @param sourceX defines the screen space x coordinate to use
  3099. * @param sourceY defines the screen space y coordinate to use
  3100. * @param sourceZ defines the screen space z coordinate to use
  3101. * @param viewportWidth defines the current width of the viewport
  3102. * @param viewportHeight defines the current height of the viewport
  3103. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3104. * @param view defines the view matrix to use
  3105. * @param projection defines the projection matrix to use
  3106. * @param result defines the Vector3 where to store the result
  3107. */
  3108. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3109. /**
  3110. * Gets the minimal coordinate values between two Vector3
  3111. * @param left defines the first operand
  3112. * @param right defines the second operand
  3113. * @returns the new Vector3
  3114. */
  3115. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Gets the maximal coordinate values between two Vector3
  3118. * @param left defines the first operand
  3119. * @param right defines the second operand
  3120. * @returns the new Vector3
  3121. */
  3122. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3123. /**
  3124. * Returns the distance between the vectors "value1" and "value2"
  3125. * @param value1 defines the first operand
  3126. * @param value2 defines the second operand
  3127. * @returns the distance
  3128. */
  3129. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3130. /**
  3131. * Returns the squared distance between the vectors "value1" and "value2"
  3132. * @param value1 defines the first operand
  3133. * @param value2 defines the second operand
  3134. * @returns the squared distance
  3135. */
  3136. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3137. /**
  3138. * Returns a new Vector3 located at the center between "value1" and "value2"
  3139. * @param value1 defines the first operand
  3140. * @param value2 defines the second operand
  3141. * @returns the new Vector3
  3142. */
  3143. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3144. /**
  3145. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3146. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3147. * to something in order to rotate it from its local system to the given target system
  3148. * Note: axis1, axis2 and axis3 are normalized during this operation
  3149. * @param axis1 defines the first axis
  3150. * @param axis2 defines the second axis
  3151. * @param axis3 defines the third axis
  3152. * @returns a new Vector3
  3153. */
  3154. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3155. /**
  3156. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3157. * @param axis1 defines the first axis
  3158. * @param axis2 defines the second axis
  3159. * @param axis3 defines the third axis
  3160. * @param ref defines the Vector3 where to store the result
  3161. */
  3162. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3163. }
  3164. /**
  3165. * Vector4 class created for EulerAngle class conversion to Quaternion
  3166. */
  3167. export class Vector4 {
  3168. /** x value of the vector */
  3169. x: number;
  3170. /** y value of the vector */
  3171. y: number;
  3172. /** z value of the vector */
  3173. z: number;
  3174. /** w value of the vector */
  3175. w: number;
  3176. /**
  3177. * Creates a Vector4 object from the given floats.
  3178. * @param x x value of the vector
  3179. * @param y y value of the vector
  3180. * @param z z value of the vector
  3181. * @param w w value of the vector
  3182. */
  3183. constructor(
  3184. /** x value of the vector */
  3185. x: number,
  3186. /** y value of the vector */
  3187. y: number,
  3188. /** z value of the vector */
  3189. z: number,
  3190. /** w value of the vector */
  3191. w: number);
  3192. /**
  3193. * Returns the string with the Vector4 coordinates.
  3194. * @returns a string containing all the vector values
  3195. */
  3196. toString(): string;
  3197. /**
  3198. * Returns the string "Vector4".
  3199. * @returns "Vector4"
  3200. */
  3201. getClassName(): string;
  3202. /**
  3203. * Returns the Vector4 hash code.
  3204. * @returns a unique hash code
  3205. */
  3206. getHashCode(): number;
  3207. /**
  3208. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3209. * @returns the resulting array
  3210. */
  3211. asArray(): number[];
  3212. /**
  3213. * Populates the given array from the given index with the Vector4 coordinates.
  3214. * @param array array to populate
  3215. * @param index index of the array to start at (default: 0)
  3216. * @returns the Vector4.
  3217. */
  3218. toArray(array: FloatArray, index?: number): Vector4;
  3219. /**
  3220. * Adds the given vector to the current Vector4.
  3221. * @param otherVector the vector to add
  3222. * @returns the updated Vector4.
  3223. */
  3224. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3225. /**
  3226. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3227. * @param otherVector the vector to add
  3228. * @returns the resulting vector
  3229. */
  3230. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3231. /**
  3232. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3233. * @param otherVector the vector to add
  3234. * @param result the vector to store the result
  3235. * @returns the current Vector4.
  3236. */
  3237. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3238. /**
  3239. * Subtract in place the given vector from the current Vector4.
  3240. * @param otherVector the vector to subtract
  3241. * @returns the updated Vector4.
  3242. */
  3243. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3246. * @param otherVector the vector to add
  3247. * @returns the new vector with the result
  3248. */
  3249. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3250. /**
  3251. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3252. * @param otherVector the vector to subtract
  3253. * @param result the vector to store the result
  3254. * @returns the current Vector4.
  3255. */
  3256. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3257. /**
  3258. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3259. */
  3260. /**
  3261. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3262. * @param x value to subtract
  3263. * @param y value to subtract
  3264. * @param z value to subtract
  3265. * @param w value to subtract
  3266. * @returns new vector containing the result
  3267. */
  3268. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3269. /**
  3270. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3271. * @param x value to subtract
  3272. * @param y value to subtract
  3273. * @param z value to subtract
  3274. * @param w value to subtract
  3275. * @param result the vector to store the result in
  3276. * @returns the current Vector4.
  3277. */
  3278. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3279. /**
  3280. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3281. * @returns a new vector with the negated values
  3282. */
  3283. negate(): Vector4;
  3284. /**
  3285. * Negate this vector in place
  3286. * @returns this
  3287. */
  3288. negateInPlace(): Vector4;
  3289. /**
  3290. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3291. * @param result defines the Vector3 object where to store the result
  3292. * @returns the current Vector4
  3293. */
  3294. negateToRef(result: Vector4): Vector4;
  3295. /**
  3296. * Multiplies the current Vector4 coordinates by scale (float).
  3297. * @param scale the number to scale with
  3298. * @returns the updated Vector4.
  3299. */
  3300. scaleInPlace(scale: number): Vector4;
  3301. /**
  3302. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3303. * @param scale the number to scale with
  3304. * @returns a new vector with the result
  3305. */
  3306. scale(scale: number): Vector4;
  3307. /**
  3308. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3309. * @param scale the number to scale with
  3310. * @param result a vector to store the result in
  3311. * @returns the current Vector4.
  3312. */
  3313. scaleToRef(scale: number, result: Vector4): Vector4;
  3314. /**
  3315. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3316. * @param scale defines the scale factor
  3317. * @param result defines the Vector4 object where to store the result
  3318. * @returns the unmodified current Vector4
  3319. */
  3320. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3321. /**
  3322. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3323. * @param otherVector the vector to compare against
  3324. * @returns true if they are equal
  3325. */
  3326. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3327. /**
  3328. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3329. * @param otherVector vector to compare against
  3330. * @param epsilon (Default: very small number)
  3331. * @returns true if they are equal
  3332. */
  3333. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3334. /**
  3335. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3336. * @param x x value to compare against
  3337. * @param y y value to compare against
  3338. * @param z z value to compare against
  3339. * @param w w value to compare against
  3340. * @returns true if equal
  3341. */
  3342. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3343. /**
  3344. * Multiplies in place the current Vector4 by the given one.
  3345. * @param otherVector vector to multiple with
  3346. * @returns the updated Vector4.
  3347. */
  3348. multiplyInPlace(otherVector: Vector4): Vector4;
  3349. /**
  3350. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3351. * @param otherVector vector to multiple with
  3352. * @returns resulting new vector
  3353. */
  3354. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3355. /**
  3356. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3357. * @param otherVector vector to multiple with
  3358. * @param result vector to store the result
  3359. * @returns the current Vector4.
  3360. */
  3361. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3362. /**
  3363. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3364. * @param x x value multiply with
  3365. * @param y y value multiply with
  3366. * @param z z value multiply with
  3367. * @param w w value multiply with
  3368. * @returns resulting new vector
  3369. */
  3370. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3371. /**
  3372. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3373. * @param otherVector vector to devide with
  3374. * @returns resulting new vector
  3375. */
  3376. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3377. /**
  3378. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3379. * @param otherVector vector to devide with
  3380. * @param result vector to store the result
  3381. * @returns the current Vector4.
  3382. */
  3383. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3384. /**
  3385. * Divides the current Vector3 coordinates by the given ones.
  3386. * @param otherVector vector to devide with
  3387. * @returns the updated Vector3.
  3388. */
  3389. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3390. /**
  3391. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3392. * @param other defines the second operand
  3393. * @returns the current updated Vector4
  3394. */
  3395. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3398. * @param other defines the second operand
  3399. * @returns the current updated Vector4
  3400. */
  3401. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Gets a new Vector4 from current Vector4 floored values
  3404. * @returns a new Vector4
  3405. */
  3406. floor(): Vector4;
  3407. /**
  3408. * Gets a new Vector4 from current Vector3 floored values
  3409. * @returns a new Vector4
  3410. */
  3411. fract(): Vector4;
  3412. /**
  3413. * Returns the Vector4 length (float).
  3414. * @returns the length
  3415. */
  3416. length(): number;
  3417. /**
  3418. * Returns the Vector4 squared length (float).
  3419. * @returns the length squared
  3420. */
  3421. lengthSquared(): number;
  3422. /**
  3423. * Normalizes in place the Vector4.
  3424. * @returns the updated Vector4.
  3425. */
  3426. normalize(): Vector4;
  3427. /**
  3428. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3429. * @returns this converted to a new vector3
  3430. */
  3431. toVector3(): Vector3;
  3432. /**
  3433. * Returns a new Vector4 copied from the current one.
  3434. * @returns the new cloned vector
  3435. */
  3436. clone(): Vector4;
  3437. /**
  3438. * Updates the current Vector4 with the given one coordinates.
  3439. * @param source the source vector to copy from
  3440. * @returns the updated Vector4.
  3441. */
  3442. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3443. /**
  3444. * Updates the current Vector4 coordinates with the given floats.
  3445. * @param x float to copy from
  3446. * @param y float to copy from
  3447. * @param z float to copy from
  3448. * @param w float to copy from
  3449. * @returns the updated Vector4.
  3450. */
  3451. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3452. /**
  3453. * Updates the current Vector4 coordinates with the given floats.
  3454. * @param x float to set from
  3455. * @param y float to set from
  3456. * @param z float to set from
  3457. * @param w float to set from
  3458. * @returns the updated Vector4.
  3459. */
  3460. set(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Copies the given float to the current Vector3 coordinates
  3463. * @param v defines the x, y, z and w coordinates of the operand
  3464. * @returns the current updated Vector3
  3465. */
  3466. setAll(v: number): Vector4;
  3467. /**
  3468. * Returns a new Vector4 set from the starting index of the given array.
  3469. * @param array the array to pull values from
  3470. * @param offset the offset into the array to start at
  3471. * @returns the new vector
  3472. */
  3473. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3474. /**
  3475. * Updates the given vector "result" from the starting index of the given array.
  3476. * @param array the array to pull values from
  3477. * @param offset the offset into the array to start at
  3478. * @param result the vector to store the result in
  3479. */
  3480. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3481. /**
  3482. * Updates the given vector "result" from the starting index of the given Float32Array.
  3483. * @param array the array to pull values from
  3484. * @param offset the offset into the array to start at
  3485. * @param result the vector to store the result in
  3486. */
  3487. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3488. /**
  3489. * Updates the given vector "result" coordinates from the given floats.
  3490. * @param x float to set from
  3491. * @param y float to set from
  3492. * @param z float to set from
  3493. * @param w float to set from
  3494. * @param result the vector to the floats in
  3495. */
  3496. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3497. /**
  3498. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3499. * @returns the new vector
  3500. */
  3501. static Zero(): Vector4;
  3502. /**
  3503. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3504. * @returns the new vector
  3505. */
  3506. static One(): Vector4;
  3507. /**
  3508. * Returns a new normalized Vector4 from the given one.
  3509. * @param vector the vector to normalize
  3510. * @returns the vector
  3511. */
  3512. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3513. /**
  3514. * Updates the given vector "result" from the normalization of the given one.
  3515. * @param vector the vector to normalize
  3516. * @param result the vector to store the result in
  3517. */
  3518. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3519. /**
  3520. * Returns a vector with the minimum values from the left and right vectors
  3521. * @param left left vector to minimize
  3522. * @param right right vector to minimize
  3523. * @returns a new vector with the minimum of the left and right vector values
  3524. */
  3525. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3526. /**
  3527. * Returns a vector with the maximum values from the left and right vectors
  3528. * @param left left vector to maximize
  3529. * @param right right vector to maximize
  3530. * @returns a new vector with the maximum of the left and right vector values
  3531. */
  3532. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Returns the distance (float) between the vectors "value1" and "value2".
  3535. * @param value1 value to calulate the distance between
  3536. * @param value2 value to calulate the distance between
  3537. * @return the distance between the two vectors
  3538. */
  3539. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3540. /**
  3541. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3542. * @param value1 value to calulate the distance between
  3543. * @param value2 value to calulate the distance between
  3544. * @return the distance between the two vectors squared
  3545. */
  3546. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3547. /**
  3548. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3549. * @param value1 value to calulate the center between
  3550. * @param value2 value to calulate the center between
  3551. * @return the center between the two vectors
  3552. */
  3553. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3554. /**
  3555. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3556. * This methods computes transformed normalized direction vectors only.
  3557. * @param vector the vector to transform
  3558. * @param transformation the transformation matrix to apply
  3559. * @returns the new vector
  3560. */
  3561. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3562. /**
  3563. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3564. * This methods computes transformed normalized direction vectors only.
  3565. * @param vector the vector to transform
  3566. * @param transformation the transformation matrix to apply
  3567. * @param result the vector to store the result in
  3568. */
  3569. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3570. /**
  3571. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3572. * This methods computes transformed normalized direction vectors only.
  3573. * @param x value to transform
  3574. * @param y value to transform
  3575. * @param z value to transform
  3576. * @param w value to transform
  3577. * @param transformation the transformation matrix to apply
  3578. * @param result the vector to store the results in
  3579. */
  3580. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3581. /**
  3582. * Creates a new Vector4 from a Vector3
  3583. * @param source defines the source data
  3584. * @param w defines the 4th component (default is 0)
  3585. * @returns a new Vector4
  3586. */
  3587. static FromVector3(source: Vector3, w?: number): Vector4;
  3588. }
  3589. /**
  3590. * Class used to store quaternion data
  3591. * @see https://en.wikipedia.org/wiki/Quaternion
  3592. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3593. */
  3594. export class Quaternion {
  3595. /** defines the first component (0 by default) */
  3596. x: number;
  3597. /** defines the second component (0 by default) */
  3598. y: number;
  3599. /** defines the third component (0 by default) */
  3600. z: number;
  3601. /** defines the fourth component (1.0 by default) */
  3602. w: number;
  3603. /**
  3604. * Creates a new Quaternion from the given floats
  3605. * @param x defines the first component (0 by default)
  3606. * @param y defines the second component (0 by default)
  3607. * @param z defines the third component (0 by default)
  3608. * @param w defines the fourth component (1.0 by default)
  3609. */
  3610. constructor(
  3611. /** defines the first component (0 by default) */
  3612. x?: number,
  3613. /** defines the second component (0 by default) */
  3614. y?: number,
  3615. /** defines the third component (0 by default) */
  3616. z?: number,
  3617. /** defines the fourth component (1.0 by default) */
  3618. w?: number);
  3619. /**
  3620. * Gets a string representation for the current quaternion
  3621. * @returns a string with the Quaternion coordinates
  3622. */
  3623. toString(): string;
  3624. /**
  3625. * Gets the class name of the quaternion
  3626. * @returns the string "Quaternion"
  3627. */
  3628. getClassName(): string;
  3629. /**
  3630. * Gets a hash code for this quaternion
  3631. * @returns the quaternion hash code
  3632. */
  3633. getHashCode(): number;
  3634. /**
  3635. * Copy the quaternion to an array
  3636. * @returns a new array populated with 4 elements from the quaternion coordinates
  3637. */
  3638. asArray(): number[];
  3639. /**
  3640. * Check if two quaternions are equals
  3641. * @param otherQuaternion defines the second operand
  3642. * @return true if the current quaternion and the given one coordinates are strictly equals
  3643. */
  3644. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3645. /**
  3646. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3647. * @param otherQuaternion defines the other quaternion
  3648. * @param epsilon defines the minimal distance to consider equality
  3649. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3650. */
  3651. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3652. /**
  3653. * Clone the current quaternion
  3654. * @returns a new quaternion copied from the current one
  3655. */
  3656. clone(): Quaternion;
  3657. /**
  3658. * Copy a quaternion to the current one
  3659. * @param other defines the other quaternion
  3660. * @returns the updated current quaternion
  3661. */
  3662. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3663. /**
  3664. * Updates the current quaternion with the given float coordinates
  3665. * @param x defines the x coordinate
  3666. * @param y defines the y coordinate
  3667. * @param z defines the z coordinate
  3668. * @param w defines the w coordinate
  3669. * @returns the updated current quaternion
  3670. */
  3671. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3672. /**
  3673. * Updates the current quaternion from the given float coordinates
  3674. * @param x defines the x coordinate
  3675. * @param y defines the y coordinate
  3676. * @param z defines the z coordinate
  3677. * @param w defines the w coordinate
  3678. * @returns the updated current quaternion
  3679. */
  3680. set(x: number, y: number, z: number, w: number): Quaternion;
  3681. /**
  3682. * Adds two quaternions
  3683. * @param other defines the second operand
  3684. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3685. */
  3686. add(other: DeepImmutable<Quaternion>): Quaternion;
  3687. /**
  3688. * Add a quaternion to the current one
  3689. * @param other defines the quaternion to add
  3690. * @returns the current quaternion
  3691. */
  3692. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3693. /**
  3694. * Subtract two quaternions
  3695. * @param other defines the second operand
  3696. * @returns a new quaternion as the subtraction result of the given one from the current one
  3697. */
  3698. subtract(other: Quaternion): Quaternion;
  3699. /**
  3700. * Multiplies the current quaternion by a scale factor
  3701. * @param value defines the scale factor
  3702. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3703. */
  3704. scale(value: number): Quaternion;
  3705. /**
  3706. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3707. * @param scale defines the scale factor
  3708. * @param result defines the Quaternion object where to store the result
  3709. * @returns the unmodified current quaternion
  3710. */
  3711. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3712. /**
  3713. * Multiplies in place the current quaternion by a scale factor
  3714. * @param value defines the scale factor
  3715. * @returns the current modified quaternion
  3716. */
  3717. scaleInPlace(value: number): Quaternion;
  3718. /**
  3719. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3720. * @param scale defines the scale factor
  3721. * @param result defines the Quaternion object where to store the result
  3722. * @returns the unmodified current quaternion
  3723. */
  3724. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3725. /**
  3726. * Multiplies two quaternions
  3727. * @param q1 defines the second operand
  3728. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3729. */
  3730. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3731. /**
  3732. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3733. * @param q1 defines the second operand
  3734. * @param result defines the target quaternion
  3735. * @returns the current quaternion
  3736. */
  3737. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3738. /**
  3739. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3740. * @param q1 defines the second operand
  3741. * @returns the currentupdated quaternion
  3742. */
  3743. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3744. /**
  3745. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3746. * @param ref defines the target quaternion
  3747. * @returns the current quaternion
  3748. */
  3749. conjugateToRef(ref: Quaternion): Quaternion;
  3750. /**
  3751. * Conjugates in place (1-q) the current quaternion
  3752. * @returns the current updated quaternion
  3753. */
  3754. conjugateInPlace(): Quaternion;
  3755. /**
  3756. * Conjugates in place (1-q) the current quaternion
  3757. * @returns a new quaternion
  3758. */
  3759. conjugate(): Quaternion;
  3760. /**
  3761. * Gets length of current quaternion
  3762. * @returns the quaternion length (float)
  3763. */
  3764. length(): number;
  3765. /**
  3766. * Normalize in place the current quaternion
  3767. * @returns the current updated quaternion
  3768. */
  3769. normalize(): Quaternion;
  3770. /**
  3771. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3772. * @param order is a reserved parameter and is ignore for now
  3773. * @returns a new Vector3 containing the Euler angles
  3774. */
  3775. toEulerAngles(order?: string): Vector3;
  3776. /**
  3777. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3778. * @param result defines the vector which will be filled with the Euler angles
  3779. * @param order is a reserved parameter and is ignore for now
  3780. * @returns the current unchanged quaternion
  3781. */
  3782. toEulerAnglesToRef(result: Vector3): Quaternion;
  3783. /**
  3784. * Updates the given rotation matrix with the current quaternion values
  3785. * @param result defines the target matrix
  3786. * @returns the current unchanged quaternion
  3787. */
  3788. toRotationMatrix(result: Matrix): Quaternion;
  3789. /**
  3790. * Updates the current quaternion from the given rotation matrix values
  3791. * @param matrix defines the source matrix
  3792. * @returns the current updated quaternion
  3793. */
  3794. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3795. /**
  3796. * Creates a new quaternion from a rotation matrix
  3797. * @param matrix defines the source matrix
  3798. * @returns a new quaternion created from the given rotation matrix values
  3799. */
  3800. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3801. /**
  3802. * Updates the given quaternion with the given rotation matrix values
  3803. * @param matrix defines the source matrix
  3804. * @param result defines the target quaternion
  3805. */
  3806. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3807. /**
  3808. * Returns the dot product (float) between the quaternions "left" and "right"
  3809. * @param left defines the left operand
  3810. * @param right defines the right operand
  3811. * @returns the dot product
  3812. */
  3813. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3814. /**
  3815. * Checks if the two quaternions are close to each other
  3816. * @param quat0 defines the first quaternion to check
  3817. * @param quat1 defines the second quaternion to check
  3818. * @returns true if the two quaternions are close to each other
  3819. */
  3820. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3821. /**
  3822. * Creates an empty quaternion
  3823. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3824. */
  3825. static Zero(): Quaternion;
  3826. /**
  3827. * Inverse a given quaternion
  3828. * @param q defines the source quaternion
  3829. * @returns a new quaternion as the inverted current quaternion
  3830. */
  3831. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Inverse a given quaternion
  3834. * @param q defines the source quaternion
  3835. * @param result the quaternion the result will be stored in
  3836. * @returns the result quaternion
  3837. */
  3838. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3839. /**
  3840. * Creates an identity quaternion
  3841. * @returns the identity quaternion
  3842. */
  3843. static Identity(): Quaternion;
  3844. /**
  3845. * Gets a boolean indicating if the given quaternion is identity
  3846. * @param quaternion defines the quaternion to check
  3847. * @returns true if the quaternion is identity
  3848. */
  3849. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3850. /**
  3851. * Creates a quaternion from a rotation around an axis
  3852. * @param axis defines the axis to use
  3853. * @param angle defines the angle to use
  3854. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3855. */
  3856. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3857. /**
  3858. * Creates a rotation around an axis and stores it into the given quaternion
  3859. * @param axis defines the axis to use
  3860. * @param angle defines the angle to use
  3861. * @param result defines the target quaternion
  3862. * @returns the target quaternion
  3863. */
  3864. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3865. /**
  3866. * Creates a new quaternion from data stored into an array
  3867. * @param array defines the data source
  3868. * @param offset defines the offset in the source array where the data starts
  3869. * @returns a new quaternion
  3870. */
  3871. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3872. /**
  3873. * Updates the given quaternion "result" from the starting index of the given array.
  3874. * @param array the array to pull values from
  3875. * @param offset the offset into the array to start at
  3876. * @param result the quaternion to store the result in
  3877. */
  3878. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3879. /**
  3880. * Create a quaternion from Euler rotation angles
  3881. * @param x Pitch
  3882. * @param y Yaw
  3883. * @param z Roll
  3884. * @returns the new Quaternion
  3885. */
  3886. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3887. /**
  3888. * Updates a quaternion from Euler rotation angles
  3889. * @param x Pitch
  3890. * @param y Yaw
  3891. * @param z Roll
  3892. * @param result the quaternion to store the result
  3893. * @returns the updated quaternion
  3894. */
  3895. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3896. /**
  3897. * Create a quaternion from Euler rotation vector
  3898. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3899. * @returns the new Quaternion
  3900. */
  3901. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3902. /**
  3903. * Updates a quaternion from Euler rotation vector
  3904. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3905. * @param result the quaternion to store the result
  3906. * @returns the updated quaternion
  3907. */
  3908. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3911. * @param yaw defines the rotation around Y axis
  3912. * @param pitch defines the rotation around X axis
  3913. * @param roll defines the rotation around Z axis
  3914. * @returns the new quaternion
  3915. */
  3916. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3917. /**
  3918. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3919. * @param yaw defines the rotation around Y axis
  3920. * @param pitch defines the rotation around X axis
  3921. * @param roll defines the rotation around Z axis
  3922. * @param result defines the target quaternion
  3923. */
  3924. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3925. /**
  3926. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3927. * @param alpha defines the rotation around first axis
  3928. * @param beta defines the rotation around second axis
  3929. * @param gamma defines the rotation around third axis
  3930. * @returns the new quaternion
  3931. */
  3932. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3935. * @param alpha defines the rotation around first axis
  3936. * @param beta defines the rotation around second axis
  3937. * @param gamma defines the rotation around third axis
  3938. * @param result defines the target quaternion
  3939. */
  3940. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3941. /**
  3942. * 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)
  3943. * @param axis1 defines the first axis
  3944. * @param axis2 defines the second axis
  3945. * @param axis3 defines the third axis
  3946. * @returns the new quaternion
  3947. */
  3948. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3949. /**
  3950. * 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
  3951. * @param axis1 defines the first axis
  3952. * @param axis2 defines the second axis
  3953. * @param axis3 defines the third axis
  3954. * @param ref defines the target quaternion
  3955. */
  3956. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3957. /**
  3958. * Interpolates between two quaternions
  3959. * @param left defines first quaternion
  3960. * @param right defines second quaternion
  3961. * @param amount defines the gradient to use
  3962. * @returns the new interpolated quaternion
  3963. */
  3964. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3965. /**
  3966. * Interpolates between two quaternions and stores it into a target quaternion
  3967. * @param left defines first quaternion
  3968. * @param right defines second quaternion
  3969. * @param amount defines the gradient to use
  3970. * @param result defines the target quaternion
  3971. */
  3972. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3973. /**
  3974. * Interpolate between two quaternions using Hermite interpolation
  3975. * @param value1 defines first quaternion
  3976. * @param tangent1 defines the incoming tangent
  3977. * @param value2 defines second quaternion
  3978. * @param tangent2 defines the outgoing tangent
  3979. * @param amount defines the target quaternion
  3980. * @returns the new interpolated quaternion
  3981. */
  3982. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3983. }
  3984. /**
  3985. * Class used to store matrix data (4x4)
  3986. */
  3987. export class Matrix {
  3988. private static _updateFlagSeed;
  3989. private static _identityReadOnly;
  3990. private _isIdentity;
  3991. private _isIdentityDirty;
  3992. private _isIdentity3x2;
  3993. private _isIdentity3x2Dirty;
  3994. /**
  3995. * Gets the update flag of the matrix which is an unique number for the matrix.
  3996. * It will be incremented every time the matrix data change.
  3997. * You can use it to speed the comparison between two versions of the same matrix.
  3998. */
  3999. updateFlag: number;
  4000. private readonly _m;
  4001. /**
  4002. * Gets the internal data of the matrix
  4003. */
  4004. get m(): DeepImmutable<Float32Array>;
  4005. /** @hidden */
  4006. _markAsUpdated(): void;
  4007. /** @hidden */
  4008. private _updateIdentityStatus;
  4009. /**
  4010. * Creates an empty matrix (filled with zeros)
  4011. */
  4012. constructor();
  4013. /**
  4014. * Check if the current matrix is identity
  4015. * @returns true is the matrix is the identity matrix
  4016. */
  4017. isIdentity(): boolean;
  4018. /**
  4019. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4020. * @returns true is the matrix is the identity matrix
  4021. */
  4022. isIdentityAs3x2(): boolean;
  4023. /**
  4024. * Gets the determinant of the matrix
  4025. * @returns the matrix determinant
  4026. */
  4027. determinant(): number;
  4028. /**
  4029. * Returns the matrix as a Float32Array
  4030. * @returns the matrix underlying array
  4031. */
  4032. toArray(): DeepImmutable<Float32Array>;
  4033. /**
  4034. * Returns the matrix as a Float32Array
  4035. * @returns the matrix underlying array.
  4036. */
  4037. asArray(): DeepImmutable<Float32Array>;
  4038. /**
  4039. * Inverts the current matrix in place
  4040. * @returns the current inverted matrix
  4041. */
  4042. invert(): Matrix;
  4043. /**
  4044. * Sets all the matrix elements to zero
  4045. * @returns the current matrix
  4046. */
  4047. reset(): Matrix;
  4048. /**
  4049. * Adds the current matrix with a second one
  4050. * @param other defines the matrix to add
  4051. * @returns a new matrix as the addition of the current matrix and the given one
  4052. */
  4053. add(other: DeepImmutable<Matrix>): Matrix;
  4054. /**
  4055. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4056. * @param other defines the matrix to add
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4061. /**
  4062. * Adds in place the given matrix to the current matrix
  4063. * @param other defines the second operand
  4064. * @returns the current updated matrix
  4065. */
  4066. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4067. /**
  4068. * Sets the given matrix to the current inverted Matrix
  4069. * @param other defines the target matrix
  4070. * @returns the unmodified current matrix
  4071. */
  4072. invertToRef(other: Matrix): Matrix;
  4073. /**
  4074. * add a value at the specified position in the current Matrix
  4075. * @param index the index of the value within the matrix. between 0 and 15.
  4076. * @param value the value to be added
  4077. * @returns the current updated matrix
  4078. */
  4079. addAtIndex(index: number, value: number): Matrix;
  4080. /**
  4081. * mutiply the specified position in the current Matrix by a value
  4082. * @param index the index of the value within the matrix. between 0 and 15.
  4083. * @param value the value to be added
  4084. * @returns the current updated matrix
  4085. */
  4086. multiplyAtIndex(index: number, value: number): Matrix;
  4087. /**
  4088. * Inserts the translation vector (using 3 floats) in the current matrix
  4089. * @param x defines the 1st component of the translation
  4090. * @param y defines the 2nd component of the translation
  4091. * @param z defines the 3rd component of the translation
  4092. * @returns the current updated matrix
  4093. */
  4094. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4095. /**
  4096. * Adds the translation vector (using 3 floats) in the current matrix
  4097. * @param x defines the 1st component of the translation
  4098. * @param y defines the 2nd component of the translation
  4099. * @param z defines the 3rd component of the translation
  4100. * @returns the current updated matrix
  4101. */
  4102. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4103. /**
  4104. * Inserts the translation vector in the current matrix
  4105. * @param vector3 defines the translation to insert
  4106. * @returns the current updated matrix
  4107. */
  4108. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4109. /**
  4110. * Gets the translation value of the current matrix
  4111. * @returns a new Vector3 as the extracted translation from the matrix
  4112. */
  4113. getTranslation(): Vector3;
  4114. /**
  4115. * Fill a Vector3 with the extracted translation from the matrix
  4116. * @param result defines the Vector3 where to store the translation
  4117. * @returns the current matrix
  4118. */
  4119. getTranslationToRef(result: Vector3): Matrix;
  4120. /**
  4121. * Remove rotation and scaling part from the matrix
  4122. * @returns the updated matrix
  4123. */
  4124. removeRotationAndScaling(): Matrix;
  4125. /**
  4126. * Multiply two matrices
  4127. * @param other defines the second operand
  4128. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4129. */
  4130. multiply(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Copy the current matrix from the given one
  4133. * @param other defines the source matrix
  4134. * @returns the current updated matrix
  4135. */
  4136. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4137. /**
  4138. * Populates the given array from the starting index with the current matrix values
  4139. * @param array defines the target array
  4140. * @param offset defines the offset in the target array where to start storing values
  4141. * @returns the current matrix
  4142. */
  4143. copyToArray(array: Float32Array, offset?: number): Matrix;
  4144. /**
  4145. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4146. * @param other defines the second operand
  4147. * @param result defines the matrix where to store the multiplication
  4148. * @returns the current matrix
  4149. */
  4150. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4151. /**
  4152. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4153. * @param other defines the second operand
  4154. * @param result defines the array where to store the multiplication
  4155. * @param offset defines the offset in the target array where to start storing values
  4156. * @returns the current matrix
  4157. */
  4158. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4159. /**
  4160. * Check equality between this matrix and a second one
  4161. * @param value defines the second matrix to compare
  4162. * @returns true is the current matrix and the given one values are strictly equal
  4163. */
  4164. equals(value: DeepImmutable<Matrix>): boolean;
  4165. /**
  4166. * Clone the current matrix
  4167. * @returns a new matrix from the current matrix
  4168. */
  4169. clone(): Matrix;
  4170. /**
  4171. * Returns the name of the current matrix class
  4172. * @returns the string "Matrix"
  4173. */
  4174. getClassName(): string;
  4175. /**
  4176. * Gets the hash code of the current matrix
  4177. * @returns the hash code
  4178. */
  4179. getHashCode(): number;
  4180. /**
  4181. * Decomposes the current Matrix into a translation, rotation and scaling components
  4182. * @param scale defines the scale vector3 given as a reference to update
  4183. * @param rotation defines the rotation quaternion given as a reference to update
  4184. * @param translation defines the translation vector3 given as a reference to update
  4185. * @returns true if operation was successful
  4186. */
  4187. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4188. /**
  4189. * Gets specific row of the matrix
  4190. * @param index defines the number of the row to get
  4191. * @returns the index-th row of the current matrix as a new Vector4
  4192. */
  4193. getRow(index: number): Nullable<Vector4>;
  4194. /**
  4195. * Sets the index-th row of the current matrix to the vector4 values
  4196. * @param index defines the number of the row to set
  4197. * @param row defines the target vector4
  4198. * @returns the updated current matrix
  4199. */
  4200. setRow(index: number, row: Vector4): Matrix;
  4201. /**
  4202. * Compute the transpose of the matrix
  4203. * @returns the new transposed matrix
  4204. */
  4205. transpose(): Matrix;
  4206. /**
  4207. * Compute the transpose of the matrix and store it in a given matrix
  4208. * @param result defines the target matrix
  4209. * @returns the current matrix
  4210. */
  4211. transposeToRef(result: Matrix): Matrix;
  4212. /**
  4213. * Sets the index-th row of the current matrix with the given 4 x float values
  4214. * @param index defines the row index
  4215. * @param x defines the x component to set
  4216. * @param y defines the y component to set
  4217. * @param z defines the z component to set
  4218. * @param w defines the w component to set
  4219. * @returns the updated current matrix
  4220. */
  4221. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4222. /**
  4223. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4224. * @param scale defines the scale factor
  4225. * @returns a new matrix
  4226. */
  4227. scale(scale: number): Matrix;
  4228. /**
  4229. * Scale the current matrix values by a factor to a given result matrix
  4230. * @param scale defines the scale factor
  4231. * @param result defines the matrix to store the result
  4232. * @returns the current matrix
  4233. */
  4234. scaleToRef(scale: number, result: Matrix): Matrix;
  4235. /**
  4236. * Scale the current matrix values by a factor and add the result to a given matrix
  4237. * @param scale defines the scale factor
  4238. * @param result defines the Matrix to store the result
  4239. * @returns the current matrix
  4240. */
  4241. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4242. /**
  4243. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4244. * @param ref matrix to store the result
  4245. */
  4246. toNormalMatrix(ref: Matrix): void;
  4247. /**
  4248. * Gets only rotation part of the current matrix
  4249. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4250. */
  4251. getRotationMatrix(): Matrix;
  4252. /**
  4253. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4254. * @param result defines the target matrix to store data to
  4255. * @returns the current matrix
  4256. */
  4257. getRotationMatrixToRef(result: Matrix): Matrix;
  4258. /**
  4259. * Toggles model matrix from being right handed to left handed in place and vice versa
  4260. */
  4261. toggleModelMatrixHandInPlace(): void;
  4262. /**
  4263. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4264. */
  4265. toggleProjectionMatrixHandInPlace(): void;
  4266. /**
  4267. * Creates a matrix from an array
  4268. * @param array defines the source array
  4269. * @param offset defines an offset in the source array
  4270. * @returns a new Matrix set from the starting index of the given array
  4271. */
  4272. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4273. /**
  4274. * Copy the content of an array into a given matrix
  4275. * @param array defines the source array
  4276. * @param offset defines an offset in the source array
  4277. * @param result defines the target matrix
  4278. */
  4279. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4280. /**
  4281. * Stores an array into a matrix after having multiplied each component by a given factor
  4282. * @param array defines the source array
  4283. * @param offset defines the offset in the source array
  4284. * @param scale defines the scaling factor
  4285. * @param result defines the target matrix
  4286. */
  4287. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4288. /**
  4289. * Gets an identity matrix that must not be updated
  4290. */
  4291. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4292. /**
  4293. * Stores a list of values (16) inside a given matrix
  4294. * @param initialM11 defines 1st value of 1st row
  4295. * @param initialM12 defines 2nd value of 1st row
  4296. * @param initialM13 defines 3rd value of 1st row
  4297. * @param initialM14 defines 4th value of 1st row
  4298. * @param initialM21 defines 1st value of 2nd row
  4299. * @param initialM22 defines 2nd value of 2nd row
  4300. * @param initialM23 defines 3rd value of 2nd row
  4301. * @param initialM24 defines 4th value of 2nd row
  4302. * @param initialM31 defines 1st value of 3rd row
  4303. * @param initialM32 defines 2nd value of 3rd row
  4304. * @param initialM33 defines 3rd value of 3rd row
  4305. * @param initialM34 defines 4th value of 3rd row
  4306. * @param initialM41 defines 1st value of 4th row
  4307. * @param initialM42 defines 2nd value of 4th row
  4308. * @param initialM43 defines 3rd value of 4th row
  4309. * @param initialM44 defines 4th value of 4th row
  4310. * @param result defines the target matrix
  4311. */
  4312. 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;
  4313. /**
  4314. * Creates new matrix from a list of values (16)
  4315. * @param initialM11 defines 1st value of 1st row
  4316. * @param initialM12 defines 2nd value of 1st row
  4317. * @param initialM13 defines 3rd value of 1st row
  4318. * @param initialM14 defines 4th value of 1st row
  4319. * @param initialM21 defines 1st value of 2nd row
  4320. * @param initialM22 defines 2nd value of 2nd row
  4321. * @param initialM23 defines 3rd value of 2nd row
  4322. * @param initialM24 defines 4th value of 2nd row
  4323. * @param initialM31 defines 1st value of 3rd row
  4324. * @param initialM32 defines 2nd value of 3rd row
  4325. * @param initialM33 defines 3rd value of 3rd row
  4326. * @param initialM34 defines 4th value of 3rd row
  4327. * @param initialM41 defines 1st value of 4th row
  4328. * @param initialM42 defines 2nd value of 4th row
  4329. * @param initialM43 defines 3rd value of 4th row
  4330. * @param initialM44 defines 4th value of 4th row
  4331. * @returns the new matrix
  4332. */
  4333. 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;
  4334. /**
  4335. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4336. * @param scale defines the scale vector3
  4337. * @param rotation defines the rotation quaternion
  4338. * @param translation defines the translation vector3
  4339. * @returns a new matrix
  4340. */
  4341. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4342. /**
  4343. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4344. * @param scale defines the scale vector3
  4345. * @param rotation defines the rotation quaternion
  4346. * @param translation defines the translation vector3
  4347. * @param result defines the target matrix
  4348. */
  4349. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4350. /**
  4351. * Creates a new identity matrix
  4352. * @returns a new identity matrix
  4353. */
  4354. static Identity(): Matrix;
  4355. /**
  4356. * Creates a new identity matrix and stores the result in a given matrix
  4357. * @param result defines the target matrix
  4358. */
  4359. static IdentityToRef(result: Matrix): void;
  4360. /**
  4361. * Creates a new zero matrix
  4362. * @returns a new zero matrix
  4363. */
  4364. static Zero(): Matrix;
  4365. /**
  4366. * Creates a new rotation matrix for "angle" radians around the X axis
  4367. * @param angle defines the angle (in radians) to use
  4368. * @return the new matrix
  4369. */
  4370. static RotationX(angle: number): Matrix;
  4371. /**
  4372. * Creates a new matrix as the invert of a given matrix
  4373. * @param source defines the source matrix
  4374. * @returns the new matrix
  4375. */
  4376. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4377. /**
  4378. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4379. * @param angle defines the angle (in radians) to use
  4380. * @param result defines the target matrix
  4381. */
  4382. static RotationXToRef(angle: number, result: Matrix): void;
  4383. /**
  4384. * Creates a new rotation matrix for "angle" radians around the Y axis
  4385. * @param angle defines the angle (in radians) to use
  4386. * @return the new matrix
  4387. */
  4388. static RotationY(angle: number): Matrix;
  4389. /**
  4390. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4391. * @param angle defines the angle (in radians) to use
  4392. * @param result defines the target matrix
  4393. */
  4394. static RotationYToRef(angle: number, result: Matrix): void;
  4395. /**
  4396. * Creates a new rotation matrix for "angle" radians around the Z axis
  4397. * @param angle defines the angle (in radians) to use
  4398. * @return the new matrix
  4399. */
  4400. static RotationZ(angle: number): Matrix;
  4401. /**
  4402. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4403. * @param angle defines the angle (in radians) to use
  4404. * @param result defines the target matrix
  4405. */
  4406. static RotationZToRef(angle: number, result: Matrix): void;
  4407. /**
  4408. * Creates a new rotation matrix for "angle" radians around the given axis
  4409. * @param axis defines the axis to use
  4410. * @param angle defines the angle (in radians) to use
  4411. * @return the new matrix
  4412. */
  4413. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4414. /**
  4415. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4416. * @param axis defines the axis to use
  4417. * @param angle defines the angle (in radians) to use
  4418. * @param result defines the target matrix
  4419. */
  4420. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4421. /**
  4422. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4423. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4424. * @param from defines the vector to align
  4425. * @param to defines the vector to align to
  4426. * @param result defines the target matrix
  4427. */
  4428. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4429. /**
  4430. * Creates a rotation matrix
  4431. * @param yaw defines the yaw angle in radians (Y axis)
  4432. * @param pitch defines the pitch angle in radians (X axis)
  4433. * @param roll defines the roll angle in radians (X axis)
  4434. * @returns the new rotation matrix
  4435. */
  4436. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4437. /**
  4438. * Creates a rotation matrix and stores it in a given matrix
  4439. * @param yaw defines the yaw angle in radians (Y axis)
  4440. * @param pitch defines the pitch angle in radians (X axis)
  4441. * @param roll defines the roll angle in radians (X axis)
  4442. * @param result defines the target matrix
  4443. */
  4444. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4445. /**
  4446. * Creates a scaling matrix
  4447. * @param x defines the scale factor on X axis
  4448. * @param y defines the scale factor on Y axis
  4449. * @param z defines the scale factor on Z axis
  4450. * @returns the new matrix
  4451. */
  4452. static Scaling(x: number, y: number, z: number): Matrix;
  4453. /**
  4454. * Creates a scaling matrix and stores it in a given matrix
  4455. * @param x defines the scale factor on X axis
  4456. * @param y defines the scale factor on Y axis
  4457. * @param z defines the scale factor on Z axis
  4458. * @param result defines the target matrix
  4459. */
  4460. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4461. /**
  4462. * Creates a translation matrix
  4463. * @param x defines the translation on X axis
  4464. * @param y defines the translation on Y axis
  4465. * @param z defines the translationon Z axis
  4466. * @returns the new matrix
  4467. */
  4468. static Translation(x: number, y: number, z: number): Matrix;
  4469. /**
  4470. * Creates a translation matrix and stores it in a given matrix
  4471. * @param x defines the translation on X axis
  4472. * @param y defines the translation on Y axis
  4473. * @param z defines the translationon Z axis
  4474. * @param result defines the target matrix
  4475. */
  4476. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4477. /**
  4478. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4479. * @param startValue defines the start value
  4480. * @param endValue defines the end value
  4481. * @param gradient defines the gradient factor
  4482. * @returns the new matrix
  4483. */
  4484. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4485. /**
  4486. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4487. * @param startValue defines the start value
  4488. * @param endValue defines the end value
  4489. * @param gradient defines the gradient factor
  4490. * @param result defines the Matrix object where to store data
  4491. */
  4492. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4493. /**
  4494. * Builds a new matrix whose values are computed by:
  4495. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4496. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4497. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4498. * @param startValue defines the first matrix
  4499. * @param endValue defines the second matrix
  4500. * @param gradient defines the gradient between the two matrices
  4501. * @returns the new matrix
  4502. */
  4503. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4504. /**
  4505. * Update a matrix to values which are computed by:
  4506. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4507. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4508. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4509. * @param startValue defines the first matrix
  4510. * @param endValue defines the second matrix
  4511. * @param gradient defines the gradient between the two matrices
  4512. * @param result defines the target matrix
  4513. */
  4514. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4515. /**
  4516. * 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"
  4517. * This function works in left handed mode
  4518. * @param eye defines the final position of the entity
  4519. * @param target defines where the entity should look at
  4520. * @param up defines the up vector for the entity
  4521. * @returns the new matrix
  4522. */
  4523. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4524. /**
  4525. * 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".
  4526. * This function works in left handed mode
  4527. * @param eye defines the final position of the entity
  4528. * @param target defines where the entity should look at
  4529. * @param up defines the up vector for the entity
  4530. * @param result defines the target matrix
  4531. */
  4532. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4533. /**
  4534. * 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"
  4535. * This function works in right handed mode
  4536. * @param eye defines the final position of the entity
  4537. * @param target defines where the entity should look at
  4538. * @param up defines the up vector for the entity
  4539. * @returns the new matrix
  4540. */
  4541. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4542. /**
  4543. * 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".
  4544. * This function works in right handed mode
  4545. * @param eye defines the final position of the entity
  4546. * @param target defines where the entity should look at
  4547. * @param up defines the up vector for the entity
  4548. * @param result defines the target matrix
  4549. */
  4550. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4551. /**
  4552. * Create a left-handed orthographic projection matrix
  4553. * @param width defines the viewport width
  4554. * @param height defines the viewport height
  4555. * @param znear defines the near clip plane
  4556. * @param zfar defines the far clip plane
  4557. * @returns a new matrix as a left-handed orthographic projection matrix
  4558. */
  4559. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4560. /**
  4561. * Store a left-handed orthographic projection to a given matrix
  4562. * @param width defines the viewport width
  4563. * @param height defines the viewport height
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @param result defines the target matrix
  4567. */
  4568. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4569. /**
  4570. * Create a left-handed orthographic projection matrix
  4571. * @param left defines the viewport left coordinate
  4572. * @param right defines the viewport right coordinate
  4573. * @param bottom defines the viewport bottom coordinate
  4574. * @param top defines the viewport top coordinate
  4575. * @param znear defines the near clip plane
  4576. * @param zfar defines the far clip plane
  4577. * @returns a new matrix as a left-handed orthographic projection matrix
  4578. */
  4579. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4580. /**
  4581. * Stores a left-handed orthographic projection into a given matrix
  4582. * @param left defines the viewport left coordinate
  4583. * @param right defines the viewport right coordinate
  4584. * @param bottom defines the viewport bottom coordinate
  4585. * @param top defines the viewport top coordinate
  4586. * @param znear defines the near clip plane
  4587. * @param zfar defines the far clip plane
  4588. * @param result defines the target matrix
  4589. */
  4590. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4591. /**
  4592. * Creates a right-handed orthographic projection matrix
  4593. * @param left defines the viewport left coordinate
  4594. * @param right defines the viewport right coordinate
  4595. * @param bottom defines the viewport bottom coordinate
  4596. * @param top defines the viewport top coordinate
  4597. * @param znear defines the near clip plane
  4598. * @param zfar defines the far clip plane
  4599. * @returns a new matrix as a right-handed orthographic projection matrix
  4600. */
  4601. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4602. /**
  4603. * Stores a right-handed orthographic projection into a given matrix
  4604. * @param left defines the viewport left coordinate
  4605. * @param right defines the viewport right coordinate
  4606. * @param bottom defines the viewport bottom coordinate
  4607. * @param top defines the viewport top coordinate
  4608. * @param znear defines the near clip plane
  4609. * @param zfar defines the far clip plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4613. /**
  4614. * Creates a left-handed perspective projection matrix
  4615. * @param width defines the viewport width
  4616. * @param height defines the viewport height
  4617. * @param znear defines the near clip plane
  4618. * @param zfar defines the far clip plane
  4619. * @returns a new matrix as a left-handed perspective projection matrix
  4620. */
  4621. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4622. /**
  4623. * Creates a left-handed perspective projection matrix
  4624. * @param fov defines the horizontal field of view
  4625. * @param aspect defines the aspect ratio
  4626. * @param znear defines the near clip plane
  4627. * @param zfar defines the far clip plane
  4628. * @returns a new matrix as a left-handed perspective projection matrix
  4629. */
  4630. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4631. /**
  4632. * Stores a left-handed perspective projection into a given matrix
  4633. * @param fov defines the horizontal field of view
  4634. * @param aspect defines the aspect ratio
  4635. * @param znear defines the near clip plane
  4636. * @param zfar defines the far clip plane
  4637. * @param result defines the target matrix
  4638. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4639. */
  4640. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4641. /**
  4642. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4643. * @param fov defines the horizontal field of view
  4644. * @param aspect defines the aspect ratio
  4645. * @param znear defines the near clip plane
  4646. * @param zfar not used as infinity is used as far clip
  4647. * @param result defines the target matrix
  4648. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4649. */
  4650. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4651. /**
  4652. * Creates a right-handed perspective projection matrix
  4653. * @param fov defines the horizontal field of view
  4654. * @param aspect defines the aspect ratio
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a right-handed perspective projection matrix
  4658. */
  4659. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Stores a right-handed perspective projection into a given matrix
  4662. * @param fov defines the horizontal field of view
  4663. * @param aspect defines the aspect ratio
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4668. */
  4669. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4670. /**
  4671. * Stores a right-handed perspective projection into a given matrix
  4672. * @param fov defines the horizontal field of view
  4673. * @param aspect defines the aspect ratio
  4674. * @param znear defines the near clip plane
  4675. * @param zfar not used as infinity is used as far clip
  4676. * @param result defines the target matrix
  4677. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4678. */
  4679. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4680. /**
  4681. * Stores a perspective projection for WebVR info a given matrix
  4682. * @param fov defines the field of view
  4683. * @param znear defines the near clip plane
  4684. * @param zfar defines the far clip plane
  4685. * @param result defines the target matrix
  4686. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4687. */
  4688. static PerspectiveFovWebVRToRef(fov: {
  4689. upDegrees: number;
  4690. downDegrees: number;
  4691. leftDegrees: number;
  4692. rightDegrees: number;
  4693. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4694. /**
  4695. * Computes a complete transformation matrix
  4696. * @param viewport defines the viewport to use
  4697. * @param world defines the world matrix
  4698. * @param view defines the view matrix
  4699. * @param projection defines the projection matrix
  4700. * @param zmin defines the near clip plane
  4701. * @param zmax defines the far clip plane
  4702. * @returns the transformation matrix
  4703. */
  4704. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4705. /**
  4706. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4707. * @param matrix defines the matrix to use
  4708. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4709. */
  4710. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4711. /**
  4712. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4713. * @param matrix defines the matrix to use
  4714. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4715. */
  4716. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4717. /**
  4718. * Compute the transpose of a given matrix
  4719. * @param matrix defines the matrix to transpose
  4720. * @returns the new matrix
  4721. */
  4722. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4723. /**
  4724. * Compute the transpose of a matrix and store it in a target matrix
  4725. * @param matrix defines the matrix to transpose
  4726. * @param result defines the target matrix
  4727. */
  4728. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4729. /**
  4730. * Computes a reflection matrix from a plane
  4731. * @param plane defines the reflection plane
  4732. * @returns a new matrix
  4733. */
  4734. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4735. /**
  4736. * Computes a reflection matrix from a plane
  4737. * @param plane defines the reflection plane
  4738. * @param result defines the target matrix
  4739. */
  4740. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4741. /**
  4742. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4743. * @param xaxis defines the value of the 1st axis
  4744. * @param yaxis defines the value of the 2nd axis
  4745. * @param zaxis defines the value of the 3rd axis
  4746. * @param result defines the target matrix
  4747. */
  4748. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4749. /**
  4750. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4751. * @param quat defines the quaternion to use
  4752. * @param result defines the target matrix
  4753. */
  4754. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4755. }
  4756. /**
  4757. * @hidden
  4758. */
  4759. export class TmpVectors {
  4760. static Vector2: Vector2[];
  4761. static Vector3: Vector3[];
  4762. static Vector4: Vector4[];
  4763. static Quaternion: Quaternion[];
  4764. static Matrix: Matrix[];
  4765. }
  4766. }
  4767. declare module BABYLON {
  4768. /**
  4769. * Defines potential orientation for back face culling
  4770. */
  4771. export enum Orientation {
  4772. /**
  4773. * Clockwise
  4774. */
  4775. CW = 0,
  4776. /** Counter clockwise */
  4777. CCW = 1
  4778. }
  4779. /** Class used to represent a Bezier curve */
  4780. export class BezierCurve {
  4781. /**
  4782. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4783. * @param t defines the time
  4784. * @param x1 defines the left coordinate on X axis
  4785. * @param y1 defines the left coordinate on Y axis
  4786. * @param x2 defines the right coordinate on X axis
  4787. * @param y2 defines the right coordinate on Y axis
  4788. * @returns the interpolated value
  4789. */
  4790. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4791. }
  4792. /**
  4793. * Defines angle representation
  4794. */
  4795. export class Angle {
  4796. private _radians;
  4797. /**
  4798. * Creates an Angle object of "radians" radians (float).
  4799. * @param radians the angle in radians
  4800. */
  4801. constructor(radians: number);
  4802. /**
  4803. * Get value in degrees
  4804. * @returns the Angle value in degrees (float)
  4805. */
  4806. degrees(): number;
  4807. /**
  4808. * Get value in radians
  4809. * @returns the Angle value in radians (float)
  4810. */
  4811. radians(): number;
  4812. /**
  4813. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4814. * @param a defines first vector
  4815. * @param b defines second vector
  4816. * @returns a new Angle
  4817. */
  4818. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4819. /**
  4820. * Gets a new Angle object from the given float in radians
  4821. * @param radians defines the angle value in radians
  4822. * @returns a new Angle
  4823. */
  4824. static FromRadians(radians: number): Angle;
  4825. /**
  4826. * Gets a new Angle object from the given float in degrees
  4827. * @param degrees defines the angle value in degrees
  4828. * @returns a new Angle
  4829. */
  4830. static FromDegrees(degrees: number): Angle;
  4831. }
  4832. /**
  4833. * This represents an arc in a 2d space.
  4834. */
  4835. export class Arc2 {
  4836. /** Defines the start point of the arc */
  4837. startPoint: Vector2;
  4838. /** Defines the mid point of the arc */
  4839. midPoint: Vector2;
  4840. /** Defines the end point of the arc */
  4841. endPoint: Vector2;
  4842. /**
  4843. * Defines the center point of the arc.
  4844. */
  4845. centerPoint: Vector2;
  4846. /**
  4847. * Defines the radius of the arc.
  4848. */
  4849. radius: number;
  4850. /**
  4851. * Defines the angle of the arc (from mid point to end point).
  4852. */
  4853. angle: Angle;
  4854. /**
  4855. * Defines the start angle of the arc (from start point to middle point).
  4856. */
  4857. startAngle: Angle;
  4858. /**
  4859. * Defines the orientation of the arc (clock wise/counter clock wise).
  4860. */
  4861. orientation: Orientation;
  4862. /**
  4863. * Creates an Arc object from the three given points : start, middle and end.
  4864. * @param startPoint Defines the start point of the arc
  4865. * @param midPoint Defines the midlle point of the arc
  4866. * @param endPoint Defines the end point of the arc
  4867. */
  4868. constructor(
  4869. /** Defines the start point of the arc */
  4870. startPoint: Vector2,
  4871. /** Defines the mid point of the arc */
  4872. midPoint: Vector2,
  4873. /** Defines the end point of the arc */
  4874. endPoint: Vector2);
  4875. }
  4876. /**
  4877. * Represents a 2D path made up of multiple 2D points
  4878. */
  4879. export class Path2 {
  4880. private _points;
  4881. private _length;
  4882. /**
  4883. * If the path start and end point are the same
  4884. */
  4885. closed: boolean;
  4886. /**
  4887. * Creates a Path2 object from the starting 2D coordinates x and y.
  4888. * @param x the starting points x value
  4889. * @param y the starting points y value
  4890. */
  4891. constructor(x: number, y: number);
  4892. /**
  4893. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4894. * @param x the added points x value
  4895. * @param y the added points y value
  4896. * @returns the updated Path2.
  4897. */
  4898. addLineTo(x: number, y: number): Path2;
  4899. /**
  4900. * 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.
  4901. * @param midX middle point x value
  4902. * @param midY middle point y value
  4903. * @param endX end point x value
  4904. * @param endY end point y value
  4905. * @param numberOfSegments (default: 36)
  4906. * @returns the updated Path2.
  4907. */
  4908. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4909. /**
  4910. * Closes the Path2.
  4911. * @returns the Path2.
  4912. */
  4913. close(): Path2;
  4914. /**
  4915. * Gets the sum of the distance between each sequential point in the path
  4916. * @returns the Path2 total length (float).
  4917. */
  4918. length(): number;
  4919. /**
  4920. * Gets the points which construct the path
  4921. * @returns the Path2 internal array of points.
  4922. */
  4923. getPoints(): Vector2[];
  4924. /**
  4925. * Retreives the point at the distance aways from the starting point
  4926. * @param normalizedLengthPosition the length along the path to retreive the point from
  4927. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4928. */
  4929. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4930. /**
  4931. * Creates a new path starting from an x and y position
  4932. * @param x starting x value
  4933. * @param y starting y value
  4934. * @returns a new Path2 starting at the coordinates (x, y).
  4935. */
  4936. static StartingAt(x: number, y: number): Path2;
  4937. }
  4938. /**
  4939. * Represents a 3D path made up of multiple 3D points
  4940. */
  4941. export class Path3D {
  4942. /**
  4943. * an array of Vector3, the curve axis of the Path3D
  4944. */
  4945. path: Vector3[];
  4946. private _curve;
  4947. private _distances;
  4948. private _tangents;
  4949. private _normals;
  4950. private _binormals;
  4951. private _raw;
  4952. private _alignTangentsWithPath;
  4953. private readonly _pointAtData;
  4954. /**
  4955. * new Path3D(path, normal, raw)
  4956. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4957. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4958. * @param path an array of Vector3, the curve axis of the Path3D
  4959. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4960. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4961. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4962. */
  4963. constructor(
  4964. /**
  4965. * an array of Vector3, the curve axis of the Path3D
  4966. */
  4967. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4968. /**
  4969. * Returns the Path3D array of successive Vector3 designing its curve.
  4970. * @returns the Path3D array of successive Vector3 designing its curve.
  4971. */
  4972. getCurve(): Vector3[];
  4973. /**
  4974. * Returns the Path3D array of successive Vector3 designing its curve.
  4975. * @returns the Path3D array of successive Vector3 designing its curve.
  4976. */
  4977. getPoints(): Vector3[];
  4978. /**
  4979. * @returns the computed length (float) of the path.
  4980. */
  4981. length(): number;
  4982. /**
  4983. * Returns an array populated with tangent vectors on each Path3D curve point.
  4984. * @returns an array populated with tangent vectors on each Path3D curve point.
  4985. */
  4986. getTangents(): Vector3[];
  4987. /**
  4988. * Returns an array populated with normal vectors on each Path3D curve point.
  4989. * @returns an array populated with normal vectors on each Path3D curve point.
  4990. */
  4991. getNormals(): Vector3[];
  4992. /**
  4993. * Returns an array populated with binormal vectors on each Path3D curve point.
  4994. * @returns an array populated with binormal vectors on each Path3D curve point.
  4995. */
  4996. getBinormals(): Vector3[];
  4997. /**
  4998. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4999. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5000. */
  5001. getDistances(): number[];
  5002. /**
  5003. * Returns an interpolated point along this path
  5004. * @param position the position of the point along this path, from 0.0 to 1.0
  5005. * @returns a new Vector3 as the point
  5006. */
  5007. getPointAt(position: number): Vector3;
  5008. /**
  5009. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5010. * @param position the position of the point along this path, from 0.0 to 1.0
  5011. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5012. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5013. */
  5014. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5015. /**
  5016. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5017. * @param position the position of the point along this path, from 0.0 to 1.0
  5018. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5019. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5020. */
  5021. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5022. /**
  5023. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5024. * @param position the position of the point along this path, from 0.0 to 1.0
  5025. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5026. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5027. */
  5028. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5029. /**
  5030. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5031. * @param position the position of the point along this path, from 0.0 to 1.0
  5032. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5033. */
  5034. getDistanceAt(position: number): number;
  5035. /**
  5036. * Returns the array index of the previous point of an interpolated point along this path
  5037. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5038. * @returns the array index
  5039. */
  5040. getPreviousPointIndexAt(position: number): number;
  5041. /**
  5042. * 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)
  5043. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5044. * @returns the sub position
  5045. */
  5046. getSubPositionAt(position: number): number;
  5047. /**
  5048. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5049. * @param target the vector of which to get the closest position to
  5050. * @returns the position of the closest virtual point on this path to the target vector
  5051. */
  5052. getClosestPositionTo(target: Vector3): number;
  5053. /**
  5054. * Returns a sub path (slice) of this path
  5055. * @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
  5056. * @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
  5057. * @returns a sub path (slice) of this path
  5058. */
  5059. slice(start?: number, end?: number): Path3D;
  5060. /**
  5061. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5062. * @param path path which all values are copied into the curves points
  5063. * @param firstNormal which should be projected onto the curve
  5064. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5065. * @returns the same object updated.
  5066. */
  5067. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5068. private _compute;
  5069. private _getFirstNonNullVector;
  5070. private _getLastNonNullVector;
  5071. private _normalVector;
  5072. /**
  5073. * Updates the point at data for an interpolated point along this curve
  5074. * @param position the position of the point along this curve, from 0.0 to 1.0
  5075. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5076. * @returns the (updated) point at data
  5077. */
  5078. private _updatePointAtData;
  5079. /**
  5080. * Updates the point at data from the specified parameters
  5081. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5082. * @param point the interpolated point
  5083. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5084. */
  5085. private _setPointAtData;
  5086. /**
  5087. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5088. */
  5089. private _updateInterpolationMatrix;
  5090. }
  5091. /**
  5092. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5093. * A Curve3 is designed from a series of successive Vector3.
  5094. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5095. */
  5096. export class Curve3 {
  5097. private _points;
  5098. private _length;
  5099. /**
  5100. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5101. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5102. * @param v1 (Vector3) the control point
  5103. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5104. * @param nbPoints (integer) the wanted number of points in the curve
  5105. * @returns the created Curve3
  5106. */
  5107. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5108. /**
  5109. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5110. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5111. * @param v1 (Vector3) the first control point
  5112. * @param v2 (Vector3) the second control point
  5113. * @param v3 (Vector3) the end point of the Cubic Bezier
  5114. * @param nbPoints (integer) the wanted number of points in the curve
  5115. * @returns the created Curve3
  5116. */
  5117. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5118. /**
  5119. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5120. * @param p1 (Vector3) the origin point of the Hermite Spline
  5121. * @param t1 (Vector3) the tangent vector at the origin point
  5122. * @param p2 (Vector3) the end point of the Hermite Spline
  5123. * @param t2 (Vector3) the tangent vector at the end point
  5124. * @param nbPoints (integer) the wanted number of points in the curve
  5125. * @returns the created Curve3
  5126. */
  5127. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5128. /**
  5129. * Returns a Curve3 object along a CatmullRom Spline curve :
  5130. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5131. * @param nbPoints (integer) the wanted number of points between each curve control points
  5132. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5133. * @returns the created Curve3
  5134. */
  5135. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5136. /**
  5137. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5138. * A Curve3 is designed from a series of successive Vector3.
  5139. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5140. * @param points points which make up the curve
  5141. */
  5142. constructor(points: Vector3[]);
  5143. /**
  5144. * @returns the Curve3 stored array of successive Vector3
  5145. */
  5146. getPoints(): Vector3[];
  5147. /**
  5148. * @returns the computed length (float) of the curve.
  5149. */
  5150. length(): number;
  5151. /**
  5152. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5153. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5154. * curveA and curveB keep unchanged.
  5155. * @param curve the curve to continue from this curve
  5156. * @returns the newly constructed curve
  5157. */
  5158. continue(curve: DeepImmutable<Curve3>): Curve3;
  5159. private _computeLength;
  5160. }
  5161. }
  5162. declare module BABYLON {
  5163. /**
  5164. * This represents the main contract an easing function should follow.
  5165. * Easing functions are used throughout the animation system.
  5166. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5167. */
  5168. export interface IEasingFunction {
  5169. /**
  5170. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5171. * of the easing function.
  5172. * The link below provides some of the most common examples of easing functions.
  5173. * @see https://easings.net/
  5174. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5175. * @returns the corresponding value on the curve defined by the easing function
  5176. */
  5177. ease(gradient: number): number;
  5178. }
  5179. /**
  5180. * Base class used for every default easing function.
  5181. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5182. */
  5183. export class EasingFunction implements IEasingFunction {
  5184. /**
  5185. * Interpolation follows the mathematical formula associated with the easing function.
  5186. */
  5187. static readonly EASINGMODE_EASEIN: number;
  5188. /**
  5189. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5190. */
  5191. static readonly EASINGMODE_EASEOUT: number;
  5192. /**
  5193. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5194. */
  5195. static readonly EASINGMODE_EASEINOUT: number;
  5196. private _easingMode;
  5197. /**
  5198. * Sets the easing mode of the current function.
  5199. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5200. */
  5201. setEasingMode(easingMode: number): void;
  5202. /**
  5203. * Gets the current easing mode.
  5204. * @returns the easing mode
  5205. */
  5206. getEasingMode(): number;
  5207. /**
  5208. * @hidden
  5209. */
  5210. easeInCore(gradient: number): number;
  5211. /**
  5212. * Given an input gradient between 0 and 1, this returns the corresponding value
  5213. * of the easing function.
  5214. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5215. * @returns the corresponding value on the curve defined by the easing function
  5216. */
  5217. ease(gradient: number): number;
  5218. }
  5219. /**
  5220. * Easing function with a circle shape (see link below).
  5221. * @see https://easings.net/#easeInCirc
  5222. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5223. */
  5224. export class CircleEase extends EasingFunction implements IEasingFunction {
  5225. /** @hidden */
  5226. easeInCore(gradient: number): number;
  5227. }
  5228. /**
  5229. * Easing function with a ease back shape (see link below).
  5230. * @see https://easings.net/#easeInBack
  5231. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5232. */
  5233. export class BackEase extends EasingFunction implements IEasingFunction {
  5234. /** Defines the amplitude of the function */
  5235. amplitude: number;
  5236. /**
  5237. * Instantiates a back ease easing
  5238. * @see https://easings.net/#easeInBack
  5239. * @param amplitude Defines the amplitude of the function
  5240. */
  5241. constructor(
  5242. /** Defines the amplitude of the function */
  5243. amplitude?: number);
  5244. /** @hidden */
  5245. easeInCore(gradient: number): number;
  5246. }
  5247. /**
  5248. * Easing function with a bouncing shape (see link below).
  5249. * @see https://easings.net/#easeInBounce
  5250. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5251. */
  5252. export class BounceEase extends EasingFunction implements IEasingFunction {
  5253. /** Defines the number of bounces */
  5254. bounces: number;
  5255. /** Defines the amplitude of the bounce */
  5256. bounciness: number;
  5257. /**
  5258. * Instantiates a bounce easing
  5259. * @see https://easings.net/#easeInBounce
  5260. * @param bounces Defines the number of bounces
  5261. * @param bounciness Defines the amplitude of the bounce
  5262. */
  5263. constructor(
  5264. /** Defines the number of bounces */
  5265. bounces?: number,
  5266. /** Defines the amplitude of the bounce */
  5267. bounciness?: number);
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a power of 3 shape (see link below).
  5273. * @see https://easings.net/#easeInCubic
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class CubicEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with an elastic shape (see link below).
  5282. * @see https://easings.net/#easeInElastic
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5286. /** Defines the number of oscillations*/
  5287. oscillations: number;
  5288. /** Defines the amplitude of the oscillations*/
  5289. springiness: number;
  5290. /**
  5291. * Instantiates an elastic easing function
  5292. * @see https://easings.net/#easeInElastic
  5293. * @param oscillations Defines the number of oscillations
  5294. * @param springiness Defines the amplitude of the oscillations
  5295. */
  5296. constructor(
  5297. /** Defines the number of oscillations*/
  5298. oscillations?: number,
  5299. /** Defines the amplitude of the oscillations*/
  5300. springiness?: number);
  5301. /** @hidden */
  5302. easeInCore(gradient: number): number;
  5303. }
  5304. /**
  5305. * Easing function with an exponential shape (see link below).
  5306. * @see https://easings.net/#easeInExpo
  5307. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5308. */
  5309. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5310. /** Defines the exponent of the function */
  5311. exponent: number;
  5312. /**
  5313. * Instantiates an exponential easing function
  5314. * @see https://easings.net/#easeInExpo
  5315. * @param exponent Defines the exponent of the function
  5316. */
  5317. constructor(
  5318. /** Defines the exponent of the function */
  5319. exponent?: number);
  5320. /** @hidden */
  5321. easeInCore(gradient: number): number;
  5322. }
  5323. /**
  5324. * Easing function with a power shape (see link below).
  5325. * @see https://easings.net/#easeInQuad
  5326. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5327. */
  5328. export class PowerEase extends EasingFunction implements IEasingFunction {
  5329. /** Defines the power of the function */
  5330. power: number;
  5331. /**
  5332. * Instantiates an power base easing function
  5333. * @see https://easings.net/#easeInQuad
  5334. * @param power Defines the power of the function
  5335. */
  5336. constructor(
  5337. /** Defines the power of the function */
  5338. power?: number);
  5339. /** @hidden */
  5340. easeInCore(gradient: number): number;
  5341. }
  5342. /**
  5343. * Easing function with a power of 2 shape (see link below).
  5344. * @see https://easings.net/#easeInQuad
  5345. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5346. */
  5347. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5348. /** @hidden */
  5349. easeInCore(gradient: number): number;
  5350. }
  5351. /**
  5352. * Easing function with a power of 4 shape (see link below).
  5353. * @see https://easings.net/#easeInQuart
  5354. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5355. */
  5356. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5357. /** @hidden */
  5358. easeInCore(gradient: number): number;
  5359. }
  5360. /**
  5361. * Easing function with a power of 5 shape (see link below).
  5362. * @see https://easings.net/#easeInQuint
  5363. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5364. */
  5365. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5366. /** @hidden */
  5367. easeInCore(gradient: number): number;
  5368. }
  5369. /**
  5370. * Easing function with a sin shape (see link below).
  5371. * @see https://easings.net/#easeInSine
  5372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5373. */
  5374. export class SineEase extends EasingFunction implements IEasingFunction {
  5375. /** @hidden */
  5376. easeInCore(gradient: number): number;
  5377. }
  5378. /**
  5379. * Easing function with a bezier shape (see link below).
  5380. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5382. */
  5383. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5384. /** Defines the x component of the start tangent in the bezier curve */
  5385. x1: number;
  5386. /** Defines the y component of the start tangent in the bezier curve */
  5387. y1: number;
  5388. /** Defines the x component of the end tangent in the bezier curve */
  5389. x2: number;
  5390. /** Defines the y component of the end tangent in the bezier curve */
  5391. y2: number;
  5392. /**
  5393. * Instantiates a bezier function
  5394. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5395. * @param x1 Defines the x component of the start tangent in the bezier curve
  5396. * @param y1 Defines the y component of the start tangent in the bezier curve
  5397. * @param x2 Defines the x component of the end tangent in the bezier curve
  5398. * @param y2 Defines the y component of the end tangent in the bezier curve
  5399. */
  5400. constructor(
  5401. /** Defines the x component of the start tangent in the bezier curve */
  5402. x1?: number,
  5403. /** Defines the y component of the start tangent in the bezier curve */
  5404. y1?: number,
  5405. /** Defines the x component of the end tangent in the bezier curve */
  5406. x2?: number,
  5407. /** Defines the y component of the end tangent in the bezier curve */
  5408. y2?: number);
  5409. /** @hidden */
  5410. easeInCore(gradient: number): number;
  5411. }
  5412. }
  5413. declare module BABYLON {
  5414. /**
  5415. * Class used to hold a RBG color
  5416. */
  5417. export class Color3 {
  5418. /**
  5419. * Defines the red component (between 0 and 1, default is 0)
  5420. */
  5421. r: number;
  5422. /**
  5423. * Defines the green component (between 0 and 1, default is 0)
  5424. */
  5425. g: number;
  5426. /**
  5427. * Defines the blue component (between 0 and 1, default is 0)
  5428. */
  5429. b: number;
  5430. /**
  5431. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5432. * @param r defines the red component (between 0 and 1, default is 0)
  5433. * @param g defines the green component (between 0 and 1, default is 0)
  5434. * @param b defines the blue component (between 0 and 1, default is 0)
  5435. */
  5436. constructor(
  5437. /**
  5438. * Defines the red component (between 0 and 1, default is 0)
  5439. */
  5440. r?: number,
  5441. /**
  5442. * Defines the green component (between 0 and 1, default is 0)
  5443. */
  5444. g?: number,
  5445. /**
  5446. * Defines the blue component (between 0 and 1, default is 0)
  5447. */
  5448. b?: number);
  5449. /**
  5450. * Creates a string with the Color3 current values
  5451. * @returns the string representation of the Color3 object
  5452. */
  5453. toString(): string;
  5454. /**
  5455. * Returns the string "Color3"
  5456. * @returns "Color3"
  5457. */
  5458. getClassName(): string;
  5459. /**
  5460. * Compute the Color3 hash code
  5461. * @returns an unique number that can be used to hash Color3 objects
  5462. */
  5463. getHashCode(): number;
  5464. /**
  5465. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5466. * @param array defines the array where to store the r,g,b components
  5467. * @param index defines an optional index in the target array to define where to start storing values
  5468. * @returns the current Color3 object
  5469. */
  5470. toArray(array: FloatArray, index?: number): Color3;
  5471. /**
  5472. * Returns a new Color4 object from the current Color3 and the given alpha
  5473. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5474. * @returns a new Color4 object
  5475. */
  5476. toColor4(alpha?: number): Color4;
  5477. /**
  5478. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5479. * @returns the new array
  5480. */
  5481. asArray(): number[];
  5482. /**
  5483. * Returns the luminance value
  5484. * @returns a float value
  5485. */
  5486. toLuminance(): number;
  5487. /**
  5488. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5489. * @param otherColor defines the second operand
  5490. * @returns the new Color3 object
  5491. */
  5492. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5493. /**
  5494. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5495. * @param otherColor defines the second operand
  5496. * @param result defines the Color3 object where to store the result
  5497. * @returns the current Color3
  5498. */
  5499. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5500. /**
  5501. * Determines equality between Color3 objects
  5502. * @param otherColor defines the second operand
  5503. * @returns true if the rgb values are equal to the given ones
  5504. */
  5505. equals(otherColor: DeepImmutable<Color3>): boolean;
  5506. /**
  5507. * Determines equality between the current Color3 object and a set of r,b,g values
  5508. * @param r defines the red component to check
  5509. * @param g defines the green component to check
  5510. * @param b defines the blue component to check
  5511. * @returns true if the rgb values are equal to the given ones
  5512. */
  5513. equalsFloats(r: number, g: number, b: number): boolean;
  5514. /**
  5515. * Multiplies in place each rgb value by scale
  5516. * @param scale defines the scaling factor
  5517. * @returns the updated Color3
  5518. */
  5519. scale(scale: number): Color3;
  5520. /**
  5521. * Multiplies the rgb values by scale and stores the result into "result"
  5522. * @param scale defines the scaling factor
  5523. * @param result defines the Color3 object where to store the result
  5524. * @returns the unmodified current Color3
  5525. */
  5526. scaleToRef(scale: number, result: Color3): Color3;
  5527. /**
  5528. * Scale the current Color3 values by a factor and add the result to a given Color3
  5529. * @param scale defines the scale factor
  5530. * @param result defines color to store the result into
  5531. * @returns the unmodified current Color3
  5532. */
  5533. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5534. /**
  5535. * Clamps the rgb values by the min and max values and stores the result into "result"
  5536. * @param min defines minimum clamping value (default is 0)
  5537. * @param max defines maximum clamping value (default is 1)
  5538. * @param result defines color to store the result into
  5539. * @returns the original Color3
  5540. */
  5541. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5542. /**
  5543. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5544. * @param otherColor defines the second operand
  5545. * @returns the new Color3
  5546. */
  5547. add(otherColor: DeepImmutable<Color3>): Color3;
  5548. /**
  5549. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5550. * @param otherColor defines the second operand
  5551. * @param result defines Color3 object to store the result into
  5552. * @returns the unmodified current Color3
  5553. */
  5554. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5555. /**
  5556. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5557. * @param otherColor defines the second operand
  5558. * @returns the new Color3
  5559. */
  5560. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5561. /**
  5562. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5563. * @param otherColor defines the second operand
  5564. * @param result defines Color3 object to store the result into
  5565. * @returns the unmodified current Color3
  5566. */
  5567. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5568. /**
  5569. * Copy the current object
  5570. * @returns a new Color3 copied the current one
  5571. */
  5572. clone(): Color3;
  5573. /**
  5574. * Copies the rgb values from the source in the current Color3
  5575. * @param source defines the source Color3 object
  5576. * @returns the updated Color3 object
  5577. */
  5578. copyFrom(source: DeepImmutable<Color3>): Color3;
  5579. /**
  5580. * Updates the Color3 rgb values from the given floats
  5581. * @param r defines the red component to read from
  5582. * @param g defines the green component to read from
  5583. * @param b defines the blue component to read from
  5584. * @returns the current Color3 object
  5585. */
  5586. copyFromFloats(r: number, g: number, b: number): Color3;
  5587. /**
  5588. * Updates the Color3 rgb values from the given floats
  5589. * @param r defines the red component to read from
  5590. * @param g defines the green component to read from
  5591. * @param b defines the blue component to read from
  5592. * @returns the current Color3 object
  5593. */
  5594. set(r: number, g: number, b: number): Color3;
  5595. /**
  5596. * Compute the Color3 hexadecimal code as a string
  5597. * @returns a string containing the hexadecimal representation of the Color3 object
  5598. */
  5599. toHexString(): string;
  5600. /**
  5601. * Computes a new Color3 converted from the current one to linear space
  5602. * @returns a new Color3 object
  5603. */
  5604. toLinearSpace(): Color3;
  5605. /**
  5606. * Converts current color in rgb space to HSV values
  5607. * @returns a new color3 representing the HSV values
  5608. */
  5609. toHSV(): Color3;
  5610. /**
  5611. * Converts current color in rgb space to HSV values
  5612. * @param result defines the Color3 where to store the HSV values
  5613. */
  5614. toHSVToRef(result: Color3): void;
  5615. /**
  5616. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5617. * @param convertedColor defines the Color3 object where to store the linear space version
  5618. * @returns the unmodified Color3
  5619. */
  5620. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5621. /**
  5622. * Computes a new Color3 converted from the current one to gamma space
  5623. * @returns a new Color3 object
  5624. */
  5625. toGammaSpace(): Color3;
  5626. /**
  5627. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5628. * @param convertedColor defines the Color3 object where to store the gamma space version
  5629. * @returns the unmodified Color3
  5630. */
  5631. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5632. private static _BlackReadOnly;
  5633. /**
  5634. * Convert Hue, saturation and value to a Color3 (RGB)
  5635. * @param hue defines the hue
  5636. * @param saturation defines the saturation
  5637. * @param value defines the value
  5638. * @param result defines the Color3 where to store the RGB values
  5639. */
  5640. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5641. /**
  5642. * Creates a new Color3 from the string containing valid hexadecimal values
  5643. * @param hex defines a string containing valid hexadecimal values
  5644. * @returns a new Color3 object
  5645. */
  5646. static FromHexString(hex: string): Color3;
  5647. /**
  5648. * Creates a new Color3 from the starting index of the given array
  5649. * @param array defines the source array
  5650. * @param offset defines an offset in the source array
  5651. * @returns a new Color3 object
  5652. */
  5653. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5654. /**
  5655. * Creates a new Color3 from integer values (< 256)
  5656. * @param r defines the red component to read from (value between 0 and 255)
  5657. * @param g defines the green component to read from (value between 0 and 255)
  5658. * @param b defines the blue component to read from (value between 0 and 255)
  5659. * @returns a new Color3 object
  5660. */
  5661. static FromInts(r: number, g: number, b: number): Color3;
  5662. /**
  5663. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5664. * @param start defines the start Color3 value
  5665. * @param end defines the end Color3 value
  5666. * @param amount defines the gradient value between start and end
  5667. * @returns a new Color3 object
  5668. */
  5669. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5670. /**
  5671. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5672. * @param left defines the start value
  5673. * @param right defines the end value
  5674. * @param amount defines the gradient factor
  5675. * @param result defines the Color3 object where to store the result
  5676. */
  5677. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5678. /**
  5679. * Returns a Color3 value containing a red color
  5680. * @returns a new Color3 object
  5681. */
  5682. static Red(): Color3;
  5683. /**
  5684. * Returns a Color3 value containing a green color
  5685. * @returns a new Color3 object
  5686. */
  5687. static Green(): Color3;
  5688. /**
  5689. * Returns a Color3 value containing a blue color
  5690. * @returns a new Color3 object
  5691. */
  5692. static Blue(): Color3;
  5693. /**
  5694. * Returns a Color3 value containing a black color
  5695. * @returns a new Color3 object
  5696. */
  5697. static Black(): Color3;
  5698. /**
  5699. * Gets a Color3 value containing a black color that must not be updated
  5700. */
  5701. static get BlackReadOnly(): DeepImmutable<Color3>;
  5702. /**
  5703. * Returns a Color3 value containing a white color
  5704. * @returns a new Color3 object
  5705. */
  5706. static White(): Color3;
  5707. /**
  5708. * Returns a Color3 value containing a purple color
  5709. * @returns a new Color3 object
  5710. */
  5711. static Purple(): Color3;
  5712. /**
  5713. * Returns a Color3 value containing a magenta color
  5714. * @returns a new Color3 object
  5715. */
  5716. static Magenta(): Color3;
  5717. /**
  5718. * Returns a Color3 value containing a yellow color
  5719. * @returns a new Color3 object
  5720. */
  5721. static Yellow(): Color3;
  5722. /**
  5723. * Returns a Color3 value containing a gray color
  5724. * @returns a new Color3 object
  5725. */
  5726. static Gray(): Color3;
  5727. /**
  5728. * Returns a Color3 value containing a teal color
  5729. * @returns a new Color3 object
  5730. */
  5731. static Teal(): Color3;
  5732. /**
  5733. * Returns a Color3 value containing a random color
  5734. * @returns a new Color3 object
  5735. */
  5736. static Random(): Color3;
  5737. }
  5738. /**
  5739. * Class used to hold a RBGA color
  5740. */
  5741. export class Color4 {
  5742. /**
  5743. * Defines the red component (between 0 and 1, default is 0)
  5744. */
  5745. r: number;
  5746. /**
  5747. * Defines the green component (between 0 and 1, default is 0)
  5748. */
  5749. g: number;
  5750. /**
  5751. * Defines the blue component (between 0 and 1, default is 0)
  5752. */
  5753. b: number;
  5754. /**
  5755. * Defines the alpha component (between 0 and 1, default is 1)
  5756. */
  5757. a: number;
  5758. /**
  5759. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5760. * @param r defines the red component (between 0 and 1, default is 0)
  5761. * @param g defines the green component (between 0 and 1, default is 0)
  5762. * @param b defines the blue component (between 0 and 1, default is 0)
  5763. * @param a defines the alpha component (between 0 and 1, default is 1)
  5764. */
  5765. constructor(
  5766. /**
  5767. * Defines the red component (between 0 and 1, default is 0)
  5768. */
  5769. r?: number,
  5770. /**
  5771. * Defines the green component (between 0 and 1, default is 0)
  5772. */
  5773. g?: number,
  5774. /**
  5775. * Defines the blue component (between 0 and 1, default is 0)
  5776. */
  5777. b?: number,
  5778. /**
  5779. * Defines the alpha component (between 0 and 1, default is 1)
  5780. */
  5781. a?: number);
  5782. /**
  5783. * Adds in place the given Color4 values to the current Color4 object
  5784. * @param right defines the second operand
  5785. * @returns the current updated Color4 object
  5786. */
  5787. addInPlace(right: DeepImmutable<Color4>): Color4;
  5788. /**
  5789. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5790. * @returns the new array
  5791. */
  5792. asArray(): number[];
  5793. /**
  5794. * Stores from the starting index in the given array the Color4 successive values
  5795. * @param array defines the array where to store the r,g,b components
  5796. * @param index defines an optional index in the target array to define where to start storing values
  5797. * @returns the current Color4 object
  5798. */
  5799. toArray(array: number[], index?: number): Color4;
  5800. /**
  5801. * Determines equality between Color4 objects
  5802. * @param otherColor defines the second operand
  5803. * @returns true if the rgba values are equal to the given ones
  5804. */
  5805. equals(otherColor: DeepImmutable<Color4>): boolean;
  5806. /**
  5807. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5808. * @param right defines the second operand
  5809. * @returns a new Color4 object
  5810. */
  5811. add(right: DeepImmutable<Color4>): Color4;
  5812. /**
  5813. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5814. * @param right defines the second operand
  5815. * @returns a new Color4 object
  5816. */
  5817. subtract(right: DeepImmutable<Color4>): Color4;
  5818. /**
  5819. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5820. * @param right defines the second operand
  5821. * @param result defines the Color4 object where to store the result
  5822. * @returns the current Color4 object
  5823. */
  5824. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5825. /**
  5826. * Creates a new Color4 with the current Color4 values multiplied by scale
  5827. * @param scale defines the scaling factor to apply
  5828. * @returns a new Color4 object
  5829. */
  5830. scale(scale: number): Color4;
  5831. /**
  5832. * Multiplies the current Color4 values by scale and stores the result in "result"
  5833. * @param scale defines the scaling factor to apply
  5834. * @param result defines the Color4 object where to store the result
  5835. * @returns the current unmodified Color4
  5836. */
  5837. scaleToRef(scale: number, result: Color4): Color4;
  5838. /**
  5839. * Scale the current Color4 values by a factor and add the result to a given Color4
  5840. * @param scale defines the scale factor
  5841. * @param result defines the Color4 object where to store the result
  5842. * @returns the unmodified current Color4
  5843. */
  5844. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5845. /**
  5846. * Clamps the rgb values by the min and max values and stores the result into "result"
  5847. * @param min defines minimum clamping value (default is 0)
  5848. * @param max defines maximum clamping value (default is 1)
  5849. * @param result defines color to store the result into.
  5850. * @returns the cuurent Color4
  5851. */
  5852. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5853. /**
  5854. * Multipy an Color4 value by another and return a new Color4 object
  5855. * @param color defines the Color4 value to multiply by
  5856. * @returns a new Color4 object
  5857. */
  5858. multiply(color: Color4): Color4;
  5859. /**
  5860. * Multipy a Color4 value by another and push the result in a reference value
  5861. * @param color defines the Color4 value to multiply by
  5862. * @param result defines the Color4 to fill the result in
  5863. * @returns the result Color4
  5864. */
  5865. multiplyToRef(color: Color4, result: Color4): Color4;
  5866. /**
  5867. * Creates a string with the Color4 current values
  5868. * @returns the string representation of the Color4 object
  5869. */
  5870. toString(): string;
  5871. /**
  5872. * Returns the string "Color4"
  5873. * @returns "Color4"
  5874. */
  5875. getClassName(): string;
  5876. /**
  5877. * Compute the Color4 hash code
  5878. * @returns an unique number that can be used to hash Color4 objects
  5879. */
  5880. getHashCode(): number;
  5881. /**
  5882. * Creates a new Color4 copied from the current one
  5883. * @returns a new Color4 object
  5884. */
  5885. clone(): Color4;
  5886. /**
  5887. * Copies the given Color4 values into the current one
  5888. * @param source defines the source Color4 object
  5889. * @returns the current updated Color4 object
  5890. */
  5891. copyFrom(source: Color4): Color4;
  5892. /**
  5893. * Copies the given float values into the current one
  5894. * @param r defines the red component to read from
  5895. * @param g defines the green component to read from
  5896. * @param b defines the blue component to read from
  5897. * @param a defines the alpha component to read from
  5898. * @returns the current updated Color4 object
  5899. */
  5900. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5901. /**
  5902. * Copies the given float values into the current one
  5903. * @param r defines the red component to read from
  5904. * @param g defines the green component to read from
  5905. * @param b defines the blue component to read from
  5906. * @param a defines the alpha component to read from
  5907. * @returns the current updated Color4 object
  5908. */
  5909. set(r: number, g: number, b: number, a: number): Color4;
  5910. /**
  5911. * Compute the Color4 hexadecimal code as a string
  5912. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5913. * @returns a string containing the hexadecimal representation of the Color4 object
  5914. */
  5915. toHexString(returnAsColor3?: boolean): string;
  5916. /**
  5917. * Computes a new Color4 converted from the current one to linear space
  5918. * @returns a new Color4 object
  5919. */
  5920. toLinearSpace(): Color4;
  5921. /**
  5922. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5923. * @param convertedColor defines the Color4 object where to store the linear space version
  5924. * @returns the unmodified Color4
  5925. */
  5926. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5927. /**
  5928. * Computes a new Color4 converted from the current one to gamma space
  5929. * @returns a new Color4 object
  5930. */
  5931. toGammaSpace(): Color4;
  5932. /**
  5933. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5934. * @param convertedColor defines the Color4 object where to store the gamma space version
  5935. * @returns the unmodified Color4
  5936. */
  5937. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5938. /**
  5939. * Creates a new Color4 from the string containing valid hexadecimal values
  5940. * @param hex defines a string containing valid hexadecimal values
  5941. * @returns a new Color4 object
  5942. */
  5943. static FromHexString(hex: string): Color4;
  5944. /**
  5945. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5946. * @param left defines the start value
  5947. * @param right defines the end value
  5948. * @param amount defines the gradient factor
  5949. * @returns a new Color4 object
  5950. */
  5951. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5952. /**
  5953. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5954. * @param left defines the start value
  5955. * @param right defines the end value
  5956. * @param amount defines the gradient factor
  5957. * @param result defines the Color4 object where to store data
  5958. */
  5959. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5960. /**
  5961. * Creates a new Color4 from a Color3 and an alpha value
  5962. * @param color3 defines the source Color3 to read from
  5963. * @param alpha defines the alpha component (1.0 by default)
  5964. * @returns a new Color4 object
  5965. */
  5966. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5967. /**
  5968. * Creates a new Color4 from the starting index element of the given array
  5969. * @param array defines the source array to read from
  5970. * @param offset defines the offset in the source array
  5971. * @returns a new Color4 object
  5972. */
  5973. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5974. /**
  5975. * Creates a new Color3 from integer values (< 256)
  5976. * @param r defines the red component to read from (value between 0 and 255)
  5977. * @param g defines the green component to read from (value between 0 and 255)
  5978. * @param b defines the blue component to read from (value between 0 and 255)
  5979. * @param a defines the alpha component to read from (value between 0 and 255)
  5980. * @returns a new Color3 object
  5981. */
  5982. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5983. /**
  5984. * Check the content of a given array and convert it to an array containing RGBA data
  5985. * If the original array was already containing count * 4 values then it is returned directly
  5986. * @param colors defines the array to check
  5987. * @param count defines the number of RGBA data to expect
  5988. * @returns an array containing count * 4 values (RGBA)
  5989. */
  5990. static CheckColors4(colors: number[], count: number): number[];
  5991. }
  5992. /**
  5993. * @hidden
  5994. */
  5995. export class TmpColors {
  5996. static Color3: Color3[];
  5997. static Color4: Color4[];
  5998. }
  5999. }
  6000. declare module BABYLON {
  6001. /**
  6002. * Defines an interface which represents an animation key frame
  6003. */
  6004. export interface IAnimationKey {
  6005. /**
  6006. * Frame of the key frame
  6007. */
  6008. frame: number;
  6009. /**
  6010. * Value at the specifies key frame
  6011. */
  6012. value: any;
  6013. /**
  6014. * The input tangent for the cubic hermite spline
  6015. */
  6016. inTangent?: any;
  6017. /**
  6018. * The output tangent for the cubic hermite spline
  6019. */
  6020. outTangent?: any;
  6021. /**
  6022. * The animation interpolation type
  6023. */
  6024. interpolation?: AnimationKeyInterpolation;
  6025. }
  6026. /**
  6027. * Enum for the animation key frame interpolation type
  6028. */
  6029. export enum AnimationKeyInterpolation {
  6030. /**
  6031. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6032. */
  6033. STEP = 1
  6034. }
  6035. }
  6036. declare module BABYLON {
  6037. /**
  6038. * Represents the range of an animation
  6039. */
  6040. export class AnimationRange {
  6041. /**The name of the animation range**/
  6042. name: string;
  6043. /**The starting frame of the animation */
  6044. from: number;
  6045. /**The ending frame of the animation*/
  6046. to: number;
  6047. /**
  6048. * Initializes the range of an animation
  6049. * @param name The name of the animation range
  6050. * @param from The starting frame of the animation
  6051. * @param to The ending frame of the animation
  6052. */
  6053. constructor(
  6054. /**The name of the animation range**/
  6055. name: string,
  6056. /**The starting frame of the animation */
  6057. from: number,
  6058. /**The ending frame of the animation*/
  6059. to: number);
  6060. /**
  6061. * Makes a copy of the animation range
  6062. * @returns A copy of the animation range
  6063. */
  6064. clone(): AnimationRange;
  6065. }
  6066. }
  6067. declare module BABYLON {
  6068. /**
  6069. * Composed of a frame, and an action function
  6070. */
  6071. export class AnimationEvent {
  6072. /** The frame for which the event is triggered **/
  6073. frame: number;
  6074. /** The event to perform when triggered **/
  6075. action: (currentFrame: number) => void;
  6076. /** Specifies if the event should be triggered only once**/
  6077. onlyOnce?: boolean | undefined;
  6078. /**
  6079. * Specifies if the animation event is done
  6080. */
  6081. isDone: boolean;
  6082. /**
  6083. * Initializes the animation event
  6084. * @param frame The frame for which the event is triggered
  6085. * @param action The event to perform when triggered
  6086. * @param onlyOnce Specifies if the event should be triggered only once
  6087. */
  6088. constructor(
  6089. /** The frame for which the event is triggered **/
  6090. frame: number,
  6091. /** The event to perform when triggered **/
  6092. action: (currentFrame: number) => void,
  6093. /** Specifies if the event should be triggered only once**/
  6094. onlyOnce?: boolean | undefined);
  6095. /** @hidden */
  6096. _clone(): AnimationEvent;
  6097. }
  6098. }
  6099. declare module BABYLON {
  6100. /**
  6101. * Interface used to define a behavior
  6102. */
  6103. export interface Behavior<T> {
  6104. /** gets or sets behavior's name */
  6105. name: string;
  6106. /**
  6107. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6108. */
  6109. init(): void;
  6110. /**
  6111. * Called when the behavior is attached to a target
  6112. * @param target defines the target where the behavior is attached to
  6113. */
  6114. attach(target: T): void;
  6115. /**
  6116. * Called when the behavior is detached from its target
  6117. */
  6118. detach(): void;
  6119. }
  6120. /**
  6121. * Interface implemented by classes supporting behaviors
  6122. */
  6123. export interface IBehaviorAware<T> {
  6124. /**
  6125. * Attach a behavior
  6126. * @param behavior defines the behavior to attach
  6127. * @returns the current host
  6128. */
  6129. addBehavior(behavior: Behavior<T>): T;
  6130. /**
  6131. * Remove a behavior from the current object
  6132. * @param behavior defines the behavior to detach
  6133. * @returns the current host
  6134. */
  6135. removeBehavior(behavior: Behavior<T>): T;
  6136. /**
  6137. * Gets a behavior using its name to search
  6138. * @param name defines the name to search
  6139. * @returns the behavior or null if not found
  6140. */
  6141. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6142. }
  6143. }
  6144. declare module BABYLON {
  6145. /**
  6146. * Defines an array and its length.
  6147. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6148. */
  6149. export interface ISmartArrayLike<T> {
  6150. /**
  6151. * The data of the array.
  6152. */
  6153. data: Array<T>;
  6154. /**
  6155. * The active length of the array.
  6156. */
  6157. length: number;
  6158. }
  6159. /**
  6160. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6161. */
  6162. export class SmartArray<T> implements ISmartArrayLike<T> {
  6163. /**
  6164. * The full set of data from the array.
  6165. */
  6166. data: Array<T>;
  6167. /**
  6168. * The active length of the array.
  6169. */
  6170. length: number;
  6171. protected _id: number;
  6172. /**
  6173. * Instantiates a Smart Array.
  6174. * @param capacity defines the default capacity of the array.
  6175. */
  6176. constructor(capacity: number);
  6177. /**
  6178. * Pushes a value at the end of the active data.
  6179. * @param value defines the object to push in the array.
  6180. */
  6181. push(value: T): void;
  6182. /**
  6183. * Iterates over the active data and apply the lambda to them.
  6184. * @param func defines the action to apply on each value.
  6185. */
  6186. forEach(func: (content: T) => void): void;
  6187. /**
  6188. * Sorts the full sets of data.
  6189. * @param compareFn defines the comparison function to apply.
  6190. */
  6191. sort(compareFn: (a: T, b: T) => number): void;
  6192. /**
  6193. * Resets the active data to an empty array.
  6194. */
  6195. reset(): void;
  6196. /**
  6197. * Releases all the data from the array as well as the array.
  6198. */
  6199. dispose(): void;
  6200. /**
  6201. * Concats the active data with a given array.
  6202. * @param array defines the data to concatenate with.
  6203. */
  6204. concat(array: any): void;
  6205. /**
  6206. * Returns the position of a value in the active data.
  6207. * @param value defines the value to find the index for
  6208. * @returns the index if found in the active data otherwise -1
  6209. */
  6210. indexOf(value: T): number;
  6211. /**
  6212. * Returns whether an element is part of the active data.
  6213. * @param value defines the value to look for
  6214. * @returns true if found in the active data otherwise false
  6215. */
  6216. contains(value: T): boolean;
  6217. private static _GlobalId;
  6218. }
  6219. /**
  6220. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6221. * The data in this array can only be present once
  6222. */
  6223. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6224. private _duplicateId;
  6225. /**
  6226. * Pushes a value at the end of the active data.
  6227. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6228. * @param value defines the object to push in the array.
  6229. */
  6230. push(value: T): void;
  6231. /**
  6232. * Pushes a value at the end of the active data.
  6233. * If the data is already present, it won t be added again
  6234. * @param value defines the object to push in the array.
  6235. * @returns true if added false if it was already present
  6236. */
  6237. pushNoDuplicate(value: T): boolean;
  6238. /**
  6239. * Resets the active data to an empty array.
  6240. */
  6241. reset(): void;
  6242. /**
  6243. * Concats the active data with a given array.
  6244. * This ensures no dupplicate will be present in the result.
  6245. * @param array defines the data to concatenate with.
  6246. */
  6247. concatWithNoDuplicate(array: any): void;
  6248. }
  6249. }
  6250. declare module BABYLON {
  6251. /**
  6252. * @ignore
  6253. * This is a list of all the different input types that are available in the application.
  6254. * Fo instance: ArcRotateCameraGamepadInput...
  6255. */
  6256. export var CameraInputTypes: {};
  6257. /**
  6258. * This is the contract to implement in order to create a new input class.
  6259. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6260. */
  6261. export interface ICameraInput<TCamera extends Camera> {
  6262. /**
  6263. * Defines the camera the input is attached to.
  6264. */
  6265. camera: Nullable<TCamera>;
  6266. /**
  6267. * Gets the class name of the current intput.
  6268. * @returns the class name
  6269. */
  6270. getClassName(): string;
  6271. /**
  6272. * Get the friendly name associated with the input class.
  6273. * @returns the input friendly name
  6274. */
  6275. getSimpleName(): string;
  6276. /**
  6277. * Attach the input controls to a specific dom element to get the input from.
  6278. * @param element Defines the element the controls should be listened from
  6279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6280. */
  6281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6282. /**
  6283. * Detach the current controls from the specified dom element.
  6284. * @param element Defines the element to stop listening the inputs from
  6285. */
  6286. detachControl(element: Nullable<HTMLElement>): void;
  6287. /**
  6288. * Update the current camera state depending on the inputs that have been used this frame.
  6289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6290. */
  6291. checkInputs?: () => void;
  6292. }
  6293. /**
  6294. * Represents a map of input types to input instance or input index to input instance.
  6295. */
  6296. export interface CameraInputsMap<TCamera extends Camera> {
  6297. /**
  6298. * Accessor to the input by input type.
  6299. */
  6300. [name: string]: ICameraInput<TCamera>;
  6301. /**
  6302. * Accessor to the input by input index.
  6303. */
  6304. [idx: number]: ICameraInput<TCamera>;
  6305. }
  6306. /**
  6307. * This represents the input manager used within a camera.
  6308. * It helps dealing with all the different kind of input attached to a camera.
  6309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6310. */
  6311. export class CameraInputsManager<TCamera extends Camera> {
  6312. /**
  6313. * Defines the list of inputs attahed to the camera.
  6314. */
  6315. attached: CameraInputsMap<TCamera>;
  6316. /**
  6317. * Defines the dom element the camera is collecting inputs from.
  6318. * This is null if the controls have not been attached.
  6319. */
  6320. attachedElement: Nullable<HTMLElement>;
  6321. /**
  6322. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6323. */
  6324. noPreventDefault: boolean;
  6325. /**
  6326. * Defined the camera the input manager belongs to.
  6327. */
  6328. camera: TCamera;
  6329. /**
  6330. * Update the current camera state depending on the inputs that have been used this frame.
  6331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6332. */
  6333. checkInputs: () => void;
  6334. /**
  6335. * Instantiate a new Camera Input Manager.
  6336. * @param camera Defines the camera the input manager blongs to
  6337. */
  6338. constructor(camera: TCamera);
  6339. /**
  6340. * Add an input method to a camera
  6341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6342. * @param input camera input method
  6343. */
  6344. add(input: ICameraInput<TCamera>): void;
  6345. /**
  6346. * Remove a specific input method from a camera
  6347. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6348. * @param inputToRemove camera input method
  6349. */
  6350. remove(inputToRemove: ICameraInput<TCamera>): void;
  6351. /**
  6352. * Remove a specific input type from a camera
  6353. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6354. * @param inputType the type of the input to remove
  6355. */
  6356. removeByType(inputType: string): void;
  6357. private _addCheckInputs;
  6358. /**
  6359. * Attach the input controls to the currently attached dom element to listen the events from.
  6360. * @param input Defines the input to attach
  6361. */
  6362. attachInput(input: ICameraInput<TCamera>): void;
  6363. /**
  6364. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6365. * @param element Defines the dom element to collect the events from
  6366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6367. */
  6368. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6369. /**
  6370. * Detach the current manager inputs controls from a specific dom element.
  6371. * @param element Defines the dom element to collect the events from
  6372. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6373. */
  6374. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6375. /**
  6376. * Rebuild the dynamic inputCheck function from the current list of
  6377. * defined inputs in the manager.
  6378. */
  6379. rebuildInputCheck(): void;
  6380. /**
  6381. * Remove all attached input methods from a camera
  6382. */
  6383. clear(): void;
  6384. /**
  6385. * Serialize the current input manager attached to a camera.
  6386. * This ensures than once parsed,
  6387. * the input associated to the camera will be identical to the current ones
  6388. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6389. */
  6390. serialize(serializedCamera: any): void;
  6391. /**
  6392. * Parses an input manager serialized JSON to restore the previous list of inputs
  6393. * and states associated to a camera.
  6394. * @param parsedCamera Defines the JSON to parse
  6395. */
  6396. parse(parsedCamera: any): void;
  6397. }
  6398. }
  6399. declare module BABYLON {
  6400. /**
  6401. * Class used to store data that will be store in GPU memory
  6402. */
  6403. export class Buffer {
  6404. private _engine;
  6405. private _buffer;
  6406. /** @hidden */
  6407. _data: Nullable<DataArray>;
  6408. private _updatable;
  6409. private _instanced;
  6410. private _divisor;
  6411. /**
  6412. * Gets the byte stride.
  6413. */
  6414. readonly byteStride: number;
  6415. /**
  6416. * Constructor
  6417. * @param engine the engine
  6418. * @param data the data to use for this buffer
  6419. * @param updatable whether the data is updatable
  6420. * @param stride the stride (optional)
  6421. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6422. * @param instanced whether the buffer is instanced (optional)
  6423. * @param useBytes set to true if the stride in in bytes (optional)
  6424. * @param divisor sets an optional divisor for instances (1 by default)
  6425. */
  6426. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6427. /**
  6428. * Create a new VertexBuffer based on the current buffer
  6429. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6430. * @param offset defines offset in the buffer (0 by default)
  6431. * @param size defines the size in floats of attributes (position is 3 for instance)
  6432. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6433. * @param instanced defines if the vertex buffer contains indexed data
  6434. * @param useBytes defines if the offset and stride are in bytes *
  6435. * @param divisor sets an optional divisor for instances (1 by default)
  6436. * @returns the new vertex buffer
  6437. */
  6438. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6439. /**
  6440. * Gets a boolean indicating if the Buffer is updatable?
  6441. * @returns true if the buffer is updatable
  6442. */
  6443. isUpdatable(): boolean;
  6444. /**
  6445. * Gets current buffer's data
  6446. * @returns a DataArray or null
  6447. */
  6448. getData(): Nullable<DataArray>;
  6449. /**
  6450. * Gets underlying native buffer
  6451. * @returns underlying native buffer
  6452. */
  6453. getBuffer(): Nullable<DataBuffer>;
  6454. /**
  6455. * Gets the stride in float32 units (i.e. byte stride / 4).
  6456. * May not be an integer if the byte stride is not divisible by 4.
  6457. * @returns the stride in float32 units
  6458. * @deprecated Please use byteStride instead.
  6459. */
  6460. getStrideSize(): number;
  6461. /**
  6462. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6463. * @param data defines the data to store
  6464. */
  6465. create(data?: Nullable<DataArray>): void;
  6466. /** @hidden */
  6467. _rebuild(): void;
  6468. /**
  6469. * Update current buffer data
  6470. * @param data defines the data to store
  6471. */
  6472. update(data: DataArray): void;
  6473. /**
  6474. * Updates the data directly.
  6475. * @param data the new data
  6476. * @param offset the new offset
  6477. * @param vertexCount the vertex count (optional)
  6478. * @param useBytes set to true if the offset is in bytes
  6479. */
  6480. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6481. /**
  6482. * Release all resources
  6483. */
  6484. dispose(): void;
  6485. }
  6486. /**
  6487. * Specialized buffer used to store vertex data
  6488. */
  6489. export class VertexBuffer {
  6490. /** @hidden */
  6491. _buffer: Buffer;
  6492. private _kind;
  6493. private _size;
  6494. private _ownsBuffer;
  6495. private _instanced;
  6496. private _instanceDivisor;
  6497. /**
  6498. * The byte type.
  6499. */
  6500. static readonly BYTE: number;
  6501. /**
  6502. * The unsigned byte type.
  6503. */
  6504. static readonly UNSIGNED_BYTE: number;
  6505. /**
  6506. * The short type.
  6507. */
  6508. static readonly SHORT: number;
  6509. /**
  6510. * The unsigned short type.
  6511. */
  6512. static readonly UNSIGNED_SHORT: number;
  6513. /**
  6514. * The integer type.
  6515. */
  6516. static readonly INT: number;
  6517. /**
  6518. * The unsigned integer type.
  6519. */
  6520. static readonly UNSIGNED_INT: number;
  6521. /**
  6522. * The float type.
  6523. */
  6524. static readonly FLOAT: number;
  6525. /**
  6526. * Gets or sets the instance divisor when in instanced mode
  6527. */
  6528. get instanceDivisor(): number;
  6529. set instanceDivisor(value: number);
  6530. /**
  6531. * Gets the byte stride.
  6532. */
  6533. readonly byteStride: number;
  6534. /**
  6535. * Gets the byte offset.
  6536. */
  6537. readonly byteOffset: number;
  6538. /**
  6539. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6540. */
  6541. readonly normalized: boolean;
  6542. /**
  6543. * Gets the data type of each component in the array.
  6544. */
  6545. readonly type: number;
  6546. /**
  6547. * Constructor
  6548. * @param engine the engine
  6549. * @param data the data to use for this vertex buffer
  6550. * @param kind the vertex buffer kind
  6551. * @param updatable whether the data is updatable
  6552. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6553. * @param stride the stride (optional)
  6554. * @param instanced whether the buffer is instanced (optional)
  6555. * @param offset the offset of the data (optional)
  6556. * @param size the number of components (optional)
  6557. * @param type the type of the component (optional)
  6558. * @param normalized whether the data contains normalized data (optional)
  6559. * @param useBytes set to true if stride and offset are in bytes (optional)
  6560. * @param divisor defines the instance divisor to use (1 by default)
  6561. */
  6562. 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);
  6563. /** @hidden */
  6564. _rebuild(): void;
  6565. /**
  6566. * Returns the kind of the VertexBuffer (string)
  6567. * @returns a string
  6568. */
  6569. getKind(): string;
  6570. /**
  6571. * Gets a boolean indicating if the VertexBuffer is updatable?
  6572. * @returns true if the buffer is updatable
  6573. */
  6574. isUpdatable(): boolean;
  6575. /**
  6576. * Gets current buffer's data
  6577. * @returns a DataArray or null
  6578. */
  6579. getData(): Nullable<DataArray>;
  6580. /**
  6581. * Gets underlying native buffer
  6582. * @returns underlying native buffer
  6583. */
  6584. getBuffer(): Nullable<DataBuffer>;
  6585. /**
  6586. * Gets the stride in float32 units (i.e. byte stride / 4).
  6587. * May not be an integer if the byte stride is not divisible by 4.
  6588. * @returns the stride in float32 units
  6589. * @deprecated Please use byteStride instead.
  6590. */
  6591. getStrideSize(): number;
  6592. /**
  6593. * Returns the offset as a multiple of the type byte length.
  6594. * @returns the offset in bytes
  6595. * @deprecated Please use byteOffset instead.
  6596. */
  6597. getOffset(): number;
  6598. /**
  6599. * Returns the number of components per vertex attribute (integer)
  6600. * @returns the size in float
  6601. */
  6602. getSize(): number;
  6603. /**
  6604. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6605. * @returns true if this buffer is instanced
  6606. */
  6607. getIsInstanced(): boolean;
  6608. /**
  6609. * Returns the instancing divisor, zero for non-instanced (integer).
  6610. * @returns a number
  6611. */
  6612. getInstanceDivisor(): number;
  6613. /**
  6614. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6615. * @param data defines the data to store
  6616. */
  6617. create(data?: DataArray): void;
  6618. /**
  6619. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6620. * This function will create a new buffer if the current one is not updatable
  6621. * @param data defines the data to store
  6622. */
  6623. update(data: DataArray): void;
  6624. /**
  6625. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6626. * Returns the directly updated WebGLBuffer.
  6627. * @param data the new data
  6628. * @param offset the new offset
  6629. * @param useBytes set to true if the offset is in bytes
  6630. */
  6631. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6632. /**
  6633. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6634. */
  6635. dispose(): void;
  6636. /**
  6637. * Enumerates each value of this vertex buffer as numbers.
  6638. * @param count the number of values to enumerate
  6639. * @param callback the callback function called for each value
  6640. */
  6641. forEach(count: number, callback: (value: number, index: number) => void): void;
  6642. /**
  6643. * Positions
  6644. */
  6645. static readonly PositionKind: string;
  6646. /**
  6647. * Normals
  6648. */
  6649. static readonly NormalKind: string;
  6650. /**
  6651. * Tangents
  6652. */
  6653. static readonly TangentKind: string;
  6654. /**
  6655. * Texture coordinates
  6656. */
  6657. static readonly UVKind: string;
  6658. /**
  6659. * Texture coordinates 2
  6660. */
  6661. static readonly UV2Kind: string;
  6662. /**
  6663. * Texture coordinates 3
  6664. */
  6665. static readonly UV3Kind: string;
  6666. /**
  6667. * Texture coordinates 4
  6668. */
  6669. static readonly UV4Kind: string;
  6670. /**
  6671. * Texture coordinates 5
  6672. */
  6673. static readonly UV5Kind: string;
  6674. /**
  6675. * Texture coordinates 6
  6676. */
  6677. static readonly UV6Kind: string;
  6678. /**
  6679. * Colors
  6680. */
  6681. static readonly ColorKind: string;
  6682. /**
  6683. * Matrix indices (for bones)
  6684. */
  6685. static readonly MatricesIndicesKind: string;
  6686. /**
  6687. * Matrix weights (for bones)
  6688. */
  6689. static readonly MatricesWeightsKind: string;
  6690. /**
  6691. * Additional matrix indices (for bones)
  6692. */
  6693. static readonly MatricesIndicesExtraKind: string;
  6694. /**
  6695. * Additional matrix weights (for bones)
  6696. */
  6697. static readonly MatricesWeightsExtraKind: string;
  6698. /**
  6699. * Deduces the stride given a kind.
  6700. * @param kind The kind string to deduce
  6701. * @returns The deduced stride
  6702. */
  6703. static DeduceStride(kind: string): number;
  6704. /**
  6705. * Gets the byte length of the given type.
  6706. * @param type the type
  6707. * @returns the number of bytes
  6708. */
  6709. static GetTypeByteLength(type: number): number;
  6710. /**
  6711. * Enumerates each value of the given parameters as numbers.
  6712. * @param data the data to enumerate
  6713. * @param byteOffset the byte offset of the data
  6714. * @param byteStride the byte stride of the data
  6715. * @param componentCount the number of components per element
  6716. * @param componentType the type of the component
  6717. * @param count the number of values to enumerate
  6718. * @param normalized whether the data is normalized
  6719. * @param callback the callback function called for each value
  6720. */
  6721. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6722. private static _GetFloatValue;
  6723. }
  6724. }
  6725. declare module BABYLON {
  6726. /**
  6727. * @hidden
  6728. */
  6729. export class IntersectionInfo {
  6730. bu: Nullable<number>;
  6731. bv: Nullable<number>;
  6732. distance: number;
  6733. faceId: number;
  6734. subMeshId: number;
  6735. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6736. }
  6737. }
  6738. declare module BABYLON {
  6739. /**
  6740. * Class used to store bounding sphere information
  6741. */
  6742. export class BoundingSphere {
  6743. /**
  6744. * Gets the center of the bounding sphere in local space
  6745. */
  6746. readonly center: Vector3;
  6747. /**
  6748. * Radius of the bounding sphere in local space
  6749. */
  6750. radius: number;
  6751. /**
  6752. * Gets the center of the bounding sphere in world space
  6753. */
  6754. readonly centerWorld: Vector3;
  6755. /**
  6756. * Radius of the bounding sphere in world space
  6757. */
  6758. radiusWorld: number;
  6759. /**
  6760. * Gets the minimum vector in local space
  6761. */
  6762. readonly minimum: Vector3;
  6763. /**
  6764. * Gets the maximum vector in local space
  6765. */
  6766. readonly maximum: Vector3;
  6767. private _worldMatrix;
  6768. private static readonly TmpVector3;
  6769. /**
  6770. * Creates a new bounding sphere
  6771. * @param min defines the minimum vector (in local space)
  6772. * @param max defines the maximum vector (in local space)
  6773. * @param worldMatrix defines the new world matrix
  6774. */
  6775. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6776. /**
  6777. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6778. * @param min defines the new minimum vector (in local space)
  6779. * @param max defines the new maximum vector (in local space)
  6780. * @param worldMatrix defines the new world matrix
  6781. */
  6782. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6783. /**
  6784. * Scale the current bounding sphere by applying a scale factor
  6785. * @param factor defines the scale factor to apply
  6786. * @returns the current bounding box
  6787. */
  6788. scale(factor: number): BoundingSphere;
  6789. /**
  6790. * Gets the world matrix of the bounding box
  6791. * @returns a matrix
  6792. */
  6793. getWorldMatrix(): DeepImmutable<Matrix>;
  6794. /** @hidden */
  6795. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6796. /**
  6797. * Tests if the bounding sphere is intersecting the frustum planes
  6798. * @param frustumPlanes defines the frustum planes to test
  6799. * @returns true if there is an intersection
  6800. */
  6801. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6802. /**
  6803. * Tests if the bounding sphere center is in between the frustum planes.
  6804. * Used for optimistic fast inclusion.
  6805. * @param frustumPlanes defines the frustum planes to test
  6806. * @returns true if the sphere center is in between the frustum planes
  6807. */
  6808. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6809. /**
  6810. * Tests if a point is inside the bounding sphere
  6811. * @param point defines the point to test
  6812. * @returns true if the point is inside the bounding sphere
  6813. */
  6814. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6815. /**
  6816. * Checks if two sphere intersct
  6817. * @param sphere0 sphere 0
  6818. * @param sphere1 sphere 1
  6819. * @returns true if the speres intersect
  6820. */
  6821. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6822. }
  6823. }
  6824. declare module BABYLON {
  6825. /**
  6826. * Class used to store bounding box information
  6827. */
  6828. export class BoundingBox implements ICullable {
  6829. /**
  6830. * Gets the 8 vectors representing the bounding box in local space
  6831. */
  6832. readonly vectors: Vector3[];
  6833. /**
  6834. * Gets the center of the bounding box in local space
  6835. */
  6836. readonly center: Vector3;
  6837. /**
  6838. * Gets the center of the bounding box in world space
  6839. */
  6840. readonly centerWorld: Vector3;
  6841. /**
  6842. * Gets the extend size in local space
  6843. */
  6844. readonly extendSize: Vector3;
  6845. /**
  6846. * Gets the extend size in world space
  6847. */
  6848. readonly extendSizeWorld: Vector3;
  6849. /**
  6850. * Gets the OBB (object bounding box) directions
  6851. */
  6852. readonly directions: Vector3[];
  6853. /**
  6854. * Gets the 8 vectors representing the bounding box in world space
  6855. */
  6856. readonly vectorsWorld: Vector3[];
  6857. /**
  6858. * Gets the minimum vector in world space
  6859. */
  6860. readonly minimumWorld: Vector3;
  6861. /**
  6862. * Gets the maximum vector in world space
  6863. */
  6864. readonly maximumWorld: Vector3;
  6865. /**
  6866. * Gets the minimum vector in local space
  6867. */
  6868. readonly minimum: Vector3;
  6869. /**
  6870. * Gets the maximum vector in local space
  6871. */
  6872. readonly maximum: Vector3;
  6873. private _worldMatrix;
  6874. private static readonly TmpVector3;
  6875. /**
  6876. * @hidden
  6877. */
  6878. _tag: number;
  6879. /**
  6880. * Creates a new bounding box
  6881. * @param min defines the minimum vector (in local space)
  6882. * @param max defines the maximum vector (in local space)
  6883. * @param worldMatrix defines the new world matrix
  6884. */
  6885. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6886. /**
  6887. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6888. * @param min defines the new minimum vector (in local space)
  6889. * @param max defines the new maximum vector (in local space)
  6890. * @param worldMatrix defines the new world matrix
  6891. */
  6892. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6893. /**
  6894. * Scale the current bounding box by applying a scale factor
  6895. * @param factor defines the scale factor to apply
  6896. * @returns the current bounding box
  6897. */
  6898. scale(factor: number): BoundingBox;
  6899. /**
  6900. * Gets the world matrix of the bounding box
  6901. * @returns a matrix
  6902. */
  6903. getWorldMatrix(): DeepImmutable<Matrix>;
  6904. /** @hidden */
  6905. _update(world: DeepImmutable<Matrix>): void;
  6906. /**
  6907. * Tests if the bounding box is intersecting the frustum planes
  6908. * @param frustumPlanes defines the frustum planes to test
  6909. * @returns true if there is an intersection
  6910. */
  6911. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6912. /**
  6913. * Tests if the bounding box is entirely inside the frustum planes
  6914. * @param frustumPlanes defines the frustum planes to test
  6915. * @returns true if there is an inclusion
  6916. */
  6917. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6918. /**
  6919. * Tests if a point is inside the bounding box
  6920. * @param point defines the point to test
  6921. * @returns true if the point is inside the bounding box
  6922. */
  6923. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6924. /**
  6925. * Tests if the bounding box intersects with a bounding sphere
  6926. * @param sphere defines the sphere to test
  6927. * @returns true if there is an intersection
  6928. */
  6929. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6930. /**
  6931. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6932. * @param min defines the min vector to use
  6933. * @param max defines the max vector to use
  6934. * @returns true if there is an intersection
  6935. */
  6936. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6937. /**
  6938. * Tests if two bounding boxes are intersections
  6939. * @param box0 defines the first box to test
  6940. * @param box1 defines the second box to test
  6941. * @returns true if there is an intersection
  6942. */
  6943. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6944. /**
  6945. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6946. * @param minPoint defines the minimum vector of the bounding box
  6947. * @param maxPoint defines the maximum vector of the bounding box
  6948. * @param sphereCenter defines the sphere center
  6949. * @param sphereRadius defines the sphere radius
  6950. * @returns true if there is an intersection
  6951. */
  6952. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6953. /**
  6954. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6955. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6956. * @param frustumPlanes defines the frustum planes to test
  6957. * @return true if there is an inclusion
  6958. */
  6959. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6960. /**
  6961. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6962. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6963. * @param frustumPlanes defines the frustum planes to test
  6964. * @return true if there is an intersection
  6965. */
  6966. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6967. }
  6968. }
  6969. declare module BABYLON {
  6970. /** @hidden */
  6971. export class Collider {
  6972. /** Define if a collision was found */
  6973. collisionFound: boolean;
  6974. /**
  6975. * Define last intersection point in local space
  6976. */
  6977. intersectionPoint: Vector3;
  6978. /**
  6979. * Define last collided mesh
  6980. */
  6981. collidedMesh: Nullable<AbstractMesh>;
  6982. private _collisionPoint;
  6983. private _planeIntersectionPoint;
  6984. private _tempVector;
  6985. private _tempVector2;
  6986. private _tempVector3;
  6987. private _tempVector4;
  6988. private _edge;
  6989. private _baseToVertex;
  6990. private _destinationPoint;
  6991. private _slidePlaneNormal;
  6992. private _displacementVector;
  6993. /** @hidden */
  6994. _radius: Vector3;
  6995. /** @hidden */
  6996. _retry: number;
  6997. private _velocity;
  6998. private _basePoint;
  6999. private _epsilon;
  7000. /** @hidden */
  7001. _velocityWorldLength: number;
  7002. /** @hidden */
  7003. _basePointWorld: Vector3;
  7004. private _velocityWorld;
  7005. private _normalizedVelocity;
  7006. /** @hidden */
  7007. _initialVelocity: Vector3;
  7008. /** @hidden */
  7009. _initialPosition: Vector3;
  7010. private _nearestDistance;
  7011. private _collisionMask;
  7012. get collisionMask(): number;
  7013. set collisionMask(mask: number);
  7014. /**
  7015. * Gets the plane normal used to compute the sliding response (in local space)
  7016. */
  7017. get slidePlaneNormal(): Vector3;
  7018. /** @hidden */
  7019. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7020. /** @hidden */
  7021. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7022. /** @hidden */
  7023. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7024. /** @hidden */
  7025. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7026. /** @hidden */
  7027. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7028. /** @hidden */
  7029. _getResponse(pos: Vector3, vel: Vector3): void;
  7030. }
  7031. }
  7032. declare module BABYLON {
  7033. /**
  7034. * Interface for cullable objects
  7035. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7036. */
  7037. export interface ICullable {
  7038. /**
  7039. * Checks if the object or part of the object is in the frustum
  7040. * @param frustumPlanes Camera near/planes
  7041. * @returns true if the object is in frustum otherwise false
  7042. */
  7043. isInFrustum(frustumPlanes: Plane[]): boolean;
  7044. /**
  7045. * Checks if a cullable object (mesh...) is in the camera frustum
  7046. * Unlike isInFrustum this cheks the full bounding box
  7047. * @param frustumPlanes Camera near/planes
  7048. * @returns true if the object is in frustum otherwise false
  7049. */
  7050. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7051. }
  7052. /**
  7053. * Info for a bounding data of a mesh
  7054. */
  7055. export class BoundingInfo implements ICullable {
  7056. /**
  7057. * Bounding box for the mesh
  7058. */
  7059. readonly boundingBox: BoundingBox;
  7060. /**
  7061. * Bounding sphere for the mesh
  7062. */
  7063. readonly boundingSphere: BoundingSphere;
  7064. private _isLocked;
  7065. private static readonly TmpVector3;
  7066. /**
  7067. * Constructs bounding info
  7068. * @param minimum min vector of the bounding box/sphere
  7069. * @param maximum max vector of the bounding box/sphere
  7070. * @param worldMatrix defines the new world matrix
  7071. */
  7072. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7073. /**
  7074. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7075. * @param min defines the new minimum vector (in local space)
  7076. * @param max defines the new maximum vector (in local space)
  7077. * @param worldMatrix defines the new world matrix
  7078. */
  7079. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * min vector of the bounding box/sphere
  7082. */
  7083. get minimum(): Vector3;
  7084. /**
  7085. * max vector of the bounding box/sphere
  7086. */
  7087. get maximum(): Vector3;
  7088. /**
  7089. * If the info is locked and won't be updated to avoid perf overhead
  7090. */
  7091. get isLocked(): boolean;
  7092. set isLocked(value: boolean);
  7093. /**
  7094. * Updates the bounding sphere and box
  7095. * @param world world matrix to be used to update
  7096. */
  7097. update(world: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7100. * @param center New center of the bounding info
  7101. * @param extend New extend of the bounding info
  7102. * @returns the current bounding info
  7103. */
  7104. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7105. /**
  7106. * Scale the current bounding info by applying a scale factor
  7107. * @param factor defines the scale factor to apply
  7108. * @returns the current bounding info
  7109. */
  7110. scale(factor: number): BoundingInfo;
  7111. /**
  7112. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7113. * @param frustumPlanes defines the frustum to test
  7114. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7115. * @returns true if the bounding info is in the frustum planes
  7116. */
  7117. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7118. /**
  7119. * Gets the world distance between the min and max points of the bounding box
  7120. */
  7121. get diagonalLength(): number;
  7122. /**
  7123. * Checks if a cullable object (mesh...) is in the camera frustum
  7124. * Unlike isInFrustum this cheks the full bounding box
  7125. * @param frustumPlanes Camera near/planes
  7126. * @returns true if the object is in frustum otherwise false
  7127. */
  7128. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7129. /** @hidden */
  7130. _checkCollision(collider: Collider): boolean;
  7131. /**
  7132. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7133. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7134. * @param point the point to check intersection with
  7135. * @returns if the point intersects
  7136. */
  7137. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7138. /**
  7139. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7140. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7141. * @param boundingInfo the bounding info to check intersection with
  7142. * @param precise if the intersection should be done using OBB
  7143. * @returns if the bounding info intersects
  7144. */
  7145. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7146. }
  7147. }
  7148. declare module BABYLON {
  7149. /**
  7150. * Extracts minimum and maximum values from a list of indexed positions
  7151. * @param positions defines the positions to use
  7152. * @param indices defines the indices to the positions
  7153. * @param indexStart defines the start index
  7154. * @param indexCount defines the end index
  7155. * @param bias defines bias value to add to the result
  7156. * @return minimum and maximum values
  7157. */
  7158. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7159. minimum: Vector3;
  7160. maximum: Vector3;
  7161. };
  7162. /**
  7163. * Extracts minimum and maximum values from a list of positions
  7164. * @param positions defines the positions to use
  7165. * @param start defines the start index in the positions array
  7166. * @param count defines the number of positions to handle
  7167. * @param bias defines bias value to add to the result
  7168. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7169. * @return minimum and maximum values
  7170. */
  7171. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7172. minimum: Vector3;
  7173. maximum: Vector3;
  7174. };
  7175. }
  7176. declare module BABYLON {
  7177. /** @hidden */
  7178. export class WebGLDataBuffer extends DataBuffer {
  7179. private _buffer;
  7180. constructor(resource: WebGLBuffer);
  7181. get underlyingResource(): any;
  7182. }
  7183. }
  7184. declare module BABYLON {
  7185. /** @hidden */
  7186. export class WebGLPipelineContext implements IPipelineContext {
  7187. engine: ThinEngine;
  7188. program: Nullable<WebGLProgram>;
  7189. context?: WebGLRenderingContext;
  7190. vertexShader?: WebGLShader;
  7191. fragmentShader?: WebGLShader;
  7192. isParallelCompiled: boolean;
  7193. onCompiled?: () => void;
  7194. transformFeedback?: WebGLTransformFeedback | null;
  7195. vertexCompilationError: Nullable<string>;
  7196. fragmentCompilationError: Nullable<string>;
  7197. programLinkError: Nullable<string>;
  7198. programValidationError: Nullable<string>;
  7199. get isAsync(): boolean;
  7200. get isReady(): boolean;
  7201. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7202. _getVertexShaderCode(): string | null;
  7203. _getFragmentShaderCode(): string | null;
  7204. }
  7205. }
  7206. declare module BABYLON {
  7207. interface ThinEngine {
  7208. /**
  7209. * Create an uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param elements defines the content of the uniform buffer
  7212. * @returns the webGL uniform buffer
  7213. */
  7214. createUniformBuffer(elements: FloatArray): DataBuffer;
  7215. /**
  7216. * Create a dynamic uniform buffer
  7217. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7218. * @param elements defines the content of the uniform buffer
  7219. * @returns the webGL uniform buffer
  7220. */
  7221. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7222. /**
  7223. * Update an existing uniform buffer
  7224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7225. * @param uniformBuffer defines the target uniform buffer
  7226. * @param elements defines the content to update
  7227. * @param offset defines the offset in the uniform buffer where update should start
  7228. * @param count defines the size of the data to update
  7229. */
  7230. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7231. /**
  7232. * Bind an uniform buffer to the current webGL context
  7233. * @param buffer defines the buffer to bind
  7234. */
  7235. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7236. /**
  7237. * Bind a buffer to the current webGL context at a given location
  7238. * @param buffer defines the buffer to bind
  7239. * @param location defines the index where to bind the buffer
  7240. */
  7241. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7242. /**
  7243. * Bind a specific block at a given index in a specific shader program
  7244. * @param pipelineContext defines the pipeline context to use
  7245. * @param blockName defines the block name
  7246. * @param index defines the index where to bind the block
  7247. */
  7248. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7249. }
  7250. }
  7251. declare module BABYLON {
  7252. /**
  7253. * Uniform buffer objects.
  7254. *
  7255. * Handles blocks of uniform on the GPU.
  7256. *
  7257. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7258. *
  7259. * For more information, please refer to :
  7260. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7261. */
  7262. export class UniformBuffer {
  7263. private _engine;
  7264. private _buffer;
  7265. private _data;
  7266. private _bufferData;
  7267. private _dynamic?;
  7268. private _uniformLocations;
  7269. private _uniformSizes;
  7270. private _uniformLocationPointer;
  7271. private _needSync;
  7272. private _noUBO;
  7273. private _currentEffect;
  7274. /** @hidden */
  7275. _alreadyBound: boolean;
  7276. private static _MAX_UNIFORM_SIZE;
  7277. private static _tempBuffer;
  7278. /**
  7279. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7280. * This is dynamic to allow compat with webgl 1 and 2.
  7281. * You will need to pass the name of the uniform as well as the value.
  7282. */
  7283. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7284. /**
  7285. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7286. * This is dynamic to allow compat with webgl 1 and 2.
  7287. * You will need to pass the name of the uniform as well as the value.
  7288. */
  7289. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7290. /**
  7291. * Lambda to Update a single float in a uniform buffer.
  7292. * This is dynamic to allow compat with webgl 1 and 2.
  7293. * You will need to pass the name of the uniform as well as the value.
  7294. */
  7295. updateFloat: (name: string, x: number) => void;
  7296. /**
  7297. * Lambda to Update a vec2 of float in a uniform buffer.
  7298. * This is dynamic to allow compat with webgl 1 and 2.
  7299. * You will need to pass the name of the uniform as well as the value.
  7300. */
  7301. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7302. /**
  7303. * Lambda to Update a vec3 of float in a uniform buffer.
  7304. * This is dynamic to allow compat with webgl 1 and 2.
  7305. * You will need to pass the name of the uniform as well as the value.
  7306. */
  7307. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7308. /**
  7309. * Lambda to Update a vec4 of float in a uniform buffer.
  7310. * This is dynamic to allow compat with webgl 1 and 2.
  7311. * You will need to pass the name of the uniform as well as the value.
  7312. */
  7313. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7314. /**
  7315. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7316. * This is dynamic to allow compat with webgl 1 and 2.
  7317. * You will need to pass the name of the uniform as well as the value.
  7318. */
  7319. updateMatrix: (name: string, mat: Matrix) => void;
  7320. /**
  7321. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7322. * This is dynamic to allow compat with webgl 1 and 2.
  7323. * You will need to pass the name of the uniform as well as the value.
  7324. */
  7325. updateVector3: (name: string, vector: Vector3) => void;
  7326. /**
  7327. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7328. * This is dynamic to allow compat with webgl 1 and 2.
  7329. * You will need to pass the name of the uniform as well as the value.
  7330. */
  7331. updateVector4: (name: string, vector: Vector4) => void;
  7332. /**
  7333. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7334. * This is dynamic to allow compat with webgl 1 and 2.
  7335. * You will need to pass the name of the uniform as well as the value.
  7336. */
  7337. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7338. /**
  7339. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7340. * This is dynamic to allow compat with webgl 1 and 2.
  7341. * You will need to pass the name of the uniform as well as the value.
  7342. */
  7343. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7344. /**
  7345. * Instantiates a new Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. * @param engine Define the engine the buffer is associated with
  7354. * @param data Define the data contained in the buffer
  7355. * @param dynamic Define if the buffer is updatable
  7356. */
  7357. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7358. /**
  7359. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7360. * or just falling back on setUniformXXX calls.
  7361. */
  7362. get useUbo(): boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is in sync
  7365. * with the javascript cache data.
  7366. */
  7367. get isSync(): boolean;
  7368. /**
  7369. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7370. * Also, a dynamic UniformBuffer will disable cache verification and always
  7371. * update the underlying WebGL uniform buffer to the GPU.
  7372. * @returns if Dynamic, otherwise false
  7373. */
  7374. isDynamic(): boolean;
  7375. /**
  7376. * The data cache on JS side.
  7377. * @returns the underlying data as a float array
  7378. */
  7379. getData(): Float32Array;
  7380. /**
  7381. * The underlying WebGL Uniform buffer.
  7382. * @returns the webgl buffer
  7383. */
  7384. getBuffer(): Nullable<DataBuffer>;
  7385. /**
  7386. * std140 layout specifies how to align data within an UBO structure.
  7387. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7388. * for specs.
  7389. */
  7390. private _fillAlignment;
  7391. /**
  7392. * Adds an uniform in the buffer.
  7393. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7394. * for the layout to be correct !
  7395. * @param name Name of the uniform, as used in the uniform block in the shader.
  7396. * @param size Data size, or data directly.
  7397. */
  7398. addUniform(name: string, size: number | number[]): void;
  7399. /**
  7400. * Adds a Matrix 4x4 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. * @param mat A 4x4 matrix.
  7403. */
  7404. addMatrix(name: string, mat: Matrix): void;
  7405. /**
  7406. * Adds a vec2 to the uniform buffer.
  7407. * @param name Name of the uniform, as used in the uniform block in the shader.
  7408. * @param x Define the x component value of the vec2
  7409. * @param y Define the y component value of the vec2
  7410. */
  7411. addFloat2(name: string, x: number, y: number): void;
  7412. /**
  7413. * Adds a vec3 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param x Define the x component value of the vec3
  7416. * @param y Define the y component value of the vec3
  7417. * @param z Define the z component value of the vec3
  7418. */
  7419. addFloat3(name: string, x: number, y: number, z: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param color Define the vec3 from a Color
  7424. */
  7425. addColor3(name: string, color: Color3): void;
  7426. /**
  7427. * Adds a vec4 to the uniform buffer.
  7428. * @param name Name of the uniform, as used in the uniform block in the shader.
  7429. * @param color Define the rgb components from a Color
  7430. * @param alpha Define the a component of the vec4
  7431. */
  7432. addColor4(name: string, color: Color3, alpha: number): void;
  7433. /**
  7434. * Adds a vec3 to the uniform buffer.
  7435. * @param name Name of the uniform, as used in the uniform block in the shader.
  7436. * @param vector Define the vec3 components from a Vector
  7437. */
  7438. addVector3(name: string, vector: Vector3): void;
  7439. /**
  7440. * Adds a Matrix 3x3 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix3x3(name: string): void;
  7444. /**
  7445. * Adds a Matrix 2x2 to the uniform buffer.
  7446. * @param name Name of the uniform, as used in the uniform block in the shader.
  7447. */
  7448. addMatrix2x2(name: string): void;
  7449. /**
  7450. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7451. */
  7452. create(): void;
  7453. /** @hidden */
  7454. _rebuild(): void;
  7455. /**
  7456. * Updates the WebGL Uniform Buffer on the GPU.
  7457. * If the `dynamic` flag is set to true, no cache comparison is done.
  7458. * Otherwise, the buffer will be updated only if the cache differs.
  7459. */
  7460. update(): void;
  7461. /**
  7462. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7463. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7464. * @param data Define the flattened data
  7465. * @param size Define the size of the data.
  7466. */
  7467. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7468. private _valueCache;
  7469. private _cacheMatrix;
  7470. private _updateMatrix3x3ForUniform;
  7471. private _updateMatrix3x3ForEffect;
  7472. private _updateMatrix2x2ForEffect;
  7473. private _updateMatrix2x2ForUniform;
  7474. private _updateFloatForEffect;
  7475. private _updateFloatForUniform;
  7476. private _updateFloat2ForEffect;
  7477. private _updateFloat2ForUniform;
  7478. private _updateFloat3ForEffect;
  7479. private _updateFloat3ForUniform;
  7480. private _updateFloat4ForEffect;
  7481. private _updateFloat4ForUniform;
  7482. private _updateMatrixForEffect;
  7483. private _updateMatrixForUniform;
  7484. private _updateVector3ForEffect;
  7485. private _updateVector3ForUniform;
  7486. private _updateVector4ForEffect;
  7487. private _updateVector4ForUniform;
  7488. private _updateColor3ForEffect;
  7489. private _updateColor3ForUniform;
  7490. private _updateColor4ForEffect;
  7491. private _updateColor4ForUniform;
  7492. /**
  7493. * Sets a sampler uniform on the effect.
  7494. * @param name Define the name of the sampler.
  7495. * @param texture Define the texture to set in the sampler
  7496. */
  7497. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7498. /**
  7499. * Directly updates the value of the uniform in the cache AND on the GPU.
  7500. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7501. * @param data Define the flattened data
  7502. */
  7503. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7504. /**
  7505. * Binds this uniform buffer to an effect.
  7506. * @param effect Define the effect to bind the buffer to
  7507. * @param name Name of the uniform block in the shader.
  7508. */
  7509. bindToEffect(effect: Effect, name: string): void;
  7510. /**
  7511. * Disposes the uniform buffer.
  7512. */
  7513. dispose(): void;
  7514. }
  7515. }
  7516. declare module BABYLON {
  7517. /**
  7518. * Enum that determines the text-wrapping mode to use.
  7519. */
  7520. export enum InspectableType {
  7521. /**
  7522. * Checkbox for booleans
  7523. */
  7524. Checkbox = 0,
  7525. /**
  7526. * Sliders for numbers
  7527. */
  7528. Slider = 1,
  7529. /**
  7530. * Vector3
  7531. */
  7532. Vector3 = 2,
  7533. /**
  7534. * Quaternions
  7535. */
  7536. Quaternion = 3,
  7537. /**
  7538. * Color3
  7539. */
  7540. Color3 = 4,
  7541. /**
  7542. * String
  7543. */
  7544. String = 5
  7545. }
  7546. /**
  7547. * Interface used to define custom inspectable properties.
  7548. * This interface is used by the inspector to display custom property grids
  7549. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7550. */
  7551. export interface IInspectable {
  7552. /**
  7553. * Gets the label to display
  7554. */
  7555. label: string;
  7556. /**
  7557. * Gets the name of the property to edit
  7558. */
  7559. propertyName: string;
  7560. /**
  7561. * Gets the type of the editor to use
  7562. */
  7563. type: InspectableType;
  7564. /**
  7565. * Gets the minimum value of the property when using in "slider" mode
  7566. */
  7567. min?: number;
  7568. /**
  7569. * Gets the maximum value of the property when using in "slider" mode
  7570. */
  7571. max?: number;
  7572. /**
  7573. * Gets the setp to use when using in "slider" mode
  7574. */
  7575. step?: number;
  7576. }
  7577. }
  7578. declare module BABYLON {
  7579. /**
  7580. * Class used to provide helper for timing
  7581. */
  7582. export class TimingTools {
  7583. /**
  7584. * Polyfill for setImmediate
  7585. * @param action defines the action to execute after the current execution block
  7586. */
  7587. static SetImmediate(action: () => void): void;
  7588. }
  7589. }
  7590. declare module BABYLON {
  7591. /**
  7592. * Class used to enable instatition of objects by class name
  7593. */
  7594. export class InstantiationTools {
  7595. /**
  7596. * Use this object to register external classes like custom textures or material
  7597. * to allow the laoders to instantiate them
  7598. */
  7599. static RegisteredExternalClasses: {
  7600. [key: string]: Object;
  7601. };
  7602. /**
  7603. * Tries to instantiate a new object from a given class name
  7604. * @param className defines the class name to instantiate
  7605. * @returns the new object or null if the system was not able to do the instantiation
  7606. */
  7607. static Instantiate(className: string): any;
  7608. }
  7609. }
  7610. declare module BABYLON {
  7611. /**
  7612. * Define options used to create a depth texture
  7613. */
  7614. export class DepthTextureCreationOptions {
  7615. /** Specifies whether or not a stencil should be allocated in the texture */
  7616. generateStencil?: boolean;
  7617. /** Specifies whether or not bilinear filtering is enable on the texture */
  7618. bilinearFiltering?: boolean;
  7619. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7620. comparisonFunction?: number;
  7621. /** Specifies if the created texture is a cube texture */
  7622. isCube?: boolean;
  7623. }
  7624. }
  7625. declare module BABYLON {
  7626. interface ThinEngine {
  7627. /**
  7628. * Creates a depth stencil cube texture.
  7629. * This is only available in WebGL 2.
  7630. * @param size The size of face edge in the cube texture.
  7631. * @param options The options defining the cube texture.
  7632. * @returns The cube texture
  7633. */
  7634. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7635. /**
  7636. * Creates a cube texture
  7637. * @param rootUrl defines the url where the files to load is located
  7638. * @param scene defines the current scene
  7639. * @param files defines the list of files to load (1 per face)
  7640. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7641. * @param onLoad defines an optional callback raised when the texture is loaded
  7642. * @param onError defines an optional callback raised if there is an issue to load the texture
  7643. * @param format defines the format of the data
  7644. * @param forcedExtension defines the extension to use to pick the right loader
  7645. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7646. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7647. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7648. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7649. * @returns the cube texture as an InternalTexture
  7650. */
  7651. 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;
  7652. /**
  7653. * Creates a cube texture
  7654. * @param rootUrl defines the url where the files to load is located
  7655. * @param scene defines the current scene
  7656. * @param files defines the list of files to load (1 per face)
  7657. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7658. * @param onLoad defines an optional callback raised when the texture is loaded
  7659. * @param onError defines an optional callback raised if there is an issue to load the texture
  7660. * @param format defines the format of the data
  7661. * @param forcedExtension defines the extension to use to pick the right loader
  7662. * @returns the cube texture as an InternalTexture
  7663. */
  7664. 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;
  7665. /**
  7666. * Creates a cube texture
  7667. * @param rootUrl defines the url where the files to load is located
  7668. * @param scene defines the current scene
  7669. * @param files defines the list of files to load (1 per face)
  7670. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7671. * @param onLoad defines an optional callback raised when the texture is loaded
  7672. * @param onError defines an optional callback raised if there is an issue to load the texture
  7673. * @param format defines the format of the data
  7674. * @param forcedExtension defines the extension to use to pick the right loader
  7675. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7676. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7677. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7678. * @returns the cube texture as an InternalTexture
  7679. */
  7680. 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;
  7681. /** @hidden */
  7682. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7683. /** @hidden */
  7684. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7687. /** @hidden */
  7688. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7689. /**
  7690. * @hidden
  7691. */
  7692. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7693. }
  7694. }
  7695. declare module BABYLON {
  7696. /**
  7697. * Class for creating a cube texture
  7698. */
  7699. export class CubeTexture extends BaseTexture {
  7700. private _delayedOnLoad;
  7701. /**
  7702. * Observable triggered once the texture has been loaded.
  7703. */
  7704. onLoadObservable: Observable<CubeTexture>;
  7705. /**
  7706. * The url of the texture
  7707. */
  7708. url: string;
  7709. /**
  7710. * Gets or sets the center of the bounding box associated with the cube texture.
  7711. * It must define where the camera used to render the texture was set
  7712. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7713. */
  7714. boundingBoxPosition: Vector3;
  7715. private _boundingBoxSize;
  7716. /**
  7717. * Gets or sets the size of the bounding box associated with the cube texture
  7718. * When defined, the cubemap will switch to local mode
  7719. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7720. * @example https://www.babylonjs-playground.com/#RNASML
  7721. */
  7722. set boundingBoxSize(value: Vector3);
  7723. /**
  7724. * Returns the bounding box size
  7725. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7726. */
  7727. get boundingBoxSize(): Vector3;
  7728. protected _rotationY: number;
  7729. /**
  7730. * Sets texture matrix rotation angle around Y axis in radians.
  7731. */
  7732. set rotationY(value: number);
  7733. /**
  7734. * Gets texture matrix rotation angle around Y axis radians.
  7735. */
  7736. get rotationY(): number;
  7737. /**
  7738. * Are mip maps generated for this texture or not.
  7739. */
  7740. get noMipmap(): boolean;
  7741. private _noMipmap;
  7742. private _files;
  7743. protected _forcedExtension: Nullable<string>;
  7744. private _extensions;
  7745. private _textureMatrix;
  7746. private _format;
  7747. private _createPolynomials;
  7748. /** @hidden */
  7749. _prefiltered: boolean;
  7750. /**
  7751. * Creates a cube texture from an array of image urls
  7752. * @param files defines an array of image urls
  7753. * @param scene defines the hosting scene
  7754. * @param noMipmap specifies if mip maps are not used
  7755. * @returns a cube texture
  7756. */
  7757. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7758. /**
  7759. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7760. * @param url defines the url of the prefiltered texture
  7761. * @param scene defines the scene the texture is attached to
  7762. * @param forcedExtension defines the extension of the file if different from the url
  7763. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7764. * @return the prefiltered texture
  7765. */
  7766. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7767. /**
  7768. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7769. * as prefiltered data.
  7770. * @param rootUrl defines the url of the texture or the root name of the six images
  7771. * @param scene defines the scene the texture is attached to
  7772. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7773. * @param noMipmap defines if mipmaps should be created or not
  7774. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7775. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7776. * @param onError defines a callback triggered in case of error during load
  7777. * @param format defines the internal format to use for the texture once loaded
  7778. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7779. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7780. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7781. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7782. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7783. * @return the cube texture
  7784. */
  7785. 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);
  7786. /**
  7787. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7788. */
  7789. get isPrefiltered(): boolean;
  7790. /**
  7791. * Get the current class name of the texture useful for serialization or dynamic coding.
  7792. * @returns "CubeTexture"
  7793. */
  7794. getClassName(): string;
  7795. /**
  7796. * Update the url (and optional buffer) of this texture if url was null during construction.
  7797. * @param url the url of the texture
  7798. * @param forcedExtension defines the extension to use
  7799. * @param onLoad callback called when the texture is loaded (defaults to null)
  7800. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7801. */
  7802. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7803. /**
  7804. * Delays loading of the cube texture
  7805. * @param forcedExtension defines the extension to use
  7806. */
  7807. delayLoad(forcedExtension?: string): void;
  7808. /**
  7809. * Returns the reflection texture matrix
  7810. * @returns the reflection texture matrix
  7811. */
  7812. getReflectionTextureMatrix(): Matrix;
  7813. /**
  7814. * Sets the reflection texture matrix
  7815. * @param value Reflection texture matrix
  7816. */
  7817. setReflectionTextureMatrix(value: Matrix): void;
  7818. /**
  7819. * Parses text to create a cube texture
  7820. * @param parsedTexture define the serialized text to read from
  7821. * @param scene defines the hosting scene
  7822. * @param rootUrl defines the root url of the cube texture
  7823. * @returns a cube texture
  7824. */
  7825. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7826. /**
  7827. * Makes a clone, or deep copy, of the cube texture
  7828. * @returns a new cube texture
  7829. */
  7830. clone(): CubeTexture;
  7831. }
  7832. }
  7833. declare module BABYLON {
  7834. /**
  7835. * Manages the defines for the Material
  7836. */
  7837. export class MaterialDefines {
  7838. /** @hidden */
  7839. protected _keys: string[];
  7840. private _isDirty;
  7841. /** @hidden */
  7842. _renderId: number;
  7843. /** @hidden */
  7844. _areLightsDirty: boolean;
  7845. /** @hidden */
  7846. _areLightsDisposed: boolean;
  7847. /** @hidden */
  7848. _areAttributesDirty: boolean;
  7849. /** @hidden */
  7850. _areTexturesDirty: boolean;
  7851. /** @hidden */
  7852. _areFresnelDirty: boolean;
  7853. /** @hidden */
  7854. _areMiscDirty: boolean;
  7855. /** @hidden */
  7856. _areImageProcessingDirty: boolean;
  7857. /** @hidden */
  7858. _normals: boolean;
  7859. /** @hidden */
  7860. _uvs: boolean;
  7861. /** @hidden */
  7862. _needNormals: boolean;
  7863. /** @hidden */
  7864. _needUVs: boolean;
  7865. [id: string]: any;
  7866. /**
  7867. * Specifies if the material needs to be re-calculated
  7868. */
  7869. get isDirty(): boolean;
  7870. /**
  7871. * Marks the material to indicate that it has been re-calculated
  7872. */
  7873. markAsProcessed(): void;
  7874. /**
  7875. * Marks the material to indicate that it needs to be re-calculated
  7876. */
  7877. markAsUnprocessed(): void;
  7878. /**
  7879. * Marks the material to indicate all of its defines need to be re-calculated
  7880. */
  7881. markAllAsDirty(): void;
  7882. /**
  7883. * Marks the material to indicate that image processing needs to be re-calculated
  7884. */
  7885. markAsImageProcessingDirty(): void;
  7886. /**
  7887. * Marks the material to indicate the lights need to be re-calculated
  7888. * @param disposed Defines whether the light is dirty due to dispose or not
  7889. */
  7890. markAsLightDirty(disposed?: boolean): void;
  7891. /**
  7892. * Marks the attribute state as changed
  7893. */
  7894. markAsAttributesDirty(): void;
  7895. /**
  7896. * Marks the texture state as changed
  7897. */
  7898. markAsTexturesDirty(): void;
  7899. /**
  7900. * Marks the fresnel state as changed
  7901. */
  7902. markAsFresnelDirty(): void;
  7903. /**
  7904. * Marks the misc state as changed
  7905. */
  7906. markAsMiscDirty(): void;
  7907. /**
  7908. * Rebuilds the material defines
  7909. */
  7910. rebuild(): void;
  7911. /**
  7912. * Specifies if two material defines are equal
  7913. * @param other - A material define instance to compare to
  7914. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7915. */
  7916. isEqual(other: MaterialDefines): boolean;
  7917. /**
  7918. * Clones this instance's defines to another instance
  7919. * @param other - material defines to clone values to
  7920. */
  7921. cloneTo(other: MaterialDefines): void;
  7922. /**
  7923. * Resets the material define values
  7924. */
  7925. reset(): void;
  7926. /**
  7927. * Converts the material define values to a string
  7928. * @returns - String of material define information
  7929. */
  7930. toString(): string;
  7931. }
  7932. }
  7933. declare module BABYLON {
  7934. /**
  7935. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7936. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7937. * 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;
  7938. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7939. */
  7940. export class ColorCurves {
  7941. private _dirty;
  7942. private _tempColor;
  7943. private _globalCurve;
  7944. private _highlightsCurve;
  7945. private _midtonesCurve;
  7946. private _shadowsCurve;
  7947. private _positiveCurve;
  7948. private _negativeCurve;
  7949. private _globalHue;
  7950. private _globalDensity;
  7951. private _globalSaturation;
  7952. private _globalExposure;
  7953. /**
  7954. * Gets the global Hue value.
  7955. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7956. */
  7957. get globalHue(): number;
  7958. /**
  7959. * Sets the global Hue value.
  7960. * 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).
  7961. */
  7962. set globalHue(value: number);
  7963. /**
  7964. * Gets the global Density value.
  7965. * 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.
  7966. * Values less than zero provide a filter of opposite hue.
  7967. */
  7968. get globalDensity(): number;
  7969. /**
  7970. * Sets the global 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. set globalDensity(value: number);
  7975. /**
  7976. * Gets the global Saturation value.
  7977. * 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.
  7978. */
  7979. get globalSaturation(): number;
  7980. /**
  7981. * Sets the global Saturation value.
  7982. * 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.
  7983. */
  7984. set globalSaturation(value: number);
  7985. /**
  7986. * Gets the global Exposure value.
  7987. * 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.
  7988. */
  7989. get globalExposure(): number;
  7990. /**
  7991. * Sets the global Exposure value.
  7992. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7993. */
  7994. set globalExposure(value: number);
  7995. private _highlightsHue;
  7996. private _highlightsDensity;
  7997. private _highlightsSaturation;
  7998. private _highlightsExposure;
  7999. /**
  8000. * Gets the highlights Hue value.
  8001. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8002. */
  8003. get highlightsHue(): number;
  8004. /**
  8005. * Sets the highlights Hue value.
  8006. * 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).
  8007. */
  8008. set highlightsHue(value: number);
  8009. /**
  8010. * Gets the highlights Density value.
  8011. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8012. * Values less than zero provide a filter of opposite hue.
  8013. */
  8014. get highlightsDensity(): number;
  8015. /**
  8016. * Sets the highlights 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. set highlightsDensity(value: number);
  8021. /**
  8022. * Gets the highlights Saturation value.
  8023. * 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.
  8024. */
  8025. get highlightsSaturation(): number;
  8026. /**
  8027. * Sets the highlights Saturation value.
  8028. * 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.
  8029. */
  8030. set highlightsSaturation(value: number);
  8031. /**
  8032. * Gets the highlights Exposure value.
  8033. * 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.
  8034. */
  8035. get highlightsExposure(): number;
  8036. /**
  8037. * Sets the highlights Exposure value.
  8038. * 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.
  8039. */
  8040. set highlightsExposure(value: number);
  8041. private _midtonesHue;
  8042. private _midtonesDensity;
  8043. private _midtonesSaturation;
  8044. private _midtonesExposure;
  8045. /**
  8046. * Gets the midtones Hue value.
  8047. * 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).
  8048. */
  8049. get midtonesHue(): number;
  8050. /**
  8051. * Sets the midtones Hue value.
  8052. * 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).
  8053. */
  8054. set midtonesHue(value: number);
  8055. /**
  8056. * Gets the midtones Density value.
  8057. * 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.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. get midtonesDensity(): number;
  8061. /**
  8062. * Sets the midtones 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. set midtonesDensity(value: number);
  8067. /**
  8068. * Gets the midtones Saturation value.
  8069. * 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.
  8070. */
  8071. get midtonesSaturation(): number;
  8072. /**
  8073. * Sets the midtones Saturation value.
  8074. * 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.
  8075. */
  8076. set midtonesSaturation(value: number);
  8077. /**
  8078. * Gets the midtones Exposure value.
  8079. * 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.
  8080. */
  8081. get midtonesExposure(): number;
  8082. /**
  8083. * Sets the midtones Exposure value.
  8084. * 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.
  8085. */
  8086. set midtonesExposure(value: number);
  8087. private _shadowsHue;
  8088. private _shadowsDensity;
  8089. private _shadowsSaturation;
  8090. private _shadowsExposure;
  8091. /**
  8092. * Gets the shadows Hue value.
  8093. * 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).
  8094. */
  8095. get shadowsHue(): number;
  8096. /**
  8097. * Sets the shadows Hue value.
  8098. * 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).
  8099. */
  8100. set shadowsHue(value: number);
  8101. /**
  8102. * Gets the shadows Density value.
  8103. * 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.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. get shadowsDensity(): number;
  8107. /**
  8108. * Sets the shadows Density value.
  8109. * 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.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. set shadowsDensity(value: number);
  8113. /**
  8114. * Gets the shadows Saturation value.
  8115. * 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.
  8116. */
  8117. get shadowsSaturation(): number;
  8118. /**
  8119. * Sets the shadows Saturation value.
  8120. * 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.
  8121. */
  8122. set shadowsSaturation(value: number);
  8123. /**
  8124. * Gets the shadows Exposure value.
  8125. * 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.
  8126. */
  8127. get shadowsExposure(): number;
  8128. /**
  8129. * Sets the shadows Exposure value.
  8130. * 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.
  8131. */
  8132. set shadowsExposure(value: number);
  8133. /**
  8134. * Returns the class name
  8135. * @returns The class name
  8136. */
  8137. getClassName(): string;
  8138. /**
  8139. * Binds the color curves to the shader.
  8140. * @param colorCurves The color curve to bind
  8141. * @param effect The effect to bind to
  8142. * @param positiveUniform The positive uniform shader parameter
  8143. * @param neutralUniform The neutral uniform shader parameter
  8144. * @param negativeUniform The negative uniform shader parameter
  8145. */
  8146. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8147. /**
  8148. * Prepare the list of uniforms associated with the ColorCurves effects.
  8149. * @param uniformsList The list of uniforms used in the effect
  8150. */
  8151. static PrepareUniforms(uniformsList: string[]): void;
  8152. /**
  8153. * Returns color grading data based on a hue, density, saturation and exposure value.
  8154. * @param filterHue The hue of the color filter.
  8155. * @param filterDensity The density of the color filter.
  8156. * @param saturation The saturation.
  8157. * @param exposure The exposure.
  8158. * @param result The result data container.
  8159. */
  8160. private getColorGradingDataToRef;
  8161. /**
  8162. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8163. * @param value The input slider value in range [-100,100].
  8164. * @returns Adjusted value.
  8165. */
  8166. private static applyColorGradingSliderNonlinear;
  8167. /**
  8168. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8169. * @param hue The hue (H) input.
  8170. * @param saturation The saturation (S) input.
  8171. * @param brightness The brightness (B) input.
  8172. * @result An RGBA color represented as Vector4.
  8173. */
  8174. private static fromHSBToRef;
  8175. /**
  8176. * Returns a value clamped between min and max
  8177. * @param value The value to clamp
  8178. * @param min The minimum of value
  8179. * @param max The maximum of value
  8180. * @returns The clamped value.
  8181. */
  8182. private static clamp;
  8183. /**
  8184. * Clones the current color curve instance.
  8185. * @return The cloned curves
  8186. */
  8187. clone(): ColorCurves;
  8188. /**
  8189. * Serializes the current color curve instance to a json representation.
  8190. * @return a JSON representation
  8191. */
  8192. serialize(): any;
  8193. /**
  8194. * Parses the color curve from a json representation.
  8195. * @param source the JSON source to parse
  8196. * @return The parsed curves
  8197. */
  8198. static Parse(source: any): ColorCurves;
  8199. }
  8200. }
  8201. declare module BABYLON {
  8202. /**
  8203. * Interface to follow in your material defines to integrate easily the
  8204. * Image proccessing functions.
  8205. * @hidden
  8206. */
  8207. export interface IImageProcessingConfigurationDefines {
  8208. IMAGEPROCESSING: boolean;
  8209. VIGNETTE: boolean;
  8210. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8211. VIGNETTEBLENDMODEOPAQUE: boolean;
  8212. TONEMAPPING: boolean;
  8213. TONEMAPPING_ACES: boolean;
  8214. CONTRAST: boolean;
  8215. EXPOSURE: boolean;
  8216. COLORCURVES: boolean;
  8217. COLORGRADING: boolean;
  8218. COLORGRADING3D: boolean;
  8219. SAMPLER3DGREENDEPTH: boolean;
  8220. SAMPLER3DBGRMAP: boolean;
  8221. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8222. }
  8223. /**
  8224. * @hidden
  8225. */
  8226. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8227. IMAGEPROCESSING: boolean;
  8228. VIGNETTE: boolean;
  8229. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8230. VIGNETTEBLENDMODEOPAQUE: boolean;
  8231. TONEMAPPING: boolean;
  8232. TONEMAPPING_ACES: boolean;
  8233. CONTRAST: boolean;
  8234. COLORCURVES: boolean;
  8235. COLORGRADING: boolean;
  8236. COLORGRADING3D: boolean;
  8237. SAMPLER3DGREENDEPTH: boolean;
  8238. SAMPLER3DBGRMAP: boolean;
  8239. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8240. EXPOSURE: boolean;
  8241. constructor();
  8242. }
  8243. /**
  8244. * This groups together the common properties used for image processing either in direct forward pass
  8245. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8246. * or not.
  8247. */
  8248. export class ImageProcessingConfiguration {
  8249. /**
  8250. * Default tone mapping applied in BabylonJS.
  8251. */
  8252. static readonly TONEMAPPING_STANDARD: number;
  8253. /**
  8254. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8255. * to other engines rendering to increase portability.
  8256. */
  8257. static readonly TONEMAPPING_ACES: number;
  8258. /**
  8259. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8260. */
  8261. colorCurves: Nullable<ColorCurves>;
  8262. private _colorCurvesEnabled;
  8263. /**
  8264. * Gets wether the color curves effect is enabled.
  8265. */
  8266. get colorCurvesEnabled(): boolean;
  8267. /**
  8268. * Sets wether the color curves effect is enabled.
  8269. */
  8270. set colorCurvesEnabled(value: boolean);
  8271. private _colorGradingTexture;
  8272. /**
  8273. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8274. */
  8275. get colorGradingTexture(): Nullable<BaseTexture>;
  8276. /**
  8277. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8278. */
  8279. set colorGradingTexture(value: Nullable<BaseTexture>);
  8280. private _colorGradingEnabled;
  8281. /**
  8282. * Gets wether the color grading effect is enabled.
  8283. */
  8284. get colorGradingEnabled(): boolean;
  8285. /**
  8286. * Sets wether the color grading effect is enabled.
  8287. */
  8288. set colorGradingEnabled(value: boolean);
  8289. private _colorGradingWithGreenDepth;
  8290. /**
  8291. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8292. */
  8293. get colorGradingWithGreenDepth(): boolean;
  8294. /**
  8295. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8296. */
  8297. set colorGradingWithGreenDepth(value: boolean);
  8298. private _colorGradingBGR;
  8299. /**
  8300. * Gets wether the color grading texture contains BGR values.
  8301. */
  8302. get colorGradingBGR(): boolean;
  8303. /**
  8304. * Sets wether the color grading texture contains BGR values.
  8305. */
  8306. set colorGradingBGR(value: boolean);
  8307. /** @hidden */
  8308. _exposure: number;
  8309. /**
  8310. * Gets the Exposure used in the effect.
  8311. */
  8312. get exposure(): number;
  8313. /**
  8314. * Sets the Exposure used in the effect.
  8315. */
  8316. set exposure(value: number);
  8317. private _toneMappingEnabled;
  8318. /**
  8319. * Gets wether the tone mapping effect is enabled.
  8320. */
  8321. get toneMappingEnabled(): boolean;
  8322. /**
  8323. * Sets wether the tone mapping effect is enabled.
  8324. */
  8325. set toneMappingEnabled(value: boolean);
  8326. private _toneMappingType;
  8327. /**
  8328. * Gets the type of tone mapping effect.
  8329. */
  8330. get toneMappingType(): number;
  8331. /**
  8332. * Sets the type of tone mapping effect used in BabylonJS.
  8333. */
  8334. set toneMappingType(value: number);
  8335. protected _contrast: number;
  8336. /**
  8337. * Gets the contrast used in the effect.
  8338. */
  8339. get contrast(): number;
  8340. /**
  8341. * Sets the contrast used in the effect.
  8342. */
  8343. set contrast(value: number);
  8344. /**
  8345. * Vignette stretch size.
  8346. */
  8347. vignetteStretch: number;
  8348. /**
  8349. * Vignette centre X Offset.
  8350. */
  8351. vignetteCentreX: number;
  8352. /**
  8353. * Vignette centre Y Offset.
  8354. */
  8355. vignetteCentreY: number;
  8356. /**
  8357. * Vignette weight or intensity of the vignette effect.
  8358. */
  8359. vignetteWeight: number;
  8360. /**
  8361. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8362. * if vignetteEnabled is set to true.
  8363. */
  8364. vignetteColor: Color4;
  8365. /**
  8366. * Camera field of view used by the Vignette effect.
  8367. */
  8368. vignetteCameraFov: number;
  8369. private _vignetteBlendMode;
  8370. /**
  8371. * Gets the vignette blend mode allowing different kind of effect.
  8372. */
  8373. get vignetteBlendMode(): number;
  8374. /**
  8375. * Sets the vignette blend mode allowing different kind of effect.
  8376. */
  8377. set vignetteBlendMode(value: number);
  8378. private _vignetteEnabled;
  8379. /**
  8380. * Gets wether the vignette effect is enabled.
  8381. */
  8382. get vignetteEnabled(): boolean;
  8383. /**
  8384. * Sets wether the vignette effect is enabled.
  8385. */
  8386. set vignetteEnabled(value: boolean);
  8387. private _applyByPostProcess;
  8388. /**
  8389. * Gets wether the image processing is applied through a post process or not.
  8390. */
  8391. get applyByPostProcess(): boolean;
  8392. /**
  8393. * Sets wether the image processing is applied through a post process or not.
  8394. */
  8395. set applyByPostProcess(value: boolean);
  8396. private _isEnabled;
  8397. /**
  8398. * Gets wether the image processing is enabled or not.
  8399. */
  8400. get isEnabled(): boolean;
  8401. /**
  8402. * Sets wether the image processing is enabled or not.
  8403. */
  8404. set isEnabled(value: boolean);
  8405. /**
  8406. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8407. */
  8408. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8409. /**
  8410. * Method called each time the image processing information changes requires to recompile the effect.
  8411. */
  8412. protected _updateParameters(): void;
  8413. /**
  8414. * Gets the current class name.
  8415. * @return "ImageProcessingConfiguration"
  8416. */
  8417. getClassName(): string;
  8418. /**
  8419. * Prepare the list of uniforms associated with the Image Processing effects.
  8420. * @param uniforms The list of uniforms used in the effect
  8421. * @param defines the list of defines currently in use
  8422. */
  8423. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8424. /**
  8425. * Prepare the list of samplers associated with the Image Processing effects.
  8426. * @param samplersList The list of uniforms used in the effect
  8427. * @param defines the list of defines currently in use
  8428. */
  8429. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8430. /**
  8431. * Prepare the list of defines associated to the shader.
  8432. * @param defines the list of defines to complete
  8433. * @param forPostProcess Define if we are currently in post process mode or not
  8434. */
  8435. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8436. /**
  8437. * Returns true if all the image processing information are ready.
  8438. * @returns True if ready, otherwise, false
  8439. */
  8440. isReady(): boolean;
  8441. /**
  8442. * Binds the image processing to the shader.
  8443. * @param effect The effect to bind to
  8444. * @param overrideAspectRatio Override the aspect ratio of the effect
  8445. */
  8446. bind(effect: Effect, overrideAspectRatio?: number): void;
  8447. /**
  8448. * Clones the current image processing instance.
  8449. * @return The cloned image processing
  8450. */
  8451. clone(): ImageProcessingConfiguration;
  8452. /**
  8453. * Serializes the current image processing instance to a json representation.
  8454. * @return a JSON representation
  8455. */
  8456. serialize(): any;
  8457. /**
  8458. * Parses the image processing from a json representation.
  8459. * @param source the JSON source to parse
  8460. * @return The parsed image processing
  8461. */
  8462. static Parse(source: any): ImageProcessingConfiguration;
  8463. private static _VIGNETTEMODE_MULTIPLY;
  8464. private static _VIGNETTEMODE_OPAQUE;
  8465. /**
  8466. * Used to apply the vignette as a mix with the pixel color.
  8467. */
  8468. static get VIGNETTEMODE_MULTIPLY(): number;
  8469. /**
  8470. * Used to apply the vignette as a replacement of the pixel color.
  8471. */
  8472. static get VIGNETTEMODE_OPAQUE(): number;
  8473. }
  8474. }
  8475. declare module BABYLON {
  8476. /** @hidden */
  8477. export var postprocessVertexShader: {
  8478. name: string;
  8479. shader: string;
  8480. };
  8481. }
  8482. declare module BABYLON {
  8483. interface ThinEngine {
  8484. /**
  8485. * Creates a new render target texture
  8486. * @param size defines the size of the texture
  8487. * @param options defines the options used to create the texture
  8488. * @returns a new render target texture stored in an InternalTexture
  8489. */
  8490. createRenderTargetTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. layers?: number;
  8494. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8495. /**
  8496. * Creates a depth stencil texture.
  8497. * This is only available in WebGL 2 or with the depth texture extension available.
  8498. * @param size The size of face edge in the texture.
  8499. * @param options The options defining the texture.
  8500. * @returns The texture
  8501. */
  8502. createDepthStencilTexture(size: number | {
  8503. width: number;
  8504. height: number;
  8505. layers?: number;
  8506. }, options: DepthTextureCreationOptions): InternalTexture;
  8507. /** @hidden */
  8508. _createDepthStencilTexture(size: number | {
  8509. width: number;
  8510. height: number;
  8511. layers?: number;
  8512. }, options: DepthTextureCreationOptions): InternalTexture;
  8513. }
  8514. }
  8515. declare module BABYLON {
  8516. /** Defines supported spaces */
  8517. export enum Space {
  8518. /** Local (object) space */
  8519. LOCAL = 0,
  8520. /** World space */
  8521. WORLD = 1,
  8522. /** Bone space */
  8523. BONE = 2
  8524. }
  8525. /** Defines the 3 main axes */
  8526. export class Axis {
  8527. /** X axis */
  8528. static X: Vector3;
  8529. /** Y axis */
  8530. static Y: Vector3;
  8531. /** Z axis */
  8532. static Z: Vector3;
  8533. }
  8534. }
  8535. declare module BABYLON {
  8536. /**
  8537. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8538. * This is the base of the follow, arc rotate cameras and Free camera
  8539. * @see http://doc.babylonjs.com/features/cameras
  8540. */
  8541. export class TargetCamera extends Camera {
  8542. private static _RigCamTransformMatrix;
  8543. private static _TargetTransformMatrix;
  8544. private static _TargetFocalPoint;
  8545. /**
  8546. * Define the current direction the camera is moving to
  8547. */
  8548. cameraDirection: Vector3;
  8549. /**
  8550. * Define the current rotation the camera is rotating to
  8551. */
  8552. cameraRotation: Vector2;
  8553. /**
  8554. * When set, the up vector of the camera will be updated by the rotation of the camera
  8555. */
  8556. updateUpVectorFromRotation: boolean;
  8557. private _tmpQuaternion;
  8558. /**
  8559. * Define the current rotation of the camera
  8560. */
  8561. rotation: Vector3;
  8562. /**
  8563. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8564. */
  8565. rotationQuaternion: Quaternion;
  8566. /**
  8567. * Define the current speed of the camera
  8568. */
  8569. speed: number;
  8570. /**
  8571. * Add constraint to the camera to prevent it to move freely in all directions and
  8572. * around all axis.
  8573. */
  8574. noRotationConstraint: boolean;
  8575. /**
  8576. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8577. * panning
  8578. */
  8579. invertRotation: boolean;
  8580. /**
  8581. * Speed multiplier for inverse camera panning
  8582. */
  8583. inverseRotationSpeed: number;
  8584. /**
  8585. * Define the current target of the camera as an object or a position.
  8586. */
  8587. lockedTarget: any;
  8588. /** @hidden */
  8589. _currentTarget: Vector3;
  8590. /** @hidden */
  8591. _initialFocalDistance: number;
  8592. /** @hidden */
  8593. _viewMatrix: Matrix;
  8594. /** @hidden */
  8595. _camMatrix: Matrix;
  8596. /** @hidden */
  8597. _cameraTransformMatrix: Matrix;
  8598. /** @hidden */
  8599. _cameraRotationMatrix: Matrix;
  8600. /** @hidden */
  8601. _referencePoint: Vector3;
  8602. /** @hidden */
  8603. _transformedReferencePoint: Vector3;
  8604. protected _globalCurrentTarget: Vector3;
  8605. protected _globalCurrentUpVector: Vector3;
  8606. /** @hidden */
  8607. _reset: () => void;
  8608. private _defaultUp;
  8609. /**
  8610. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8611. * This is the base of the follow, arc rotate cameras and Free camera
  8612. * @see http://doc.babylonjs.com/features/cameras
  8613. * @param name Defines the name of the camera in the scene
  8614. * @param position Defines the start position of the camera in the scene
  8615. * @param scene Defines the scene the camera belongs to
  8616. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8617. */
  8618. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8619. /**
  8620. * Gets the position in front of the camera at a given distance.
  8621. * @param distance The distance from the camera we want the position to be
  8622. * @returns the position
  8623. */
  8624. getFrontPosition(distance: number): Vector3;
  8625. /** @hidden */
  8626. _getLockedTargetPosition(): Nullable<Vector3>;
  8627. private _storedPosition;
  8628. private _storedRotation;
  8629. private _storedRotationQuaternion;
  8630. /**
  8631. * Store current camera state of the camera (fov, position, rotation, etc..)
  8632. * @returns the camera
  8633. */
  8634. storeState(): Camera;
  8635. /**
  8636. * Restored camera state. You must call storeState() first
  8637. * @returns whether it was successful or not
  8638. * @hidden
  8639. */
  8640. _restoreStateValues(): boolean;
  8641. /** @hidden */
  8642. _initCache(): void;
  8643. /** @hidden */
  8644. _updateCache(ignoreParentClass?: boolean): void;
  8645. /** @hidden */
  8646. _isSynchronizedViewMatrix(): boolean;
  8647. /** @hidden */
  8648. _computeLocalCameraSpeed(): number;
  8649. /**
  8650. * Defines the target the camera should look at.
  8651. * @param target Defines the new target as a Vector or a mesh
  8652. */
  8653. setTarget(target: Vector3): void;
  8654. /**
  8655. * Return the current target position of the camera. This value is expressed in local space.
  8656. * @returns the target position
  8657. */
  8658. getTarget(): Vector3;
  8659. /** @hidden */
  8660. _decideIfNeedsToMove(): boolean;
  8661. /** @hidden */
  8662. _updatePosition(): void;
  8663. /** @hidden */
  8664. _checkInputs(): void;
  8665. protected _updateCameraRotationMatrix(): void;
  8666. /**
  8667. * 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)
  8668. * @returns the current camera
  8669. */
  8670. private _rotateUpVectorWithCameraRotationMatrix;
  8671. private _cachedRotationZ;
  8672. private _cachedQuaternionRotationZ;
  8673. /** @hidden */
  8674. _getViewMatrix(): Matrix;
  8675. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8676. /**
  8677. * @hidden
  8678. */
  8679. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8680. /**
  8681. * @hidden
  8682. */
  8683. _updateRigCameras(): void;
  8684. private _getRigCamPositionAndTarget;
  8685. /**
  8686. * Gets the current object class name.
  8687. * @return the class name
  8688. */
  8689. getClassName(): string;
  8690. }
  8691. }
  8692. declare module BABYLON {
  8693. /**
  8694. * Gather the list of keyboard event types as constants.
  8695. */
  8696. export class KeyboardEventTypes {
  8697. /**
  8698. * The keydown event is fired when a key becomes active (pressed).
  8699. */
  8700. static readonly KEYDOWN: number;
  8701. /**
  8702. * The keyup event is fired when a key has been released.
  8703. */
  8704. static readonly KEYUP: number;
  8705. }
  8706. /**
  8707. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8708. */
  8709. export class KeyboardInfo {
  8710. /**
  8711. * Defines the type of event (KeyboardEventTypes)
  8712. */
  8713. type: number;
  8714. /**
  8715. * Defines the related dom event
  8716. */
  8717. event: KeyboardEvent;
  8718. /**
  8719. * Instantiates a new keyboard info.
  8720. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8721. * @param type Defines the type of event (KeyboardEventTypes)
  8722. * @param event Defines the related dom event
  8723. */
  8724. constructor(
  8725. /**
  8726. * Defines the type of event (KeyboardEventTypes)
  8727. */
  8728. type: number,
  8729. /**
  8730. * Defines the related dom event
  8731. */
  8732. event: KeyboardEvent);
  8733. }
  8734. /**
  8735. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8736. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8737. */
  8738. export class KeyboardInfoPre extends KeyboardInfo {
  8739. /**
  8740. * Defines the type of event (KeyboardEventTypes)
  8741. */
  8742. type: number;
  8743. /**
  8744. * Defines the related dom event
  8745. */
  8746. event: KeyboardEvent;
  8747. /**
  8748. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8749. */
  8750. skipOnPointerObservable: boolean;
  8751. /**
  8752. * Instantiates a new keyboard pre info.
  8753. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8754. * @param type Defines the type of event (KeyboardEventTypes)
  8755. * @param event Defines the related dom event
  8756. */
  8757. constructor(
  8758. /**
  8759. * Defines the type of event (KeyboardEventTypes)
  8760. */
  8761. type: number,
  8762. /**
  8763. * Defines the related dom event
  8764. */
  8765. event: KeyboardEvent);
  8766. }
  8767. }
  8768. declare module BABYLON {
  8769. /**
  8770. * Manage the keyboard inputs to control the movement of a free camera.
  8771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8772. */
  8773. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8774. /**
  8775. * Defines the camera the input is attached to.
  8776. */
  8777. camera: FreeCamera;
  8778. /**
  8779. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8780. */
  8781. keysUp: number[];
  8782. /**
  8783. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8784. */
  8785. keysUpward: number[];
  8786. /**
  8787. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8788. */
  8789. keysDown: number[];
  8790. /**
  8791. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8792. */
  8793. keysDownward: number[];
  8794. /**
  8795. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8796. */
  8797. keysLeft: number[];
  8798. /**
  8799. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8800. */
  8801. keysRight: number[];
  8802. private _keys;
  8803. private _onCanvasBlurObserver;
  8804. private _onKeyboardObserver;
  8805. private _engine;
  8806. private _scene;
  8807. /**
  8808. * Attach the input controls to a specific dom element to get the input from.
  8809. * @param element Defines the element the controls should be listened from
  8810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8811. */
  8812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8813. /**
  8814. * Detach the current controls from the specified dom element.
  8815. * @param element Defines the element to stop listening the inputs from
  8816. */
  8817. detachControl(element: Nullable<HTMLElement>): void;
  8818. /**
  8819. * Update the current camera state depending on the inputs that have been used this frame.
  8820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8821. */
  8822. checkInputs(): void;
  8823. /**
  8824. * Gets the class name of the current intput.
  8825. * @returns the class name
  8826. */
  8827. getClassName(): string;
  8828. /** @hidden */
  8829. _onLostFocus(): void;
  8830. /**
  8831. * Get the friendly name associated with the input class.
  8832. * @returns the input friendly name
  8833. */
  8834. getSimpleName(): string;
  8835. }
  8836. }
  8837. declare module BABYLON {
  8838. /**
  8839. * Interface describing all the common properties and methods a shadow light needs to implement.
  8840. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8841. * as well as binding the different shadow properties to the effects.
  8842. */
  8843. export interface IShadowLight extends Light {
  8844. /**
  8845. * The light id in the scene (used in scene.findLighById for instance)
  8846. */
  8847. id: string;
  8848. /**
  8849. * The position the shdow will be casted from.
  8850. */
  8851. position: Vector3;
  8852. /**
  8853. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8854. */
  8855. direction: Vector3;
  8856. /**
  8857. * The transformed position. Position of the light in world space taking parenting in account.
  8858. */
  8859. transformedPosition: Vector3;
  8860. /**
  8861. * The transformed direction. Direction of the light in world space taking parenting in account.
  8862. */
  8863. transformedDirection: Vector3;
  8864. /**
  8865. * The friendly name of the light in the scene.
  8866. */
  8867. name: string;
  8868. /**
  8869. * Defines the shadow projection clipping minimum z value.
  8870. */
  8871. shadowMinZ: number;
  8872. /**
  8873. * Defines the shadow projection clipping maximum z value.
  8874. */
  8875. shadowMaxZ: number;
  8876. /**
  8877. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8878. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8879. */
  8880. computeTransformedInformation(): boolean;
  8881. /**
  8882. * Gets the scene the light belongs to.
  8883. * @returns The scene
  8884. */
  8885. getScene(): Scene;
  8886. /**
  8887. * Callback defining a custom Projection Matrix Builder.
  8888. * This can be used to override the default projection matrix computation.
  8889. */
  8890. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8891. /**
  8892. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8893. * @param matrix The materix to updated with the projection information
  8894. * @param viewMatrix The transform matrix of the light
  8895. * @param renderList The list of mesh to render in the map
  8896. * @returns The current light
  8897. */
  8898. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8899. /**
  8900. * Gets the current depth scale used in ESM.
  8901. * @returns The scale
  8902. */
  8903. getDepthScale(): number;
  8904. /**
  8905. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8906. * @returns true if a cube texture needs to be use
  8907. */
  8908. needCube(): boolean;
  8909. /**
  8910. * Detects if the projection matrix requires to be recomputed this frame.
  8911. * @returns true if it requires to be recomputed otherwise, false.
  8912. */
  8913. needProjectionMatrixCompute(): boolean;
  8914. /**
  8915. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8916. */
  8917. forceProjectionMatrixCompute(): void;
  8918. /**
  8919. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8920. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8921. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8922. */
  8923. getShadowDirection(faceIndex?: number): Vector3;
  8924. /**
  8925. * Gets the minZ used for shadow according to both the scene and the light.
  8926. * @param activeCamera The camera we are returning the min for
  8927. * @returns the depth min z
  8928. */
  8929. getDepthMinZ(activeCamera: Camera): number;
  8930. /**
  8931. * Gets the maxZ used for shadow according to both the scene and the light.
  8932. * @param activeCamera The camera we are returning the max for
  8933. * @returns the depth max z
  8934. */
  8935. getDepthMaxZ(activeCamera: Camera): number;
  8936. }
  8937. /**
  8938. * Base implementation IShadowLight
  8939. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8940. */
  8941. export abstract class ShadowLight extends Light implements IShadowLight {
  8942. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8943. protected _position: Vector3;
  8944. protected _setPosition(value: Vector3): void;
  8945. /**
  8946. * Sets the position the shadow will be casted from. Also use as the light position for both
  8947. * point and spot lights.
  8948. */
  8949. get position(): Vector3;
  8950. /**
  8951. * Sets the position the shadow will be casted from. Also use as the light position for both
  8952. * point and spot lights.
  8953. */
  8954. set position(value: Vector3);
  8955. protected _direction: Vector3;
  8956. protected _setDirection(value: Vector3): void;
  8957. /**
  8958. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8959. * Also use as the light direction on spot and directional lights.
  8960. */
  8961. get direction(): Vector3;
  8962. /**
  8963. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8964. * Also use as the light direction on spot and directional lights.
  8965. */
  8966. set direction(value: Vector3);
  8967. protected _shadowMinZ: number;
  8968. /**
  8969. * Gets the shadow projection clipping minimum z value.
  8970. */
  8971. get shadowMinZ(): number;
  8972. /**
  8973. * Sets the shadow projection clipping minimum z value.
  8974. */
  8975. set shadowMinZ(value: number);
  8976. protected _shadowMaxZ: number;
  8977. /**
  8978. * Sets the shadow projection clipping maximum z value.
  8979. */
  8980. get shadowMaxZ(): number;
  8981. /**
  8982. * Gets the shadow projection clipping maximum z value.
  8983. */
  8984. set shadowMaxZ(value: number);
  8985. /**
  8986. * Callback defining a custom Projection Matrix Builder.
  8987. * This can be used to override the default projection matrix computation.
  8988. */
  8989. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8990. /**
  8991. * The transformed position. Position of the light in world space taking parenting in account.
  8992. */
  8993. transformedPosition: Vector3;
  8994. /**
  8995. * The transformed direction. Direction of the light in world space taking parenting in account.
  8996. */
  8997. transformedDirection: Vector3;
  8998. private _needProjectionMatrixCompute;
  8999. /**
  9000. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9001. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9002. */
  9003. computeTransformedInformation(): boolean;
  9004. /**
  9005. * Return the depth scale used for the shadow map.
  9006. * @returns the depth scale.
  9007. */
  9008. getDepthScale(): number;
  9009. /**
  9010. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9011. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9012. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9013. */
  9014. getShadowDirection(faceIndex?: number): Vector3;
  9015. /**
  9016. * Returns the ShadowLight absolute position in the World.
  9017. * @returns the position vector in world space
  9018. */
  9019. getAbsolutePosition(): Vector3;
  9020. /**
  9021. * Sets the ShadowLight direction toward the passed target.
  9022. * @param target The point to target in local space
  9023. * @returns the updated ShadowLight direction
  9024. */
  9025. setDirectionToTarget(target: Vector3): Vector3;
  9026. /**
  9027. * Returns the light rotation in euler definition.
  9028. * @returns the x y z rotation in local space.
  9029. */
  9030. getRotation(): Vector3;
  9031. /**
  9032. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9033. * @returns true if a cube texture needs to be use
  9034. */
  9035. needCube(): boolean;
  9036. /**
  9037. * Detects if the projection matrix requires to be recomputed this frame.
  9038. * @returns true if it requires to be recomputed otherwise, false.
  9039. */
  9040. needProjectionMatrixCompute(): boolean;
  9041. /**
  9042. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9043. */
  9044. forceProjectionMatrixCompute(): void;
  9045. /** @hidden */
  9046. _initCache(): void;
  9047. /** @hidden */
  9048. _isSynchronized(): boolean;
  9049. /**
  9050. * Computes the world matrix of the node
  9051. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9052. * @returns the world matrix
  9053. */
  9054. computeWorldMatrix(force?: boolean): Matrix;
  9055. /**
  9056. * Gets the minZ used for shadow according to both the scene and the light.
  9057. * @param activeCamera The camera we are returning the min for
  9058. * @returns the depth min z
  9059. */
  9060. getDepthMinZ(activeCamera: Camera): number;
  9061. /**
  9062. * Gets the maxZ used for shadow according to both the scene and the light.
  9063. * @param activeCamera The camera we are returning the max for
  9064. * @returns the depth max z
  9065. */
  9066. getDepthMaxZ(activeCamera: Camera): number;
  9067. /**
  9068. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9069. * @param matrix The materix to updated with the projection information
  9070. * @param viewMatrix The transform matrix of the light
  9071. * @param renderList The list of mesh to render in the map
  9072. * @returns The current light
  9073. */
  9074. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9075. }
  9076. }
  9077. declare module BABYLON {
  9078. /**
  9079. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9080. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9081. */
  9082. export class EffectFallbacks implements IEffectFallbacks {
  9083. private _defines;
  9084. private _currentRank;
  9085. private _maxRank;
  9086. private _mesh;
  9087. /**
  9088. * Removes the fallback from the bound mesh.
  9089. */
  9090. unBindMesh(): void;
  9091. /**
  9092. * Adds a fallback on the specified property.
  9093. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9094. * @param define The name of the define in the shader
  9095. */
  9096. addFallback(rank: number, define: string): void;
  9097. /**
  9098. * Sets the mesh to use CPU skinning when needing to fallback.
  9099. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9100. * @param mesh The mesh to use the fallbacks.
  9101. */
  9102. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9103. /**
  9104. * Checks to see if more fallbacks are still availible.
  9105. */
  9106. get hasMoreFallbacks(): boolean;
  9107. /**
  9108. * Removes the defines that should be removed when falling back.
  9109. * @param currentDefines defines the current define statements for the shader.
  9110. * @param effect defines the current effect we try to compile
  9111. * @returns The resulting defines with defines of the current rank removed.
  9112. */
  9113. reduce(currentDefines: string, effect: Effect): string;
  9114. }
  9115. }
  9116. declare module BABYLON {
  9117. /**
  9118. * "Static Class" containing the most commonly used helper while dealing with material for
  9119. * rendering purpose.
  9120. *
  9121. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9122. *
  9123. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9124. */
  9125. export class MaterialHelper {
  9126. /**
  9127. * Bind the current view position to an effect.
  9128. * @param effect The effect to be bound
  9129. * @param scene The scene the eyes position is used from
  9130. */
  9131. static BindEyePosition(effect: Effect, scene: Scene): void;
  9132. /**
  9133. * Helps preparing the defines values about the UVs in used in the effect.
  9134. * UVs are shared as much as we can accross channels in the shaders.
  9135. * @param texture The texture we are preparing the UVs for
  9136. * @param defines The defines to update
  9137. * @param key The channel key "diffuse", "specular"... used in the shader
  9138. */
  9139. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9140. /**
  9141. * Binds a texture matrix value to its corrsponding uniform
  9142. * @param texture The texture to bind the matrix for
  9143. * @param uniformBuffer The uniform buffer receivin the data
  9144. * @param key The channel key "diffuse", "specular"... used in the shader
  9145. */
  9146. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9147. /**
  9148. * Gets the current status of the fog (should it be enabled?)
  9149. * @param mesh defines the mesh to evaluate for fog support
  9150. * @param scene defines the hosting scene
  9151. * @returns true if fog must be enabled
  9152. */
  9153. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9154. /**
  9155. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9156. * @param mesh defines the current mesh
  9157. * @param scene defines the current scene
  9158. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9159. * @param pointsCloud defines if point cloud rendering has to be turned on
  9160. * @param fogEnabled defines if fog has to be turned on
  9161. * @param alphaTest defines if alpha testing has to be turned on
  9162. * @param defines defines the current list of defines
  9163. */
  9164. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9165. /**
  9166. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9167. * @param scene defines the current scene
  9168. * @param engine defines the current engine
  9169. * @param defines specifies the list of active defines
  9170. * @param useInstances defines if instances have to be turned on
  9171. * @param useClipPlane defines if clip plane have to be turned on
  9172. */
  9173. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9174. /**
  9175. * Prepares the defines for bones
  9176. * @param mesh The mesh containing the geometry data we will draw
  9177. * @param defines The defines to update
  9178. */
  9179. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9180. /**
  9181. * Prepares the defines for morph targets
  9182. * @param mesh The mesh containing the geometry data we will draw
  9183. * @param defines The defines to update
  9184. */
  9185. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9186. /**
  9187. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9188. * @param mesh The mesh containing the geometry data we will draw
  9189. * @param defines The defines to update
  9190. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9191. * @param useBones Precise whether bones should be used or not (override mesh info)
  9192. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9193. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9194. * @returns false if defines are considered not dirty and have not been checked
  9195. */
  9196. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9197. /**
  9198. * Prepares the defines related to multiview
  9199. * @param scene The scene we are intending to draw
  9200. * @param defines The defines to update
  9201. */
  9202. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9203. /**
  9204. * Prepares the defines related to the light information passed in parameter
  9205. * @param scene The scene we are intending to draw
  9206. * @param mesh The mesh the effect is compiling for
  9207. * @param light The light the effect is compiling for
  9208. * @param lightIndex The index of the light
  9209. * @param defines The defines to update
  9210. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9211. * @param state Defines the current state regarding what is needed (normals, etc...)
  9212. */
  9213. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9214. needNormals: boolean;
  9215. needRebuild: boolean;
  9216. shadowEnabled: boolean;
  9217. specularEnabled: boolean;
  9218. lightmapMode: boolean;
  9219. }): void;
  9220. /**
  9221. * Prepares the defines related to the light information passed in parameter
  9222. * @param scene The scene we are intending to draw
  9223. * @param mesh The mesh the effect is compiling for
  9224. * @param defines The defines to update
  9225. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9226. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9227. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9228. * @returns true if normals will be required for the rest of the effect
  9229. */
  9230. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9231. /**
  9232. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9233. * @param lightIndex defines the light index
  9234. * @param uniformsList The uniform list
  9235. * @param samplersList The sampler list
  9236. * @param projectedLightTexture defines if projected texture must be used
  9237. * @param uniformBuffersList defines an optional list of uniform buffers
  9238. */
  9239. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9240. /**
  9241. * Prepares the uniforms and samplers list to be used in the effect
  9242. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9243. * @param samplersList The sampler list
  9244. * @param defines The defines helping in the list generation
  9245. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9246. */
  9247. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9248. /**
  9249. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9250. * @param defines The defines to update while falling back
  9251. * @param fallbacks The authorized effect fallbacks
  9252. * @param maxSimultaneousLights The maximum number of lights allowed
  9253. * @param rank the current rank of the Effect
  9254. * @returns The newly affected rank
  9255. */
  9256. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9257. private static _TmpMorphInfluencers;
  9258. /**
  9259. * Prepares the list of attributes required for morph targets according to the effect defines.
  9260. * @param attribs The current list of supported attribs
  9261. * @param mesh The mesh to prepare the morph targets attributes for
  9262. * @param influencers The number of influencers
  9263. */
  9264. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9265. /**
  9266. * Prepares the list of attributes required for morph targets according to the effect defines.
  9267. * @param attribs The current list of supported attribs
  9268. * @param mesh The mesh to prepare the morph targets attributes for
  9269. * @param defines The current Defines of the effect
  9270. */
  9271. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9272. /**
  9273. * Prepares the list of attributes required for bones according to the effect defines.
  9274. * @param attribs The current list of supported attribs
  9275. * @param mesh The mesh to prepare the bones attributes for
  9276. * @param defines The current Defines of the effect
  9277. * @param fallbacks The current efffect fallback strategy
  9278. */
  9279. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9280. /**
  9281. * Check and prepare the list of attributes required for instances according to the effect defines.
  9282. * @param attribs The current list of supported attribs
  9283. * @param defines The current MaterialDefines of the effect
  9284. */
  9285. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9286. /**
  9287. * Add the list of attributes required for instances to the attribs array.
  9288. * @param attribs The current list of supported attribs
  9289. */
  9290. static PushAttributesForInstances(attribs: string[]): void;
  9291. /**
  9292. * Binds the light information to the effect.
  9293. * @param light The light containing the generator
  9294. * @param effect The effect we are binding the data to
  9295. * @param lightIndex The light index in the effect used to render
  9296. */
  9297. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9298. /**
  9299. * Binds the lights information from the scene to the effect for the given mesh.
  9300. * @param light Light to bind
  9301. * @param lightIndex Light index
  9302. * @param scene The scene where the light belongs to
  9303. * @param effect The effect we are binding the data to
  9304. * @param useSpecular Defines if specular is supported
  9305. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9306. */
  9307. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9308. /**
  9309. * Binds the lights information from the scene to the effect for the given mesh.
  9310. * @param scene The scene the lights belongs to
  9311. * @param mesh The mesh we are binding the information to render
  9312. * @param effect The effect we are binding the data to
  9313. * @param defines The generated defines for the effect
  9314. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9315. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9316. */
  9317. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9318. private static _tempFogColor;
  9319. /**
  9320. * Binds the fog information from the scene to the effect for the given mesh.
  9321. * @param scene The scene the lights belongs to
  9322. * @param mesh The mesh we are binding the information to render
  9323. * @param effect The effect we are binding the data to
  9324. * @param linearSpace Defines if the fog effect is applied in linear space
  9325. */
  9326. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9327. /**
  9328. * Binds the bones information from the mesh to the effect.
  9329. * @param mesh The mesh we are binding the information to render
  9330. * @param effect The effect we are binding the data to
  9331. */
  9332. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9333. /**
  9334. * Binds the morph targets information from the mesh to the effect.
  9335. * @param abstractMesh The mesh we are binding the information to render
  9336. * @param effect The effect we are binding the data to
  9337. */
  9338. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9339. /**
  9340. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9341. * @param defines The generated defines used in the effect
  9342. * @param effect The effect we are binding the data to
  9343. * @param scene The scene we are willing to render with logarithmic scale for
  9344. */
  9345. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9346. /**
  9347. * Binds the clip plane information from the scene to the effect.
  9348. * @param scene The scene the clip plane information are extracted from
  9349. * @param effect The effect we are binding the data to
  9350. */
  9351. static BindClipPlane(effect: Effect, scene: Scene): void;
  9352. }
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var packingFunctions: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var shadowMapFragmentDeclaration: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var clipPlaneFragmentDeclaration: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var clipPlaneFragment: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /** @hidden */
  9384. export var shadowMapFragment: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module BABYLON {
  9390. /** @hidden */
  9391. export var shadowMapPixelShader: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module BABYLON {
  9397. /** @hidden */
  9398. export var bonesDeclaration: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module BABYLON {
  9404. /** @hidden */
  9405. export var morphTargetsVertexGlobalDeclaration: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module BABYLON {
  9411. /** @hidden */
  9412. export var morphTargetsVertexDeclaration: {
  9413. name: string;
  9414. shader: string;
  9415. };
  9416. }
  9417. declare module BABYLON {
  9418. /** @hidden */
  9419. export var instancesDeclaration: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module BABYLON {
  9425. /** @hidden */
  9426. export var helperFunctions: {
  9427. name: string;
  9428. shader: string;
  9429. };
  9430. }
  9431. declare module BABYLON {
  9432. /** @hidden */
  9433. export var shadowMapVertexDeclaration: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module BABYLON {
  9439. /** @hidden */
  9440. export var clipPlaneVertexDeclaration: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module BABYLON {
  9446. /** @hidden */
  9447. export var morphTargetsVertex: {
  9448. name: string;
  9449. shader: string;
  9450. };
  9451. }
  9452. declare module BABYLON {
  9453. /** @hidden */
  9454. export var instancesVertex: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module BABYLON {
  9460. /** @hidden */
  9461. export var bonesVertex: {
  9462. name: string;
  9463. shader: string;
  9464. };
  9465. }
  9466. declare module BABYLON {
  9467. /** @hidden */
  9468. export var shadowMapVertexNormalBias: {
  9469. name: string;
  9470. shader: string;
  9471. };
  9472. }
  9473. declare module BABYLON {
  9474. /** @hidden */
  9475. export var shadowMapVertexMetric: {
  9476. name: string;
  9477. shader: string;
  9478. };
  9479. }
  9480. declare module BABYLON {
  9481. /** @hidden */
  9482. export var clipPlaneVertex: {
  9483. name: string;
  9484. shader: string;
  9485. };
  9486. }
  9487. declare module BABYLON {
  9488. /** @hidden */
  9489. export var shadowMapVertexShader: {
  9490. name: string;
  9491. shader: string;
  9492. };
  9493. }
  9494. declare module BABYLON {
  9495. /** @hidden */
  9496. export var depthBoxBlurPixelShader: {
  9497. name: string;
  9498. shader: string;
  9499. };
  9500. }
  9501. declare module BABYLON {
  9502. /**
  9503. * Class representing a ray with position and direction
  9504. */
  9505. export class Ray {
  9506. /** origin point */
  9507. origin: Vector3;
  9508. /** direction */
  9509. direction: Vector3;
  9510. /** length of the ray */
  9511. length: number;
  9512. private static readonly TmpVector3;
  9513. private _tmpRay;
  9514. /**
  9515. * Creates a new ray
  9516. * @param origin origin point
  9517. * @param direction direction
  9518. * @param length length of the ray
  9519. */
  9520. constructor(
  9521. /** origin point */
  9522. origin: Vector3,
  9523. /** direction */
  9524. direction: Vector3,
  9525. /** length of the ray */
  9526. length?: number);
  9527. /**
  9528. * Checks if the ray intersects a box
  9529. * This does not account for the ray lenght by design to improve perfs.
  9530. * @param minimum bound of the box
  9531. * @param maximum bound of the box
  9532. * @param intersectionTreshold extra extend to be added to the box in all direction
  9533. * @returns if the box was hit
  9534. */
  9535. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9536. /**
  9537. * Checks if the ray intersects a box
  9538. * This does not account for the ray lenght by design to improve perfs.
  9539. * @param box the bounding box to check
  9540. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9541. * @returns if the box was hit
  9542. */
  9543. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9544. /**
  9545. * If the ray hits a sphere
  9546. * @param sphere the bounding sphere to check
  9547. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9548. * @returns true if it hits the sphere
  9549. */
  9550. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9551. /**
  9552. * If the ray hits a triange
  9553. * @param vertex0 triangle vertex
  9554. * @param vertex1 triangle vertex
  9555. * @param vertex2 triangle vertex
  9556. * @returns intersection information if hit
  9557. */
  9558. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9559. /**
  9560. * Checks if ray intersects a plane
  9561. * @param plane the plane to check
  9562. * @returns the distance away it was hit
  9563. */
  9564. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9565. /**
  9566. * Calculate the intercept of a ray on a given axis
  9567. * @param axis to check 'x' | 'y' | 'z'
  9568. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9569. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9570. */
  9571. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9572. /**
  9573. * Checks if ray intersects a mesh
  9574. * @param mesh the mesh to check
  9575. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9576. * @returns picking info of the intersecton
  9577. */
  9578. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9579. /**
  9580. * Checks if ray intersects a mesh
  9581. * @param meshes the meshes to check
  9582. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9583. * @param results array to store result in
  9584. * @returns Array of picking infos
  9585. */
  9586. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9587. private _comparePickingInfo;
  9588. private static smallnum;
  9589. private static rayl;
  9590. /**
  9591. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9592. * @param sega the first point of the segment to test the intersection against
  9593. * @param segb the second point of the segment to test the intersection against
  9594. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9595. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9596. */
  9597. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9598. /**
  9599. * Update the ray from viewport position
  9600. * @param x position
  9601. * @param y y position
  9602. * @param viewportWidth viewport width
  9603. * @param viewportHeight viewport height
  9604. * @param world world matrix
  9605. * @param view view matrix
  9606. * @param projection projection matrix
  9607. * @returns this ray updated
  9608. */
  9609. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9610. /**
  9611. * Creates a ray with origin and direction of 0,0,0
  9612. * @returns the new ray
  9613. */
  9614. static Zero(): Ray;
  9615. /**
  9616. * Creates a new ray from screen space and viewport
  9617. * @param x position
  9618. * @param y y position
  9619. * @param viewportWidth viewport width
  9620. * @param viewportHeight viewport height
  9621. * @param world world matrix
  9622. * @param view view matrix
  9623. * @param projection projection matrix
  9624. * @returns new ray
  9625. */
  9626. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9627. /**
  9628. * 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
  9629. * transformed to the given world matrix.
  9630. * @param origin The origin point
  9631. * @param end The end point
  9632. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9633. * @returns the new ray
  9634. */
  9635. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9636. /**
  9637. * Transforms a ray by a matrix
  9638. * @param ray ray to transform
  9639. * @param matrix matrix to apply
  9640. * @returns the resulting new ray
  9641. */
  9642. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9643. /**
  9644. * Transforms a ray by a matrix
  9645. * @param ray ray to transform
  9646. * @param matrix matrix to apply
  9647. * @param result ray to store result in
  9648. */
  9649. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9650. /**
  9651. * Unproject a ray from screen space to object space
  9652. * @param sourceX defines the screen space x coordinate to use
  9653. * @param sourceY defines the screen space y coordinate to use
  9654. * @param viewportWidth defines the current width of the viewport
  9655. * @param viewportHeight defines the current height of the viewport
  9656. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9657. * @param view defines the view matrix to use
  9658. * @param projection defines the projection matrix to use
  9659. */
  9660. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9661. }
  9662. /**
  9663. * Type used to define predicate used to select faces when a mesh intersection is detected
  9664. */
  9665. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9666. interface Scene {
  9667. /** @hidden */
  9668. _tempPickingRay: Nullable<Ray>;
  9669. /** @hidden */
  9670. _cachedRayForTransform: Ray;
  9671. /** @hidden */
  9672. _pickWithRayInverseMatrix: Matrix;
  9673. /** @hidden */
  9674. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9675. /** @hidden */
  9676. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9677. }
  9678. }
  9679. declare module BABYLON {
  9680. /**
  9681. * Groups all the scene component constants in one place to ease maintenance.
  9682. * @hidden
  9683. */
  9684. export class SceneComponentConstants {
  9685. static readonly NAME_EFFECTLAYER: string;
  9686. static readonly NAME_LAYER: string;
  9687. static readonly NAME_LENSFLARESYSTEM: string;
  9688. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9689. static readonly NAME_PARTICLESYSTEM: string;
  9690. static readonly NAME_GAMEPAD: string;
  9691. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9692. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9693. static readonly NAME_DEPTHRENDERER: string;
  9694. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9695. static readonly NAME_SPRITE: string;
  9696. static readonly NAME_OUTLINERENDERER: string;
  9697. static readonly NAME_PROCEDURALTEXTURE: string;
  9698. static readonly NAME_SHADOWGENERATOR: string;
  9699. static readonly NAME_OCTREE: string;
  9700. static readonly NAME_PHYSICSENGINE: string;
  9701. static readonly NAME_AUDIO: string;
  9702. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9703. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9704. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9705. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9706. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9707. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9708. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9709. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9710. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9711. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9712. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9713. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9714. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9715. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9716. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9717. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9718. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9719. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9720. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9721. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9722. static readonly STEP_AFTERRENDER_AUDIO: number;
  9723. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9724. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9725. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9726. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9727. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9728. static readonly STEP_POINTERMOVE_SPRITE: number;
  9729. static readonly STEP_POINTERDOWN_SPRITE: number;
  9730. static readonly STEP_POINTERUP_SPRITE: number;
  9731. }
  9732. /**
  9733. * This represents a scene component.
  9734. *
  9735. * This is used to decouple the dependency the scene is having on the different workloads like
  9736. * layers, post processes...
  9737. */
  9738. export interface ISceneComponent {
  9739. /**
  9740. * The name of the component. Each component must have a unique name.
  9741. */
  9742. name: string;
  9743. /**
  9744. * The scene the component belongs to.
  9745. */
  9746. scene: Scene;
  9747. /**
  9748. * Register the component to one instance of a scene.
  9749. */
  9750. register(): void;
  9751. /**
  9752. * Rebuilds the elements related to this component in case of
  9753. * context lost for instance.
  9754. */
  9755. rebuild(): void;
  9756. /**
  9757. * Disposes the component and the associated ressources.
  9758. */
  9759. dispose(): void;
  9760. }
  9761. /**
  9762. * This represents a SERIALIZABLE scene component.
  9763. *
  9764. * This extends Scene Component to add Serialization methods on top.
  9765. */
  9766. export interface ISceneSerializableComponent extends ISceneComponent {
  9767. /**
  9768. * Adds all the elements from the container to the scene
  9769. * @param container the container holding the elements
  9770. */
  9771. addFromContainer(container: AbstractScene): void;
  9772. /**
  9773. * Removes all the elements in the container from the scene
  9774. * @param container contains the elements to remove
  9775. * @param dispose if the removed element should be disposed (default: false)
  9776. */
  9777. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9778. /**
  9779. * Serializes the component data to the specified json object
  9780. * @param serializationObject The object to serialize to
  9781. */
  9782. serialize(serializationObject: any): void;
  9783. }
  9784. /**
  9785. * Strong typing of a Mesh related stage step action
  9786. */
  9787. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9788. /**
  9789. * Strong typing of a Evaluate Sub Mesh related stage step action
  9790. */
  9791. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9792. /**
  9793. * Strong typing of a Active Mesh related stage step action
  9794. */
  9795. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9796. /**
  9797. * Strong typing of a Camera related stage step action
  9798. */
  9799. export type CameraStageAction = (camera: Camera) => void;
  9800. /**
  9801. * Strong typing of a Camera Frame buffer related stage step action
  9802. */
  9803. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9804. /**
  9805. * Strong typing of a Render Target related stage step action
  9806. */
  9807. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9808. /**
  9809. * Strong typing of a RenderingGroup related stage step action
  9810. */
  9811. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9812. /**
  9813. * Strong typing of a Mesh Render related stage step action
  9814. */
  9815. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9816. /**
  9817. * Strong typing of a simple stage step action
  9818. */
  9819. export type SimpleStageAction = () => void;
  9820. /**
  9821. * Strong typing of a render target action.
  9822. */
  9823. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9824. /**
  9825. * Strong typing of a pointer move action.
  9826. */
  9827. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9828. /**
  9829. * Strong typing of a pointer up/down action.
  9830. */
  9831. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9832. /**
  9833. * Representation of a stage in the scene (Basically a list of ordered steps)
  9834. * @hidden
  9835. */
  9836. export class Stage<T extends Function> extends Array<{
  9837. index: number;
  9838. component: ISceneComponent;
  9839. action: T;
  9840. }> {
  9841. /**
  9842. * Hide ctor from the rest of the world.
  9843. * @param items The items to add.
  9844. */
  9845. private constructor();
  9846. /**
  9847. * Creates a new Stage.
  9848. * @returns A new instance of a Stage
  9849. */
  9850. static Create<T extends Function>(): Stage<T>;
  9851. /**
  9852. * Registers a step in an ordered way in the targeted stage.
  9853. * @param index Defines the position to register the step in
  9854. * @param component Defines the component attached to the step
  9855. * @param action Defines the action to launch during the step
  9856. */
  9857. registerStep(index: number, component: ISceneComponent, action: T): void;
  9858. /**
  9859. * Clears all the steps from the stage.
  9860. */
  9861. clear(): void;
  9862. }
  9863. }
  9864. declare module BABYLON {
  9865. interface Scene {
  9866. /** @hidden */
  9867. _pointerOverSprite: Nullable<Sprite>;
  9868. /** @hidden */
  9869. _pickedDownSprite: Nullable<Sprite>;
  9870. /** @hidden */
  9871. _tempSpritePickingRay: Nullable<Ray>;
  9872. /**
  9873. * All of the sprite managers added to this scene
  9874. * @see http://doc.babylonjs.com/babylon101/sprites
  9875. */
  9876. spriteManagers: Array<ISpriteManager>;
  9877. /**
  9878. * An event triggered when sprites rendering is about to start
  9879. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9880. */
  9881. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9882. /**
  9883. * An event triggered when sprites rendering is done
  9884. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9885. */
  9886. onAfterSpritesRenderingObservable: Observable<Scene>;
  9887. /** @hidden */
  9888. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9889. /** Launch a ray to try to pick a sprite in the scene
  9890. * @param x position on screen
  9891. * @param y position on screen
  9892. * @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
  9893. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9894. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9895. * @returns a PickingInfo
  9896. */
  9897. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9898. /** Use the given ray to pick a sprite in the scene
  9899. * @param ray The ray (in world space) to use to pick meshes
  9900. * @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
  9901. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9902. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9903. * @returns a PickingInfo
  9904. */
  9905. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9906. /** @hidden */
  9907. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9908. /** Launch a ray to try to pick sprites in the scene
  9909. * @param x position on screen
  9910. * @param y position on screen
  9911. * @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
  9912. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9913. * @returns a PickingInfo array
  9914. */
  9915. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9916. /** Use the given ray to pick sprites in the scene
  9917. * @param ray The ray (in world space) to use to pick meshes
  9918. * @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
  9919. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9920. * @returns a PickingInfo array
  9921. */
  9922. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9923. /**
  9924. * Force the sprite under the pointer
  9925. * @param sprite defines the sprite to use
  9926. */
  9927. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9928. /**
  9929. * Gets the sprite under the pointer
  9930. * @returns a Sprite or null if no sprite is under the pointer
  9931. */
  9932. getPointerOverSprite(): Nullable<Sprite>;
  9933. }
  9934. /**
  9935. * Defines the sprite scene component responsible to manage sprites
  9936. * in a given scene.
  9937. */
  9938. export class SpriteSceneComponent implements ISceneComponent {
  9939. /**
  9940. * The component name helpfull to identify the component in the list of scene components.
  9941. */
  9942. readonly name: string;
  9943. /**
  9944. * The scene the component belongs to.
  9945. */
  9946. scene: Scene;
  9947. /** @hidden */
  9948. private _spritePredicate;
  9949. /**
  9950. * Creates a new instance of the component for the given scene
  9951. * @param scene Defines the scene to register the component in
  9952. */
  9953. constructor(scene: Scene);
  9954. /**
  9955. * Registers the component in a given scene
  9956. */
  9957. register(): void;
  9958. /**
  9959. * Rebuilds the elements related to this component in case of
  9960. * context lost for instance.
  9961. */
  9962. rebuild(): void;
  9963. /**
  9964. * Disposes the component and the associated ressources.
  9965. */
  9966. dispose(): void;
  9967. private _pickSpriteButKeepRay;
  9968. private _pointerMove;
  9969. private _pointerDown;
  9970. private _pointerUp;
  9971. }
  9972. }
  9973. declare module BABYLON {
  9974. /** @hidden */
  9975. export var fogFragmentDeclaration: {
  9976. name: string;
  9977. shader: string;
  9978. };
  9979. }
  9980. declare module BABYLON {
  9981. /** @hidden */
  9982. export var fogFragment: {
  9983. name: string;
  9984. shader: string;
  9985. };
  9986. }
  9987. declare module BABYLON {
  9988. /** @hidden */
  9989. export var spritesPixelShader: {
  9990. name: string;
  9991. shader: string;
  9992. };
  9993. }
  9994. declare module BABYLON {
  9995. /** @hidden */
  9996. export var fogVertexDeclaration: {
  9997. name: string;
  9998. shader: string;
  9999. };
  10000. }
  10001. declare module BABYLON {
  10002. /** @hidden */
  10003. export var spritesVertexShader: {
  10004. name: string;
  10005. shader: string;
  10006. };
  10007. }
  10008. declare module BABYLON {
  10009. /**
  10010. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10011. */
  10012. export interface ISpriteManager extends IDisposable {
  10013. /**
  10014. * Restricts the camera to viewing objects with the same layerMask.
  10015. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10016. */
  10017. layerMask: number;
  10018. /**
  10019. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10020. */
  10021. isPickable: boolean;
  10022. /**
  10023. * Specifies the rendering group id for this mesh (0 by default)
  10024. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10025. */
  10026. renderingGroupId: number;
  10027. /**
  10028. * Defines the list of sprites managed by the manager.
  10029. */
  10030. sprites: Array<Sprite>;
  10031. /**
  10032. * Tests the intersection of a sprite with a specific ray.
  10033. * @param ray The ray we are sending to test the collision
  10034. * @param camera The camera space we are sending rays in
  10035. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10036. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10037. * @returns picking info or null.
  10038. */
  10039. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10040. /**
  10041. * Intersects the sprites with a ray
  10042. * @param ray defines the ray to intersect with
  10043. * @param camera defines the current active camera
  10044. * @param predicate defines a predicate used to select candidate sprites
  10045. * @returns null if no hit or a PickingInfo array
  10046. */
  10047. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10048. /**
  10049. * Renders the list of sprites on screen.
  10050. */
  10051. render(): void;
  10052. }
  10053. /**
  10054. * Class used to manage multiple sprites on the same spritesheet
  10055. * @see http://doc.babylonjs.com/babylon101/sprites
  10056. */
  10057. export class SpriteManager implements ISpriteManager {
  10058. /** defines the manager's name */
  10059. name: string;
  10060. /** Gets the list of sprites */
  10061. sprites: Sprite[];
  10062. /** Gets or sets the rendering group id (0 by default) */
  10063. renderingGroupId: number;
  10064. /** Gets or sets camera layer mask */
  10065. layerMask: number;
  10066. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10067. fogEnabled: boolean;
  10068. /** Gets or sets a boolean indicating if the sprites are pickable */
  10069. isPickable: boolean;
  10070. /** Defines the default width of a cell in the spritesheet */
  10071. cellWidth: number;
  10072. /** Defines the default height of a cell in the spritesheet */
  10073. cellHeight: number;
  10074. /** Associative array from JSON sprite data file */
  10075. private _cellData;
  10076. /** Array of sprite names from JSON sprite data file */
  10077. private _spriteMap;
  10078. /** True when packed cell data from JSON file is ready*/
  10079. private _packedAndReady;
  10080. private _textureContent;
  10081. /**
  10082. * An event triggered when the manager is disposed.
  10083. */
  10084. onDisposeObservable: Observable<SpriteManager>;
  10085. private _onDisposeObserver;
  10086. /**
  10087. * Callback called when the manager is disposed
  10088. */
  10089. set onDispose(callback: () => void);
  10090. private _capacity;
  10091. private _fromPacked;
  10092. private _spriteTexture;
  10093. private _epsilon;
  10094. private _scene;
  10095. private _vertexData;
  10096. private _buffer;
  10097. private _vertexBuffers;
  10098. private _indexBuffer;
  10099. private _effectBase;
  10100. private _effectFog;
  10101. /**
  10102. * Gets or sets the spritesheet texture
  10103. */
  10104. get texture(): Texture;
  10105. set texture(value: Texture);
  10106. private _blendMode;
  10107. /**
  10108. * Blend mode use to render the particle, it can be any of
  10109. * the static Constants.ALPHA_x properties provided in this class.
  10110. * Default value is Constants.ALPHA_COMBINE
  10111. */
  10112. get blendMode(): number;
  10113. set blendMode(blendMode: number);
  10114. /** Disables writing to the depth buffer when rendering the sprites.
  10115. * It can be handy to disable depth writing when using textures without alpha channel
  10116. * and setting some specific blend modes.
  10117. */
  10118. disableDepthWrite: boolean;
  10119. /**
  10120. * Creates a new sprite manager
  10121. * @param name defines the manager's name
  10122. * @param imgUrl defines the sprite sheet url
  10123. * @param capacity defines the maximum allowed number of sprites
  10124. * @param cellSize defines the size of a sprite cell
  10125. * @param scene defines the hosting scene
  10126. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10127. * @param samplingMode defines the smapling mode to use with spritesheet
  10128. * @param fromPacked set to false; do not alter
  10129. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10130. */
  10131. constructor(
  10132. /** defines the manager's name */
  10133. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10134. private _makePacked;
  10135. private _appendSpriteVertex;
  10136. private _checkTextureAlpha;
  10137. /**
  10138. * Intersects the sprites with a ray
  10139. * @param ray defines the ray to intersect with
  10140. * @param camera defines the current active camera
  10141. * @param predicate defines a predicate used to select candidate sprites
  10142. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10143. * @returns null if no hit or a PickingInfo
  10144. */
  10145. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10146. /**
  10147. * Intersects the sprites with a ray
  10148. * @param ray defines the ray to intersect with
  10149. * @param camera defines the current active camera
  10150. * @param predicate defines a predicate used to select candidate sprites
  10151. * @returns null if no hit or a PickingInfo array
  10152. */
  10153. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10154. /**
  10155. * Render all child sprites
  10156. */
  10157. render(): void;
  10158. /**
  10159. * Release associated resources
  10160. */
  10161. dispose(): void;
  10162. }
  10163. }
  10164. declare module BABYLON {
  10165. /** Interface used by value gradients (color, factor, ...) */
  10166. export interface IValueGradient {
  10167. /**
  10168. * Gets or sets the gradient value (between 0 and 1)
  10169. */
  10170. gradient: number;
  10171. }
  10172. /** Class used to store color4 gradient */
  10173. export class ColorGradient implements IValueGradient {
  10174. /**
  10175. * Gets or sets the gradient value (between 0 and 1)
  10176. */
  10177. gradient: number;
  10178. /**
  10179. * Gets or sets first associated color
  10180. */
  10181. color1: Color4;
  10182. /**
  10183. * Gets or sets second associated color
  10184. */
  10185. color2?: Color4 | undefined;
  10186. /**
  10187. * Creates a new color4 gradient
  10188. * @param gradient gets or sets the gradient value (between 0 and 1)
  10189. * @param color1 gets or sets first associated color
  10190. * @param color2 gets or sets first second color
  10191. */
  10192. constructor(
  10193. /**
  10194. * Gets or sets the gradient value (between 0 and 1)
  10195. */
  10196. gradient: number,
  10197. /**
  10198. * Gets or sets first associated color
  10199. */
  10200. color1: Color4,
  10201. /**
  10202. * Gets or sets second associated color
  10203. */
  10204. color2?: Color4 | undefined);
  10205. /**
  10206. * Will get a color picked randomly between color1 and color2.
  10207. * If color2 is undefined then color1 will be used
  10208. * @param result defines the target Color4 to store the result in
  10209. */
  10210. getColorToRef(result: Color4): void;
  10211. }
  10212. /** Class used to store color 3 gradient */
  10213. export class Color3Gradient implements IValueGradient {
  10214. /**
  10215. * Gets or sets the gradient value (between 0 and 1)
  10216. */
  10217. gradient: number;
  10218. /**
  10219. * Gets or sets the associated color
  10220. */
  10221. color: Color3;
  10222. /**
  10223. * Creates a new color3 gradient
  10224. * @param gradient gets or sets the gradient value (between 0 and 1)
  10225. * @param color gets or sets associated color
  10226. */
  10227. constructor(
  10228. /**
  10229. * Gets or sets the gradient value (between 0 and 1)
  10230. */
  10231. gradient: number,
  10232. /**
  10233. * Gets or sets the associated color
  10234. */
  10235. color: Color3);
  10236. }
  10237. /** Class used to store factor gradient */
  10238. export class FactorGradient implements IValueGradient {
  10239. /**
  10240. * Gets or sets the gradient value (between 0 and 1)
  10241. */
  10242. gradient: number;
  10243. /**
  10244. * Gets or sets first associated factor
  10245. */
  10246. factor1: number;
  10247. /**
  10248. * Gets or sets second associated factor
  10249. */
  10250. factor2?: number | undefined;
  10251. /**
  10252. * Creates a new factor gradient
  10253. * @param gradient gets or sets the gradient value (between 0 and 1)
  10254. * @param factor1 gets or sets first associated factor
  10255. * @param factor2 gets or sets second associated factor
  10256. */
  10257. constructor(
  10258. /**
  10259. * Gets or sets the gradient value (between 0 and 1)
  10260. */
  10261. gradient: number,
  10262. /**
  10263. * Gets or sets first associated factor
  10264. */
  10265. factor1: number,
  10266. /**
  10267. * Gets or sets second associated factor
  10268. */
  10269. factor2?: number | undefined);
  10270. /**
  10271. * Will get a number picked randomly between factor1 and factor2.
  10272. * If factor2 is undefined then factor1 will be used
  10273. * @returns the picked number
  10274. */
  10275. getFactor(): number;
  10276. }
  10277. /**
  10278. * Helper used to simplify some generic gradient tasks
  10279. */
  10280. export class GradientHelper {
  10281. /**
  10282. * Gets the current gradient from an array of IValueGradient
  10283. * @param ratio defines the current ratio to get
  10284. * @param gradients defines the array of IValueGradient
  10285. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10286. */
  10287. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10288. }
  10289. }
  10290. declare module BABYLON {
  10291. /**
  10292. * Interface for the size containing width and height
  10293. */
  10294. export interface ISize {
  10295. /**
  10296. * Width
  10297. */
  10298. width: number;
  10299. /**
  10300. * Heighht
  10301. */
  10302. height: number;
  10303. }
  10304. /**
  10305. * Size containing widht and height
  10306. */
  10307. export class Size implements ISize {
  10308. /**
  10309. * Width
  10310. */
  10311. width: number;
  10312. /**
  10313. * Height
  10314. */
  10315. height: number;
  10316. /**
  10317. * Creates a Size object from the given width and height (floats).
  10318. * @param width width of the new size
  10319. * @param height height of the new size
  10320. */
  10321. constructor(width: number, height: number);
  10322. /**
  10323. * Returns a string with the Size width and height
  10324. * @returns a string with the Size width and height
  10325. */
  10326. toString(): string;
  10327. /**
  10328. * "Size"
  10329. * @returns the string "Size"
  10330. */
  10331. getClassName(): string;
  10332. /**
  10333. * Returns the Size hash code.
  10334. * @returns a hash code for a unique width and height
  10335. */
  10336. getHashCode(): number;
  10337. /**
  10338. * Updates the current size from the given one.
  10339. * @param src the given size
  10340. */
  10341. copyFrom(src: Size): void;
  10342. /**
  10343. * Updates in place the current Size from the given floats.
  10344. * @param width width of the new size
  10345. * @param height height of the new size
  10346. * @returns the updated Size.
  10347. */
  10348. copyFromFloats(width: number, height: number): Size;
  10349. /**
  10350. * Updates in place the current Size from the given floats.
  10351. * @param width width to set
  10352. * @param height height to set
  10353. * @returns the updated Size.
  10354. */
  10355. set(width: number, height: number): Size;
  10356. /**
  10357. * Multiplies the width and height by numbers
  10358. * @param w factor to multiple the width by
  10359. * @param h factor to multiple the height by
  10360. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10361. */
  10362. multiplyByFloats(w: number, h: number): Size;
  10363. /**
  10364. * Clones the size
  10365. * @returns a new Size copied from the given one.
  10366. */
  10367. clone(): Size;
  10368. /**
  10369. * True if the current Size and the given one width and height are strictly equal.
  10370. * @param other the other size to compare against
  10371. * @returns True if the current Size and the given one width and height are strictly equal.
  10372. */
  10373. equals(other: Size): boolean;
  10374. /**
  10375. * The surface of the Size : width * height (float).
  10376. */
  10377. get surface(): number;
  10378. /**
  10379. * Create a new size of zero
  10380. * @returns a new Size set to (0.0, 0.0)
  10381. */
  10382. static Zero(): Size;
  10383. /**
  10384. * Sums the width and height of two sizes
  10385. * @param otherSize size to add to this size
  10386. * @returns a new Size set as the addition result of the current Size and the given one.
  10387. */
  10388. add(otherSize: Size): Size;
  10389. /**
  10390. * Subtracts the width and height of two
  10391. * @param otherSize size to subtract to this size
  10392. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10393. */
  10394. subtract(otherSize: Size): Size;
  10395. /**
  10396. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10397. * @param start starting size to lerp between
  10398. * @param end end size to lerp between
  10399. * @param amount amount to lerp between the start and end values
  10400. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10401. */
  10402. static Lerp(start: Size, end: Size, amount: number): Size;
  10403. }
  10404. }
  10405. declare module BABYLON {
  10406. interface ThinEngine {
  10407. /**
  10408. * Creates a dynamic texture
  10409. * @param width defines the width of the texture
  10410. * @param height defines the height of the texture
  10411. * @param generateMipMaps defines if the engine should generate the mip levels
  10412. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10413. * @returns the dynamic texture inside an InternalTexture
  10414. */
  10415. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10416. /**
  10417. * Update the content of a dynamic texture
  10418. * @param texture defines the texture to update
  10419. * @param canvas defines the canvas containing the source
  10420. * @param invertY defines if data must be stored with Y axis inverted
  10421. * @param premulAlpha defines if alpha is stored as premultiplied
  10422. * @param format defines the format of the data
  10423. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10424. */
  10425. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10426. }
  10427. }
  10428. declare module BABYLON {
  10429. /**
  10430. * Helper class used to generate a canvas to manipulate images
  10431. */
  10432. export class CanvasGenerator {
  10433. /**
  10434. * Create a new canvas (or offscreen canvas depending on the context)
  10435. * @param width defines the expected width
  10436. * @param height defines the expected height
  10437. * @return a new canvas or offscreen canvas
  10438. */
  10439. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10440. }
  10441. }
  10442. declare module BABYLON {
  10443. /**
  10444. * A class extending Texture allowing drawing on a texture
  10445. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10446. */
  10447. export class DynamicTexture extends Texture {
  10448. private _generateMipMaps;
  10449. private _canvas;
  10450. private _context;
  10451. private _engine;
  10452. /**
  10453. * Creates a DynamicTexture
  10454. * @param name defines the name of the texture
  10455. * @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
  10456. * @param scene defines the scene where you want the texture
  10457. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10458. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10459. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10460. */
  10461. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10462. /**
  10463. * Get the current class name of the texture useful for serialization or dynamic coding.
  10464. * @returns "DynamicTexture"
  10465. */
  10466. getClassName(): string;
  10467. /**
  10468. * Gets the current state of canRescale
  10469. */
  10470. get canRescale(): boolean;
  10471. private _recreate;
  10472. /**
  10473. * Scales the texture
  10474. * @param ratio the scale factor to apply to both width and height
  10475. */
  10476. scale(ratio: number): void;
  10477. /**
  10478. * Resizes the texture
  10479. * @param width the new width
  10480. * @param height the new height
  10481. */
  10482. scaleTo(width: number, height: number): void;
  10483. /**
  10484. * Gets the context of the canvas used by the texture
  10485. * @returns the canvas context of the dynamic texture
  10486. */
  10487. getContext(): CanvasRenderingContext2D;
  10488. /**
  10489. * Clears the texture
  10490. */
  10491. clear(): void;
  10492. /**
  10493. * Updates the texture
  10494. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10495. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10496. */
  10497. update(invertY?: boolean, premulAlpha?: boolean): void;
  10498. /**
  10499. * Draws text onto the texture
  10500. * @param text defines the text to be drawn
  10501. * @param x defines the placement of the text from the left
  10502. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10503. * @param font defines the font to be used with font-style, font-size, font-name
  10504. * @param color defines the color used for the text
  10505. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10506. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10507. * @param update defines whether texture is immediately update (default is true)
  10508. */
  10509. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10510. /**
  10511. * Clones the texture
  10512. * @returns the clone of the texture.
  10513. */
  10514. clone(): DynamicTexture;
  10515. /**
  10516. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10517. * @returns a serialized dynamic texture object
  10518. */
  10519. serialize(): any;
  10520. /** @hidden */
  10521. _rebuild(): void;
  10522. }
  10523. }
  10524. declare module BABYLON {
  10525. interface ThinEngine {
  10526. /**
  10527. * Creates a raw texture
  10528. * @param data defines the data to store in the texture
  10529. * @param width defines the width of the texture
  10530. * @param height defines the height of the texture
  10531. * @param format defines the format of the data
  10532. * @param generateMipMaps defines if the engine should generate the mip levels
  10533. * @param invertY defines if data must be stored with Y axis inverted
  10534. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10535. * @param compression defines the compression used (null by default)
  10536. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10537. * @returns the raw texture inside an InternalTexture
  10538. */
  10539. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10540. /**
  10541. * Update a raw texture
  10542. * @param texture defines the texture to update
  10543. * @param data defines the data to store in the texture
  10544. * @param format defines the format of the data
  10545. * @param invertY defines if data must be stored with Y axis inverted
  10546. */
  10547. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10548. /**
  10549. * Update a raw texture
  10550. * @param texture defines the texture to update
  10551. * @param data defines the data to store in the texture
  10552. * @param format defines the format of the data
  10553. * @param invertY defines if data must be stored with Y axis inverted
  10554. * @param compression defines the compression used (null by default)
  10555. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10556. */
  10557. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10558. /**
  10559. * Creates a new raw cube texture
  10560. * @param data defines the array of data to use to create each face
  10561. * @param size defines the size of the textures
  10562. * @param format defines the format of the data
  10563. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10564. * @param generateMipMaps defines if the engine should generate the mip levels
  10565. * @param invertY defines if data must be stored with Y axis inverted
  10566. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10567. * @param compression defines the compression used (null by default)
  10568. * @returns the cube texture as an InternalTexture
  10569. */
  10570. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10571. /**
  10572. * Update a raw cube texture
  10573. * @param texture defines the texture to udpdate
  10574. * @param data defines the data to store
  10575. * @param format defines the data format
  10576. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10577. * @param invertY defines if data must be stored with Y axis inverted
  10578. */
  10579. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10580. /**
  10581. * Update a raw cube texture
  10582. * @param texture defines the texture to udpdate
  10583. * @param data defines the data to store
  10584. * @param format defines the data format
  10585. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10586. * @param invertY defines if data must be stored with Y axis inverted
  10587. * @param compression defines the compression used (null by default)
  10588. */
  10589. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10590. /**
  10591. * Update a raw cube texture
  10592. * @param texture defines the texture to udpdate
  10593. * @param data defines the data to store
  10594. * @param format defines the data format
  10595. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10596. * @param invertY defines if data must be stored with Y axis inverted
  10597. * @param compression defines the compression used (null by default)
  10598. * @param level defines which level of the texture to update
  10599. */
  10600. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10601. /**
  10602. * Creates a new raw cube texture from a specified url
  10603. * @param url defines the url where the data is located
  10604. * @param scene defines the current scene
  10605. * @param size defines the size of the textures
  10606. * @param format defines the format of the data
  10607. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10608. * @param noMipmap defines if the engine should avoid generating the mip levels
  10609. * @param callback defines a callback used to extract texture data from loaded data
  10610. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10611. * @param onLoad defines a callback called when texture is loaded
  10612. * @param onError defines a callback called if there is an error
  10613. * @returns the cube texture as an InternalTexture
  10614. */
  10615. 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;
  10616. /**
  10617. * Creates a new raw cube texture from a specified url
  10618. * @param url defines the url where the data is located
  10619. * @param scene defines the current scene
  10620. * @param size defines the size of the textures
  10621. * @param format defines the format of the data
  10622. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10623. * @param noMipmap defines if the engine should avoid generating the mip levels
  10624. * @param callback defines a callback used to extract texture data from loaded data
  10625. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10626. * @param onLoad defines a callback called when texture is loaded
  10627. * @param onError defines a callback called if there is an error
  10628. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10629. * @param invertY defines if data must be stored with Y axis inverted
  10630. * @returns the cube texture as an InternalTexture
  10631. */
  10632. 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;
  10633. /**
  10634. * Creates a new raw 3D texture
  10635. * @param data defines the data used to create the texture
  10636. * @param width defines the width of the texture
  10637. * @param height defines the height of the texture
  10638. * @param depth defines the depth of the texture
  10639. * @param format defines the format of the texture
  10640. * @param generateMipMaps defines if the engine must generate mip levels
  10641. * @param invertY defines if data must be stored with Y axis inverted
  10642. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10643. * @param compression defines the compressed used (can be null)
  10644. * @param textureType defines the compressed used (can be null)
  10645. * @returns a new raw 3D texture (stored in an InternalTexture)
  10646. */
  10647. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10648. /**
  10649. * Update a raw 3D texture
  10650. * @param texture defines the texture to update
  10651. * @param data defines the data to store
  10652. * @param format defines the data format
  10653. * @param invertY defines if data must be stored with Y axis inverted
  10654. */
  10655. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10656. /**
  10657. * Update a raw 3D texture
  10658. * @param texture defines the texture to update
  10659. * @param data defines the data to store
  10660. * @param format defines the data format
  10661. * @param invertY defines if data must be stored with Y axis inverted
  10662. * @param compression defines the used compression (can be null)
  10663. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10664. */
  10665. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10666. /**
  10667. * Creates a new raw 2D array texture
  10668. * @param data defines the data used to create the texture
  10669. * @param width defines the width of the texture
  10670. * @param height defines the height of the texture
  10671. * @param depth defines the number of layers of the texture
  10672. * @param format defines the format of the texture
  10673. * @param generateMipMaps defines if the engine must generate mip levels
  10674. * @param invertY defines if data must be stored with Y axis inverted
  10675. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10676. * @param compression defines the compressed used (can be null)
  10677. * @param textureType defines the compressed used (can be null)
  10678. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10679. */
  10680. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10681. /**
  10682. * Update a raw 2D array texture
  10683. * @param texture defines the texture to update
  10684. * @param data defines the data to store
  10685. * @param format defines the data format
  10686. * @param invertY defines if data must be stored with Y axis inverted
  10687. */
  10688. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10689. /**
  10690. * Update a raw 2D array texture
  10691. * @param texture defines the texture to update
  10692. * @param data defines the data to store
  10693. * @param format defines the data format
  10694. * @param invertY defines if data must be stored with Y axis inverted
  10695. * @param compression defines the used compression (can be null)
  10696. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10697. */
  10698. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10699. }
  10700. }
  10701. declare module BABYLON {
  10702. /**
  10703. * Raw texture can help creating a texture directly from an array of data.
  10704. * This can be super useful if you either get the data from an uncompressed source or
  10705. * if you wish to create your texture pixel by pixel.
  10706. */
  10707. export class RawTexture extends Texture {
  10708. /**
  10709. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10710. */
  10711. format: number;
  10712. private _engine;
  10713. /**
  10714. * Instantiates a new RawTexture.
  10715. * Raw texture can help creating a texture directly from an array of data.
  10716. * This can be super useful if you either get the data from an uncompressed source or
  10717. * if you wish to create your texture pixel by pixel.
  10718. * @param data define the array of data to use to create the texture
  10719. * @param width define the width of the texture
  10720. * @param height define the height of the texture
  10721. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10722. * @param scene define the scene the texture belongs to
  10723. * @param generateMipMaps define whether mip maps should be generated or not
  10724. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10725. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10726. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10727. */
  10728. constructor(data: ArrayBufferView, width: number, height: number,
  10729. /**
  10730. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10731. */
  10732. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10733. /**
  10734. * Updates the texture underlying data.
  10735. * @param data Define the new data of the texture
  10736. */
  10737. update(data: ArrayBufferView): void;
  10738. /**
  10739. * Creates a luminance texture from some data.
  10740. * @param data Define the texture data
  10741. * @param width Define the width of the texture
  10742. * @param height Define the height of the texture
  10743. * @param scene Define the scene the texture belongs to
  10744. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10745. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10746. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10747. * @returns the luminance texture
  10748. */
  10749. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10750. /**
  10751. * Creates a luminance alpha texture from some data.
  10752. * @param data Define the texture data
  10753. * @param width Define the width of the texture
  10754. * @param height Define the height of the texture
  10755. * @param scene Define the scene the texture belongs to
  10756. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10757. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10758. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10759. * @returns the luminance alpha texture
  10760. */
  10761. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10762. /**
  10763. * Creates an alpha texture from some data.
  10764. * @param data Define the texture data
  10765. * @param width Define the width of the texture
  10766. * @param height Define the height of the texture
  10767. * @param scene Define the scene the texture belongs to
  10768. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10769. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10770. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10771. * @returns the alpha texture
  10772. */
  10773. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10774. /**
  10775. * Creates a RGB texture from some data.
  10776. * @param data Define the texture data
  10777. * @param width Define the width of the texture
  10778. * @param height Define the height of the texture
  10779. * @param scene Define the scene the texture belongs to
  10780. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10781. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10782. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10783. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10784. * @returns the RGB alpha texture
  10785. */
  10786. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10787. /**
  10788. * Creates a RGBA texture from some data.
  10789. * @param data Define the texture data
  10790. * @param width Define the width of the texture
  10791. * @param height Define the height of the texture
  10792. * @param scene Define the scene the texture belongs to
  10793. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10794. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10795. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10796. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10797. * @returns the RGBA texture
  10798. */
  10799. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10800. /**
  10801. * Creates a R texture from some data.
  10802. * @param data Define the texture data
  10803. * @param width Define the width of the texture
  10804. * @param height Define the height of the texture
  10805. * @param scene Define the scene the texture belongs to
  10806. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10807. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10808. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10809. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10810. * @returns the R texture
  10811. */
  10812. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10813. }
  10814. }
  10815. declare module BABYLON {
  10816. interface AbstractScene {
  10817. /**
  10818. * The list of procedural textures added to the scene
  10819. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10820. */
  10821. proceduralTextures: Array<ProceduralTexture>;
  10822. }
  10823. /**
  10824. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10825. * in a given scene.
  10826. */
  10827. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10828. /**
  10829. * The component name helpfull to identify the component in the list of scene components.
  10830. */
  10831. readonly name: string;
  10832. /**
  10833. * The scene the component belongs to.
  10834. */
  10835. scene: Scene;
  10836. /**
  10837. * Creates a new instance of the component for the given scene
  10838. * @param scene Defines the scene to register the component in
  10839. */
  10840. constructor(scene: Scene);
  10841. /**
  10842. * Registers the component in a given scene
  10843. */
  10844. register(): void;
  10845. /**
  10846. * Rebuilds the elements related to this component in case of
  10847. * context lost for instance.
  10848. */
  10849. rebuild(): void;
  10850. /**
  10851. * Disposes the component and the associated ressources.
  10852. */
  10853. dispose(): void;
  10854. private _beforeClear;
  10855. }
  10856. }
  10857. declare module BABYLON {
  10858. interface ThinEngine {
  10859. /**
  10860. * Creates a new render target cube texture
  10861. * @param size defines the size of the texture
  10862. * @param options defines the options used to create the texture
  10863. * @returns a new render target cube texture stored in an InternalTexture
  10864. */
  10865. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10866. }
  10867. }
  10868. declare module BABYLON {
  10869. /** @hidden */
  10870. export var proceduralVertexShader: {
  10871. name: string;
  10872. shader: string;
  10873. };
  10874. }
  10875. declare module BABYLON {
  10876. /**
  10877. * 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.
  10878. * This is the base class of any Procedural texture and contains most of the shareable code.
  10879. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10880. */
  10881. export class ProceduralTexture extends Texture {
  10882. isCube: boolean;
  10883. /**
  10884. * Define if the texture is enabled or not (disabled texture will not render)
  10885. */
  10886. isEnabled: boolean;
  10887. /**
  10888. * Define if the texture must be cleared before rendering (default is true)
  10889. */
  10890. autoClear: boolean;
  10891. /**
  10892. * Callback called when the texture is generated
  10893. */
  10894. onGenerated: () => void;
  10895. /**
  10896. * Event raised when the texture is generated
  10897. */
  10898. onGeneratedObservable: Observable<ProceduralTexture>;
  10899. /** @hidden */
  10900. _generateMipMaps: boolean;
  10901. /** @hidden **/
  10902. _effect: Effect;
  10903. /** @hidden */
  10904. _textures: {
  10905. [key: string]: Texture;
  10906. };
  10907. /** @hidden */
  10908. protected _fallbackTexture: Nullable<Texture>;
  10909. private _size;
  10910. private _currentRefreshId;
  10911. private _frameId;
  10912. private _refreshRate;
  10913. private _vertexBuffers;
  10914. private _indexBuffer;
  10915. private _uniforms;
  10916. private _samplers;
  10917. private _fragment;
  10918. private _floats;
  10919. private _ints;
  10920. private _floatsArrays;
  10921. private _colors3;
  10922. private _colors4;
  10923. private _vectors2;
  10924. private _vectors3;
  10925. private _matrices;
  10926. private _fallbackTextureUsed;
  10927. private _engine;
  10928. private _cachedDefines;
  10929. private _contentUpdateId;
  10930. private _contentData;
  10931. /**
  10932. * Instantiates a new procedural texture.
  10933. * 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.
  10934. * This is the base class of any Procedural texture and contains most of the shareable code.
  10935. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10936. * @param name Define the name of the texture
  10937. * @param size Define the size of the texture to create
  10938. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10939. * @param scene Define the scene the texture belongs to
  10940. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10941. * @param generateMipMaps Define if the texture should creates mip maps or not
  10942. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10943. */
  10944. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10945. /**
  10946. * The effect that is created when initializing the post process.
  10947. * @returns The created effect corresponding the the postprocess.
  10948. */
  10949. getEffect(): Effect;
  10950. /**
  10951. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10952. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10953. */
  10954. getContent(): Nullable<ArrayBufferView>;
  10955. private _createIndexBuffer;
  10956. /** @hidden */
  10957. _rebuild(): void;
  10958. /**
  10959. * Resets the texture in order to recreate its associated resources.
  10960. * This can be called in case of context loss
  10961. */
  10962. reset(): void;
  10963. protected _getDefines(): string;
  10964. /**
  10965. * Is the texture ready to be used ? (rendered at least once)
  10966. * @returns true if ready, otherwise, false.
  10967. */
  10968. isReady(): boolean;
  10969. /**
  10970. * Resets the refresh counter of the texture and start bak from scratch.
  10971. * Could be useful to regenerate the texture if it is setup to render only once.
  10972. */
  10973. resetRefreshCounter(): void;
  10974. /**
  10975. * Set the fragment shader to use in order to render the texture.
  10976. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10977. */
  10978. setFragment(fragment: any): void;
  10979. /**
  10980. * Define the refresh rate of the texture or the rendering frequency.
  10981. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10982. */
  10983. get refreshRate(): number;
  10984. set refreshRate(value: number);
  10985. /** @hidden */
  10986. _shouldRender(): boolean;
  10987. /**
  10988. * Get the size the texture is rendering at.
  10989. * @returns the size (texture is always squared)
  10990. */
  10991. getRenderSize(): number;
  10992. /**
  10993. * Resize the texture to new value.
  10994. * @param size Define the new size the texture should have
  10995. * @param generateMipMaps Define whether the new texture should create mip maps
  10996. */
  10997. resize(size: number, generateMipMaps: boolean): void;
  10998. private _checkUniform;
  10999. /**
  11000. * Set a texture in the shader program used to render.
  11001. * @param name Define the name of the uniform samplers as defined in the shader
  11002. * @param texture Define the texture to bind to this sampler
  11003. * @return the texture itself allowing "fluent" like uniform updates
  11004. */
  11005. setTexture(name: string, texture: Texture): ProceduralTexture;
  11006. /**
  11007. * Set a float in the shader.
  11008. * @param name Define the name of the uniform as defined in the shader
  11009. * @param value Define the value to give to the uniform
  11010. * @return the texture itself allowing "fluent" like uniform updates
  11011. */
  11012. setFloat(name: string, value: number): ProceduralTexture;
  11013. /**
  11014. * Set a int in the shader.
  11015. * @param name Define the name of the uniform as defined in the shader
  11016. * @param value Define the value to give to the uniform
  11017. * @return the texture itself allowing "fluent" like uniform updates
  11018. */
  11019. setInt(name: string, value: number): ProceduralTexture;
  11020. /**
  11021. * Set an array of floats in the shader.
  11022. * @param name Define the name of the uniform as defined in the shader
  11023. * @param value Define the value to give to the uniform
  11024. * @return the texture itself allowing "fluent" like uniform updates
  11025. */
  11026. setFloats(name: string, value: number[]): ProceduralTexture;
  11027. /**
  11028. * Set a vec3 in the shader from a Color3.
  11029. * @param name Define the name of the uniform as defined in the shader
  11030. * @param value Define the value to give to the uniform
  11031. * @return the texture itself allowing "fluent" like uniform updates
  11032. */
  11033. setColor3(name: string, value: Color3): ProceduralTexture;
  11034. /**
  11035. * Set a vec4 in the shader from a Color4.
  11036. * @param name Define the name of the uniform as defined in the shader
  11037. * @param value Define the value to give to the uniform
  11038. * @return the texture itself allowing "fluent" like uniform updates
  11039. */
  11040. setColor4(name: string, value: Color4): ProceduralTexture;
  11041. /**
  11042. * Set a vec2 in the shader from a Vector2.
  11043. * @param name Define the name of the uniform as defined in the shader
  11044. * @param value Define the value to give to the uniform
  11045. * @return the texture itself allowing "fluent" like uniform updates
  11046. */
  11047. setVector2(name: string, value: Vector2): ProceduralTexture;
  11048. /**
  11049. * Set a vec3 in the shader from a Vector3.
  11050. * @param name Define the name of the uniform as defined in the shader
  11051. * @param value Define the value to give to the uniform
  11052. * @return the texture itself allowing "fluent" like uniform updates
  11053. */
  11054. setVector3(name: string, value: Vector3): ProceduralTexture;
  11055. /**
  11056. * Set a mat4 in the shader from a MAtrix.
  11057. * @param name Define the name of the uniform as defined in the shader
  11058. * @param value Define the value to give to the uniform
  11059. * @return the texture itself allowing "fluent" like uniform updates
  11060. */
  11061. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11062. /**
  11063. * Render the texture to its associated render target.
  11064. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11065. */
  11066. render(useCameraPostProcess?: boolean): void;
  11067. /**
  11068. * Clone the texture.
  11069. * @returns the cloned texture
  11070. */
  11071. clone(): ProceduralTexture;
  11072. /**
  11073. * Dispose the texture and release its asoociated resources.
  11074. */
  11075. dispose(): void;
  11076. }
  11077. }
  11078. declare module BABYLON {
  11079. /**
  11080. * This represents the base class for particle system in Babylon.
  11081. * 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.
  11082. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11083. * @example https://doc.babylonjs.com/babylon101/particles
  11084. */
  11085. export class BaseParticleSystem {
  11086. /**
  11087. * Source color is added to the destination color without alpha affecting the result
  11088. */
  11089. static BLENDMODE_ONEONE: number;
  11090. /**
  11091. * Blend current color and particle color using particle’s alpha
  11092. */
  11093. static BLENDMODE_STANDARD: number;
  11094. /**
  11095. * Add current color and particle color multiplied by particle’s alpha
  11096. */
  11097. static BLENDMODE_ADD: number;
  11098. /**
  11099. * Multiply current color with particle color
  11100. */
  11101. static BLENDMODE_MULTIPLY: number;
  11102. /**
  11103. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11104. */
  11105. static BLENDMODE_MULTIPLYADD: number;
  11106. /**
  11107. * List of animations used by the particle system.
  11108. */
  11109. animations: Animation[];
  11110. /**
  11111. * Gets or sets the unique id of the particle system
  11112. */
  11113. uniqueId: number;
  11114. /**
  11115. * The id of the Particle system.
  11116. */
  11117. id: string;
  11118. /**
  11119. * The friendly name of the Particle system.
  11120. */
  11121. name: string;
  11122. /**
  11123. * Snippet ID if the particle system was created from the snippet server
  11124. */
  11125. snippetId: string;
  11126. /**
  11127. * The rendering group used by the Particle system to chose when to render.
  11128. */
  11129. renderingGroupId: number;
  11130. /**
  11131. * The emitter represents the Mesh or position we are attaching the particle system to.
  11132. */
  11133. emitter: Nullable<AbstractMesh | Vector3>;
  11134. /**
  11135. * The maximum number of particles to emit per frame
  11136. */
  11137. emitRate: number;
  11138. /**
  11139. * If you want to launch only a few particles at once, that can be done, as well.
  11140. */
  11141. manualEmitCount: number;
  11142. /**
  11143. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11144. */
  11145. updateSpeed: number;
  11146. /**
  11147. * The amount of time the particle system is running (depends of the overall update speed).
  11148. */
  11149. targetStopDuration: number;
  11150. /**
  11151. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11152. */
  11153. disposeOnStop: boolean;
  11154. /**
  11155. * Minimum power of emitting particles.
  11156. */
  11157. minEmitPower: number;
  11158. /**
  11159. * Maximum power of emitting particles.
  11160. */
  11161. maxEmitPower: number;
  11162. /**
  11163. * Minimum life time of emitting particles.
  11164. */
  11165. minLifeTime: number;
  11166. /**
  11167. * Maximum life time of emitting particles.
  11168. */
  11169. maxLifeTime: number;
  11170. /**
  11171. * Minimum Size of emitting particles.
  11172. */
  11173. minSize: number;
  11174. /**
  11175. * Maximum Size of emitting particles.
  11176. */
  11177. maxSize: number;
  11178. /**
  11179. * Minimum scale of emitting particles on X axis.
  11180. */
  11181. minScaleX: number;
  11182. /**
  11183. * Maximum scale of emitting particles on X axis.
  11184. */
  11185. maxScaleX: number;
  11186. /**
  11187. * Minimum scale of emitting particles on Y axis.
  11188. */
  11189. minScaleY: number;
  11190. /**
  11191. * Maximum scale of emitting particles on Y axis.
  11192. */
  11193. maxScaleY: number;
  11194. /**
  11195. * Gets or sets the minimal initial rotation in radians.
  11196. */
  11197. minInitialRotation: number;
  11198. /**
  11199. * Gets or sets the maximal initial rotation in radians.
  11200. */
  11201. maxInitialRotation: number;
  11202. /**
  11203. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11204. */
  11205. minAngularSpeed: number;
  11206. /**
  11207. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11208. */
  11209. maxAngularSpeed: number;
  11210. /**
  11211. * The texture used to render each particle. (this can be a spritesheet)
  11212. */
  11213. particleTexture: Nullable<Texture>;
  11214. /**
  11215. * The layer mask we are rendering the particles through.
  11216. */
  11217. layerMask: number;
  11218. /**
  11219. * This can help using your own shader to render the particle system.
  11220. * The according effect will be created
  11221. */
  11222. customShader: any;
  11223. /**
  11224. * By default particle system starts as soon as they are created. This prevents the
  11225. * automatic start to happen and let you decide when to start emitting particles.
  11226. */
  11227. preventAutoStart: boolean;
  11228. private _noiseTexture;
  11229. /**
  11230. * Gets or sets a texture used to add random noise to particle positions
  11231. */
  11232. get noiseTexture(): Nullable<ProceduralTexture>;
  11233. set noiseTexture(value: Nullable<ProceduralTexture>);
  11234. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11235. noiseStrength: Vector3;
  11236. /**
  11237. * Callback triggered when the particle animation is ending.
  11238. */
  11239. onAnimationEnd: Nullable<() => void>;
  11240. /**
  11241. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11242. */
  11243. blendMode: number;
  11244. /**
  11245. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11246. * to override the particles.
  11247. */
  11248. forceDepthWrite: boolean;
  11249. /** 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 */
  11250. preWarmCycles: number;
  11251. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11252. preWarmStepOffset: number;
  11253. /**
  11254. * 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)
  11255. */
  11256. spriteCellChangeSpeed: number;
  11257. /**
  11258. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11259. */
  11260. startSpriteCellID: number;
  11261. /**
  11262. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11263. */
  11264. endSpriteCellID: number;
  11265. /**
  11266. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11267. */
  11268. spriteCellWidth: number;
  11269. /**
  11270. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11271. */
  11272. spriteCellHeight: number;
  11273. /**
  11274. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11275. */
  11276. spriteRandomStartCell: boolean;
  11277. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11278. translationPivot: Vector2;
  11279. /** @hidden */
  11280. protected _isAnimationSheetEnabled: boolean;
  11281. /**
  11282. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11283. */
  11284. beginAnimationOnStart: boolean;
  11285. /**
  11286. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11287. */
  11288. beginAnimationFrom: number;
  11289. /**
  11290. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11291. */
  11292. beginAnimationTo: number;
  11293. /**
  11294. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11295. */
  11296. beginAnimationLoop: boolean;
  11297. /**
  11298. * Gets or sets a world offset applied to all particles
  11299. */
  11300. worldOffset: Vector3;
  11301. /**
  11302. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11303. */
  11304. get isAnimationSheetEnabled(): boolean;
  11305. set isAnimationSheetEnabled(value: boolean);
  11306. /**
  11307. * Get hosting scene
  11308. * @returns the scene
  11309. */
  11310. getScene(): Scene;
  11311. /**
  11312. * You can use gravity if you want to give an orientation to your particles.
  11313. */
  11314. gravity: Vector3;
  11315. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11316. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11317. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11318. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11319. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11320. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11321. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11322. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11323. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11324. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11325. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11326. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11327. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11328. /**
  11329. * Defines the delay in milliseconds before starting the system (0 by default)
  11330. */
  11331. startDelay: number;
  11332. /**
  11333. * Gets the current list of drag gradients.
  11334. * You must use addDragGradient and removeDragGradient to udpate this list
  11335. * @returns the list of drag gradients
  11336. */
  11337. getDragGradients(): Nullable<Array<FactorGradient>>;
  11338. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11339. limitVelocityDamping: number;
  11340. /**
  11341. * Gets the current list of limit velocity gradients.
  11342. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11343. * @returns the list of limit velocity gradients
  11344. */
  11345. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11346. /**
  11347. * Gets the current list of color gradients.
  11348. * You must use addColorGradient and removeColorGradient to udpate this list
  11349. * @returns the list of color gradients
  11350. */
  11351. getColorGradients(): Nullable<Array<ColorGradient>>;
  11352. /**
  11353. * Gets the current list of size gradients.
  11354. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11355. * @returns the list of size gradients
  11356. */
  11357. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11358. /**
  11359. * Gets the current list of color remap gradients.
  11360. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11361. * @returns the list of color remap gradients
  11362. */
  11363. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11364. /**
  11365. * Gets the current list of alpha remap gradients.
  11366. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11367. * @returns the list of alpha remap gradients
  11368. */
  11369. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11370. /**
  11371. * Gets the current list of life time gradients.
  11372. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11373. * @returns the list of life time gradients
  11374. */
  11375. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11376. /**
  11377. * Gets the current list of angular speed gradients.
  11378. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11379. * @returns the list of angular speed gradients
  11380. */
  11381. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11382. /**
  11383. * Gets the current list of velocity gradients.
  11384. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11385. * @returns the list of velocity gradients
  11386. */
  11387. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11388. /**
  11389. * Gets the current list of start size gradients.
  11390. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11391. * @returns the list of start size gradients
  11392. */
  11393. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11394. /**
  11395. * Gets the current list of emit rate gradients.
  11396. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11397. * @returns the list of emit rate gradients
  11398. */
  11399. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11400. /**
  11401. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11402. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11403. */
  11404. get direction1(): Vector3;
  11405. set direction1(value: Vector3);
  11406. /**
  11407. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11408. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11409. */
  11410. get direction2(): Vector3;
  11411. set direction2(value: Vector3);
  11412. /**
  11413. * 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.
  11414. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11415. */
  11416. get minEmitBox(): Vector3;
  11417. set minEmitBox(value: Vector3);
  11418. /**
  11419. * 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.
  11420. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11421. */
  11422. get maxEmitBox(): Vector3;
  11423. set maxEmitBox(value: Vector3);
  11424. /**
  11425. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11426. */
  11427. color1: Color4;
  11428. /**
  11429. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11430. */
  11431. color2: Color4;
  11432. /**
  11433. * Color the particle will have at the end of its lifetime
  11434. */
  11435. colorDead: Color4;
  11436. /**
  11437. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11438. */
  11439. textureMask: Color4;
  11440. /**
  11441. * The particle emitter type defines the emitter used by the particle system.
  11442. * It can be for example box, sphere, or cone...
  11443. */
  11444. particleEmitterType: IParticleEmitterType;
  11445. /** @hidden */
  11446. _isSubEmitter: boolean;
  11447. /**
  11448. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11449. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11450. */
  11451. billboardMode: number;
  11452. protected _isBillboardBased: boolean;
  11453. /**
  11454. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11455. */
  11456. get isBillboardBased(): boolean;
  11457. set isBillboardBased(value: boolean);
  11458. /**
  11459. * The scene the particle system belongs to.
  11460. */
  11461. protected _scene: Scene;
  11462. /**
  11463. * Local cache of defines for image processing.
  11464. */
  11465. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11466. /**
  11467. * Default configuration related to image processing available in the standard Material.
  11468. */
  11469. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11470. /**
  11471. * Gets the image processing configuration used either in this material.
  11472. */
  11473. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11474. /**
  11475. * Sets the Default image processing configuration used either in the this material.
  11476. *
  11477. * If sets to null, the scene one is in use.
  11478. */
  11479. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11480. /**
  11481. * Attaches a new image processing configuration to the Standard Material.
  11482. * @param configuration
  11483. */
  11484. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11485. /** @hidden */
  11486. protected _reset(): void;
  11487. /** @hidden */
  11488. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11489. /**
  11490. * Instantiates a particle system.
  11491. * 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.
  11492. * @param name The name of the particle system
  11493. */
  11494. constructor(name: string);
  11495. /**
  11496. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11497. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11498. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11499. * @returns the emitter
  11500. */
  11501. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11502. /**
  11503. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11504. * @param radius The radius of the hemisphere to emit from
  11505. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11506. * @returns the emitter
  11507. */
  11508. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11509. /**
  11510. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11511. * @param radius The radius of the sphere to emit from
  11512. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11513. * @returns the emitter
  11514. */
  11515. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11516. /**
  11517. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11518. * @param radius The radius of the sphere to emit from
  11519. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11520. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11521. * @returns the emitter
  11522. */
  11523. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11524. /**
  11525. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11526. * @param radius The radius of the emission cylinder
  11527. * @param height The height of the emission cylinder
  11528. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11529. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11530. * @returns the emitter
  11531. */
  11532. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11533. /**
  11534. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11535. * @param radius The radius of the cylinder to emit from
  11536. * @param height The height of the emission cylinder
  11537. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11538. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11539. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11540. * @returns the emitter
  11541. */
  11542. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11543. /**
  11544. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11545. * @param radius The radius of the cone to emit from
  11546. * @param angle The base angle of the cone
  11547. * @returns the emitter
  11548. */
  11549. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11550. /**
  11551. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11552. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11553. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11554. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11555. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11556. * @returns the emitter
  11557. */
  11558. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11559. }
  11560. }
  11561. declare module BABYLON {
  11562. /**
  11563. * Type of sub emitter
  11564. */
  11565. export enum SubEmitterType {
  11566. /**
  11567. * Attached to the particle over it's lifetime
  11568. */
  11569. ATTACHED = 0,
  11570. /**
  11571. * Created when the particle dies
  11572. */
  11573. END = 1
  11574. }
  11575. /**
  11576. * Sub emitter class used to emit particles from an existing particle
  11577. */
  11578. export class SubEmitter {
  11579. /**
  11580. * the particle system to be used by the sub emitter
  11581. */
  11582. particleSystem: ParticleSystem;
  11583. /**
  11584. * Type of the submitter (Default: END)
  11585. */
  11586. type: SubEmitterType;
  11587. /**
  11588. * 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)
  11589. * Note: This only is supported when using an emitter of type Mesh
  11590. */
  11591. inheritDirection: boolean;
  11592. /**
  11593. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11594. */
  11595. inheritedVelocityAmount: number;
  11596. /**
  11597. * Creates a sub emitter
  11598. * @param particleSystem the particle system to be used by the sub emitter
  11599. */
  11600. constructor(
  11601. /**
  11602. * the particle system to be used by the sub emitter
  11603. */
  11604. particleSystem: ParticleSystem);
  11605. /**
  11606. * Clones the sub emitter
  11607. * @returns the cloned sub emitter
  11608. */
  11609. clone(): SubEmitter;
  11610. /**
  11611. * Serialize current object to a JSON object
  11612. * @returns the serialized object
  11613. */
  11614. serialize(): any;
  11615. /** @hidden */
  11616. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11617. /**
  11618. * Creates a new SubEmitter from a serialized JSON version
  11619. * @param serializationObject defines the JSON object to read from
  11620. * @param scene defines the hosting scene
  11621. * @param rootUrl defines the rootUrl for data loading
  11622. * @returns a new SubEmitter
  11623. */
  11624. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11625. /** Release associated resources */
  11626. dispose(): void;
  11627. }
  11628. }
  11629. declare module BABYLON {
  11630. /** @hidden */
  11631. export var imageProcessingDeclaration: {
  11632. name: string;
  11633. shader: string;
  11634. };
  11635. }
  11636. declare module BABYLON {
  11637. /** @hidden */
  11638. export var imageProcessingFunctions: {
  11639. name: string;
  11640. shader: string;
  11641. };
  11642. }
  11643. declare module BABYLON {
  11644. /** @hidden */
  11645. export var particlesPixelShader: {
  11646. name: string;
  11647. shader: string;
  11648. };
  11649. }
  11650. declare module BABYLON {
  11651. /** @hidden */
  11652. export var particlesVertexShader: {
  11653. name: string;
  11654. shader: string;
  11655. };
  11656. }
  11657. declare module BABYLON {
  11658. /**
  11659. * This represents a particle system in Babylon.
  11660. * 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.
  11661. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11662. * @example https://doc.babylonjs.com/babylon101/particles
  11663. */
  11664. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11665. /**
  11666. * Billboard mode will only apply to Y axis
  11667. */
  11668. static readonly BILLBOARDMODE_Y: number;
  11669. /**
  11670. * Billboard mode will apply to all axes
  11671. */
  11672. static readonly BILLBOARDMODE_ALL: number;
  11673. /**
  11674. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11675. */
  11676. static readonly BILLBOARDMODE_STRETCHED: number;
  11677. /**
  11678. * This function can be defined to provide custom update for active particles.
  11679. * This function will be called instead of regular update (age, position, color, etc.).
  11680. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11681. */
  11682. updateFunction: (particles: Particle[]) => void;
  11683. private _emitterWorldMatrix;
  11684. /**
  11685. * This function can be defined to specify initial direction for every new particle.
  11686. * It by default use the emitterType defined function
  11687. */
  11688. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11689. /**
  11690. * This function can be defined to specify initial position for every new particle.
  11691. * It by default use the emitterType defined function
  11692. */
  11693. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11694. /**
  11695. * @hidden
  11696. */
  11697. _inheritedVelocityOffset: Vector3;
  11698. /**
  11699. * An event triggered when the system is disposed
  11700. */
  11701. onDisposeObservable: Observable<ParticleSystem>;
  11702. private _onDisposeObserver;
  11703. /**
  11704. * Sets a callback that will be triggered when the system is disposed
  11705. */
  11706. set onDispose(callback: () => void);
  11707. private _particles;
  11708. private _epsilon;
  11709. private _capacity;
  11710. private _stockParticles;
  11711. private _newPartsExcess;
  11712. private _vertexData;
  11713. private _vertexBuffer;
  11714. private _vertexBuffers;
  11715. private _spriteBuffer;
  11716. private _indexBuffer;
  11717. private _effect;
  11718. private _customEffect;
  11719. private _cachedDefines;
  11720. private _scaledColorStep;
  11721. private _colorDiff;
  11722. private _scaledDirection;
  11723. private _scaledGravity;
  11724. private _currentRenderId;
  11725. private _alive;
  11726. private _useInstancing;
  11727. private _started;
  11728. private _stopped;
  11729. private _actualFrame;
  11730. private _scaledUpdateSpeed;
  11731. private _vertexBufferSize;
  11732. /** @hidden */
  11733. _currentEmitRateGradient: Nullable<FactorGradient>;
  11734. /** @hidden */
  11735. _currentEmitRate1: number;
  11736. /** @hidden */
  11737. _currentEmitRate2: number;
  11738. /** @hidden */
  11739. _currentStartSizeGradient: Nullable<FactorGradient>;
  11740. /** @hidden */
  11741. _currentStartSize1: number;
  11742. /** @hidden */
  11743. _currentStartSize2: number;
  11744. private readonly _rawTextureWidth;
  11745. private _rampGradientsTexture;
  11746. private _useRampGradients;
  11747. /** Gets or sets a boolean indicating that ramp gradients must be used
  11748. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11749. */
  11750. get useRampGradients(): boolean;
  11751. set useRampGradients(value: boolean);
  11752. /**
  11753. * 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.
  11754. * 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: [])
  11755. */
  11756. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11757. private _subEmitters;
  11758. /**
  11759. * @hidden
  11760. * If the particle systems emitter should be disposed when the particle system is disposed
  11761. */
  11762. _disposeEmitterOnDispose: boolean;
  11763. /**
  11764. * The current active Sub-systems, this property is used by the root particle system only.
  11765. */
  11766. activeSubSystems: Array<ParticleSystem>;
  11767. /**
  11768. * Specifies if the particles are updated in emitter local space or world space
  11769. */
  11770. isLocal: boolean;
  11771. private _rootParticleSystem;
  11772. /**
  11773. * Gets the current list of active particles
  11774. */
  11775. get particles(): Particle[];
  11776. /**
  11777. * Gets the number of particles active at the same time.
  11778. * @returns The number of active particles.
  11779. */
  11780. getActiveCount(): number;
  11781. /**
  11782. * Returns the string "ParticleSystem"
  11783. * @returns a string containing the class name
  11784. */
  11785. getClassName(): string;
  11786. /**
  11787. * Gets a boolean indicating that the system is stopping
  11788. * @returns true if the system is currently stopping
  11789. */
  11790. isStopping(): boolean;
  11791. /**
  11792. * Instantiates a particle system.
  11793. * 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.
  11794. * @param name The name of the particle system
  11795. * @param capacity The max number of particles alive at the same time
  11796. * @param scene The scene the particle system belongs to
  11797. * @param customEffect a custom effect used to change the way particles are rendered by default
  11798. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11799. * @param epsilon Offset used to render the particles
  11800. */
  11801. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11802. private _addFactorGradient;
  11803. private _removeFactorGradient;
  11804. /**
  11805. * Adds a new life time gradient
  11806. * @param gradient defines the gradient to use (between 0 and 1)
  11807. * @param factor defines the life time factor to affect to the specified gradient
  11808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11809. * @returns the current particle system
  11810. */
  11811. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11812. /**
  11813. * Remove a specific life time gradient
  11814. * @param gradient defines the gradient to remove
  11815. * @returns the current particle system
  11816. */
  11817. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11818. /**
  11819. * Adds a new size gradient
  11820. * @param gradient defines the gradient to use (between 0 and 1)
  11821. * @param factor defines the size factor to affect to the specified gradient
  11822. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11823. * @returns the current particle system
  11824. */
  11825. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11826. /**
  11827. * Remove a specific size gradient
  11828. * @param gradient defines the gradient to remove
  11829. * @returns the current particle system
  11830. */
  11831. removeSizeGradient(gradient: number): IParticleSystem;
  11832. /**
  11833. * Adds a new color remap gradient
  11834. * @param gradient defines the gradient to use (between 0 and 1)
  11835. * @param min defines the color remap minimal range
  11836. * @param max defines the color remap maximal range
  11837. * @returns the current particle system
  11838. */
  11839. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11840. /**
  11841. * Remove a specific color remap gradient
  11842. * @param gradient defines the gradient to remove
  11843. * @returns the current particle system
  11844. */
  11845. removeColorRemapGradient(gradient: number): IParticleSystem;
  11846. /**
  11847. * Adds a new alpha remap gradient
  11848. * @param gradient defines the gradient to use (between 0 and 1)
  11849. * @param min defines the alpha remap minimal range
  11850. * @param max defines the alpha remap maximal range
  11851. * @returns the current particle system
  11852. */
  11853. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11854. /**
  11855. * Remove a specific alpha remap gradient
  11856. * @param gradient defines the gradient to remove
  11857. * @returns the current particle system
  11858. */
  11859. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11860. /**
  11861. * Adds a new angular speed gradient
  11862. * @param gradient defines the gradient to use (between 0 and 1)
  11863. * @param factor defines the angular speed to affect to the specified gradient
  11864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11865. * @returns the current particle system
  11866. */
  11867. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11868. /**
  11869. * Remove a specific angular speed gradient
  11870. * @param gradient defines the gradient to remove
  11871. * @returns the current particle system
  11872. */
  11873. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11874. /**
  11875. * Adds a new velocity gradient
  11876. * @param gradient defines the gradient to use (between 0 and 1)
  11877. * @param factor defines the velocity to affect to the specified gradient
  11878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11879. * @returns the current particle system
  11880. */
  11881. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11882. /**
  11883. * Remove a specific velocity gradient
  11884. * @param gradient defines the gradient to remove
  11885. * @returns the current particle system
  11886. */
  11887. removeVelocityGradient(gradient: number): IParticleSystem;
  11888. /**
  11889. * Adds a new limit velocity gradient
  11890. * @param gradient defines the gradient to use (between 0 and 1)
  11891. * @param factor defines the limit velocity value to affect to the specified gradient
  11892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11893. * @returns the current particle system
  11894. */
  11895. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11896. /**
  11897. * Remove a specific limit velocity gradient
  11898. * @param gradient defines the gradient to remove
  11899. * @returns the current particle system
  11900. */
  11901. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11902. /**
  11903. * Adds a new drag gradient
  11904. * @param gradient defines the gradient to use (between 0 and 1)
  11905. * @param factor defines the drag value to affect to the specified gradient
  11906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11907. * @returns the current particle system
  11908. */
  11909. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11910. /**
  11911. * Remove a specific drag gradient
  11912. * @param gradient defines the gradient to remove
  11913. * @returns the current particle system
  11914. */
  11915. removeDragGradient(gradient: number): IParticleSystem;
  11916. /**
  11917. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11918. * @param gradient defines the gradient to use (between 0 and 1)
  11919. * @param factor defines the emit rate value to affect to the specified gradient
  11920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11921. * @returns the current particle system
  11922. */
  11923. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11924. /**
  11925. * Remove a specific emit rate gradient
  11926. * @param gradient defines the gradient to remove
  11927. * @returns the current particle system
  11928. */
  11929. removeEmitRateGradient(gradient: number): IParticleSystem;
  11930. /**
  11931. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11932. * @param gradient defines the gradient to use (between 0 and 1)
  11933. * @param factor defines the start size value to affect to the specified gradient
  11934. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11935. * @returns the current particle system
  11936. */
  11937. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11938. /**
  11939. * Remove a specific start size gradient
  11940. * @param gradient defines the gradient to remove
  11941. * @returns the current particle system
  11942. */
  11943. removeStartSizeGradient(gradient: number): IParticleSystem;
  11944. private _createRampGradientTexture;
  11945. /**
  11946. * Gets the current list of ramp gradients.
  11947. * You must use addRampGradient and removeRampGradient to udpate this list
  11948. * @returns the list of ramp gradients
  11949. */
  11950. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11951. /** Force the system to rebuild all gradients that need to be resync */
  11952. forceRefreshGradients(): void;
  11953. private _syncRampGradientTexture;
  11954. /**
  11955. * Adds a new ramp gradient used to remap particle colors
  11956. * @param gradient defines the gradient to use (between 0 and 1)
  11957. * @param color defines the color to affect to the specified gradient
  11958. * @returns the current particle system
  11959. */
  11960. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11961. /**
  11962. * Remove a specific ramp gradient
  11963. * @param gradient defines the gradient to remove
  11964. * @returns the current particle system
  11965. */
  11966. removeRampGradient(gradient: number): ParticleSystem;
  11967. /**
  11968. * Adds a new color gradient
  11969. * @param gradient defines the gradient to use (between 0 and 1)
  11970. * @param color1 defines the color to affect to the specified gradient
  11971. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11972. * @returns this particle system
  11973. */
  11974. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11975. /**
  11976. * Remove a specific color gradient
  11977. * @param gradient defines the gradient to remove
  11978. * @returns this particle system
  11979. */
  11980. removeColorGradient(gradient: number): IParticleSystem;
  11981. private _fetchR;
  11982. protected _reset(): void;
  11983. private _resetEffect;
  11984. private _createVertexBuffers;
  11985. private _createIndexBuffer;
  11986. /**
  11987. * Gets the maximum number of particles active at the same time.
  11988. * @returns The max number of active particles.
  11989. */
  11990. getCapacity(): number;
  11991. /**
  11992. * Gets whether there are still active particles in the system.
  11993. * @returns True if it is alive, otherwise false.
  11994. */
  11995. isAlive(): boolean;
  11996. /**
  11997. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11998. * @returns True if it has been started, otherwise false.
  11999. */
  12000. isStarted(): boolean;
  12001. private _prepareSubEmitterInternalArray;
  12002. /**
  12003. * Starts the particle system and begins to emit
  12004. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12005. */
  12006. start(delay?: number): void;
  12007. /**
  12008. * Stops the particle system.
  12009. * @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.
  12010. */
  12011. stop(stopSubEmitters?: boolean): void;
  12012. /**
  12013. * Remove all active particles
  12014. */
  12015. reset(): void;
  12016. /**
  12017. * @hidden (for internal use only)
  12018. */
  12019. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12020. /**
  12021. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12022. * Its lifetime will start back at 0.
  12023. */
  12024. recycleParticle: (particle: Particle) => void;
  12025. private _stopSubEmitters;
  12026. private _createParticle;
  12027. private _removeFromRoot;
  12028. private _emitFromParticle;
  12029. private _update;
  12030. /** @hidden */
  12031. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12032. /** @hidden */
  12033. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12034. /** @hidden */
  12035. private _getEffect;
  12036. /**
  12037. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12038. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12039. */
  12040. animate(preWarmOnly?: boolean): void;
  12041. private _appendParticleVertices;
  12042. /**
  12043. * Rebuilds the particle system.
  12044. */
  12045. rebuild(): void;
  12046. /**
  12047. * Is this system ready to be used/rendered
  12048. * @return true if the system is ready
  12049. */
  12050. isReady(): boolean;
  12051. private _render;
  12052. /**
  12053. * Renders the particle system in its current state.
  12054. * @returns the current number of particles
  12055. */
  12056. render(): number;
  12057. /**
  12058. * Disposes the particle system and free the associated resources
  12059. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12060. */
  12061. dispose(disposeTexture?: boolean): void;
  12062. /**
  12063. * Clones the particle system.
  12064. * @param name The name of the cloned object
  12065. * @param newEmitter The new emitter to use
  12066. * @returns the cloned particle system
  12067. */
  12068. clone(name: string, newEmitter: any): ParticleSystem;
  12069. /**
  12070. * Serializes the particle system to a JSON object
  12071. * @param serializeTexture defines if the texture must be serialized as well
  12072. * @returns the JSON object
  12073. */
  12074. serialize(serializeTexture?: boolean): any;
  12075. /** @hidden */
  12076. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12077. /** @hidden */
  12078. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12079. /**
  12080. * Parses a JSON object to create a particle system.
  12081. * @param parsedParticleSystem The JSON object to parse
  12082. * @param scene The scene to create the particle system in
  12083. * @param rootUrl The root url to use to load external dependencies like texture
  12084. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12085. * @returns the Parsed particle system
  12086. */
  12087. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12088. }
  12089. }
  12090. declare module BABYLON {
  12091. /**
  12092. * A particle represents one of the element emitted by a particle system.
  12093. * This is mainly define by its coordinates, direction, velocity and age.
  12094. */
  12095. export class Particle {
  12096. /**
  12097. * The particle system the particle belongs to.
  12098. */
  12099. particleSystem: ParticleSystem;
  12100. private static _Count;
  12101. /**
  12102. * Unique ID of the particle
  12103. */
  12104. id: number;
  12105. /**
  12106. * The world position of the particle in the scene.
  12107. */
  12108. position: Vector3;
  12109. /**
  12110. * The world direction of the particle in the scene.
  12111. */
  12112. direction: Vector3;
  12113. /**
  12114. * The color of the particle.
  12115. */
  12116. color: Color4;
  12117. /**
  12118. * The color change of the particle per step.
  12119. */
  12120. colorStep: Color4;
  12121. /**
  12122. * Defines how long will the life of the particle be.
  12123. */
  12124. lifeTime: number;
  12125. /**
  12126. * The current age of the particle.
  12127. */
  12128. age: number;
  12129. /**
  12130. * The current size of the particle.
  12131. */
  12132. size: number;
  12133. /**
  12134. * The current scale of the particle.
  12135. */
  12136. scale: Vector2;
  12137. /**
  12138. * The current angle of the particle.
  12139. */
  12140. angle: number;
  12141. /**
  12142. * Defines how fast is the angle changing.
  12143. */
  12144. angularSpeed: number;
  12145. /**
  12146. * Defines the cell index used by the particle to be rendered from a sprite.
  12147. */
  12148. cellIndex: number;
  12149. /**
  12150. * The information required to support color remapping
  12151. */
  12152. remapData: Vector4;
  12153. /** @hidden */
  12154. _randomCellOffset?: number;
  12155. /** @hidden */
  12156. _initialDirection: Nullable<Vector3>;
  12157. /** @hidden */
  12158. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12159. /** @hidden */
  12160. _initialStartSpriteCellID: number;
  12161. /** @hidden */
  12162. _initialEndSpriteCellID: number;
  12163. /** @hidden */
  12164. _currentColorGradient: Nullable<ColorGradient>;
  12165. /** @hidden */
  12166. _currentColor1: Color4;
  12167. /** @hidden */
  12168. _currentColor2: Color4;
  12169. /** @hidden */
  12170. _currentSizeGradient: Nullable<FactorGradient>;
  12171. /** @hidden */
  12172. _currentSize1: number;
  12173. /** @hidden */
  12174. _currentSize2: number;
  12175. /** @hidden */
  12176. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12177. /** @hidden */
  12178. _currentAngularSpeed1: number;
  12179. /** @hidden */
  12180. _currentAngularSpeed2: number;
  12181. /** @hidden */
  12182. _currentVelocityGradient: Nullable<FactorGradient>;
  12183. /** @hidden */
  12184. _currentVelocity1: number;
  12185. /** @hidden */
  12186. _currentVelocity2: number;
  12187. /** @hidden */
  12188. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12189. /** @hidden */
  12190. _currentLimitVelocity1: number;
  12191. /** @hidden */
  12192. _currentLimitVelocity2: number;
  12193. /** @hidden */
  12194. _currentDragGradient: Nullable<FactorGradient>;
  12195. /** @hidden */
  12196. _currentDrag1: number;
  12197. /** @hidden */
  12198. _currentDrag2: number;
  12199. /** @hidden */
  12200. _randomNoiseCoordinates1: Vector3;
  12201. /** @hidden */
  12202. _randomNoiseCoordinates2: Vector3;
  12203. /** @hidden */
  12204. _localPosition?: Vector3;
  12205. /**
  12206. * Creates a new instance Particle
  12207. * @param particleSystem the particle system the particle belongs to
  12208. */
  12209. constructor(
  12210. /**
  12211. * The particle system the particle belongs to.
  12212. */
  12213. particleSystem: ParticleSystem);
  12214. private updateCellInfoFromSystem;
  12215. /**
  12216. * Defines how the sprite cell index is updated for the particle
  12217. */
  12218. updateCellIndex(): void;
  12219. /** @hidden */
  12220. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12221. /** @hidden */
  12222. _inheritParticleInfoToSubEmitters(): void;
  12223. /** @hidden */
  12224. _reset(): void;
  12225. /**
  12226. * Copy the properties of particle to another one.
  12227. * @param other the particle to copy the information to.
  12228. */
  12229. copyTo(other: Particle): void;
  12230. }
  12231. }
  12232. declare module BABYLON {
  12233. /**
  12234. * Particle emitter represents a volume emitting particles.
  12235. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12236. */
  12237. export interface IParticleEmitterType {
  12238. /**
  12239. * Called by the particle System when the direction is computed for the created particle.
  12240. * @param worldMatrix is the world matrix of the particle system
  12241. * @param directionToUpdate is the direction vector to update with the result
  12242. * @param particle is the particle we are computed the direction for
  12243. * @param isLocal defines if the direction should be set in local space
  12244. */
  12245. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12246. /**
  12247. * Called by the particle System when the position is computed for the created particle.
  12248. * @param worldMatrix is the world matrix of the particle system
  12249. * @param positionToUpdate is the position vector to update with the result
  12250. * @param particle is the particle we are computed the position for
  12251. * @param isLocal defines if the position should be set in local space
  12252. */
  12253. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12254. /**
  12255. * Clones the current emitter and returns a copy of it
  12256. * @returns the new emitter
  12257. */
  12258. clone(): IParticleEmitterType;
  12259. /**
  12260. * Called by the GPUParticleSystem to setup the update shader
  12261. * @param effect defines the update shader
  12262. */
  12263. applyToShader(effect: Effect): void;
  12264. /**
  12265. * Returns a string to use to update the GPU particles update shader
  12266. * @returns the effect defines string
  12267. */
  12268. getEffectDefines(): string;
  12269. /**
  12270. * Returns a string representing the class name
  12271. * @returns a string containing the class name
  12272. */
  12273. getClassName(): string;
  12274. /**
  12275. * Serializes the particle system to a JSON object.
  12276. * @returns the JSON object
  12277. */
  12278. serialize(): any;
  12279. /**
  12280. * Parse properties from a JSON object
  12281. * @param serializationObject defines the JSON object
  12282. * @param scene defines the hosting scene
  12283. */
  12284. parse(serializationObject: any, scene: Scene): void;
  12285. }
  12286. }
  12287. declare module BABYLON {
  12288. /**
  12289. * Particle emitter emitting particles from the inside of a box.
  12290. * It emits the particles randomly between 2 given directions.
  12291. */
  12292. export class BoxParticleEmitter implements IParticleEmitterType {
  12293. /**
  12294. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12295. */
  12296. direction1: Vector3;
  12297. /**
  12298. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12299. */
  12300. direction2: Vector3;
  12301. /**
  12302. * 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.
  12303. */
  12304. minEmitBox: Vector3;
  12305. /**
  12306. * 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.
  12307. */
  12308. maxEmitBox: Vector3;
  12309. /**
  12310. * Creates a new instance BoxParticleEmitter
  12311. */
  12312. constructor();
  12313. /**
  12314. * Called by the particle System when the direction is computed for the created particle.
  12315. * @param worldMatrix is the world matrix of the particle system
  12316. * @param directionToUpdate is the direction vector to update with the result
  12317. * @param particle is the particle we are computed the direction for
  12318. * @param isLocal defines if the direction should be set in local space
  12319. */
  12320. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12321. /**
  12322. * Called by the particle System when the position is computed for the created particle.
  12323. * @param worldMatrix is the world matrix of the particle system
  12324. * @param positionToUpdate is the position vector to update with the result
  12325. * @param particle is the particle we are computed the position for
  12326. * @param isLocal defines if the position should be set in local space
  12327. */
  12328. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12329. /**
  12330. * Clones the current emitter and returns a copy of it
  12331. * @returns the new emitter
  12332. */
  12333. clone(): BoxParticleEmitter;
  12334. /**
  12335. * Called by the GPUParticleSystem to setup the update shader
  12336. * @param effect defines the update shader
  12337. */
  12338. applyToShader(effect: Effect): void;
  12339. /**
  12340. * Returns a string to use to update the GPU particles update shader
  12341. * @returns a string containng the defines string
  12342. */
  12343. getEffectDefines(): string;
  12344. /**
  12345. * Returns the string "BoxParticleEmitter"
  12346. * @returns a string containing the class name
  12347. */
  12348. getClassName(): string;
  12349. /**
  12350. * Serializes the particle system to a JSON object.
  12351. * @returns the JSON object
  12352. */
  12353. serialize(): any;
  12354. /**
  12355. * Parse properties from a JSON object
  12356. * @param serializationObject defines the JSON object
  12357. */
  12358. parse(serializationObject: any): void;
  12359. }
  12360. }
  12361. declare module BABYLON {
  12362. /**
  12363. * Particle emitter emitting particles from the inside of a cone.
  12364. * It emits the particles alongside the cone volume from the base to the particle.
  12365. * The emission direction might be randomized.
  12366. */
  12367. export class ConeParticleEmitter implements IParticleEmitterType {
  12368. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12369. directionRandomizer: number;
  12370. private _radius;
  12371. private _angle;
  12372. private _height;
  12373. /**
  12374. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12375. */
  12376. radiusRange: number;
  12377. /**
  12378. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12379. */
  12380. heightRange: number;
  12381. /**
  12382. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12383. */
  12384. emitFromSpawnPointOnly: boolean;
  12385. /**
  12386. * Gets or sets the radius of the emission cone
  12387. */
  12388. get radius(): number;
  12389. set radius(value: number);
  12390. /**
  12391. * Gets or sets the angle of the emission cone
  12392. */
  12393. get angle(): number;
  12394. set angle(value: number);
  12395. private _buildHeight;
  12396. /**
  12397. * Creates a new instance ConeParticleEmitter
  12398. * @param radius the radius of the emission cone (1 by default)
  12399. * @param angle the cone base angle (PI by default)
  12400. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12401. */
  12402. constructor(radius?: number, angle?: number,
  12403. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12404. directionRandomizer?: number);
  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. * @param isLocal defines if the direction should be set in local space
  12411. */
  12412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12413. /**
  12414. * Called by the particle System when the position is computed for the created particle.
  12415. * @param worldMatrix is the world matrix of the particle system
  12416. * @param positionToUpdate is the position vector to update with the result
  12417. * @param particle is the particle we are computed the position for
  12418. * @param isLocal defines if the position should be set in local space
  12419. */
  12420. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12421. /**
  12422. * Clones the current emitter and returns a copy of it
  12423. * @returns the new emitter
  12424. */
  12425. clone(): ConeParticleEmitter;
  12426. /**
  12427. * Called by the GPUParticleSystem to setup the update shader
  12428. * @param effect defines the update shader
  12429. */
  12430. applyToShader(effect: Effect): void;
  12431. /**
  12432. * Returns a string to use to update the GPU particles update shader
  12433. * @returns a string containng the defines string
  12434. */
  12435. getEffectDefines(): string;
  12436. /**
  12437. * Returns the string "ConeParticleEmitter"
  12438. * @returns a string containing the class name
  12439. */
  12440. getClassName(): string;
  12441. /**
  12442. * Serializes the particle system to a JSON object.
  12443. * @returns the JSON object
  12444. */
  12445. serialize(): any;
  12446. /**
  12447. * Parse properties from a JSON object
  12448. * @param serializationObject defines the JSON object
  12449. */
  12450. parse(serializationObject: any): void;
  12451. }
  12452. }
  12453. declare module BABYLON {
  12454. /**
  12455. * Particle emitter emitting particles from the inside of a cylinder.
  12456. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12457. */
  12458. export class CylinderParticleEmitter implements IParticleEmitterType {
  12459. /**
  12460. * The radius of the emission cylinder.
  12461. */
  12462. radius: number;
  12463. /**
  12464. * The height of the emission cylinder.
  12465. */
  12466. height: number;
  12467. /**
  12468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12469. */
  12470. radiusRange: number;
  12471. /**
  12472. * How much to randomize the particle direction [0-1].
  12473. */
  12474. directionRandomizer: number;
  12475. /**
  12476. * Creates a new instance CylinderParticleEmitter
  12477. * @param radius the radius of the emission cylinder (1 by default)
  12478. * @param height the height of the emission cylinder (1 by default)
  12479. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12480. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12481. */
  12482. constructor(
  12483. /**
  12484. * The radius of the emission cylinder.
  12485. */
  12486. radius?: number,
  12487. /**
  12488. * The height of the emission cylinder.
  12489. */
  12490. height?: number,
  12491. /**
  12492. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12493. */
  12494. radiusRange?: number,
  12495. /**
  12496. * How much to randomize the particle direction [0-1].
  12497. */
  12498. directionRandomizer?: number);
  12499. /**
  12500. * Called by the particle System when the direction is computed for the created particle.
  12501. * @param worldMatrix is the world matrix of the particle system
  12502. * @param directionToUpdate is the direction vector to update with the result
  12503. * @param particle is the particle we are computed the direction for
  12504. * @param isLocal defines if the direction should be set in local space
  12505. */
  12506. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12507. /**
  12508. * Called by the particle System when the position is computed for the created particle.
  12509. * @param worldMatrix is the world matrix of the particle system
  12510. * @param positionToUpdate is the position vector to update with the result
  12511. * @param particle is the particle we are computed the position for
  12512. * @param isLocal defines if the position should be set in local space
  12513. */
  12514. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12515. /**
  12516. * Clones the current emitter and returns a copy of it
  12517. * @returns the new emitter
  12518. */
  12519. clone(): CylinderParticleEmitter;
  12520. /**
  12521. * Called by the GPUParticleSystem to setup the update shader
  12522. * @param effect defines the update shader
  12523. */
  12524. applyToShader(effect: Effect): void;
  12525. /**
  12526. * Returns a string to use to update the GPU particles update shader
  12527. * @returns a string containng the defines string
  12528. */
  12529. getEffectDefines(): string;
  12530. /**
  12531. * Returns the string "CylinderParticleEmitter"
  12532. * @returns a string containing the class name
  12533. */
  12534. getClassName(): string;
  12535. /**
  12536. * Serializes the particle system to a JSON object.
  12537. * @returns the JSON object
  12538. */
  12539. serialize(): any;
  12540. /**
  12541. * Parse properties from a JSON object
  12542. * @param serializationObject defines the JSON object
  12543. */
  12544. parse(serializationObject: any): void;
  12545. }
  12546. /**
  12547. * Particle emitter emitting particles from the inside of a cylinder.
  12548. * It emits the particles randomly between two vectors.
  12549. */
  12550. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12551. /**
  12552. * The min limit of the emission direction.
  12553. */
  12554. direction1: Vector3;
  12555. /**
  12556. * The max limit of the emission direction.
  12557. */
  12558. direction2: Vector3;
  12559. /**
  12560. * Creates a new instance CylinderDirectedParticleEmitter
  12561. * @param radius the radius of the emission cylinder (1 by default)
  12562. * @param height the height of the emission cylinder (1 by default)
  12563. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12564. * @param direction1 the min limit of the emission direction (up vector by default)
  12565. * @param direction2 the max limit of the emission direction (up vector by default)
  12566. */
  12567. constructor(radius?: number, height?: number, radiusRange?: number,
  12568. /**
  12569. * The min limit of the emission direction.
  12570. */
  12571. direction1?: Vector3,
  12572. /**
  12573. * The max limit of the emission direction.
  12574. */
  12575. direction2?: Vector3);
  12576. /**
  12577. * Called by the particle System when the direction is computed for the created particle.
  12578. * @param worldMatrix is the world matrix of the particle system
  12579. * @param directionToUpdate is the direction vector to update with the result
  12580. * @param particle is the particle we are computed the direction for
  12581. */
  12582. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12583. /**
  12584. * Clones the current emitter and returns a copy of it
  12585. * @returns the new emitter
  12586. */
  12587. clone(): CylinderDirectedParticleEmitter;
  12588. /**
  12589. * Called by the GPUParticleSystem to setup the update shader
  12590. * @param effect defines the update shader
  12591. */
  12592. applyToShader(effect: Effect): void;
  12593. /**
  12594. * Returns a string to use to update the GPU particles update shader
  12595. * @returns a string containng the defines string
  12596. */
  12597. getEffectDefines(): string;
  12598. /**
  12599. * Returns the string "CylinderDirectedParticleEmitter"
  12600. * @returns a string containing the class name
  12601. */
  12602. getClassName(): string;
  12603. /**
  12604. * Serializes the particle system to a JSON object.
  12605. * @returns the JSON object
  12606. */
  12607. serialize(): any;
  12608. /**
  12609. * Parse properties from a JSON object
  12610. * @param serializationObject defines the JSON object
  12611. */
  12612. parse(serializationObject: any): void;
  12613. }
  12614. }
  12615. declare module BABYLON {
  12616. /**
  12617. * Particle emitter emitting particles from the inside of a hemisphere.
  12618. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12619. */
  12620. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12621. /**
  12622. * The radius of the emission hemisphere.
  12623. */
  12624. radius: number;
  12625. /**
  12626. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12627. */
  12628. radiusRange: number;
  12629. /**
  12630. * How much to randomize the particle direction [0-1].
  12631. */
  12632. directionRandomizer: number;
  12633. /**
  12634. * Creates a new instance HemisphericParticleEmitter
  12635. * @param radius the radius of the emission hemisphere (1 by default)
  12636. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12637. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12638. */
  12639. constructor(
  12640. /**
  12641. * The radius of the emission hemisphere.
  12642. */
  12643. radius?: number,
  12644. /**
  12645. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12646. */
  12647. radiusRange?: number,
  12648. /**
  12649. * How much to randomize the particle direction [0-1].
  12650. */
  12651. directionRandomizer?: number);
  12652. /**
  12653. * Called by the particle System when the direction is computed for the created particle.
  12654. * @param worldMatrix is the world matrix of the particle system
  12655. * @param directionToUpdate is the direction vector to update with the result
  12656. * @param particle is the particle we are computed the direction for
  12657. * @param isLocal defines if the direction should be set in local space
  12658. */
  12659. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12660. /**
  12661. * Called by the particle System when the position is computed for the created particle.
  12662. * @param worldMatrix is the world matrix of the particle system
  12663. * @param positionToUpdate is the position vector to update with the result
  12664. * @param particle is the particle we are computed the position for
  12665. * @param isLocal defines if the position should be set in local space
  12666. */
  12667. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12668. /**
  12669. * Clones the current emitter and returns a copy of it
  12670. * @returns the new emitter
  12671. */
  12672. clone(): HemisphericParticleEmitter;
  12673. /**
  12674. * Called by the GPUParticleSystem to setup the update shader
  12675. * @param effect defines the update shader
  12676. */
  12677. applyToShader(effect: Effect): void;
  12678. /**
  12679. * Returns a string to use to update the GPU particles update shader
  12680. * @returns a string containng the defines string
  12681. */
  12682. getEffectDefines(): string;
  12683. /**
  12684. * Returns the string "HemisphericParticleEmitter"
  12685. * @returns a string containing the class name
  12686. */
  12687. getClassName(): string;
  12688. /**
  12689. * Serializes the particle system to a JSON object.
  12690. * @returns the JSON object
  12691. */
  12692. serialize(): any;
  12693. /**
  12694. * Parse properties from a JSON object
  12695. * @param serializationObject defines the JSON object
  12696. */
  12697. parse(serializationObject: any): void;
  12698. }
  12699. }
  12700. declare module BABYLON {
  12701. /**
  12702. * Particle emitter emitting particles from a point.
  12703. * It emits the particles randomly between 2 given directions.
  12704. */
  12705. export class PointParticleEmitter implements IParticleEmitterType {
  12706. /**
  12707. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12708. */
  12709. direction1: Vector3;
  12710. /**
  12711. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12712. */
  12713. direction2: Vector3;
  12714. /**
  12715. * Creates a new instance PointParticleEmitter
  12716. */
  12717. constructor();
  12718. /**
  12719. * Called by the particle System when the direction is computed for the created particle.
  12720. * @param worldMatrix is the world matrix of the particle system
  12721. * @param directionToUpdate is the direction vector to update with the result
  12722. * @param particle is the particle we are computed the direction for
  12723. * @param isLocal defines if the direction should be set in local space
  12724. */
  12725. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12726. /**
  12727. * Called by the particle System when the position is computed for the created particle.
  12728. * @param worldMatrix is the world matrix of the particle system
  12729. * @param positionToUpdate is the position vector to update with the result
  12730. * @param particle is the particle we are computed the position for
  12731. * @param isLocal defines if the position should be set in local space
  12732. */
  12733. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12734. /**
  12735. * Clones the current emitter and returns a copy of it
  12736. * @returns the new emitter
  12737. */
  12738. clone(): PointParticleEmitter;
  12739. /**
  12740. * Called by the GPUParticleSystem to setup the update shader
  12741. * @param effect defines the update shader
  12742. */
  12743. applyToShader(effect: Effect): void;
  12744. /**
  12745. * Returns a string to use to update the GPU particles update shader
  12746. * @returns a string containng the defines string
  12747. */
  12748. getEffectDefines(): string;
  12749. /**
  12750. * Returns the string "PointParticleEmitter"
  12751. * @returns a string containing the class name
  12752. */
  12753. getClassName(): string;
  12754. /**
  12755. * Serializes the particle system to a JSON object.
  12756. * @returns the JSON object
  12757. */
  12758. serialize(): any;
  12759. /**
  12760. * Parse properties from a JSON object
  12761. * @param serializationObject defines the JSON object
  12762. */
  12763. parse(serializationObject: any): void;
  12764. }
  12765. }
  12766. declare module BABYLON {
  12767. /**
  12768. * Particle emitter emitting particles from the inside of a sphere.
  12769. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12770. */
  12771. export class SphereParticleEmitter implements IParticleEmitterType {
  12772. /**
  12773. * The radius of the emission sphere.
  12774. */
  12775. radius: number;
  12776. /**
  12777. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12778. */
  12779. radiusRange: number;
  12780. /**
  12781. * How much to randomize the particle direction [0-1].
  12782. */
  12783. directionRandomizer: number;
  12784. /**
  12785. * Creates a new instance SphereParticleEmitter
  12786. * @param radius the radius of the emission sphere (1 by default)
  12787. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12788. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12789. */
  12790. constructor(
  12791. /**
  12792. * The radius of the emission sphere.
  12793. */
  12794. radius?: number,
  12795. /**
  12796. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12797. */
  12798. radiusRange?: number,
  12799. /**
  12800. * How much to randomize the particle direction [0-1].
  12801. */
  12802. directionRandomizer?: number);
  12803. /**
  12804. * Called by the particle System when the direction is computed for the created particle.
  12805. * @param worldMatrix is the world matrix of the particle system
  12806. * @param directionToUpdate is the direction vector to update with the result
  12807. * @param particle is the particle we are computed the direction for
  12808. * @param isLocal defines if the direction should be set in local space
  12809. */
  12810. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12811. /**
  12812. * Called by the particle System when the position is computed for the created particle.
  12813. * @param worldMatrix is the world matrix of the particle system
  12814. * @param positionToUpdate is the position vector to update with the result
  12815. * @param particle is the particle we are computed the position for
  12816. * @param isLocal defines if the position should be set in local space
  12817. */
  12818. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12819. /**
  12820. * Clones the current emitter and returns a copy of it
  12821. * @returns the new emitter
  12822. */
  12823. clone(): SphereParticleEmitter;
  12824. /**
  12825. * Called by the GPUParticleSystem to setup the update shader
  12826. * @param effect defines the update shader
  12827. */
  12828. applyToShader(effect: Effect): void;
  12829. /**
  12830. * Returns a string to use to update the GPU particles update shader
  12831. * @returns a string containng the defines string
  12832. */
  12833. getEffectDefines(): string;
  12834. /**
  12835. * Returns the string "SphereParticleEmitter"
  12836. * @returns a string containing the class name
  12837. */
  12838. getClassName(): string;
  12839. /**
  12840. * Serializes the particle system to a JSON object.
  12841. * @returns the JSON object
  12842. */
  12843. serialize(): any;
  12844. /**
  12845. * Parse properties from a JSON object
  12846. * @param serializationObject defines the JSON object
  12847. */
  12848. parse(serializationObject: any): void;
  12849. }
  12850. /**
  12851. * Particle emitter emitting particles from the inside of a sphere.
  12852. * It emits the particles randomly between two vectors.
  12853. */
  12854. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12855. /**
  12856. * The min limit of the emission direction.
  12857. */
  12858. direction1: Vector3;
  12859. /**
  12860. * The max limit of the emission direction.
  12861. */
  12862. direction2: Vector3;
  12863. /**
  12864. * Creates a new instance SphereDirectedParticleEmitter
  12865. * @param radius the radius of the emission sphere (1 by default)
  12866. * @param direction1 the min limit of the emission direction (up vector by default)
  12867. * @param direction2 the max limit of the emission direction (up vector by default)
  12868. */
  12869. constructor(radius?: number,
  12870. /**
  12871. * The min limit of the emission direction.
  12872. */
  12873. direction1?: Vector3,
  12874. /**
  12875. * The max limit of the emission direction.
  12876. */
  12877. direction2?: Vector3);
  12878. /**
  12879. * Called by the particle System when the direction is computed for the created particle.
  12880. * @param worldMatrix is the world matrix of the particle system
  12881. * @param directionToUpdate is the direction vector to update with the result
  12882. * @param particle is the particle we are computed the direction for
  12883. */
  12884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12885. /**
  12886. * Clones the current emitter and returns a copy of it
  12887. * @returns the new emitter
  12888. */
  12889. clone(): SphereDirectedParticleEmitter;
  12890. /**
  12891. * Called by the GPUParticleSystem to setup the update shader
  12892. * @param effect defines the update shader
  12893. */
  12894. applyToShader(effect: Effect): void;
  12895. /**
  12896. * Returns a string to use to update the GPU particles update shader
  12897. * @returns a string containng the defines string
  12898. */
  12899. getEffectDefines(): string;
  12900. /**
  12901. * Returns the string "SphereDirectedParticleEmitter"
  12902. * @returns a string containing the class name
  12903. */
  12904. getClassName(): string;
  12905. /**
  12906. * Serializes the particle system to a JSON object.
  12907. * @returns the JSON object
  12908. */
  12909. serialize(): any;
  12910. /**
  12911. * Parse properties from a JSON object
  12912. * @param serializationObject defines the JSON object
  12913. */
  12914. parse(serializationObject: any): void;
  12915. }
  12916. }
  12917. declare module BABYLON {
  12918. /**
  12919. * Particle emitter emitting particles from a custom list of positions.
  12920. */
  12921. export class CustomParticleEmitter implements IParticleEmitterType {
  12922. /**
  12923. * Gets or sets the position generator that will create the inital position of each particle.
  12924. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12925. */
  12926. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12927. /**
  12928. * Gets or sets the destination generator that will create the final destination of each particle.
  12929. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12930. */
  12931. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12932. /**
  12933. * Creates a new instance CustomParticleEmitter
  12934. */
  12935. constructor();
  12936. /**
  12937. * Called by the particle System when the direction is computed for the created particle.
  12938. * @param worldMatrix is the world matrix of the particle system
  12939. * @param directionToUpdate is the direction vector to update with the result
  12940. * @param particle is the particle we are computed the direction for
  12941. * @param isLocal defines if the direction should be set in local space
  12942. */
  12943. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12944. /**
  12945. * Called by the particle System when the position is computed for the created particle.
  12946. * @param worldMatrix is the world matrix of the particle system
  12947. * @param positionToUpdate is the position vector to update with the result
  12948. * @param particle is the particle we are computed the position for
  12949. * @param isLocal defines if the position should be set in local space
  12950. */
  12951. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12952. /**
  12953. * Clones the current emitter and returns a copy of it
  12954. * @returns the new emitter
  12955. */
  12956. clone(): CustomParticleEmitter;
  12957. /**
  12958. * Called by the GPUParticleSystem to setup the update shader
  12959. * @param effect defines the update shader
  12960. */
  12961. applyToShader(effect: Effect): void;
  12962. /**
  12963. * Returns a string to use to update the GPU particles update shader
  12964. * @returns a string containng the defines string
  12965. */
  12966. getEffectDefines(): string;
  12967. /**
  12968. * Returns the string "PointParticleEmitter"
  12969. * @returns a string containing the class name
  12970. */
  12971. getClassName(): string;
  12972. /**
  12973. * Serializes the particle system to a JSON object.
  12974. * @returns the JSON object
  12975. */
  12976. serialize(): any;
  12977. /**
  12978. * Parse properties from a JSON object
  12979. * @param serializationObject defines the JSON object
  12980. */
  12981. parse(serializationObject: any): void;
  12982. }
  12983. }
  12984. declare module BABYLON {
  12985. /**
  12986. * Particle emitter emitting particles from the inside of a box.
  12987. * It emits the particles randomly between 2 given directions.
  12988. */
  12989. export class MeshParticleEmitter implements IParticleEmitterType {
  12990. private _indices;
  12991. private _positions;
  12992. private _normals;
  12993. private _storedNormal;
  12994. private _mesh;
  12995. /**
  12996. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12997. */
  12998. direction1: Vector3;
  12999. /**
  13000. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13001. */
  13002. direction2: Vector3;
  13003. /**
  13004. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13005. */
  13006. useMeshNormalsForDirection: boolean;
  13007. /** Defines the mesh to use as source */
  13008. get mesh(): Nullable<AbstractMesh>;
  13009. set mesh(value: Nullable<AbstractMesh>);
  13010. /**
  13011. * Creates a new instance MeshParticleEmitter
  13012. * @param mesh defines the mesh to use as source
  13013. */
  13014. constructor(mesh?: Nullable<AbstractMesh>);
  13015. /**
  13016. * Called by the particle System when the direction is computed for the created particle.
  13017. * @param worldMatrix is the world matrix of the particle system
  13018. * @param directionToUpdate is the direction vector to update with the result
  13019. * @param particle is the particle we are computed the direction for
  13020. * @param isLocal defines if the direction should be set in local space
  13021. */
  13022. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13023. /**
  13024. * Called by the particle System when the position is computed for the created particle.
  13025. * @param worldMatrix is the world matrix of the particle system
  13026. * @param positionToUpdate is the position vector to update with the result
  13027. * @param particle is the particle we are computed the position for
  13028. * @param isLocal defines if the position should be set in local space
  13029. */
  13030. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13031. /**
  13032. * Clones the current emitter and returns a copy of it
  13033. * @returns the new emitter
  13034. */
  13035. clone(): MeshParticleEmitter;
  13036. /**
  13037. * Called by the GPUParticleSystem to setup the update shader
  13038. * @param effect defines the update shader
  13039. */
  13040. applyToShader(effect: Effect): void;
  13041. /**
  13042. * Returns a string to use to update the GPU particles update shader
  13043. * @returns a string containng the defines string
  13044. */
  13045. getEffectDefines(): string;
  13046. /**
  13047. * Returns the string "BoxParticleEmitter"
  13048. * @returns a string containing the class name
  13049. */
  13050. getClassName(): string;
  13051. /**
  13052. * Serializes the particle system to a JSON object.
  13053. * @returns the JSON object
  13054. */
  13055. serialize(): any;
  13056. /**
  13057. * Parse properties from a JSON object
  13058. * @param serializationObject defines the JSON object
  13059. * @param scene defines the hosting scene
  13060. */
  13061. parse(serializationObject: any, scene: Scene): void;
  13062. }
  13063. }
  13064. declare module BABYLON {
  13065. /**
  13066. * Interface representing a particle system in Babylon.js.
  13067. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13068. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13069. */
  13070. export interface IParticleSystem {
  13071. /**
  13072. * List of animations used by the particle system.
  13073. */
  13074. animations: Animation[];
  13075. /**
  13076. * The id of the Particle system.
  13077. */
  13078. id: string;
  13079. /**
  13080. * The name of the Particle system.
  13081. */
  13082. name: string;
  13083. /**
  13084. * The emitter represents the Mesh or position we are attaching the particle system to.
  13085. */
  13086. emitter: Nullable<AbstractMesh | Vector3>;
  13087. /**
  13088. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13089. */
  13090. isBillboardBased: boolean;
  13091. /**
  13092. * The rendering group used by the Particle system to chose when to render.
  13093. */
  13094. renderingGroupId: number;
  13095. /**
  13096. * The layer mask we are rendering the particles through.
  13097. */
  13098. layerMask: number;
  13099. /**
  13100. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13101. */
  13102. updateSpeed: number;
  13103. /**
  13104. * The amount of time the particle system is running (depends of the overall update speed).
  13105. */
  13106. targetStopDuration: number;
  13107. /**
  13108. * The texture used to render each particle. (this can be a spritesheet)
  13109. */
  13110. particleTexture: Nullable<Texture>;
  13111. /**
  13112. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13113. */
  13114. blendMode: number;
  13115. /**
  13116. * Minimum life time of emitting particles.
  13117. */
  13118. minLifeTime: number;
  13119. /**
  13120. * Maximum life time of emitting particles.
  13121. */
  13122. maxLifeTime: number;
  13123. /**
  13124. * Minimum Size of emitting particles.
  13125. */
  13126. minSize: number;
  13127. /**
  13128. * Maximum Size of emitting particles.
  13129. */
  13130. maxSize: number;
  13131. /**
  13132. * Minimum scale of emitting particles on X axis.
  13133. */
  13134. minScaleX: number;
  13135. /**
  13136. * Maximum scale of emitting particles on X axis.
  13137. */
  13138. maxScaleX: number;
  13139. /**
  13140. * Minimum scale of emitting particles on Y axis.
  13141. */
  13142. minScaleY: number;
  13143. /**
  13144. * Maximum scale of emitting particles on Y axis.
  13145. */
  13146. maxScaleY: number;
  13147. /**
  13148. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13149. */
  13150. color1: Color4;
  13151. /**
  13152. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13153. */
  13154. color2: Color4;
  13155. /**
  13156. * Color the particle will have at the end of its lifetime.
  13157. */
  13158. colorDead: Color4;
  13159. /**
  13160. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13161. */
  13162. emitRate: number;
  13163. /**
  13164. * You can use gravity if you want to give an orientation to your particles.
  13165. */
  13166. gravity: Vector3;
  13167. /**
  13168. * Minimum power of emitting particles.
  13169. */
  13170. minEmitPower: number;
  13171. /**
  13172. * Maximum power of emitting particles.
  13173. */
  13174. maxEmitPower: number;
  13175. /**
  13176. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13177. */
  13178. minAngularSpeed: number;
  13179. /**
  13180. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13181. */
  13182. maxAngularSpeed: number;
  13183. /**
  13184. * Gets or sets the minimal initial rotation in radians.
  13185. */
  13186. minInitialRotation: number;
  13187. /**
  13188. * Gets or sets the maximal initial rotation in radians.
  13189. */
  13190. maxInitialRotation: number;
  13191. /**
  13192. * The particle emitter type defines the emitter used by the particle system.
  13193. * It can be for example box, sphere, or cone...
  13194. */
  13195. particleEmitterType: Nullable<IParticleEmitterType>;
  13196. /**
  13197. * Defines the delay in milliseconds before starting the system (0 by default)
  13198. */
  13199. startDelay: number;
  13200. /**
  13201. * 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
  13202. */
  13203. preWarmCycles: number;
  13204. /**
  13205. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13206. */
  13207. preWarmStepOffset: number;
  13208. /**
  13209. * 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)
  13210. */
  13211. spriteCellChangeSpeed: number;
  13212. /**
  13213. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13214. */
  13215. startSpriteCellID: number;
  13216. /**
  13217. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13218. */
  13219. endSpriteCellID: number;
  13220. /**
  13221. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13222. */
  13223. spriteCellWidth: number;
  13224. /**
  13225. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13226. */
  13227. spriteCellHeight: number;
  13228. /**
  13229. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13230. */
  13231. spriteRandomStartCell: boolean;
  13232. /**
  13233. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13234. */
  13235. isAnimationSheetEnabled: boolean;
  13236. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13237. translationPivot: Vector2;
  13238. /**
  13239. * Gets or sets a texture used to add random noise to particle positions
  13240. */
  13241. noiseTexture: Nullable<BaseTexture>;
  13242. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13243. noiseStrength: Vector3;
  13244. /**
  13245. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13246. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13247. */
  13248. billboardMode: number;
  13249. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13250. limitVelocityDamping: number;
  13251. /**
  13252. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13253. */
  13254. beginAnimationOnStart: boolean;
  13255. /**
  13256. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13257. */
  13258. beginAnimationFrom: number;
  13259. /**
  13260. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13261. */
  13262. beginAnimationTo: number;
  13263. /**
  13264. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13265. */
  13266. beginAnimationLoop: boolean;
  13267. /**
  13268. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13269. */
  13270. disposeOnStop: boolean;
  13271. /**
  13272. * Specifies if the particles are updated in emitter local space or world space
  13273. */
  13274. isLocal: boolean;
  13275. /** Snippet ID if the particle system was created from the snippet server */
  13276. snippetId: string;
  13277. /**
  13278. * Gets the maximum number of particles active at the same time.
  13279. * @returns The max number of active particles.
  13280. */
  13281. getCapacity(): number;
  13282. /**
  13283. * Gets the number of particles active at the same time.
  13284. * @returns The number of active particles.
  13285. */
  13286. getActiveCount(): number;
  13287. /**
  13288. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13289. * @returns True if it has been started, otherwise false.
  13290. */
  13291. isStarted(): boolean;
  13292. /**
  13293. * Animates the particle system for this frame.
  13294. */
  13295. animate(): void;
  13296. /**
  13297. * Renders the particle system in its current state.
  13298. * @returns the current number of particles
  13299. */
  13300. render(): number;
  13301. /**
  13302. * Dispose the particle system and frees its associated resources.
  13303. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13304. */
  13305. dispose(disposeTexture?: boolean): void;
  13306. /**
  13307. * Clones the particle system.
  13308. * @param name The name of the cloned object
  13309. * @param newEmitter The new emitter to use
  13310. * @returns the cloned particle system
  13311. */
  13312. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13313. /**
  13314. * Serializes the particle system to a JSON object
  13315. * @param serializeTexture defines if the texture must be serialized as well
  13316. * @returns the JSON object
  13317. */
  13318. serialize(serializeTexture: boolean): any;
  13319. /**
  13320. * Rebuild the particle system
  13321. */
  13322. rebuild(): void;
  13323. /** Force the system to rebuild all gradients that need to be resync */
  13324. forceRefreshGradients(): void;
  13325. /**
  13326. * Starts the particle system and begins to emit
  13327. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13328. */
  13329. start(delay?: number): void;
  13330. /**
  13331. * Stops the particle system.
  13332. */
  13333. stop(): void;
  13334. /**
  13335. * Remove all active particles
  13336. */
  13337. reset(): void;
  13338. /**
  13339. * Gets a boolean indicating that the system is stopping
  13340. * @returns true if the system is currently stopping
  13341. */
  13342. isStopping(): boolean;
  13343. /**
  13344. * Is this system ready to be used/rendered
  13345. * @return true if the system is ready
  13346. */
  13347. isReady(): boolean;
  13348. /**
  13349. * Returns the string "ParticleSystem"
  13350. * @returns a string containing the class name
  13351. */
  13352. getClassName(): string;
  13353. /**
  13354. * Adds a new color gradient
  13355. * @param gradient defines the gradient to use (between 0 and 1)
  13356. * @param color1 defines the color to affect to the specified gradient
  13357. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13358. * @returns the current particle system
  13359. */
  13360. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13361. /**
  13362. * Remove a specific color gradient
  13363. * @param gradient defines the gradient to remove
  13364. * @returns the current particle system
  13365. */
  13366. removeColorGradient(gradient: number): IParticleSystem;
  13367. /**
  13368. * Adds a new size gradient
  13369. * @param gradient defines the gradient to use (between 0 and 1)
  13370. * @param factor defines the size factor to affect to the specified gradient
  13371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13372. * @returns the current particle system
  13373. */
  13374. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13375. /**
  13376. * Remove a specific size gradient
  13377. * @param gradient defines the gradient to remove
  13378. * @returns the current particle system
  13379. */
  13380. removeSizeGradient(gradient: number): IParticleSystem;
  13381. /**
  13382. * Gets the current list of color gradients.
  13383. * You must use addColorGradient and removeColorGradient to udpate this list
  13384. * @returns the list of color gradients
  13385. */
  13386. getColorGradients(): Nullable<Array<ColorGradient>>;
  13387. /**
  13388. * Gets the current list of size gradients.
  13389. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13390. * @returns the list of size gradients
  13391. */
  13392. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13393. /**
  13394. * Gets the current list of angular speed gradients.
  13395. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13396. * @returns the list of angular speed gradients
  13397. */
  13398. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13399. /**
  13400. * Adds a new angular speed gradient
  13401. * @param gradient defines the gradient to use (between 0 and 1)
  13402. * @param factor defines the angular speed to affect to the specified gradient
  13403. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13404. * @returns the current particle system
  13405. */
  13406. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13407. /**
  13408. * Remove a specific angular speed gradient
  13409. * @param gradient defines the gradient to remove
  13410. * @returns the current particle system
  13411. */
  13412. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13413. /**
  13414. * Gets the current list of velocity gradients.
  13415. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13416. * @returns the list of velocity gradients
  13417. */
  13418. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13419. /**
  13420. * Adds a new velocity gradient
  13421. * @param gradient defines the gradient to use (between 0 and 1)
  13422. * @param factor defines the velocity to affect to the specified gradient
  13423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13424. * @returns the current particle system
  13425. */
  13426. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13427. /**
  13428. * Remove a specific velocity gradient
  13429. * @param gradient defines the gradient to remove
  13430. * @returns the current particle system
  13431. */
  13432. removeVelocityGradient(gradient: number): IParticleSystem;
  13433. /**
  13434. * Gets the current list of limit velocity gradients.
  13435. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13436. * @returns the list of limit velocity gradients
  13437. */
  13438. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13439. /**
  13440. * Adds a new limit velocity gradient
  13441. * @param gradient defines the gradient to use (between 0 and 1)
  13442. * @param factor defines the limit velocity to affect to the specified gradient
  13443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13444. * @returns the current particle system
  13445. */
  13446. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13447. /**
  13448. * Remove a specific limit velocity gradient
  13449. * @param gradient defines the gradient to remove
  13450. * @returns the current particle system
  13451. */
  13452. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13453. /**
  13454. * Adds a new drag gradient
  13455. * @param gradient defines the gradient to use (between 0 and 1)
  13456. * @param factor defines the drag to affect to the specified gradient
  13457. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13458. * @returns the current particle system
  13459. */
  13460. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13461. /**
  13462. * Remove a specific drag gradient
  13463. * @param gradient defines the gradient to remove
  13464. * @returns the current particle system
  13465. */
  13466. removeDragGradient(gradient: number): IParticleSystem;
  13467. /**
  13468. * Gets the current list of drag gradients.
  13469. * You must use addDragGradient and removeDragGradient to udpate this list
  13470. * @returns the list of drag gradients
  13471. */
  13472. getDragGradients(): Nullable<Array<FactorGradient>>;
  13473. /**
  13474. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13475. * @param gradient defines the gradient to use (between 0 and 1)
  13476. * @param factor defines the emit rate to affect to the specified gradient
  13477. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13478. * @returns the current particle system
  13479. */
  13480. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13481. /**
  13482. * Remove a specific emit rate gradient
  13483. * @param gradient defines the gradient to remove
  13484. * @returns the current particle system
  13485. */
  13486. removeEmitRateGradient(gradient: number): IParticleSystem;
  13487. /**
  13488. * Gets the current list of emit rate gradients.
  13489. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13490. * @returns the list of emit rate gradients
  13491. */
  13492. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13493. /**
  13494. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13495. * @param gradient defines the gradient to use (between 0 and 1)
  13496. * @param factor defines the start size to affect to the specified gradient
  13497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13498. * @returns the current particle system
  13499. */
  13500. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13501. /**
  13502. * Remove a specific start size gradient
  13503. * @param gradient defines the gradient to remove
  13504. * @returns the current particle system
  13505. */
  13506. removeStartSizeGradient(gradient: number): IParticleSystem;
  13507. /**
  13508. * Gets the current list of start size gradients.
  13509. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13510. * @returns the list of start size gradients
  13511. */
  13512. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13513. /**
  13514. * Adds a new life time gradient
  13515. * @param gradient defines the gradient to use (between 0 and 1)
  13516. * @param factor defines the life time factor to affect to the specified gradient
  13517. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13518. * @returns the current particle system
  13519. */
  13520. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13521. /**
  13522. * Remove a specific life time gradient
  13523. * @param gradient defines the gradient to remove
  13524. * @returns the current particle system
  13525. */
  13526. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13527. /**
  13528. * Gets the current list of life time gradients.
  13529. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13530. * @returns the list of life time gradients
  13531. */
  13532. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13533. /**
  13534. * Gets the current list of color gradients.
  13535. * You must use addColorGradient and removeColorGradient to udpate this list
  13536. * @returns the list of color gradients
  13537. */
  13538. getColorGradients(): Nullable<Array<ColorGradient>>;
  13539. /**
  13540. * Adds a new ramp gradient used to remap particle colors
  13541. * @param gradient defines the gradient to use (between 0 and 1)
  13542. * @param color defines the color to affect to the specified gradient
  13543. * @returns the current particle system
  13544. */
  13545. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13546. /**
  13547. * Gets the current list of ramp gradients.
  13548. * You must use addRampGradient and removeRampGradient to udpate this list
  13549. * @returns the list of ramp gradients
  13550. */
  13551. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13552. /** Gets or sets a boolean indicating that ramp gradients must be used
  13553. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13554. */
  13555. useRampGradients: boolean;
  13556. /**
  13557. * Adds a new color remap gradient
  13558. * @param gradient defines the gradient to use (between 0 and 1)
  13559. * @param min defines the color remap minimal range
  13560. * @param max defines the color remap maximal range
  13561. * @returns the current particle system
  13562. */
  13563. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13564. /**
  13565. * Gets the current list of color remap gradients.
  13566. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13567. * @returns the list of color remap gradients
  13568. */
  13569. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13570. /**
  13571. * Adds a new alpha remap gradient
  13572. * @param gradient defines the gradient to use (between 0 and 1)
  13573. * @param min defines the alpha remap minimal range
  13574. * @param max defines the alpha remap maximal range
  13575. * @returns the current particle system
  13576. */
  13577. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13578. /**
  13579. * Gets the current list of alpha remap gradients.
  13580. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13581. * @returns the list of alpha remap gradients
  13582. */
  13583. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13584. /**
  13585. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13586. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13587. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13588. * @returns the emitter
  13589. */
  13590. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13591. /**
  13592. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13593. * @param radius The radius of the hemisphere to emit from
  13594. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13595. * @returns the emitter
  13596. */
  13597. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13598. /**
  13599. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13600. * @param radius The radius of the sphere to emit from
  13601. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13602. * @returns the emitter
  13603. */
  13604. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13605. /**
  13606. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13607. * @param radius The radius of the sphere to emit from
  13608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13610. * @returns the emitter
  13611. */
  13612. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13613. /**
  13614. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13615. * @param radius The radius of the emission cylinder
  13616. * @param height The height of the emission cylinder
  13617. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13618. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13619. * @returns the emitter
  13620. */
  13621. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13622. /**
  13623. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13624. * @param radius The radius of the cylinder to emit from
  13625. * @param height The height of the emission cylinder
  13626. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13629. * @returns the emitter
  13630. */
  13631. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13632. /**
  13633. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13634. * @param radius The radius of the cone to emit from
  13635. * @param angle The base angle of the cone
  13636. * @returns the emitter
  13637. */
  13638. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13639. /**
  13640. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13641. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13642. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13643. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13644. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13645. * @returns the emitter
  13646. */
  13647. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13648. /**
  13649. * Get hosting scene
  13650. * @returns the scene
  13651. */
  13652. getScene(): Scene;
  13653. }
  13654. }
  13655. declare module BABYLON {
  13656. /**
  13657. * 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.
  13658. * @see https://doc.babylonjs.com/how_to/transformnode
  13659. */
  13660. export class TransformNode extends Node {
  13661. /**
  13662. * Object will not rotate to face the camera
  13663. */
  13664. static BILLBOARDMODE_NONE: number;
  13665. /**
  13666. * Object will rotate to face the camera but only on the x axis
  13667. */
  13668. static BILLBOARDMODE_X: number;
  13669. /**
  13670. * Object will rotate to face the camera but only on the y axis
  13671. */
  13672. static BILLBOARDMODE_Y: number;
  13673. /**
  13674. * Object will rotate to face the camera but only on the z axis
  13675. */
  13676. static BILLBOARDMODE_Z: number;
  13677. /**
  13678. * Object will rotate to face the camera
  13679. */
  13680. static BILLBOARDMODE_ALL: number;
  13681. /**
  13682. * Object will rotate to face the camera's position instead of orientation
  13683. */
  13684. static BILLBOARDMODE_USE_POSITION: number;
  13685. private _forward;
  13686. private _forwardInverted;
  13687. private _up;
  13688. private _right;
  13689. private _rightInverted;
  13690. private _position;
  13691. private _rotation;
  13692. private _rotationQuaternion;
  13693. protected _scaling: Vector3;
  13694. protected _isDirty: boolean;
  13695. private _transformToBoneReferal;
  13696. private _isAbsoluteSynced;
  13697. private _billboardMode;
  13698. /**
  13699. * Gets or sets the billboard mode. Default is 0.
  13700. *
  13701. * | Value | Type | Description |
  13702. * | --- | --- | --- |
  13703. * | 0 | BILLBOARDMODE_NONE | |
  13704. * | 1 | BILLBOARDMODE_X | |
  13705. * | 2 | BILLBOARDMODE_Y | |
  13706. * | 4 | BILLBOARDMODE_Z | |
  13707. * | 7 | BILLBOARDMODE_ALL | |
  13708. *
  13709. */
  13710. get billboardMode(): number;
  13711. set billboardMode(value: number);
  13712. private _preserveParentRotationForBillboard;
  13713. /**
  13714. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13715. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13716. */
  13717. get preserveParentRotationForBillboard(): boolean;
  13718. set preserveParentRotationForBillboard(value: boolean);
  13719. /**
  13720. * 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
  13721. */
  13722. scalingDeterminant: number;
  13723. private _infiniteDistance;
  13724. /**
  13725. * Gets or sets the distance of the object to max, often used by skybox
  13726. */
  13727. get infiniteDistance(): boolean;
  13728. set infiniteDistance(value: boolean);
  13729. /**
  13730. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13731. * By default the system will update normals to compensate
  13732. */
  13733. ignoreNonUniformScaling: boolean;
  13734. /**
  13735. * 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
  13736. */
  13737. reIntegrateRotationIntoRotationQuaternion: boolean;
  13738. /** @hidden */
  13739. _poseMatrix: Nullable<Matrix>;
  13740. /** @hidden */
  13741. _localMatrix: Matrix;
  13742. private _usePivotMatrix;
  13743. private _absolutePosition;
  13744. private _absoluteScaling;
  13745. private _absoluteRotationQuaternion;
  13746. private _pivotMatrix;
  13747. private _pivotMatrixInverse;
  13748. protected _postMultiplyPivotMatrix: boolean;
  13749. protected _isWorldMatrixFrozen: boolean;
  13750. /** @hidden */
  13751. _indexInSceneTransformNodesArray: number;
  13752. /**
  13753. * An event triggered after the world matrix is updated
  13754. */
  13755. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13756. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13757. /**
  13758. * Gets a string identifying the name of the class
  13759. * @returns "TransformNode" string
  13760. */
  13761. getClassName(): string;
  13762. /**
  13763. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13764. */
  13765. get position(): Vector3;
  13766. set position(newPosition: Vector3);
  13767. /**
  13768. * 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)).
  13769. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13770. */
  13771. get rotation(): Vector3;
  13772. set rotation(newRotation: Vector3);
  13773. /**
  13774. * 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)).
  13775. */
  13776. get scaling(): Vector3;
  13777. set scaling(newScaling: Vector3);
  13778. /**
  13779. * 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).
  13780. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13781. */
  13782. get rotationQuaternion(): Nullable<Quaternion>;
  13783. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13784. /**
  13785. * The forward direction of that transform in world space.
  13786. */
  13787. get forward(): Vector3;
  13788. /**
  13789. * The up direction of that transform in world space.
  13790. */
  13791. get up(): Vector3;
  13792. /**
  13793. * The right direction of that transform in world space.
  13794. */
  13795. get right(): Vector3;
  13796. /**
  13797. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13798. * @param matrix the matrix to copy the pose from
  13799. * @returns this TransformNode.
  13800. */
  13801. updatePoseMatrix(matrix: Matrix): TransformNode;
  13802. /**
  13803. * Returns the mesh Pose matrix.
  13804. * @returns the pose matrix
  13805. */
  13806. getPoseMatrix(): Matrix;
  13807. /** @hidden */
  13808. _isSynchronized(): boolean;
  13809. /** @hidden */
  13810. _initCache(): void;
  13811. /**
  13812. * Flag the transform node as dirty (Forcing it to update everything)
  13813. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13814. * @returns this transform node
  13815. */
  13816. markAsDirty(property: string): TransformNode;
  13817. /**
  13818. * Returns the current mesh absolute position.
  13819. * Returns a Vector3.
  13820. */
  13821. get absolutePosition(): Vector3;
  13822. /**
  13823. * Returns the current mesh absolute scaling.
  13824. * Returns a Vector3.
  13825. */
  13826. get absoluteScaling(): Vector3;
  13827. /**
  13828. * Returns the current mesh absolute rotation.
  13829. * Returns a Quaternion.
  13830. */
  13831. get absoluteRotationQuaternion(): Quaternion;
  13832. /**
  13833. * Sets a new matrix to apply before all other transformation
  13834. * @param matrix defines the transform matrix
  13835. * @returns the current TransformNode
  13836. */
  13837. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13838. /**
  13839. * Sets a new pivot matrix to the current node
  13840. * @param matrix defines the new pivot matrix to use
  13841. * @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
  13842. * @returns the current TransformNode
  13843. */
  13844. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13845. /**
  13846. * Returns the mesh pivot matrix.
  13847. * Default : Identity.
  13848. * @returns the matrix
  13849. */
  13850. getPivotMatrix(): Matrix;
  13851. /**
  13852. * Instantiate (when possible) or clone that node with its hierarchy
  13853. * @param newParent defines the new parent to use for the instance (or clone)
  13854. * @param options defines options to configure how copy is done
  13855. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13856. * @returns an instance (or a clone) of the current node with its hiearchy
  13857. */
  13858. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13859. doNotInstantiate: boolean;
  13860. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13861. /**
  13862. * Prevents the World matrix to be computed any longer
  13863. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13864. * @returns the TransformNode.
  13865. */
  13866. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13867. /**
  13868. * Allows back the World matrix computation.
  13869. * @returns the TransformNode.
  13870. */
  13871. unfreezeWorldMatrix(): this;
  13872. /**
  13873. * True if the World matrix has been frozen.
  13874. */
  13875. get isWorldMatrixFrozen(): boolean;
  13876. /**
  13877. * Retuns the mesh absolute position in the World.
  13878. * @returns a Vector3.
  13879. */
  13880. getAbsolutePosition(): Vector3;
  13881. /**
  13882. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13883. * @param absolutePosition the absolute position to set
  13884. * @returns the TransformNode.
  13885. */
  13886. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13887. /**
  13888. * Sets the mesh position in its local space.
  13889. * @param vector3 the position to set in localspace
  13890. * @returns the TransformNode.
  13891. */
  13892. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13893. /**
  13894. * Returns the mesh position in the local space from the current World matrix values.
  13895. * @returns a new Vector3.
  13896. */
  13897. getPositionExpressedInLocalSpace(): Vector3;
  13898. /**
  13899. * Translates the mesh along the passed Vector3 in its local space.
  13900. * @param vector3 the distance to translate in localspace
  13901. * @returns the TransformNode.
  13902. */
  13903. locallyTranslate(vector3: Vector3): TransformNode;
  13904. private static _lookAtVectorCache;
  13905. /**
  13906. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13907. * @param targetPoint the position (must be in same space as current mesh) to look at
  13908. * @param yawCor optional yaw (y-axis) correction in radians
  13909. * @param pitchCor optional pitch (x-axis) correction in radians
  13910. * @param rollCor optional roll (z-axis) correction in radians
  13911. * @param space the choosen space of the target
  13912. * @returns the TransformNode.
  13913. */
  13914. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13915. /**
  13916. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13917. * This Vector3 is expressed in the World space.
  13918. * @param localAxis axis to rotate
  13919. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13920. */
  13921. getDirection(localAxis: Vector3): Vector3;
  13922. /**
  13923. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13924. * localAxis is expressed in the mesh local space.
  13925. * result is computed in the Wordl space from the mesh World matrix.
  13926. * @param localAxis axis to rotate
  13927. * @param result the resulting transformnode
  13928. * @returns this TransformNode.
  13929. */
  13930. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13931. /**
  13932. * Sets this transform node rotation to the given local axis.
  13933. * @param localAxis the axis in local space
  13934. * @param yawCor optional yaw (y-axis) correction in radians
  13935. * @param pitchCor optional pitch (x-axis) correction in radians
  13936. * @param rollCor optional roll (z-axis) correction in radians
  13937. * @returns this TransformNode
  13938. */
  13939. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13940. /**
  13941. * Sets a new pivot point to the current node
  13942. * @param point defines the new pivot point to use
  13943. * @param space defines if the point is in world or local space (local by default)
  13944. * @returns the current TransformNode
  13945. */
  13946. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13947. /**
  13948. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13949. * @returns the pivot point
  13950. */
  13951. getPivotPoint(): Vector3;
  13952. /**
  13953. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13954. * @param result the vector3 to store the result
  13955. * @returns this TransformNode.
  13956. */
  13957. getPivotPointToRef(result: Vector3): TransformNode;
  13958. /**
  13959. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13960. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13961. */
  13962. getAbsolutePivotPoint(): Vector3;
  13963. /**
  13964. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13965. * @param result vector3 to store the result
  13966. * @returns this TransformNode.
  13967. */
  13968. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13969. /**
  13970. * Defines the passed node as the parent of the current node.
  13971. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13972. * @see https://doc.babylonjs.com/how_to/parenting
  13973. * @param node the node ot set as the parent
  13974. * @returns this TransformNode.
  13975. */
  13976. setParent(node: Nullable<Node>): TransformNode;
  13977. private _nonUniformScaling;
  13978. /**
  13979. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13980. */
  13981. get nonUniformScaling(): boolean;
  13982. /** @hidden */
  13983. _updateNonUniformScalingState(value: boolean): boolean;
  13984. /**
  13985. * Attach the current TransformNode to another TransformNode associated with a bone
  13986. * @param bone Bone affecting the TransformNode
  13987. * @param affectedTransformNode TransformNode associated with the bone
  13988. * @returns this object
  13989. */
  13990. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13991. /**
  13992. * Detach the transform node if its associated with a bone
  13993. * @returns this object
  13994. */
  13995. detachFromBone(): TransformNode;
  13996. private static _rotationAxisCache;
  13997. /**
  13998. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13999. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14000. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14001. * The passed axis is also normalized.
  14002. * @param axis the axis to rotate around
  14003. * @param amount the amount to rotate in radians
  14004. * @param space Space to rotate in (Default: local)
  14005. * @returns the TransformNode.
  14006. */
  14007. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14008. /**
  14009. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14010. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14011. * The passed axis is also normalized. .
  14012. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14013. * @param point the point to rotate around
  14014. * @param axis the axis to rotate around
  14015. * @param amount the amount to rotate in radians
  14016. * @returns the TransformNode
  14017. */
  14018. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14019. /**
  14020. * Translates the mesh along the axis vector for the passed distance in the given space.
  14021. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14022. * @param axis the axis to translate in
  14023. * @param distance the distance to translate
  14024. * @param space Space to rotate in (Default: local)
  14025. * @returns the TransformNode.
  14026. */
  14027. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14028. /**
  14029. * Adds a rotation step to the mesh current rotation.
  14030. * x, y, z are Euler angles expressed in radians.
  14031. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14032. * This means this rotation is made in the mesh local space only.
  14033. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14034. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14035. * ```javascript
  14036. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14037. * ```
  14038. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14039. * 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.
  14040. * @param x Rotation to add
  14041. * @param y Rotation to add
  14042. * @param z Rotation to add
  14043. * @returns the TransformNode.
  14044. */
  14045. addRotation(x: number, y: number, z: number): TransformNode;
  14046. /**
  14047. * @hidden
  14048. */
  14049. protected _getEffectiveParent(): Nullable<Node>;
  14050. /**
  14051. * Computes the world matrix of the node
  14052. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14053. * @returns the world matrix
  14054. */
  14055. computeWorldMatrix(force?: boolean): Matrix;
  14056. /**
  14057. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14058. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14059. */
  14060. resetLocalMatrix(independentOfChildren?: boolean): void;
  14061. protected _afterComputeWorldMatrix(): void;
  14062. /**
  14063. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14064. * @param func callback function to add
  14065. *
  14066. * @returns the TransformNode.
  14067. */
  14068. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14069. /**
  14070. * Removes a registered callback function.
  14071. * @param func callback function to remove
  14072. * @returns the TransformNode.
  14073. */
  14074. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14075. /**
  14076. * Gets the position of the current mesh in camera space
  14077. * @param camera defines the camera to use
  14078. * @returns a position
  14079. */
  14080. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14081. /**
  14082. * Returns the distance from the mesh to the active camera
  14083. * @param camera defines the camera to use
  14084. * @returns the distance
  14085. */
  14086. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14087. /**
  14088. * Clone the current transform node
  14089. * @param name Name of the new clone
  14090. * @param newParent New parent for the clone
  14091. * @param doNotCloneChildren Do not clone children hierarchy
  14092. * @returns the new transform node
  14093. */
  14094. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14095. /**
  14096. * Serializes the objects information.
  14097. * @param currentSerializationObject defines the object to serialize in
  14098. * @returns the serialized object
  14099. */
  14100. serialize(currentSerializationObject?: any): any;
  14101. /**
  14102. * Returns a new TransformNode object parsed from the source provided.
  14103. * @param parsedTransformNode is the source.
  14104. * @param scene the scne the object belongs to
  14105. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14106. * @returns a new TransformNode object parsed from the source provided.
  14107. */
  14108. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14109. /**
  14110. * Get all child-transformNodes of this node
  14111. * @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
  14112. * @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
  14113. * @returns an array of TransformNode
  14114. */
  14115. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14116. /**
  14117. * Releases resources associated with this transform node.
  14118. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14119. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14120. */
  14121. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14122. /**
  14123. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14124. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14125. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14126. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14127. * @returns the current mesh
  14128. */
  14129. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14130. private _syncAbsoluteScalingAndRotation;
  14131. }
  14132. }
  14133. declare module BABYLON {
  14134. /**
  14135. * Class used to override all child animations of a given target
  14136. */
  14137. export class AnimationPropertiesOverride {
  14138. /**
  14139. * Gets or sets a value indicating if animation blending must be used
  14140. */
  14141. enableBlending: boolean;
  14142. /**
  14143. * Gets or sets the blending speed to use when enableBlending is true
  14144. */
  14145. blendingSpeed: number;
  14146. /**
  14147. * Gets or sets the default loop mode to use
  14148. */
  14149. loopMode: number;
  14150. }
  14151. }
  14152. declare module BABYLON {
  14153. /**
  14154. * Class used to store bone information
  14155. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14156. */
  14157. export class Bone extends Node {
  14158. /**
  14159. * defines the bone name
  14160. */
  14161. name: string;
  14162. private static _tmpVecs;
  14163. private static _tmpQuat;
  14164. private static _tmpMats;
  14165. /**
  14166. * Gets the list of child bones
  14167. */
  14168. children: Bone[];
  14169. /** Gets the animations associated with this bone */
  14170. animations: Animation[];
  14171. /**
  14172. * Gets or sets bone length
  14173. */
  14174. length: number;
  14175. /**
  14176. * @hidden Internal only
  14177. * Set this value to map this bone to a different index in the transform matrices
  14178. * Set this value to -1 to exclude the bone from the transform matrices
  14179. */
  14180. _index: Nullable<number>;
  14181. private _skeleton;
  14182. private _localMatrix;
  14183. private _restPose;
  14184. private _baseMatrix;
  14185. private _absoluteTransform;
  14186. private _invertedAbsoluteTransform;
  14187. private _parent;
  14188. private _scalingDeterminant;
  14189. private _worldTransform;
  14190. private _localScaling;
  14191. private _localRotation;
  14192. private _localPosition;
  14193. private _needToDecompose;
  14194. private _needToCompose;
  14195. /** @hidden */
  14196. _linkedTransformNode: Nullable<TransformNode>;
  14197. /** @hidden */
  14198. _waitingTransformNodeId: Nullable<string>;
  14199. /** @hidden */
  14200. get _matrix(): Matrix;
  14201. /** @hidden */
  14202. set _matrix(value: Matrix);
  14203. /**
  14204. * Create a new bone
  14205. * @param name defines the bone name
  14206. * @param skeleton defines the parent skeleton
  14207. * @param parentBone defines the parent (can be null if the bone is the root)
  14208. * @param localMatrix defines the local matrix
  14209. * @param restPose defines the rest pose matrix
  14210. * @param baseMatrix defines the base matrix
  14211. * @param index defines index of the bone in the hiearchy
  14212. */
  14213. constructor(
  14214. /**
  14215. * defines the bone name
  14216. */
  14217. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14218. /**
  14219. * Gets the current object class name.
  14220. * @return the class name
  14221. */
  14222. getClassName(): string;
  14223. /**
  14224. * Gets the parent skeleton
  14225. * @returns a skeleton
  14226. */
  14227. getSkeleton(): Skeleton;
  14228. /**
  14229. * Gets parent bone
  14230. * @returns a bone or null if the bone is the root of the bone hierarchy
  14231. */
  14232. getParent(): Nullable<Bone>;
  14233. /**
  14234. * Returns an array containing the root bones
  14235. * @returns an array containing the root bones
  14236. */
  14237. getChildren(): Array<Bone>;
  14238. /**
  14239. * Gets the node index in matrix array generated for rendering
  14240. * @returns the node index
  14241. */
  14242. getIndex(): number;
  14243. /**
  14244. * Sets the parent bone
  14245. * @param parent defines the parent (can be null if the bone is the root)
  14246. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14247. */
  14248. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14249. /**
  14250. * Gets the local matrix
  14251. * @returns a matrix
  14252. */
  14253. getLocalMatrix(): Matrix;
  14254. /**
  14255. * Gets the base matrix (initial matrix which remains unchanged)
  14256. * @returns a matrix
  14257. */
  14258. getBaseMatrix(): Matrix;
  14259. /**
  14260. * Gets the rest pose matrix
  14261. * @returns a matrix
  14262. */
  14263. getRestPose(): Matrix;
  14264. /**
  14265. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14266. */
  14267. getWorldMatrix(): Matrix;
  14268. /**
  14269. * Sets the local matrix to rest pose matrix
  14270. */
  14271. returnToRest(): void;
  14272. /**
  14273. * Gets the inverse of the absolute transform matrix.
  14274. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14275. * @returns a matrix
  14276. */
  14277. getInvertedAbsoluteTransform(): Matrix;
  14278. /**
  14279. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14280. * @returns a matrix
  14281. */
  14282. getAbsoluteTransform(): Matrix;
  14283. /**
  14284. * Links with the given transform node.
  14285. * The local matrix of this bone is copied from the transform node every frame.
  14286. * @param transformNode defines the transform node to link to
  14287. */
  14288. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14289. /**
  14290. * Gets the node used to drive the bone's transformation
  14291. * @returns a transform node or null
  14292. */
  14293. getTransformNode(): Nullable<TransformNode>;
  14294. /** Gets or sets current position (in local space) */
  14295. get position(): Vector3;
  14296. set position(newPosition: Vector3);
  14297. /** Gets or sets current rotation (in local space) */
  14298. get rotation(): Vector3;
  14299. set rotation(newRotation: Vector3);
  14300. /** Gets or sets current rotation quaternion (in local space) */
  14301. get rotationQuaternion(): Quaternion;
  14302. set rotationQuaternion(newRotation: Quaternion);
  14303. /** Gets or sets current scaling (in local space) */
  14304. get scaling(): Vector3;
  14305. set scaling(newScaling: Vector3);
  14306. /**
  14307. * Gets the animation properties override
  14308. */
  14309. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14310. private _decompose;
  14311. private _compose;
  14312. /**
  14313. * Update the base and local matrices
  14314. * @param matrix defines the new base or local matrix
  14315. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14316. * @param updateLocalMatrix defines if the local matrix should be updated
  14317. */
  14318. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14319. /** @hidden */
  14320. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14321. /**
  14322. * Flag the bone as dirty (Forcing it to update everything)
  14323. */
  14324. markAsDirty(): void;
  14325. /** @hidden */
  14326. _markAsDirtyAndCompose(): void;
  14327. private _markAsDirtyAndDecompose;
  14328. /**
  14329. * Translate the bone in local or world space
  14330. * @param vec The amount to translate the bone
  14331. * @param space The space that the translation is in
  14332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14333. */
  14334. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14335. /**
  14336. * Set the postion of the bone in local or world space
  14337. * @param position The position to set the bone
  14338. * @param space The space that the position is in
  14339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14340. */
  14341. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14342. /**
  14343. * Set the absolute position of the bone (world space)
  14344. * @param position The position to set the bone
  14345. * @param mesh The mesh that this bone is attached to
  14346. */
  14347. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14348. /**
  14349. * Scale the bone on the x, y and z axes (in local space)
  14350. * @param x The amount to scale the bone on the x axis
  14351. * @param y The amount to scale the bone on the y axis
  14352. * @param z The amount to scale the bone on the z axis
  14353. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14354. */
  14355. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14356. /**
  14357. * Set the bone scaling in local space
  14358. * @param scale defines the scaling vector
  14359. */
  14360. setScale(scale: Vector3): void;
  14361. /**
  14362. * Gets the current scaling in local space
  14363. * @returns the current scaling vector
  14364. */
  14365. getScale(): Vector3;
  14366. /**
  14367. * Gets the current scaling in local space and stores it in a target vector
  14368. * @param result defines the target vector
  14369. */
  14370. getScaleToRef(result: Vector3): void;
  14371. /**
  14372. * Set the yaw, pitch, and roll of the bone in local or world space
  14373. * @param yaw The rotation of the bone on the y axis
  14374. * @param pitch The rotation of the bone on the x axis
  14375. * @param roll The rotation of the bone on the z axis
  14376. * @param space The space that the axes of rotation are in
  14377. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14378. */
  14379. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14380. /**
  14381. * Add a rotation to the bone on an axis in local or world space
  14382. * @param axis The axis to rotate the bone on
  14383. * @param amount The amount to rotate the bone
  14384. * @param space The space that the axis is in
  14385. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14386. */
  14387. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14388. /**
  14389. * Set the rotation of the bone to a particular axis angle in local or world space
  14390. * @param axis The axis to rotate the bone on
  14391. * @param angle The angle that the bone should be rotated to
  14392. * @param space The space that the axis is in
  14393. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14394. */
  14395. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14396. /**
  14397. * Set the euler rotation of the bone in local of world space
  14398. * @param rotation The euler rotation that the bone should be set to
  14399. * @param space The space that the rotation is in
  14400. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14401. */
  14402. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14403. /**
  14404. * Set the quaternion rotation of the bone in local of world space
  14405. * @param quat The quaternion rotation that the bone should be set to
  14406. * @param space The space that the rotation is in
  14407. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14408. */
  14409. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14410. /**
  14411. * Set the rotation matrix of the bone in local of world space
  14412. * @param rotMat The rotation matrix that the bone should be set to
  14413. * @param space The space that the rotation is in
  14414. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14415. */
  14416. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14417. private _rotateWithMatrix;
  14418. private _getNegativeRotationToRef;
  14419. /**
  14420. * Get the position of the bone in local or world space
  14421. * @param space The space that the returned position is in
  14422. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14423. * @returns The position of the bone
  14424. */
  14425. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14426. /**
  14427. * Copy the position of the bone to a vector3 in local or world space
  14428. * @param space The space that the returned position is in
  14429. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14430. * @param result The vector3 to copy the position to
  14431. */
  14432. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14433. /**
  14434. * Get the absolute position of the bone (world space)
  14435. * @param mesh The mesh that this bone is attached to
  14436. * @returns The absolute position of the bone
  14437. */
  14438. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14439. /**
  14440. * Copy the absolute position of the bone (world space) to the result param
  14441. * @param mesh The mesh that this bone is attached to
  14442. * @param result The vector3 to copy the absolute position to
  14443. */
  14444. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14445. /**
  14446. * Compute the absolute transforms of this bone and its children
  14447. */
  14448. computeAbsoluteTransforms(): void;
  14449. /**
  14450. * Get the world direction from an axis that is in the local space of the bone
  14451. * @param localAxis The local direction that is used to compute the world direction
  14452. * @param mesh The mesh that this bone is attached to
  14453. * @returns The world direction
  14454. */
  14455. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14456. /**
  14457. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14458. * @param localAxis The local direction that is used to compute the world direction
  14459. * @param mesh The mesh that this bone is attached to
  14460. * @param result The vector3 that the world direction will be copied to
  14461. */
  14462. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14463. /**
  14464. * Get the euler rotation of the bone in local or world space
  14465. * @param space The space that the rotation should be in
  14466. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14467. * @returns The euler rotation
  14468. */
  14469. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14470. /**
  14471. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14472. * @param space The space that the rotation should be in
  14473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14474. * @param result The vector3 that the rotation should be copied to
  14475. */
  14476. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14477. /**
  14478. * Get the quaternion rotation of the bone in either local or world space
  14479. * @param space The space that the rotation should be in
  14480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14481. * @returns The quaternion rotation
  14482. */
  14483. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14484. /**
  14485. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14486. * @param space The space that the rotation should be in
  14487. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14488. * @param result The quaternion that the rotation should be copied to
  14489. */
  14490. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14491. /**
  14492. * Get the rotation matrix of the bone in local or world space
  14493. * @param space The space that the rotation should be in
  14494. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14495. * @returns The rotation matrix
  14496. */
  14497. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14498. /**
  14499. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14500. * @param space The space that the rotation should be in
  14501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14502. * @param result The quaternion that the rotation should be copied to
  14503. */
  14504. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14505. /**
  14506. * Get the world position of a point that is in the local space of the bone
  14507. * @param position The local position
  14508. * @param mesh The mesh that this bone is attached to
  14509. * @returns The world position
  14510. */
  14511. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14512. /**
  14513. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14514. * @param position The local position
  14515. * @param mesh The mesh that this bone is attached to
  14516. * @param result The vector3 that the world position should be copied to
  14517. */
  14518. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14519. /**
  14520. * Get the local position of a point that is in world space
  14521. * @param position The world position
  14522. * @param mesh The mesh that this bone is attached to
  14523. * @returns The local position
  14524. */
  14525. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14526. /**
  14527. * Get the local position of a point that is in world space and copy it to the result param
  14528. * @param position The world position
  14529. * @param mesh The mesh that this bone is attached to
  14530. * @param result The vector3 that the local position should be copied to
  14531. */
  14532. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14533. }
  14534. }
  14535. declare module BABYLON {
  14536. /**
  14537. * Defines a runtime animation
  14538. */
  14539. export class RuntimeAnimation {
  14540. private _events;
  14541. /**
  14542. * The current frame of the runtime animation
  14543. */
  14544. private _currentFrame;
  14545. /**
  14546. * The animation used by the runtime animation
  14547. */
  14548. private _animation;
  14549. /**
  14550. * The target of the runtime animation
  14551. */
  14552. private _target;
  14553. /**
  14554. * The initiating animatable
  14555. */
  14556. private _host;
  14557. /**
  14558. * The original value of the runtime animation
  14559. */
  14560. private _originalValue;
  14561. /**
  14562. * The original blend value of the runtime animation
  14563. */
  14564. private _originalBlendValue;
  14565. /**
  14566. * The offsets cache of the runtime animation
  14567. */
  14568. private _offsetsCache;
  14569. /**
  14570. * The high limits cache of the runtime animation
  14571. */
  14572. private _highLimitsCache;
  14573. /**
  14574. * Specifies if the runtime animation has been stopped
  14575. */
  14576. private _stopped;
  14577. /**
  14578. * The blending factor of the runtime animation
  14579. */
  14580. private _blendingFactor;
  14581. /**
  14582. * The BabylonJS scene
  14583. */
  14584. private _scene;
  14585. /**
  14586. * The current value of the runtime animation
  14587. */
  14588. private _currentValue;
  14589. /** @hidden */
  14590. _animationState: _IAnimationState;
  14591. /**
  14592. * The active target of the runtime animation
  14593. */
  14594. private _activeTargets;
  14595. private _currentActiveTarget;
  14596. private _directTarget;
  14597. /**
  14598. * The target path of the runtime animation
  14599. */
  14600. private _targetPath;
  14601. /**
  14602. * The weight of the runtime animation
  14603. */
  14604. private _weight;
  14605. /**
  14606. * The ratio offset of the runtime animation
  14607. */
  14608. private _ratioOffset;
  14609. /**
  14610. * The previous delay of the runtime animation
  14611. */
  14612. private _previousDelay;
  14613. /**
  14614. * The previous ratio of the runtime animation
  14615. */
  14616. private _previousRatio;
  14617. private _enableBlending;
  14618. private _keys;
  14619. private _minFrame;
  14620. private _maxFrame;
  14621. private _minValue;
  14622. private _maxValue;
  14623. private _targetIsArray;
  14624. /**
  14625. * Gets the current frame of the runtime animation
  14626. */
  14627. get currentFrame(): number;
  14628. /**
  14629. * Gets the weight of the runtime animation
  14630. */
  14631. get weight(): number;
  14632. /**
  14633. * Gets the current value of the runtime animation
  14634. */
  14635. get currentValue(): any;
  14636. /**
  14637. * Gets the target path of the runtime animation
  14638. */
  14639. get targetPath(): string;
  14640. /**
  14641. * Gets the actual target of the runtime animation
  14642. */
  14643. get target(): any;
  14644. /**
  14645. * Gets the additive state of the runtime animation
  14646. */
  14647. get isAdditive(): boolean;
  14648. /** @hidden */
  14649. _onLoop: () => void;
  14650. /**
  14651. * Create a new RuntimeAnimation object
  14652. * @param target defines the target of the animation
  14653. * @param animation defines the source animation object
  14654. * @param scene defines the hosting scene
  14655. * @param host defines the initiating Animatable
  14656. */
  14657. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14658. private _preparePath;
  14659. /**
  14660. * Gets the animation from the runtime animation
  14661. */
  14662. get animation(): Animation;
  14663. /**
  14664. * Resets the runtime animation to the beginning
  14665. * @param restoreOriginal defines whether to restore the target property to the original value
  14666. */
  14667. reset(restoreOriginal?: boolean): void;
  14668. /**
  14669. * Specifies if the runtime animation is stopped
  14670. * @returns Boolean specifying if the runtime animation is stopped
  14671. */
  14672. isStopped(): boolean;
  14673. /**
  14674. * Disposes of the runtime animation
  14675. */
  14676. dispose(): void;
  14677. /**
  14678. * Apply the interpolated value to the target
  14679. * @param currentValue defines the value computed by the animation
  14680. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14681. */
  14682. setValue(currentValue: any, weight: number): void;
  14683. private _getOriginalValues;
  14684. private _setValue;
  14685. /**
  14686. * Gets the loop pmode of the runtime animation
  14687. * @returns Loop Mode
  14688. */
  14689. private _getCorrectLoopMode;
  14690. /**
  14691. * Move the current animation to a given frame
  14692. * @param frame defines the frame to move to
  14693. */
  14694. goToFrame(frame: number): void;
  14695. /**
  14696. * @hidden Internal use only
  14697. */
  14698. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14699. /**
  14700. * Execute the current animation
  14701. * @param delay defines the delay to add to the current frame
  14702. * @param from defines the lower bound of the animation range
  14703. * @param to defines the upper bound of the animation range
  14704. * @param loop defines if the current animation must loop
  14705. * @param speedRatio defines the current speed ratio
  14706. * @param weight defines the weight of the animation (default is -1 so no weight)
  14707. * @param onLoop optional callback called when animation loops
  14708. * @returns a boolean indicating if the animation is running
  14709. */
  14710. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14711. }
  14712. }
  14713. declare module BABYLON {
  14714. /**
  14715. * Class used to store an actual running animation
  14716. */
  14717. export class Animatable {
  14718. /** defines the target object */
  14719. target: any;
  14720. /** defines the starting frame number (default is 0) */
  14721. fromFrame: number;
  14722. /** defines the ending frame number (default is 100) */
  14723. toFrame: number;
  14724. /** defines if the animation must loop (default is false) */
  14725. loopAnimation: boolean;
  14726. /** defines a callback to call when animation ends if it is not looping */
  14727. onAnimationEnd?: (() => void) | null | undefined;
  14728. /** defines a callback to call when animation loops */
  14729. onAnimationLoop?: (() => void) | null | undefined;
  14730. /** defines whether the animation should be evaluated additively */
  14731. isAdditive: boolean;
  14732. private _localDelayOffset;
  14733. private _pausedDelay;
  14734. private _runtimeAnimations;
  14735. private _paused;
  14736. private _scene;
  14737. private _speedRatio;
  14738. private _weight;
  14739. private _syncRoot;
  14740. /**
  14741. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14742. * This will only apply for non looping animation (default is true)
  14743. */
  14744. disposeOnEnd: boolean;
  14745. /**
  14746. * Gets a boolean indicating if the animation has started
  14747. */
  14748. animationStarted: boolean;
  14749. /**
  14750. * Observer raised when the animation ends
  14751. */
  14752. onAnimationEndObservable: Observable<Animatable>;
  14753. /**
  14754. * Observer raised when the animation loops
  14755. */
  14756. onAnimationLoopObservable: Observable<Animatable>;
  14757. /**
  14758. * Gets the root Animatable used to synchronize and normalize animations
  14759. */
  14760. get syncRoot(): Nullable<Animatable>;
  14761. /**
  14762. * Gets the current frame of the first RuntimeAnimation
  14763. * Used to synchronize Animatables
  14764. */
  14765. get masterFrame(): number;
  14766. /**
  14767. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14768. */
  14769. get weight(): number;
  14770. set weight(value: number);
  14771. /**
  14772. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14773. */
  14774. get speedRatio(): number;
  14775. set speedRatio(value: number);
  14776. /**
  14777. * Creates a new Animatable
  14778. * @param scene defines the hosting scene
  14779. * @param target defines the target object
  14780. * @param fromFrame defines the starting frame number (default is 0)
  14781. * @param toFrame defines the ending frame number (default is 100)
  14782. * @param loopAnimation defines if the animation must loop (default is false)
  14783. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14784. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14785. * @param animations defines a group of animation to add to the new Animatable
  14786. * @param onAnimationLoop defines a callback to call when animation loops
  14787. * @param isAdditive defines whether the animation should be evaluated additively
  14788. */
  14789. constructor(scene: Scene,
  14790. /** defines the target object */
  14791. target: any,
  14792. /** defines the starting frame number (default is 0) */
  14793. fromFrame?: number,
  14794. /** defines the ending frame number (default is 100) */
  14795. toFrame?: number,
  14796. /** defines if the animation must loop (default is false) */
  14797. loopAnimation?: boolean, speedRatio?: number,
  14798. /** defines a callback to call when animation ends if it is not looping */
  14799. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14800. /** defines a callback to call when animation loops */
  14801. onAnimationLoop?: (() => void) | null | undefined,
  14802. /** defines whether the animation should be evaluated additively */
  14803. isAdditive?: boolean);
  14804. /**
  14805. * Synchronize and normalize current Animatable with a source Animatable
  14806. * This is useful when using animation weights and when animations are not of the same length
  14807. * @param root defines the root Animatable to synchronize with
  14808. * @returns the current Animatable
  14809. */
  14810. syncWith(root: Animatable): Animatable;
  14811. /**
  14812. * Gets the list of runtime animations
  14813. * @returns an array of RuntimeAnimation
  14814. */
  14815. getAnimations(): RuntimeAnimation[];
  14816. /**
  14817. * Adds more animations to the current animatable
  14818. * @param target defines the target of the animations
  14819. * @param animations defines the new animations to add
  14820. */
  14821. appendAnimations(target: any, animations: Animation[]): void;
  14822. /**
  14823. * Gets the source animation for a specific property
  14824. * @param property defines the propertyu to look for
  14825. * @returns null or the source animation for the given property
  14826. */
  14827. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14828. /**
  14829. * Gets the runtime animation for a specific property
  14830. * @param property defines the propertyu to look for
  14831. * @returns null or the runtime animation for the given property
  14832. */
  14833. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14834. /**
  14835. * Resets the animatable to its original state
  14836. */
  14837. reset(): void;
  14838. /**
  14839. * Allows the animatable to blend with current running animations
  14840. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14841. * @param blendingSpeed defines the blending speed to use
  14842. */
  14843. enableBlending(blendingSpeed: number): void;
  14844. /**
  14845. * Disable animation blending
  14846. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14847. */
  14848. disableBlending(): void;
  14849. /**
  14850. * Jump directly to a given frame
  14851. * @param frame defines the frame to jump to
  14852. */
  14853. goToFrame(frame: number): void;
  14854. /**
  14855. * Pause the animation
  14856. */
  14857. pause(): void;
  14858. /**
  14859. * Restart the animation
  14860. */
  14861. restart(): void;
  14862. private _raiseOnAnimationEnd;
  14863. /**
  14864. * Stop and delete the current animation
  14865. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14866. * @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)
  14867. */
  14868. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14869. /**
  14870. * Wait asynchronously for the animation to end
  14871. * @returns a promise which will be fullfilled when the animation ends
  14872. */
  14873. waitAsync(): Promise<Animatable>;
  14874. /** @hidden */
  14875. _animate(delay: number): boolean;
  14876. }
  14877. interface Scene {
  14878. /** @hidden */
  14879. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14880. /** @hidden */
  14881. _processLateAnimationBindingsForMatrices(holder: {
  14882. totalWeight: number;
  14883. totalAdditiveWeight: number;
  14884. animations: RuntimeAnimation[];
  14885. additiveAnimations: RuntimeAnimation[];
  14886. originalValue: Matrix;
  14887. }): any;
  14888. /** @hidden */
  14889. _processLateAnimationBindingsForQuaternions(holder: {
  14890. totalWeight: number;
  14891. totalAdditiveWeight: number;
  14892. animations: RuntimeAnimation[];
  14893. additiveAnimations: RuntimeAnimation[];
  14894. originalValue: Quaternion;
  14895. }, refQuaternion: Quaternion): Quaternion;
  14896. /** @hidden */
  14897. _processLateAnimationBindings(): void;
  14898. /**
  14899. * Will start the animation sequence of a given target
  14900. * @param target defines the target
  14901. * @param from defines from which frame should animation start
  14902. * @param to defines until which frame should animation run.
  14903. * @param weight defines the weight to apply to the animation (1.0 by default)
  14904. * @param loop defines if the animation loops
  14905. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14906. * @param onAnimationEnd defines the function to be executed when the animation ends
  14907. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14908. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14909. * @param onAnimationLoop defines the callback to call when an animation loops
  14910. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14911. * @returns the animatable object created for this animation
  14912. */
  14913. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14914. /**
  14915. * Will start the animation sequence of a given target
  14916. * @param target defines the target
  14917. * @param from defines from which frame should animation start
  14918. * @param to defines until which frame should animation run.
  14919. * @param loop defines if the animation loops
  14920. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14921. * @param onAnimationEnd defines the function to be executed when the animation ends
  14922. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14923. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14924. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14925. * @param onAnimationLoop defines the callback to call when an animation loops
  14926. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14927. * @returns the animatable object created for this animation
  14928. */
  14929. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14930. /**
  14931. * Will start the animation sequence of a given target and its hierarchy
  14932. * @param target defines the target
  14933. * @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.
  14934. * @param from defines from which frame should animation start
  14935. * @param to defines until which frame should animation run.
  14936. * @param loop defines if the animation loops
  14937. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14938. * @param onAnimationEnd defines the function to be executed when the animation ends
  14939. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14940. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14941. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14942. * @param onAnimationLoop defines the callback to call when an animation loops
  14943. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14944. * @returns the list of created animatables
  14945. */
  14946. 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, isAdditive?: boolean): Animatable[];
  14947. /**
  14948. * Begin a new animation on a given node
  14949. * @param target defines the target where the animation will take place
  14950. * @param animations defines the list of animations to start
  14951. * @param from defines the initial value
  14952. * @param to defines the final value
  14953. * @param loop defines if you want animation to loop (off by default)
  14954. * @param speedRatio defines the speed ratio to apply to all animations
  14955. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14956. * @param onAnimationLoop defines the callback to call when an animation loops
  14957. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14958. * @returns the list of created animatables
  14959. */
  14960. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14961. /**
  14962. * Begin a new animation on a given node and its hierarchy
  14963. * @param target defines the root node where the animation will take place
  14964. * @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.
  14965. * @param animations defines the list of animations to start
  14966. * @param from defines the initial value
  14967. * @param to defines the final value
  14968. * @param loop defines if you want animation to loop (off by default)
  14969. * @param speedRatio defines the speed ratio to apply to all animations
  14970. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14971. * @param onAnimationLoop defines the callback to call when an animation loops
  14972. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14973. * @returns the list of animatables created for all nodes
  14974. */
  14975. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14976. /**
  14977. * Gets the animatable associated with a specific target
  14978. * @param target defines the target of the animatable
  14979. * @returns the required animatable if found
  14980. */
  14981. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14982. /**
  14983. * Gets all animatables associated with a given target
  14984. * @param target defines the target to look animatables for
  14985. * @returns an array of Animatables
  14986. */
  14987. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14988. /**
  14989. * Stops and removes all animations that have been applied to the scene
  14990. */
  14991. stopAllAnimations(): void;
  14992. /**
  14993. * Gets the current delta time used by animation engine
  14994. */
  14995. deltaTime: number;
  14996. }
  14997. interface Bone {
  14998. /**
  14999. * Copy an animation range from another bone
  15000. * @param source defines the source bone
  15001. * @param rangeName defines the range name to copy
  15002. * @param frameOffset defines the frame offset
  15003. * @param rescaleAsRequired defines if rescaling must be applied if required
  15004. * @param skelDimensionsRatio defines the scaling ratio
  15005. * @returns true if operation was successful
  15006. */
  15007. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15008. }
  15009. }
  15010. declare module BABYLON {
  15011. /**
  15012. * Class used to handle skinning animations
  15013. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15014. */
  15015. export class Skeleton implements IAnimatable {
  15016. /** defines the skeleton name */
  15017. name: string;
  15018. /** defines the skeleton Id */
  15019. id: string;
  15020. /**
  15021. * Defines the list of child bones
  15022. */
  15023. bones: Bone[];
  15024. /**
  15025. * Defines an estimate of the dimension of the skeleton at rest
  15026. */
  15027. dimensionsAtRest: Vector3;
  15028. /**
  15029. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15030. */
  15031. needInitialSkinMatrix: boolean;
  15032. /**
  15033. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15034. */
  15035. overrideMesh: Nullable<AbstractMesh>;
  15036. /**
  15037. * Gets the list of animations attached to this skeleton
  15038. */
  15039. animations: Array<Animation>;
  15040. private _scene;
  15041. private _isDirty;
  15042. private _transformMatrices;
  15043. private _transformMatrixTexture;
  15044. private _meshesWithPoseMatrix;
  15045. private _animatables;
  15046. private _identity;
  15047. private _synchronizedWithMesh;
  15048. private _ranges;
  15049. private _lastAbsoluteTransformsUpdateId;
  15050. private _canUseTextureForBones;
  15051. private _uniqueId;
  15052. /** @hidden */
  15053. _numBonesWithLinkedTransformNode: number;
  15054. /** @hidden */
  15055. _hasWaitingData: Nullable<boolean>;
  15056. /**
  15057. * Specifies if the skeleton should be serialized
  15058. */
  15059. doNotSerialize: boolean;
  15060. private _useTextureToStoreBoneMatrices;
  15061. /**
  15062. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15063. * Please note that this option is not available if the hardware does not support it
  15064. */
  15065. get useTextureToStoreBoneMatrices(): boolean;
  15066. set useTextureToStoreBoneMatrices(value: boolean);
  15067. private _animationPropertiesOverride;
  15068. /**
  15069. * Gets or sets the animation properties override
  15070. */
  15071. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15072. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15073. /**
  15074. * List of inspectable custom properties (used by the Inspector)
  15075. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15076. */
  15077. inspectableCustomProperties: IInspectable[];
  15078. /**
  15079. * An observable triggered before computing the skeleton's matrices
  15080. */
  15081. onBeforeComputeObservable: Observable<Skeleton>;
  15082. /**
  15083. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15084. */
  15085. get isUsingTextureForMatrices(): boolean;
  15086. /**
  15087. * Gets the unique ID of this skeleton
  15088. */
  15089. get uniqueId(): number;
  15090. /**
  15091. * Creates a new skeleton
  15092. * @param name defines the skeleton name
  15093. * @param id defines the skeleton Id
  15094. * @param scene defines the hosting scene
  15095. */
  15096. constructor(
  15097. /** defines the skeleton name */
  15098. name: string,
  15099. /** defines the skeleton Id */
  15100. id: string, scene: Scene);
  15101. /**
  15102. * Gets the current object class name.
  15103. * @return the class name
  15104. */
  15105. getClassName(): string;
  15106. /**
  15107. * Returns an array containing the root bones
  15108. * @returns an array containing the root bones
  15109. */
  15110. getChildren(): Array<Bone>;
  15111. /**
  15112. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15113. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15114. * @returns a Float32Array containing matrices data
  15115. */
  15116. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15117. /**
  15118. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15119. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15120. * @returns a raw texture containing the data
  15121. */
  15122. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15123. /**
  15124. * Gets the current hosting scene
  15125. * @returns a scene object
  15126. */
  15127. getScene(): Scene;
  15128. /**
  15129. * Gets a string representing the current skeleton data
  15130. * @param fullDetails defines a boolean indicating if we want a verbose version
  15131. * @returns a string representing the current skeleton data
  15132. */
  15133. toString(fullDetails?: boolean): string;
  15134. /**
  15135. * Get bone's index searching by name
  15136. * @param name defines bone's name to search for
  15137. * @return the indice of the bone. Returns -1 if not found
  15138. */
  15139. getBoneIndexByName(name: string): number;
  15140. /**
  15141. * Creater a new animation range
  15142. * @param name defines the name of the range
  15143. * @param from defines the start key
  15144. * @param to defines the end key
  15145. */
  15146. createAnimationRange(name: string, from: number, to: number): void;
  15147. /**
  15148. * Delete a specific animation range
  15149. * @param name defines the name of the range
  15150. * @param deleteFrames defines if frames must be removed as well
  15151. */
  15152. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15153. /**
  15154. * Gets a specific animation range
  15155. * @param name defines the name of the range to look for
  15156. * @returns the requested animation range or null if not found
  15157. */
  15158. getAnimationRange(name: string): Nullable<AnimationRange>;
  15159. /**
  15160. * Gets the list of all animation ranges defined on this skeleton
  15161. * @returns an array
  15162. */
  15163. getAnimationRanges(): Nullable<AnimationRange>[];
  15164. /**
  15165. * Copy animation range from a source skeleton.
  15166. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15167. * @param source defines the source skeleton
  15168. * @param name defines the name of the range to copy
  15169. * @param rescaleAsRequired defines if rescaling must be applied if required
  15170. * @returns true if operation was successful
  15171. */
  15172. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15173. /**
  15174. * Forces the skeleton to go to rest pose
  15175. */
  15176. returnToRest(): void;
  15177. private _getHighestAnimationFrame;
  15178. /**
  15179. * Begin a specific animation range
  15180. * @param name defines the name of the range to start
  15181. * @param loop defines if looping must be turned on (false by default)
  15182. * @param speedRatio defines the speed ratio to apply (1 by default)
  15183. * @param onAnimationEnd defines a callback which will be called when animation will end
  15184. * @returns a new animatable
  15185. */
  15186. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15187. /**
  15188. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15189. * @param skeleton defines the Skeleton containing the animation range to convert
  15190. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15191. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15192. * @returns the original skeleton
  15193. */
  15194. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15195. /** @hidden */
  15196. _markAsDirty(): void;
  15197. /** @hidden */
  15198. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15199. /** @hidden */
  15200. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15201. private _computeTransformMatrices;
  15202. /**
  15203. * Build all resources required to render a skeleton
  15204. */
  15205. prepare(): void;
  15206. /**
  15207. * Gets the list of animatables currently running for this skeleton
  15208. * @returns an array of animatables
  15209. */
  15210. getAnimatables(): IAnimatable[];
  15211. /**
  15212. * Clone the current skeleton
  15213. * @param name defines the name of the new skeleton
  15214. * @param id defines the id of the new skeleton
  15215. * @returns the new skeleton
  15216. */
  15217. clone(name: string, id?: string): Skeleton;
  15218. /**
  15219. * Enable animation blending for this skeleton
  15220. * @param blendingSpeed defines the blending speed to apply
  15221. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15222. */
  15223. enableBlending(blendingSpeed?: number): void;
  15224. /**
  15225. * Releases all resources associated with the current skeleton
  15226. */
  15227. dispose(): void;
  15228. /**
  15229. * Serialize the skeleton in a JSON object
  15230. * @returns a JSON object
  15231. */
  15232. serialize(): any;
  15233. /**
  15234. * Creates a new skeleton from serialized data
  15235. * @param parsedSkeleton defines the serialized data
  15236. * @param scene defines the hosting scene
  15237. * @returns a new skeleton
  15238. */
  15239. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15240. /**
  15241. * Compute all node absolute transforms
  15242. * @param forceUpdate defines if computation must be done even if cache is up to date
  15243. */
  15244. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15245. /**
  15246. * Gets the root pose matrix
  15247. * @returns a matrix
  15248. */
  15249. getPoseMatrix(): Nullable<Matrix>;
  15250. /**
  15251. * Sorts bones per internal index
  15252. */
  15253. sortBones(): void;
  15254. private _sortBones;
  15255. }
  15256. }
  15257. declare module BABYLON {
  15258. /**
  15259. * Creates an instance based on a source mesh.
  15260. */
  15261. export class InstancedMesh extends AbstractMesh {
  15262. private _sourceMesh;
  15263. private _currentLOD;
  15264. /** @hidden */
  15265. _indexInSourceMeshInstanceArray: number;
  15266. constructor(name: string, source: Mesh);
  15267. /**
  15268. * Returns the string "InstancedMesh".
  15269. */
  15270. getClassName(): string;
  15271. /** Gets the list of lights affecting that mesh */
  15272. get lightSources(): Light[];
  15273. _resyncLightSources(): void;
  15274. _resyncLightSource(light: Light): void;
  15275. _removeLightSource(light: Light, dispose: boolean): void;
  15276. /**
  15277. * If the source mesh receives shadows
  15278. */
  15279. get receiveShadows(): boolean;
  15280. /**
  15281. * The material of the source mesh
  15282. */
  15283. get material(): Nullable<Material>;
  15284. /**
  15285. * Visibility of the source mesh
  15286. */
  15287. get visibility(): number;
  15288. /**
  15289. * Skeleton of the source mesh
  15290. */
  15291. get skeleton(): Nullable<Skeleton>;
  15292. /**
  15293. * Rendering ground id of the source mesh
  15294. */
  15295. get renderingGroupId(): number;
  15296. set renderingGroupId(value: number);
  15297. /**
  15298. * Returns the total number of vertices (integer).
  15299. */
  15300. getTotalVertices(): number;
  15301. /**
  15302. * Returns a positive integer : the total number of indices in this mesh geometry.
  15303. * @returns the numner of indices or zero if the mesh has no geometry.
  15304. */
  15305. getTotalIndices(): number;
  15306. /**
  15307. * The source mesh of the instance
  15308. */
  15309. get sourceMesh(): Mesh;
  15310. /**
  15311. * Is this node ready to be used/rendered
  15312. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15313. * @return {boolean} is it ready
  15314. */
  15315. isReady(completeCheck?: boolean): boolean;
  15316. /**
  15317. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15318. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15319. * @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.
  15320. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15321. */
  15322. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15323. /**
  15324. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15325. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15326. * The `data` are either a numeric array either a Float32Array.
  15327. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15328. * 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).
  15329. * Note that a new underlying VertexBuffer object is created each call.
  15330. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15331. *
  15332. * Possible `kind` values :
  15333. * - VertexBuffer.PositionKind
  15334. * - VertexBuffer.UVKind
  15335. * - VertexBuffer.UV2Kind
  15336. * - VertexBuffer.UV3Kind
  15337. * - VertexBuffer.UV4Kind
  15338. * - VertexBuffer.UV5Kind
  15339. * - VertexBuffer.UV6Kind
  15340. * - VertexBuffer.ColorKind
  15341. * - VertexBuffer.MatricesIndicesKind
  15342. * - VertexBuffer.MatricesIndicesExtraKind
  15343. * - VertexBuffer.MatricesWeightsKind
  15344. * - VertexBuffer.MatricesWeightsExtraKind
  15345. *
  15346. * Returns the Mesh.
  15347. */
  15348. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15349. /**
  15350. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15351. * If the mesh has no geometry, it is simply returned as it is.
  15352. * The `data` are either a numeric array either a Float32Array.
  15353. * No new underlying VertexBuffer object is created.
  15354. * 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.
  15355. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15356. *
  15357. * Possible `kind` values :
  15358. * - VertexBuffer.PositionKind
  15359. * - VertexBuffer.UVKind
  15360. * - VertexBuffer.UV2Kind
  15361. * - VertexBuffer.UV3Kind
  15362. * - VertexBuffer.UV4Kind
  15363. * - VertexBuffer.UV5Kind
  15364. * - VertexBuffer.UV6Kind
  15365. * - VertexBuffer.ColorKind
  15366. * - VertexBuffer.MatricesIndicesKind
  15367. * - VertexBuffer.MatricesIndicesExtraKind
  15368. * - VertexBuffer.MatricesWeightsKind
  15369. * - VertexBuffer.MatricesWeightsExtraKind
  15370. *
  15371. * Returns the Mesh.
  15372. */
  15373. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15374. /**
  15375. * Sets the mesh indices.
  15376. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15377. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15378. * This method creates a new index buffer each call.
  15379. * Returns the Mesh.
  15380. */
  15381. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15382. /**
  15383. * Boolean : True if the mesh owns the requested kind of data.
  15384. */
  15385. isVerticesDataPresent(kind: string): boolean;
  15386. /**
  15387. * Returns an array of indices (IndicesArray).
  15388. */
  15389. getIndices(): Nullable<IndicesArray>;
  15390. get _positions(): Nullable<Vector3[]>;
  15391. /**
  15392. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15393. * This means the mesh underlying bounding box and sphere are recomputed.
  15394. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15395. * @returns the current mesh
  15396. */
  15397. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15398. /** @hidden */
  15399. _preActivate(): InstancedMesh;
  15400. /** @hidden */
  15401. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15402. /** @hidden */
  15403. _postActivate(): void;
  15404. getWorldMatrix(): Matrix;
  15405. get isAnInstance(): boolean;
  15406. /**
  15407. * Returns the current associated LOD AbstractMesh.
  15408. */
  15409. getLOD(camera: Camera): AbstractMesh;
  15410. /** @hidden */
  15411. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15412. /** @hidden */
  15413. _syncSubMeshes(): InstancedMesh;
  15414. /** @hidden */
  15415. _generatePointsArray(): boolean;
  15416. /**
  15417. * Creates a new InstancedMesh from the current mesh.
  15418. * - name (string) : the cloned mesh name
  15419. * - newParent (optional Node) : the optional Node to parent the clone to.
  15420. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15421. *
  15422. * Returns the clone.
  15423. */
  15424. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15425. /**
  15426. * Disposes the InstancedMesh.
  15427. * Returns nothing.
  15428. */
  15429. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15430. }
  15431. interface Mesh {
  15432. /**
  15433. * Register a custom buffer that will be instanced
  15434. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15435. * @param kind defines the buffer kind
  15436. * @param stride defines the stride in floats
  15437. */
  15438. registerInstancedBuffer(kind: string, stride: number): void;
  15439. /** @hidden */
  15440. _userInstancedBuffersStorage: {
  15441. data: {
  15442. [key: string]: Float32Array;
  15443. };
  15444. sizes: {
  15445. [key: string]: number;
  15446. };
  15447. vertexBuffers: {
  15448. [key: string]: Nullable<VertexBuffer>;
  15449. };
  15450. strides: {
  15451. [key: string]: number;
  15452. };
  15453. };
  15454. }
  15455. interface AbstractMesh {
  15456. /**
  15457. * Object used to store instanced buffers defined by user
  15458. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15459. */
  15460. instancedBuffers: {
  15461. [key: string]: any;
  15462. };
  15463. }
  15464. }
  15465. declare module BABYLON {
  15466. /**
  15467. * Defines the options associated with the creation of a shader material.
  15468. */
  15469. export interface IShaderMaterialOptions {
  15470. /**
  15471. * Does the material work in alpha blend mode
  15472. */
  15473. needAlphaBlending: boolean;
  15474. /**
  15475. * Does the material work in alpha test mode
  15476. */
  15477. needAlphaTesting: boolean;
  15478. /**
  15479. * The list of attribute names used in the shader
  15480. */
  15481. attributes: string[];
  15482. /**
  15483. * The list of unifrom names used in the shader
  15484. */
  15485. uniforms: string[];
  15486. /**
  15487. * The list of UBO names used in the shader
  15488. */
  15489. uniformBuffers: string[];
  15490. /**
  15491. * The list of sampler names used in the shader
  15492. */
  15493. samplers: string[];
  15494. /**
  15495. * The list of defines used in the shader
  15496. */
  15497. defines: string[];
  15498. }
  15499. /**
  15500. * 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.
  15501. *
  15502. * This returned material effects how the mesh will look based on the code in the shaders.
  15503. *
  15504. * @see http://doc.babylonjs.com/how_to/shader_material
  15505. */
  15506. export class ShaderMaterial extends Material {
  15507. private _shaderPath;
  15508. private _options;
  15509. private _textures;
  15510. private _textureArrays;
  15511. private _floats;
  15512. private _ints;
  15513. private _floatsArrays;
  15514. private _colors3;
  15515. private _colors3Arrays;
  15516. private _colors4;
  15517. private _colors4Arrays;
  15518. private _vectors2;
  15519. private _vectors3;
  15520. private _vectors4;
  15521. private _matrices;
  15522. private _matrixArrays;
  15523. private _matrices3x3;
  15524. private _matrices2x2;
  15525. private _vectors2Arrays;
  15526. private _vectors3Arrays;
  15527. private _vectors4Arrays;
  15528. private _cachedWorldViewMatrix;
  15529. private _cachedWorldViewProjectionMatrix;
  15530. private _renderId;
  15531. private _multiview;
  15532. private _cachedDefines;
  15533. /**
  15534. * Instantiate a new shader material.
  15535. * 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.
  15536. * This returned material effects how the mesh will look based on the code in the shaders.
  15537. * @see http://doc.babylonjs.com/how_to/shader_material
  15538. * @param name Define the name of the material in the scene
  15539. * @param scene Define the scene the material belongs to
  15540. * @param shaderPath Defines the route to the shader code in one of three ways:
  15541. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15542. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15543. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15544. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15545. * @param options Define the options used to create the shader
  15546. */
  15547. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15548. /**
  15549. * Gets the shader path used to define the shader code
  15550. * It can be modified to trigger a new compilation
  15551. */
  15552. get shaderPath(): any;
  15553. /**
  15554. * Sets the shader path used to define the shader code
  15555. * It can be modified to trigger a new compilation
  15556. */
  15557. set shaderPath(shaderPath: any);
  15558. /**
  15559. * Gets the options used to compile the shader.
  15560. * They can be modified to trigger a new compilation
  15561. */
  15562. get options(): IShaderMaterialOptions;
  15563. /**
  15564. * Gets the current class name of the material e.g. "ShaderMaterial"
  15565. * Mainly use in serialization.
  15566. * @returns the class name
  15567. */
  15568. getClassName(): string;
  15569. /**
  15570. * Specifies if the material will require alpha blending
  15571. * @returns a boolean specifying if alpha blending is needed
  15572. */
  15573. needAlphaBlending(): boolean;
  15574. /**
  15575. * Specifies if this material should be rendered in alpha test mode
  15576. * @returns a boolean specifying if an alpha test is needed.
  15577. */
  15578. needAlphaTesting(): boolean;
  15579. private _checkUniform;
  15580. /**
  15581. * Set a texture in the shader.
  15582. * @param name Define the name of the uniform samplers as defined in the shader
  15583. * @param texture Define the texture to bind to this sampler
  15584. * @return the material itself allowing "fluent" like uniform updates
  15585. */
  15586. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15587. /**
  15588. * Set a texture array in the shader.
  15589. * @param name Define the name of the uniform sampler array as defined in the shader
  15590. * @param textures Define the list of textures to bind to this sampler
  15591. * @return the material itself allowing "fluent" like uniform updates
  15592. */
  15593. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15594. /**
  15595. * Set a float in the shader.
  15596. * @param name Define the name of the uniform as defined in the shader
  15597. * @param value Define the value to give to the uniform
  15598. * @return the material itself allowing "fluent" like uniform updates
  15599. */
  15600. setFloat(name: string, value: number): ShaderMaterial;
  15601. /**
  15602. * Set a int in the shader.
  15603. * @param name Define the name of the uniform as defined in the shader
  15604. * @param value Define the value to give to the uniform
  15605. * @return the material itself allowing "fluent" like uniform updates
  15606. */
  15607. setInt(name: string, value: number): ShaderMaterial;
  15608. /**
  15609. * Set an array of floats in the shader.
  15610. * @param name Define the name of the uniform as defined in the shader
  15611. * @param value Define the value to give to the uniform
  15612. * @return the material itself allowing "fluent" like uniform updates
  15613. */
  15614. setFloats(name: string, value: number[]): ShaderMaterial;
  15615. /**
  15616. * Set a vec3 in the shader from a Color3.
  15617. * @param name Define the name of the uniform as defined in the shader
  15618. * @param value Define the value to give to the uniform
  15619. * @return the material itself allowing "fluent" like uniform updates
  15620. */
  15621. setColor3(name: string, value: Color3): ShaderMaterial;
  15622. /**
  15623. * Set a vec3 array in the shader from a Color3 array.
  15624. * @param name Define the name of the uniform as defined in the shader
  15625. * @param value Define the value to give to the uniform
  15626. * @return the material itself allowing "fluent" like uniform updates
  15627. */
  15628. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15629. /**
  15630. * Set a vec4 in the shader from a Color4.
  15631. * @param name Define the name of the uniform as defined in the shader
  15632. * @param value Define the value to give to the uniform
  15633. * @return the material itself allowing "fluent" like uniform updates
  15634. */
  15635. setColor4(name: string, value: Color4): ShaderMaterial;
  15636. /**
  15637. * Set a vec4 array in the shader from a Color4 array.
  15638. * @param name Define the name of the uniform as defined in the shader
  15639. * @param value Define the value to give to the uniform
  15640. * @return the material itself allowing "fluent" like uniform updates
  15641. */
  15642. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15643. /**
  15644. * Set a vec2 in the shader from a Vector2.
  15645. * @param name Define the name of the uniform as defined in the shader
  15646. * @param value Define the value to give to the uniform
  15647. * @return the material itself allowing "fluent" like uniform updates
  15648. */
  15649. setVector2(name: string, value: Vector2): ShaderMaterial;
  15650. /**
  15651. * Set a vec3 in the shader from a Vector3.
  15652. * @param name Define the name of the uniform as defined in the shader
  15653. * @param value Define the value to give to the uniform
  15654. * @return the material itself allowing "fluent" like uniform updates
  15655. */
  15656. setVector3(name: string, value: Vector3): ShaderMaterial;
  15657. /**
  15658. * Set a vec4 in the shader from a Vector4.
  15659. * @param name Define the name of the uniform as defined in the shader
  15660. * @param value Define the value to give to the uniform
  15661. * @return the material itself allowing "fluent" like uniform updates
  15662. */
  15663. setVector4(name: string, value: Vector4): ShaderMaterial;
  15664. /**
  15665. * Set a mat4 in the shader from a Matrix.
  15666. * @param name Define the name of the uniform as defined in the shader
  15667. * @param value Define the value to give to the uniform
  15668. * @return the material itself allowing "fluent" like uniform updates
  15669. */
  15670. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15671. /**
  15672. * Set a float32Array in the shader from a matrix array.
  15673. * @param name Define the name of the uniform as defined in the shader
  15674. * @param value Define the value to give to the uniform
  15675. * @return the material itself allowing "fluent" like uniform updates
  15676. */
  15677. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15678. /**
  15679. * Set a mat3 in the shader from a Float32Array.
  15680. * @param name Define the name of the uniform as defined in the shader
  15681. * @param value Define the value to give to the uniform
  15682. * @return the material itself allowing "fluent" like uniform updates
  15683. */
  15684. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15685. /**
  15686. * Set a mat2 in the shader from a Float32Array.
  15687. * @param name Define the name of the uniform as defined in the shader
  15688. * @param value Define the value to give to the uniform
  15689. * @return the material itself allowing "fluent" like uniform updates
  15690. */
  15691. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15692. /**
  15693. * Set a vec2 array in the shader from a number array.
  15694. * @param name Define the name of the uniform as defined in the shader
  15695. * @param value Define the value to give to the uniform
  15696. * @return the material itself allowing "fluent" like uniform updates
  15697. */
  15698. setArray2(name: string, value: number[]): ShaderMaterial;
  15699. /**
  15700. * Set a vec3 array in the shader from a number array.
  15701. * @param name Define the name of the uniform as defined in the shader
  15702. * @param value Define the value to give to the uniform
  15703. * @return the material itself allowing "fluent" like uniform updates
  15704. */
  15705. setArray3(name: string, value: number[]): ShaderMaterial;
  15706. /**
  15707. * Set a vec4 array in the shader from a number array.
  15708. * @param name Define the name of the uniform as defined in the shader
  15709. * @param value Define the value to give to the uniform
  15710. * @return the material itself allowing "fluent" like uniform updates
  15711. */
  15712. setArray4(name: string, value: number[]): ShaderMaterial;
  15713. private _checkCache;
  15714. /**
  15715. * Specifies that the submesh is ready to be used
  15716. * @param mesh defines the mesh to check
  15717. * @param subMesh defines which submesh to check
  15718. * @param useInstances specifies that instances should be used
  15719. * @returns a boolean indicating that the submesh is ready or not
  15720. */
  15721. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15722. /**
  15723. * Checks if the material is ready to render the requested mesh
  15724. * @param mesh Define the mesh to render
  15725. * @param useInstances Define whether or not the material is used with instances
  15726. * @returns true if ready, otherwise false
  15727. */
  15728. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15729. /**
  15730. * Binds the world matrix to the material
  15731. * @param world defines the world transformation matrix
  15732. * @param effectOverride - If provided, use this effect instead of internal effect
  15733. */
  15734. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  15735. /**
  15736. * Binds the submesh to this material by preparing the effect and shader to draw
  15737. * @param world defines the world transformation matrix
  15738. * @param mesh defines the mesh containing the submesh
  15739. * @param subMesh defines the submesh to bind the material to
  15740. */
  15741. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15742. /**
  15743. * Binds the material to the mesh
  15744. * @param world defines the world transformation matrix
  15745. * @param mesh defines the mesh to bind the material to
  15746. * @param effectOverride - If provided, use this effect instead of internal effect
  15747. */
  15748. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  15749. protected _afterBind(mesh?: Mesh): void;
  15750. /**
  15751. * Gets the active textures from the material
  15752. * @returns an array of textures
  15753. */
  15754. getActiveTextures(): BaseTexture[];
  15755. /**
  15756. * Specifies if the material uses a texture
  15757. * @param texture defines the texture to check against the material
  15758. * @returns a boolean specifying if the material uses the texture
  15759. */
  15760. hasTexture(texture: BaseTexture): boolean;
  15761. /**
  15762. * Makes a duplicate of the material, and gives it a new name
  15763. * @param name defines the new name for the duplicated material
  15764. * @returns the cloned material
  15765. */
  15766. clone(name: string): ShaderMaterial;
  15767. /**
  15768. * Disposes the material
  15769. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15770. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15771. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15772. */
  15773. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15774. /**
  15775. * Serializes this material in a JSON representation
  15776. * @returns the serialized material object
  15777. */
  15778. serialize(): any;
  15779. /**
  15780. * Creates a shader material from parsed shader material data
  15781. * @param source defines the JSON represnetation of the material
  15782. * @param scene defines the hosting scene
  15783. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15784. * @returns a new material
  15785. */
  15786. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15787. }
  15788. }
  15789. declare module BABYLON {
  15790. /** @hidden */
  15791. export var colorPixelShader: {
  15792. name: string;
  15793. shader: string;
  15794. };
  15795. }
  15796. declare module BABYLON {
  15797. /** @hidden */
  15798. export var colorVertexShader: {
  15799. name: string;
  15800. shader: string;
  15801. };
  15802. }
  15803. declare module BABYLON {
  15804. /**
  15805. * Line mesh
  15806. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15807. */
  15808. export class LinesMesh extends Mesh {
  15809. /**
  15810. * If vertex color should be applied to the mesh
  15811. */
  15812. readonly useVertexColor?: boolean | undefined;
  15813. /**
  15814. * If vertex alpha should be applied to the mesh
  15815. */
  15816. readonly useVertexAlpha?: boolean | undefined;
  15817. /**
  15818. * Color of the line (Default: White)
  15819. */
  15820. color: Color3;
  15821. /**
  15822. * Alpha of the line (Default: 1)
  15823. */
  15824. alpha: number;
  15825. /**
  15826. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15827. * This margin is expressed in world space coordinates, so its value may vary.
  15828. * Default value is 0.1
  15829. */
  15830. intersectionThreshold: number;
  15831. private _colorShader;
  15832. private color4;
  15833. /**
  15834. * Creates a new LinesMesh
  15835. * @param name defines the name
  15836. * @param scene defines the hosting scene
  15837. * @param parent defines the parent mesh if any
  15838. * @param source defines the optional source LinesMesh used to clone data from
  15839. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15840. * When false, achieved by calling a clone(), also passing False.
  15841. * This will make creation of children, recursive.
  15842. * @param useVertexColor defines if this LinesMesh supports vertex color
  15843. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15844. */
  15845. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15846. /**
  15847. * If vertex color should be applied to the mesh
  15848. */
  15849. useVertexColor?: boolean | undefined,
  15850. /**
  15851. * If vertex alpha should be applied to the mesh
  15852. */
  15853. useVertexAlpha?: boolean | undefined);
  15854. private _addClipPlaneDefine;
  15855. private _removeClipPlaneDefine;
  15856. isReady(): boolean;
  15857. /**
  15858. * Returns the string "LineMesh"
  15859. */
  15860. getClassName(): string;
  15861. /**
  15862. * @hidden
  15863. */
  15864. get material(): Material;
  15865. /**
  15866. * @hidden
  15867. */
  15868. set material(value: Material);
  15869. /**
  15870. * @hidden
  15871. */
  15872. get checkCollisions(): boolean;
  15873. /** @hidden */
  15874. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15875. /** @hidden */
  15876. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15877. /**
  15878. * Disposes of the line mesh
  15879. * @param doNotRecurse If children should be disposed
  15880. */
  15881. dispose(doNotRecurse?: boolean): void;
  15882. /**
  15883. * Returns a new LineMesh object cloned from the current one.
  15884. */
  15885. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15886. /**
  15887. * Creates a new InstancedLinesMesh object from the mesh model.
  15888. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15889. * @param name defines the name of the new instance
  15890. * @returns a new InstancedLinesMesh
  15891. */
  15892. createInstance(name: string): InstancedLinesMesh;
  15893. }
  15894. /**
  15895. * Creates an instance based on a source LinesMesh
  15896. */
  15897. export class InstancedLinesMesh extends InstancedMesh {
  15898. /**
  15899. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15900. * This margin is expressed in world space coordinates, so its value may vary.
  15901. * Initilized with the intersectionThreshold value of the source LinesMesh
  15902. */
  15903. intersectionThreshold: number;
  15904. constructor(name: string, source: LinesMesh);
  15905. /**
  15906. * Returns the string "InstancedLinesMesh".
  15907. */
  15908. getClassName(): string;
  15909. }
  15910. }
  15911. declare module BABYLON {
  15912. /** @hidden */
  15913. export var linePixelShader: {
  15914. name: string;
  15915. shader: string;
  15916. };
  15917. }
  15918. declare module BABYLON {
  15919. /** @hidden */
  15920. export var lineVertexShader: {
  15921. name: string;
  15922. shader: string;
  15923. };
  15924. }
  15925. declare module BABYLON {
  15926. interface AbstractMesh {
  15927. /**
  15928. * Gets the edgesRenderer associated with the mesh
  15929. */
  15930. edgesRenderer: Nullable<EdgesRenderer>;
  15931. }
  15932. interface LinesMesh {
  15933. /**
  15934. * Enables the edge rendering mode on the mesh.
  15935. * This mode makes the mesh edges visible
  15936. * @param epsilon defines the maximal distance between two angles to detect a face
  15937. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15938. * @returns the currentAbstractMesh
  15939. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15940. */
  15941. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15942. }
  15943. interface InstancedLinesMesh {
  15944. /**
  15945. * Enables the edge rendering mode on the mesh.
  15946. * This mode makes the mesh edges visible
  15947. * @param epsilon defines the maximal distance between two angles to detect a face
  15948. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15949. * @returns the current InstancedLinesMesh
  15950. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15951. */
  15952. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15953. }
  15954. /**
  15955. * Defines the minimum contract an Edges renderer should follow.
  15956. */
  15957. export interface IEdgesRenderer extends IDisposable {
  15958. /**
  15959. * Gets or sets a boolean indicating if the edgesRenderer is active
  15960. */
  15961. isEnabled: boolean;
  15962. /**
  15963. * Renders the edges of the attached mesh,
  15964. */
  15965. render(): void;
  15966. /**
  15967. * Checks wether or not the edges renderer is ready to render.
  15968. * @return true if ready, otherwise false.
  15969. */
  15970. isReady(): boolean;
  15971. }
  15972. /**
  15973. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15974. */
  15975. export class EdgesRenderer implements IEdgesRenderer {
  15976. /**
  15977. * Define the size of the edges with an orthographic camera
  15978. */
  15979. edgesWidthScalerForOrthographic: number;
  15980. /**
  15981. * Define the size of the edges with a perspective camera
  15982. */
  15983. edgesWidthScalerForPerspective: number;
  15984. protected _source: AbstractMesh;
  15985. protected _linesPositions: number[];
  15986. protected _linesNormals: number[];
  15987. protected _linesIndices: number[];
  15988. protected _epsilon: number;
  15989. protected _indicesCount: number;
  15990. protected _lineShader: ShaderMaterial;
  15991. protected _ib: DataBuffer;
  15992. protected _buffers: {
  15993. [key: string]: Nullable<VertexBuffer>;
  15994. };
  15995. protected _checkVerticesInsteadOfIndices: boolean;
  15996. private _meshRebuildObserver;
  15997. private _meshDisposeObserver;
  15998. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15999. isEnabled: boolean;
  16000. /**
  16001. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16002. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16003. * @param source Mesh used to create edges
  16004. * @param epsilon sum of angles in adjacency to check for edge
  16005. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16006. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16007. */
  16008. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16009. protected _prepareRessources(): void;
  16010. /** @hidden */
  16011. _rebuild(): void;
  16012. /**
  16013. * Releases the required resources for the edges renderer
  16014. */
  16015. dispose(): void;
  16016. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16017. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16018. /**
  16019. * Checks if the pair of p0 and p1 is en edge
  16020. * @param faceIndex
  16021. * @param edge
  16022. * @param faceNormals
  16023. * @param p0
  16024. * @param p1
  16025. * @private
  16026. */
  16027. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16028. /**
  16029. * push line into the position, normal and index buffer
  16030. * @protected
  16031. */
  16032. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16033. /**
  16034. * Generates lines edges from adjacencjes
  16035. * @private
  16036. */
  16037. _generateEdgesLines(): void;
  16038. /**
  16039. * Checks wether or not the edges renderer is ready to render.
  16040. * @return true if ready, otherwise false.
  16041. */
  16042. isReady(): boolean;
  16043. /**
  16044. * Renders the edges of the attached mesh,
  16045. */
  16046. render(): void;
  16047. }
  16048. /**
  16049. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16050. */
  16051. export class LineEdgesRenderer extends EdgesRenderer {
  16052. /**
  16053. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16054. * @param source LineMesh used to generate edges
  16055. * @param epsilon not important (specified angle for edge detection)
  16056. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16057. */
  16058. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16059. /**
  16060. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16061. */
  16062. _generateEdgesLines(): void;
  16063. }
  16064. }
  16065. declare module BABYLON {
  16066. /**
  16067. * This represents the object necessary to create a rendering group.
  16068. * This is exclusively used and created by the rendering manager.
  16069. * To modify the behavior, you use the available helpers in your scene or meshes.
  16070. * @hidden
  16071. */
  16072. export class RenderingGroup {
  16073. index: number;
  16074. private static _zeroVector;
  16075. private _scene;
  16076. private _opaqueSubMeshes;
  16077. private _transparentSubMeshes;
  16078. private _alphaTestSubMeshes;
  16079. private _depthOnlySubMeshes;
  16080. private _particleSystems;
  16081. private _spriteManagers;
  16082. private _opaqueSortCompareFn;
  16083. private _alphaTestSortCompareFn;
  16084. private _transparentSortCompareFn;
  16085. private _renderOpaque;
  16086. private _renderAlphaTest;
  16087. private _renderTransparent;
  16088. /** @hidden */
  16089. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16090. onBeforeTransparentRendering: () => void;
  16091. /**
  16092. * Set the opaque sort comparison function.
  16093. * If null the sub meshes will be render in the order they were created
  16094. */
  16095. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16096. /**
  16097. * Set the alpha test sort comparison function.
  16098. * If null the sub meshes will be render in the order they were created
  16099. */
  16100. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16101. /**
  16102. * Set the transparent sort comparison function.
  16103. * If null the sub meshes will be render in the order they were created
  16104. */
  16105. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16106. /**
  16107. * Creates a new rendering group.
  16108. * @param index The rendering group index
  16109. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16110. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16111. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16112. */
  16113. 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>);
  16114. /**
  16115. * Render all the sub meshes contained in the group.
  16116. * @param customRenderFunction Used to override the default render behaviour of the group.
  16117. * @returns true if rendered some submeshes.
  16118. */
  16119. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16120. /**
  16121. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16122. * @param subMeshes The submeshes to render
  16123. */
  16124. private renderOpaqueSorted;
  16125. /**
  16126. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16127. * @param subMeshes The submeshes to render
  16128. */
  16129. private renderAlphaTestSorted;
  16130. /**
  16131. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16132. * @param subMeshes The submeshes to render
  16133. */
  16134. private renderTransparentSorted;
  16135. /**
  16136. * Renders the submeshes in a specified order.
  16137. * @param subMeshes The submeshes to sort before render
  16138. * @param sortCompareFn The comparison function use to sort
  16139. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16140. * @param transparent Specifies to activate blending if true
  16141. */
  16142. private static renderSorted;
  16143. /**
  16144. * Renders the submeshes in the order they were dispatched (no sort applied).
  16145. * @param subMeshes The submeshes to render
  16146. */
  16147. private static renderUnsorted;
  16148. /**
  16149. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16150. * are rendered back to front if in the same alpha index.
  16151. *
  16152. * @param a The first submesh
  16153. * @param b The second submesh
  16154. * @returns The result of the comparison
  16155. */
  16156. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16157. /**
  16158. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16159. * are rendered back to front.
  16160. *
  16161. * @param a The first submesh
  16162. * @param b The second submesh
  16163. * @returns The result of the comparison
  16164. */
  16165. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16166. /**
  16167. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16168. * are rendered front to back (prevent overdraw).
  16169. *
  16170. * @param a The first submesh
  16171. * @param b The second submesh
  16172. * @returns The result of the comparison
  16173. */
  16174. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16175. /**
  16176. * Resets the different lists of submeshes to prepare a new frame.
  16177. */
  16178. prepare(): void;
  16179. dispose(): void;
  16180. /**
  16181. * Inserts the submesh in its correct queue depending on its material.
  16182. * @param subMesh The submesh to dispatch
  16183. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16184. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16185. */
  16186. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16187. dispatchSprites(spriteManager: ISpriteManager): void;
  16188. dispatchParticles(particleSystem: IParticleSystem): void;
  16189. private _renderParticles;
  16190. private _renderSprites;
  16191. }
  16192. }
  16193. declare module BABYLON {
  16194. /**
  16195. * Interface describing the different options available in the rendering manager
  16196. * regarding Auto Clear between groups.
  16197. */
  16198. export interface IRenderingManagerAutoClearSetup {
  16199. /**
  16200. * Defines whether or not autoclear is enable.
  16201. */
  16202. autoClear: boolean;
  16203. /**
  16204. * Defines whether or not to autoclear the depth buffer.
  16205. */
  16206. depth: boolean;
  16207. /**
  16208. * Defines whether or not to autoclear the stencil buffer.
  16209. */
  16210. stencil: boolean;
  16211. }
  16212. /**
  16213. * This class is used by the onRenderingGroupObservable
  16214. */
  16215. export class RenderingGroupInfo {
  16216. /**
  16217. * The Scene that being rendered
  16218. */
  16219. scene: Scene;
  16220. /**
  16221. * The camera currently used for the rendering pass
  16222. */
  16223. camera: Nullable<Camera>;
  16224. /**
  16225. * The ID of the renderingGroup being processed
  16226. */
  16227. renderingGroupId: number;
  16228. }
  16229. /**
  16230. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16231. * It is enable to manage the different groups as well as the different necessary sort functions.
  16232. * This should not be used directly aside of the few static configurations
  16233. */
  16234. export class RenderingManager {
  16235. /**
  16236. * The max id used for rendering groups (not included)
  16237. */
  16238. static MAX_RENDERINGGROUPS: number;
  16239. /**
  16240. * The min id used for rendering groups (included)
  16241. */
  16242. static MIN_RENDERINGGROUPS: number;
  16243. /**
  16244. * Used to globally prevent autoclearing scenes.
  16245. */
  16246. static AUTOCLEAR: boolean;
  16247. /**
  16248. * @hidden
  16249. */
  16250. _useSceneAutoClearSetup: boolean;
  16251. private _scene;
  16252. private _renderingGroups;
  16253. private _depthStencilBufferAlreadyCleaned;
  16254. private _autoClearDepthStencil;
  16255. private _customOpaqueSortCompareFn;
  16256. private _customAlphaTestSortCompareFn;
  16257. private _customTransparentSortCompareFn;
  16258. private _renderingGroupInfo;
  16259. /**
  16260. * Instantiates a new rendering group for a particular scene
  16261. * @param scene Defines the scene the groups belongs to
  16262. */
  16263. constructor(scene: Scene);
  16264. private _clearDepthStencilBuffer;
  16265. /**
  16266. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16267. * @hidden
  16268. */
  16269. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16270. /**
  16271. * Resets the different information of the group to prepare a new frame
  16272. * @hidden
  16273. */
  16274. reset(): void;
  16275. /**
  16276. * Dispose and release the group and its associated resources.
  16277. * @hidden
  16278. */
  16279. dispose(): void;
  16280. /**
  16281. * Clear the info related to rendering groups preventing retention points during dispose.
  16282. */
  16283. freeRenderingGroups(): void;
  16284. private _prepareRenderingGroup;
  16285. /**
  16286. * Add a sprite manager to the rendering manager in order to render it this frame.
  16287. * @param spriteManager Define the sprite manager to render
  16288. */
  16289. dispatchSprites(spriteManager: ISpriteManager): void;
  16290. /**
  16291. * Add a particle system to the rendering manager in order to render it this frame.
  16292. * @param particleSystem Define the particle system to render
  16293. */
  16294. dispatchParticles(particleSystem: IParticleSystem): void;
  16295. /**
  16296. * Add a submesh to the manager in order to render it this frame
  16297. * @param subMesh The submesh to dispatch
  16298. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16299. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16300. */
  16301. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16302. /**
  16303. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16304. * This allowed control for front to back rendering or reversly depending of the special needs.
  16305. *
  16306. * @param renderingGroupId The rendering group id corresponding to its index
  16307. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16308. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16309. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16310. */
  16311. 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;
  16312. /**
  16313. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16314. *
  16315. * @param renderingGroupId The rendering group id corresponding to its index
  16316. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16317. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16318. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16319. */
  16320. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16321. /**
  16322. * Gets the current auto clear configuration for one rendering group of the rendering
  16323. * manager.
  16324. * @param index the rendering group index to get the information for
  16325. * @returns The auto clear setup for the requested rendering group
  16326. */
  16327. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16328. }
  16329. }
  16330. declare module BABYLON {
  16331. /**
  16332. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16333. */
  16334. export interface ICustomShaderOptions {
  16335. /**
  16336. * Gets or sets the custom shader name to use
  16337. */
  16338. shaderName: string;
  16339. /**
  16340. * The list of attribute names used in the shader
  16341. */
  16342. attributes?: string[];
  16343. /**
  16344. * The list of unifrom names used in the shader
  16345. */
  16346. uniforms?: string[];
  16347. /**
  16348. * The list of sampler names used in the shader
  16349. */
  16350. samplers?: string[];
  16351. /**
  16352. * The list of defines used in the shader
  16353. */
  16354. defines?: string[];
  16355. }
  16356. /**
  16357. * Interface to implement to create a shadow generator compatible with BJS.
  16358. */
  16359. export interface IShadowGenerator {
  16360. /**
  16361. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16362. * @returns The render target texture if present otherwise, null
  16363. */
  16364. getShadowMap(): Nullable<RenderTargetTexture>;
  16365. /**
  16366. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16367. * @param subMesh The submesh we want to render in the shadow map
  16368. * @param useInstances Defines wether will draw in the map using instances
  16369. * @returns true if ready otherwise, false
  16370. */
  16371. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16372. /**
  16373. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16374. * @param defines Defines of the material we want to update
  16375. * @param lightIndex Index of the light in the enabled light list of the material
  16376. */
  16377. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16378. /**
  16379. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16380. * defined in the generator but impacting the effect).
  16381. * It implies the unifroms available on the materials are the standard BJS ones.
  16382. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16383. * @param effect The effect we are binfing the information for
  16384. */
  16385. bindShadowLight(lightIndex: string, effect: Effect): void;
  16386. /**
  16387. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16388. * (eq to shadow prjection matrix * light transform matrix)
  16389. * @returns The transform matrix used to create the shadow map
  16390. */
  16391. getTransformMatrix(): Matrix;
  16392. /**
  16393. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16394. * Cube and 2D textures for instance.
  16395. */
  16396. recreateShadowMap(): void;
  16397. /**
  16398. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16399. * @param onCompiled Callback triggered at the and of the effects compilation
  16400. * @param options Sets of optional options forcing the compilation with different modes
  16401. */
  16402. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16403. useInstances: boolean;
  16404. }>): void;
  16405. /**
  16406. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16407. * @param options Sets of optional options forcing the compilation with different modes
  16408. * @returns A promise that resolves when the compilation completes
  16409. */
  16410. forceCompilationAsync(options?: Partial<{
  16411. useInstances: boolean;
  16412. }>): Promise<void>;
  16413. /**
  16414. * Serializes the shadow generator setup to a json object.
  16415. * @returns The serialized JSON object
  16416. */
  16417. serialize(): any;
  16418. /**
  16419. * Disposes the Shadow map and related Textures and effects.
  16420. */
  16421. dispose(): void;
  16422. }
  16423. /**
  16424. * Default implementation IShadowGenerator.
  16425. * This is the main object responsible of generating shadows in the framework.
  16426. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16427. */
  16428. export class ShadowGenerator implements IShadowGenerator {
  16429. /**
  16430. * Name of the shadow generator class
  16431. */
  16432. static CLASSNAME: string;
  16433. /**
  16434. * Shadow generator mode None: no filtering applied.
  16435. */
  16436. static readonly FILTER_NONE: number;
  16437. /**
  16438. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16439. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16440. */
  16441. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16442. /**
  16443. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16444. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16445. */
  16446. static readonly FILTER_POISSONSAMPLING: number;
  16447. /**
  16448. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16449. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16450. */
  16451. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16452. /**
  16453. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16454. * edge artifacts on steep falloff.
  16455. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16456. */
  16457. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16458. /**
  16459. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16460. * edge artifacts on steep falloff.
  16461. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16462. */
  16463. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16464. /**
  16465. * Shadow generator mode PCF: Percentage Closer Filtering
  16466. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16467. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16468. */
  16469. static readonly FILTER_PCF: number;
  16470. /**
  16471. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16472. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16473. * Contact Hardening
  16474. */
  16475. static readonly FILTER_PCSS: number;
  16476. /**
  16477. * Reserved for PCF and PCSS
  16478. * Highest Quality.
  16479. *
  16480. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16481. *
  16482. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16483. */
  16484. static readonly QUALITY_HIGH: number;
  16485. /**
  16486. * Reserved for PCF and PCSS
  16487. * Good tradeoff for quality/perf cross devices
  16488. *
  16489. * Execute PCF on a 3*3 kernel.
  16490. *
  16491. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16492. */
  16493. static readonly QUALITY_MEDIUM: number;
  16494. /**
  16495. * Reserved for PCF and PCSS
  16496. * The lowest quality but the fastest.
  16497. *
  16498. * Execute PCF on a 1*1 kernel.
  16499. *
  16500. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16501. */
  16502. static readonly QUALITY_LOW: number;
  16503. /** Gets or sets the custom shader name to use */
  16504. customShaderOptions: ICustomShaderOptions;
  16505. /**
  16506. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16507. */
  16508. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16509. /**
  16510. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16511. */
  16512. onAfterShadowMapRenderObservable: Observable<Effect>;
  16513. /**
  16514. * Observable triggered before a mesh is rendered in the shadow map.
  16515. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16516. */
  16517. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16518. /**
  16519. * Observable triggered after a mesh is rendered in the shadow map.
  16520. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16521. */
  16522. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16523. protected _bias: number;
  16524. /**
  16525. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16526. */
  16527. get bias(): number;
  16528. /**
  16529. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16530. */
  16531. set bias(bias: number);
  16532. protected _normalBias: number;
  16533. /**
  16534. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16535. */
  16536. get normalBias(): number;
  16537. /**
  16538. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16539. */
  16540. set normalBias(normalBias: number);
  16541. protected _blurBoxOffset: number;
  16542. /**
  16543. * Gets the blur box offset: offset applied during the blur pass.
  16544. * Only useful if useKernelBlur = false
  16545. */
  16546. get blurBoxOffset(): number;
  16547. /**
  16548. * Sets the blur box offset: offset applied during the blur pass.
  16549. * Only useful if useKernelBlur = false
  16550. */
  16551. set blurBoxOffset(value: number);
  16552. protected _blurScale: number;
  16553. /**
  16554. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16555. * 2 means half of the size.
  16556. */
  16557. get blurScale(): number;
  16558. /**
  16559. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16560. * 2 means half of the size.
  16561. */
  16562. set blurScale(value: number);
  16563. protected _blurKernel: number;
  16564. /**
  16565. * Gets the blur kernel: kernel size of the blur pass.
  16566. * Only useful if useKernelBlur = true
  16567. */
  16568. get blurKernel(): number;
  16569. /**
  16570. * Sets the blur kernel: kernel size of the blur pass.
  16571. * Only useful if useKernelBlur = true
  16572. */
  16573. set blurKernel(value: number);
  16574. protected _useKernelBlur: boolean;
  16575. /**
  16576. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16577. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16578. */
  16579. get useKernelBlur(): boolean;
  16580. /**
  16581. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16582. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16583. */
  16584. set useKernelBlur(value: boolean);
  16585. protected _depthScale: number;
  16586. /**
  16587. * Gets the depth scale used in ESM mode.
  16588. */
  16589. get depthScale(): number;
  16590. /**
  16591. * Sets the depth scale used in ESM mode.
  16592. * This can override the scale stored on the light.
  16593. */
  16594. set depthScale(value: number);
  16595. protected _validateFilter(filter: number): number;
  16596. protected _filter: number;
  16597. /**
  16598. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16599. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16600. */
  16601. get filter(): number;
  16602. /**
  16603. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16604. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16605. */
  16606. set filter(value: number);
  16607. /**
  16608. * Gets if the current filter is set to Poisson Sampling.
  16609. */
  16610. get usePoissonSampling(): boolean;
  16611. /**
  16612. * Sets the current filter to Poisson Sampling.
  16613. */
  16614. set usePoissonSampling(value: boolean);
  16615. /**
  16616. * Gets if the current filter is set to ESM.
  16617. */
  16618. get useExponentialShadowMap(): boolean;
  16619. /**
  16620. * Sets the current filter is to ESM.
  16621. */
  16622. set useExponentialShadowMap(value: boolean);
  16623. /**
  16624. * Gets if the current filter is set to filtered ESM.
  16625. */
  16626. get useBlurExponentialShadowMap(): boolean;
  16627. /**
  16628. * Gets if the current filter is set to filtered ESM.
  16629. */
  16630. set useBlurExponentialShadowMap(value: boolean);
  16631. /**
  16632. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16633. * exponential to prevent steep falloff artifacts).
  16634. */
  16635. get useCloseExponentialShadowMap(): boolean;
  16636. /**
  16637. * Sets the current filter to "close ESM" (using the inverse of the
  16638. * exponential to prevent steep falloff artifacts).
  16639. */
  16640. set useCloseExponentialShadowMap(value: boolean);
  16641. /**
  16642. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16643. * exponential to prevent steep falloff artifacts).
  16644. */
  16645. get useBlurCloseExponentialShadowMap(): boolean;
  16646. /**
  16647. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16648. * exponential to prevent steep falloff artifacts).
  16649. */
  16650. set useBlurCloseExponentialShadowMap(value: boolean);
  16651. /**
  16652. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16653. */
  16654. get usePercentageCloserFiltering(): boolean;
  16655. /**
  16656. * Sets the current filter to "PCF" (percentage closer filtering).
  16657. */
  16658. set usePercentageCloserFiltering(value: boolean);
  16659. protected _filteringQuality: number;
  16660. /**
  16661. * Gets the PCF or PCSS Quality.
  16662. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16663. */
  16664. get filteringQuality(): number;
  16665. /**
  16666. * Sets the PCF or PCSS Quality.
  16667. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16668. */
  16669. set filteringQuality(filteringQuality: number);
  16670. /**
  16671. * Gets if the current filter is set to "PCSS" (contact hardening).
  16672. */
  16673. get useContactHardeningShadow(): boolean;
  16674. /**
  16675. * Sets the current filter to "PCSS" (contact hardening).
  16676. */
  16677. set useContactHardeningShadow(value: boolean);
  16678. protected _contactHardeningLightSizeUVRatio: number;
  16679. /**
  16680. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16681. * Using a ratio helps keeping shape stability independently of the map size.
  16682. *
  16683. * It does not account for the light projection as it was having too much
  16684. * instability during the light setup or during light position changes.
  16685. *
  16686. * Only valid if useContactHardeningShadow is true.
  16687. */
  16688. get contactHardeningLightSizeUVRatio(): number;
  16689. /**
  16690. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16691. * Using a ratio helps keeping shape stability independently of the map size.
  16692. *
  16693. * It does not account for the light projection as it was having too much
  16694. * instability during the light setup or during light position changes.
  16695. *
  16696. * Only valid if useContactHardeningShadow is true.
  16697. */
  16698. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16699. protected _darkness: number;
  16700. /** Gets or sets the actual darkness of a shadow */
  16701. get darkness(): number;
  16702. set darkness(value: number);
  16703. /**
  16704. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16705. * 0 means strongest and 1 would means no shadow.
  16706. * @returns the darkness.
  16707. */
  16708. getDarkness(): number;
  16709. /**
  16710. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16711. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16712. * @returns the shadow generator allowing fluent coding.
  16713. */
  16714. setDarkness(darkness: number): ShadowGenerator;
  16715. protected _transparencyShadow: boolean;
  16716. /** Gets or sets the ability to have transparent shadow */
  16717. get transparencyShadow(): boolean;
  16718. set transparencyShadow(value: boolean);
  16719. /**
  16720. * Sets the ability to have transparent shadow (boolean).
  16721. * @param transparent True if transparent else False
  16722. * @returns the shadow generator allowing fluent coding
  16723. */
  16724. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16725. protected _shadowMap: Nullable<RenderTargetTexture>;
  16726. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16727. /**
  16728. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16729. * @returns The render target texture if present otherwise, null
  16730. */
  16731. getShadowMap(): Nullable<RenderTargetTexture>;
  16732. /**
  16733. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16734. * @returns The render target texture if the shadow map is present otherwise, null
  16735. */
  16736. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16737. /**
  16738. * Gets the class name of that object
  16739. * @returns "ShadowGenerator"
  16740. */
  16741. getClassName(): string;
  16742. /**
  16743. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16744. * @param mesh Mesh to add
  16745. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16746. * @returns the Shadow Generator itself
  16747. */
  16748. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16749. /**
  16750. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16751. * @param mesh Mesh to remove
  16752. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16753. * @returns the Shadow Generator itself
  16754. */
  16755. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16756. /**
  16757. * Controls the extent to which the shadows fade out at the edge of the frustum
  16758. */
  16759. frustumEdgeFalloff: number;
  16760. protected _light: IShadowLight;
  16761. /**
  16762. * Returns the associated light object.
  16763. * @returns the light generating the shadow
  16764. */
  16765. getLight(): IShadowLight;
  16766. /**
  16767. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16768. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16769. * It might on the other hand introduce peter panning.
  16770. */
  16771. forceBackFacesOnly: boolean;
  16772. protected _scene: Scene;
  16773. protected _lightDirection: Vector3;
  16774. protected _effect: Effect;
  16775. protected _viewMatrix: Matrix;
  16776. protected _projectionMatrix: Matrix;
  16777. protected _transformMatrix: Matrix;
  16778. protected _cachedPosition: Vector3;
  16779. protected _cachedDirection: Vector3;
  16780. protected _cachedDefines: string;
  16781. protected _currentRenderID: number;
  16782. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16783. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16784. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16785. protected _blurPostProcesses: PostProcess[];
  16786. protected _mapSize: number;
  16787. protected _currentFaceIndex: number;
  16788. protected _currentFaceIndexCache: number;
  16789. protected _textureType: number;
  16790. protected _defaultTextureMatrix: Matrix;
  16791. protected _storedUniqueId: Nullable<number>;
  16792. /** @hidden */
  16793. static _SceneComponentInitialization: (scene: Scene) => void;
  16794. /**
  16795. * Creates a ShadowGenerator object.
  16796. * A ShadowGenerator is the required tool to use the shadows.
  16797. * Each light casting shadows needs to use its own ShadowGenerator.
  16798. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16799. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16800. * @param light The light object generating the shadows.
  16801. * @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.
  16802. */
  16803. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16804. protected _initializeGenerator(): void;
  16805. protected _createTargetRenderTexture(): void;
  16806. protected _initializeShadowMap(): void;
  16807. protected _initializeBlurRTTAndPostProcesses(): void;
  16808. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16809. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  16810. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16811. protected _applyFilterValues(): void;
  16812. /**
  16813. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16814. * @param onCompiled Callback triggered at the and of the effects compilation
  16815. * @param options Sets of optional options forcing the compilation with different modes
  16816. */
  16817. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16818. useInstances: boolean;
  16819. }>): void;
  16820. /**
  16821. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16822. * @param options Sets of optional options forcing the compilation with different modes
  16823. * @returns A promise that resolves when the compilation completes
  16824. */
  16825. forceCompilationAsync(options?: Partial<{
  16826. useInstances: boolean;
  16827. }>): Promise<void>;
  16828. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16829. private _prepareShadowDefines;
  16830. /**
  16831. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16832. * @param subMesh The submesh we want to render in the shadow map
  16833. * @param useInstances Defines wether will draw in the map using instances
  16834. * @returns true if ready otherwise, false
  16835. */
  16836. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16837. /**
  16838. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16839. * @param defines Defines of the material we want to update
  16840. * @param lightIndex Index of the light in the enabled light list of the material
  16841. */
  16842. prepareDefines(defines: any, lightIndex: number): void;
  16843. /**
  16844. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16845. * defined in the generator but impacting the effect).
  16846. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16847. * @param effect The effect we are binfing the information for
  16848. */
  16849. bindShadowLight(lightIndex: string, effect: Effect): void;
  16850. /**
  16851. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16852. * (eq to shadow prjection matrix * light transform matrix)
  16853. * @returns The transform matrix used to create the shadow map
  16854. */
  16855. getTransformMatrix(): Matrix;
  16856. /**
  16857. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16858. * Cube and 2D textures for instance.
  16859. */
  16860. recreateShadowMap(): void;
  16861. protected _disposeBlurPostProcesses(): void;
  16862. protected _disposeRTTandPostProcesses(): void;
  16863. /**
  16864. * Disposes the ShadowGenerator.
  16865. * Returns nothing.
  16866. */
  16867. dispose(): void;
  16868. /**
  16869. * Serializes the shadow generator setup to a json object.
  16870. * @returns The serialized JSON object
  16871. */
  16872. serialize(): any;
  16873. /**
  16874. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16875. * @param parsedShadowGenerator The JSON object to parse
  16876. * @param scene The scene to create the shadow map for
  16877. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16878. * @returns The parsed shadow generator
  16879. */
  16880. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16881. }
  16882. }
  16883. declare module BABYLON {
  16884. /**
  16885. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16886. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16887. * 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.
  16888. */
  16889. export abstract class Light extends Node {
  16890. /**
  16891. * Falloff Default: light is falling off following the material specification:
  16892. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16893. */
  16894. static readonly FALLOFF_DEFAULT: number;
  16895. /**
  16896. * Falloff Physical: light is falling off following the inverse squared distance law.
  16897. */
  16898. static readonly FALLOFF_PHYSICAL: number;
  16899. /**
  16900. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16901. * to enhance interoperability with other engines.
  16902. */
  16903. static readonly FALLOFF_GLTF: number;
  16904. /**
  16905. * Falloff Standard: light is falling off like in the standard material
  16906. * to enhance interoperability with other materials.
  16907. */
  16908. static readonly FALLOFF_STANDARD: number;
  16909. /**
  16910. * If every light affecting the material is in this lightmapMode,
  16911. * material.lightmapTexture adds or multiplies
  16912. * (depends on material.useLightmapAsShadowmap)
  16913. * after every other light calculations.
  16914. */
  16915. static readonly LIGHTMAP_DEFAULT: number;
  16916. /**
  16917. * material.lightmapTexture as only diffuse lighting from this light
  16918. * adds only specular lighting from this light
  16919. * adds dynamic shadows
  16920. */
  16921. static readonly LIGHTMAP_SPECULAR: number;
  16922. /**
  16923. * material.lightmapTexture as only lighting
  16924. * no light calculation from this light
  16925. * only adds dynamic shadows from this light
  16926. */
  16927. static readonly LIGHTMAP_SHADOWSONLY: number;
  16928. /**
  16929. * Each light type uses the default quantity according to its type:
  16930. * point/spot lights use luminous intensity
  16931. * directional lights use illuminance
  16932. */
  16933. static readonly INTENSITYMODE_AUTOMATIC: number;
  16934. /**
  16935. * lumen (lm)
  16936. */
  16937. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16938. /**
  16939. * candela (lm/sr)
  16940. */
  16941. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16942. /**
  16943. * lux (lm/m^2)
  16944. */
  16945. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16946. /**
  16947. * nit (cd/m^2)
  16948. */
  16949. static readonly INTENSITYMODE_LUMINANCE: number;
  16950. /**
  16951. * Light type const id of the point light.
  16952. */
  16953. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16954. /**
  16955. * Light type const id of the directional light.
  16956. */
  16957. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16958. /**
  16959. * Light type const id of the spot light.
  16960. */
  16961. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16962. /**
  16963. * Light type const id of the hemispheric light.
  16964. */
  16965. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16966. /**
  16967. * Diffuse gives the basic color to an object.
  16968. */
  16969. diffuse: Color3;
  16970. /**
  16971. * Specular produces a highlight color on an object.
  16972. * Note: This is note affecting PBR materials.
  16973. */
  16974. specular: Color3;
  16975. /**
  16976. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16977. * falling off base on range or angle.
  16978. * This can be set to any values in Light.FALLOFF_x.
  16979. *
  16980. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16981. * other types of materials.
  16982. */
  16983. falloffType: number;
  16984. /**
  16985. * Strength of the light.
  16986. * Note: By default it is define in the framework own unit.
  16987. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16988. */
  16989. intensity: number;
  16990. private _range;
  16991. protected _inverseSquaredRange: number;
  16992. /**
  16993. * Defines how far from the source the light is impacting in scene units.
  16994. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16995. */
  16996. get range(): number;
  16997. /**
  16998. * Defines how far from the source the light is impacting in scene units.
  16999. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17000. */
  17001. set range(value: number);
  17002. /**
  17003. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17004. * of light.
  17005. */
  17006. private _photometricScale;
  17007. private _intensityMode;
  17008. /**
  17009. * Gets the photometric scale used to interpret the intensity.
  17010. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17011. */
  17012. get intensityMode(): number;
  17013. /**
  17014. * Sets the photometric scale used to interpret the intensity.
  17015. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17016. */
  17017. set intensityMode(value: number);
  17018. private _radius;
  17019. /**
  17020. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17021. */
  17022. get radius(): number;
  17023. /**
  17024. * sets the light radius used by PBR Materials to simulate soft area lights.
  17025. */
  17026. set radius(value: number);
  17027. private _renderPriority;
  17028. /**
  17029. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17030. * exceeding the number allowed of the materials.
  17031. */
  17032. renderPriority: number;
  17033. private _shadowEnabled;
  17034. /**
  17035. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17036. * the current shadow generator.
  17037. */
  17038. get shadowEnabled(): boolean;
  17039. /**
  17040. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17041. * the current shadow generator.
  17042. */
  17043. set shadowEnabled(value: boolean);
  17044. private _includedOnlyMeshes;
  17045. /**
  17046. * Gets the only meshes impacted by this light.
  17047. */
  17048. get includedOnlyMeshes(): AbstractMesh[];
  17049. /**
  17050. * Sets the only meshes impacted by this light.
  17051. */
  17052. set includedOnlyMeshes(value: AbstractMesh[]);
  17053. private _excludedMeshes;
  17054. /**
  17055. * Gets the meshes not impacted by this light.
  17056. */
  17057. get excludedMeshes(): AbstractMesh[];
  17058. /**
  17059. * Sets the meshes not impacted by this light.
  17060. */
  17061. set excludedMeshes(value: AbstractMesh[]);
  17062. private _excludeWithLayerMask;
  17063. /**
  17064. * Gets the layer id use to find what meshes are not impacted by the light.
  17065. * Inactive if 0
  17066. */
  17067. get excludeWithLayerMask(): number;
  17068. /**
  17069. * Sets the layer id use to find what meshes are not impacted by the light.
  17070. * Inactive if 0
  17071. */
  17072. set excludeWithLayerMask(value: number);
  17073. private _includeOnlyWithLayerMask;
  17074. /**
  17075. * Gets the layer id use to find what meshes are impacted by the light.
  17076. * Inactive if 0
  17077. */
  17078. get includeOnlyWithLayerMask(): number;
  17079. /**
  17080. * Sets the layer id use to find what meshes are impacted by the light.
  17081. * Inactive if 0
  17082. */
  17083. set includeOnlyWithLayerMask(value: number);
  17084. private _lightmapMode;
  17085. /**
  17086. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17087. */
  17088. get lightmapMode(): number;
  17089. /**
  17090. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17091. */
  17092. set lightmapMode(value: number);
  17093. /**
  17094. * Shadow generator associted to the light.
  17095. * @hidden Internal use only.
  17096. */
  17097. _shadowGenerator: Nullable<IShadowGenerator>;
  17098. /**
  17099. * @hidden Internal use only.
  17100. */
  17101. _excludedMeshesIds: string[];
  17102. /**
  17103. * @hidden Internal use only.
  17104. */
  17105. _includedOnlyMeshesIds: string[];
  17106. /**
  17107. * The current light unifom buffer.
  17108. * @hidden Internal use only.
  17109. */
  17110. _uniformBuffer: UniformBuffer;
  17111. /** @hidden */
  17112. _renderId: number;
  17113. /**
  17114. * Creates a Light object in the scene.
  17115. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17116. * @param name The firendly name of the light
  17117. * @param scene The scene the light belongs too
  17118. */
  17119. constructor(name: string, scene: Scene);
  17120. protected abstract _buildUniformLayout(): void;
  17121. /**
  17122. * Sets the passed Effect "effect" with the Light information.
  17123. * @param effect The effect to update
  17124. * @param lightIndex The index of the light in the effect to update
  17125. * @returns The light
  17126. */
  17127. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17128. /**
  17129. * Sets the passed Effect "effect" with the Light textures.
  17130. * @param effect The effect to update
  17131. * @param lightIndex The index of the light in the effect to update
  17132. * @returns The light
  17133. */
  17134. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17135. /**
  17136. * Binds the lights information from the scene to the effect for the given mesh.
  17137. * @param lightIndex Light index
  17138. * @param scene The scene where the light belongs to
  17139. * @param effect The effect we are binding the data to
  17140. * @param useSpecular Defines if specular is supported
  17141. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17142. */
  17143. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17144. /**
  17145. * Sets the passed Effect "effect" with the Light information.
  17146. * @param effect The effect to update
  17147. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17148. * @returns The light
  17149. */
  17150. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17151. /**
  17152. * Returns the string "Light".
  17153. * @returns the class name
  17154. */
  17155. getClassName(): string;
  17156. /** @hidden */
  17157. readonly _isLight: boolean;
  17158. /**
  17159. * Converts the light information to a readable string for debug purpose.
  17160. * @param fullDetails Supports for multiple levels of logging within scene loading
  17161. * @returns the human readable light info
  17162. */
  17163. toString(fullDetails?: boolean): string;
  17164. /** @hidden */
  17165. protected _syncParentEnabledState(): void;
  17166. /**
  17167. * Set the enabled state of this node.
  17168. * @param value - the new enabled state
  17169. */
  17170. setEnabled(value: boolean): void;
  17171. /**
  17172. * Returns the Light associated shadow generator if any.
  17173. * @return the associated shadow generator.
  17174. */
  17175. getShadowGenerator(): Nullable<IShadowGenerator>;
  17176. /**
  17177. * Returns a Vector3, the absolute light position in the World.
  17178. * @returns the world space position of the light
  17179. */
  17180. getAbsolutePosition(): Vector3;
  17181. /**
  17182. * Specifies if the light will affect the passed mesh.
  17183. * @param mesh The mesh to test against the light
  17184. * @return true the mesh is affected otherwise, false.
  17185. */
  17186. canAffectMesh(mesh: AbstractMesh): boolean;
  17187. /**
  17188. * Sort function to order lights for rendering.
  17189. * @param a First Light object to compare to second.
  17190. * @param b Second Light object to compare first.
  17191. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17192. */
  17193. static CompareLightsPriority(a: Light, b: Light): number;
  17194. /**
  17195. * Releases resources associated with this node.
  17196. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17197. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17198. */
  17199. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17200. /**
  17201. * Returns the light type ID (integer).
  17202. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17203. */
  17204. getTypeID(): number;
  17205. /**
  17206. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17207. * @returns the scaled intensity in intensity mode unit
  17208. */
  17209. getScaledIntensity(): number;
  17210. /**
  17211. * Returns a new Light object, named "name", from the current one.
  17212. * @param name The name of the cloned light
  17213. * @returns the new created light
  17214. */
  17215. clone(name: string): Nullable<Light>;
  17216. /**
  17217. * Serializes the current light into a Serialization object.
  17218. * @returns the serialized object.
  17219. */
  17220. serialize(): any;
  17221. /**
  17222. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17223. * This new light is named "name" and added to the passed scene.
  17224. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17225. * @param name The friendly name of the light
  17226. * @param scene The scene the new light will belong to
  17227. * @returns the constructor function
  17228. */
  17229. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17230. /**
  17231. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17232. * @param parsedLight The JSON representation of the light
  17233. * @param scene The scene to create the parsed light in
  17234. * @returns the created light after parsing
  17235. */
  17236. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17237. private _hookArrayForExcluded;
  17238. private _hookArrayForIncludedOnly;
  17239. private _resyncMeshes;
  17240. /**
  17241. * Forces the meshes to update their light related information in their rendering used effects
  17242. * @hidden Internal Use Only
  17243. */
  17244. _markMeshesAsLightDirty(): void;
  17245. /**
  17246. * Recomputes the cached photometric scale if needed.
  17247. */
  17248. private _computePhotometricScale;
  17249. /**
  17250. * Returns the Photometric Scale according to the light type and intensity mode.
  17251. */
  17252. private _getPhotometricScale;
  17253. /**
  17254. * Reorder the light in the scene according to their defined priority.
  17255. * @hidden Internal Use Only
  17256. */
  17257. _reorderLightsInScene(): void;
  17258. /**
  17259. * Prepares the list of defines specific to the light type.
  17260. * @param defines the list of defines
  17261. * @param lightIndex defines the index of the light for the effect
  17262. */
  17263. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17264. }
  17265. }
  17266. declare module BABYLON {
  17267. /**
  17268. * Interface used to define Action
  17269. */
  17270. export interface IAction {
  17271. /**
  17272. * Trigger for the action
  17273. */
  17274. trigger: number;
  17275. /** Options of the trigger */
  17276. triggerOptions: any;
  17277. /**
  17278. * Gets the trigger parameters
  17279. * @returns the trigger parameters
  17280. */
  17281. getTriggerParameter(): any;
  17282. /**
  17283. * Internal only - executes current action event
  17284. * @hidden
  17285. */
  17286. _executeCurrent(evt?: ActionEvent): void;
  17287. /**
  17288. * Serialize placeholder for child classes
  17289. * @param parent of child
  17290. * @returns the serialized object
  17291. */
  17292. serialize(parent: any): any;
  17293. /**
  17294. * Internal only
  17295. * @hidden
  17296. */
  17297. _prepare(): void;
  17298. /**
  17299. * Internal only - manager for action
  17300. * @hidden
  17301. */
  17302. _actionManager: AbstractActionManager;
  17303. /**
  17304. * Adds action to chain of actions, may be a DoNothingAction
  17305. * @param action defines the next action to execute
  17306. * @returns The action passed in
  17307. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17308. */
  17309. then(action: IAction): IAction;
  17310. }
  17311. /**
  17312. * The action to be carried out following a trigger
  17313. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17314. */
  17315. export class Action implements IAction {
  17316. /** the trigger, with or without parameters, for the action */
  17317. triggerOptions: any;
  17318. /**
  17319. * Trigger for the action
  17320. */
  17321. trigger: number;
  17322. /**
  17323. * Internal only - manager for action
  17324. * @hidden
  17325. */
  17326. _actionManager: ActionManager;
  17327. private _nextActiveAction;
  17328. private _child;
  17329. private _condition?;
  17330. private _triggerParameter;
  17331. /**
  17332. * An event triggered prior to action being executed.
  17333. */
  17334. onBeforeExecuteObservable: Observable<Action>;
  17335. /**
  17336. * Creates a new Action
  17337. * @param triggerOptions the trigger, with or without parameters, for the action
  17338. * @param condition an optional determinant of action
  17339. */
  17340. constructor(
  17341. /** the trigger, with or without parameters, for the action */
  17342. triggerOptions: any, condition?: Condition);
  17343. /**
  17344. * Internal only
  17345. * @hidden
  17346. */
  17347. _prepare(): void;
  17348. /**
  17349. * Gets the trigger parameters
  17350. * @returns the trigger parameters
  17351. */
  17352. getTriggerParameter(): any;
  17353. /**
  17354. * Internal only - executes current action event
  17355. * @hidden
  17356. */
  17357. _executeCurrent(evt?: ActionEvent): void;
  17358. /**
  17359. * Execute placeholder for child classes
  17360. * @param evt optional action event
  17361. */
  17362. execute(evt?: ActionEvent): void;
  17363. /**
  17364. * Skips to next active action
  17365. */
  17366. skipToNextActiveAction(): void;
  17367. /**
  17368. * Adds action to chain of actions, may be a DoNothingAction
  17369. * @param action defines the next action to execute
  17370. * @returns The action passed in
  17371. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17372. */
  17373. then(action: Action): Action;
  17374. /**
  17375. * Internal only
  17376. * @hidden
  17377. */
  17378. _getProperty(propertyPath: string): string;
  17379. /**
  17380. * Internal only
  17381. * @hidden
  17382. */
  17383. _getEffectiveTarget(target: any, propertyPath: string): any;
  17384. /**
  17385. * Serialize placeholder for child classes
  17386. * @param parent of child
  17387. * @returns the serialized object
  17388. */
  17389. serialize(parent: any): any;
  17390. /**
  17391. * Internal only called by serialize
  17392. * @hidden
  17393. */
  17394. protected _serialize(serializedAction: any, parent?: any): any;
  17395. /**
  17396. * Internal only
  17397. * @hidden
  17398. */
  17399. static _SerializeValueAsString: (value: any) => string;
  17400. /**
  17401. * Internal only
  17402. * @hidden
  17403. */
  17404. static _GetTargetProperty: (target: Node | Scene) => {
  17405. name: string;
  17406. targetType: string;
  17407. value: string;
  17408. };
  17409. }
  17410. }
  17411. declare module BABYLON {
  17412. /**
  17413. * A Condition applied to an Action
  17414. */
  17415. export class Condition {
  17416. /**
  17417. * Internal only - manager for action
  17418. * @hidden
  17419. */
  17420. _actionManager: ActionManager;
  17421. /**
  17422. * Internal only
  17423. * @hidden
  17424. */
  17425. _evaluationId: number;
  17426. /**
  17427. * Internal only
  17428. * @hidden
  17429. */
  17430. _currentResult: boolean;
  17431. /**
  17432. * Creates a new Condition
  17433. * @param actionManager the manager of the action the condition is applied to
  17434. */
  17435. constructor(actionManager: ActionManager);
  17436. /**
  17437. * Check if the current condition is valid
  17438. * @returns a boolean
  17439. */
  17440. isValid(): boolean;
  17441. /**
  17442. * Internal only
  17443. * @hidden
  17444. */
  17445. _getProperty(propertyPath: string): string;
  17446. /**
  17447. * Internal only
  17448. * @hidden
  17449. */
  17450. _getEffectiveTarget(target: any, propertyPath: string): any;
  17451. /**
  17452. * Serialize placeholder for child classes
  17453. * @returns the serialized object
  17454. */
  17455. serialize(): any;
  17456. /**
  17457. * Internal only
  17458. * @hidden
  17459. */
  17460. protected _serialize(serializedCondition: any): any;
  17461. }
  17462. /**
  17463. * Defines specific conditional operators as extensions of Condition
  17464. */
  17465. export class ValueCondition extends Condition {
  17466. /** path to specify the property of the target the conditional operator uses */
  17467. propertyPath: string;
  17468. /** the value compared by the conditional operator against the current value of the property */
  17469. value: any;
  17470. /** the conditional operator, default ValueCondition.IsEqual */
  17471. operator: number;
  17472. /**
  17473. * Internal only
  17474. * @hidden
  17475. */
  17476. private static _IsEqual;
  17477. /**
  17478. * Internal only
  17479. * @hidden
  17480. */
  17481. private static _IsDifferent;
  17482. /**
  17483. * Internal only
  17484. * @hidden
  17485. */
  17486. private static _IsGreater;
  17487. /**
  17488. * Internal only
  17489. * @hidden
  17490. */
  17491. private static _IsLesser;
  17492. /**
  17493. * returns the number for IsEqual
  17494. */
  17495. static get IsEqual(): number;
  17496. /**
  17497. * Returns the number for IsDifferent
  17498. */
  17499. static get IsDifferent(): number;
  17500. /**
  17501. * Returns the number for IsGreater
  17502. */
  17503. static get IsGreater(): number;
  17504. /**
  17505. * Returns the number for IsLesser
  17506. */
  17507. static get IsLesser(): number;
  17508. /**
  17509. * Internal only The action manager for the condition
  17510. * @hidden
  17511. */
  17512. _actionManager: ActionManager;
  17513. /**
  17514. * Internal only
  17515. * @hidden
  17516. */
  17517. private _target;
  17518. /**
  17519. * Internal only
  17520. * @hidden
  17521. */
  17522. private _effectiveTarget;
  17523. /**
  17524. * Internal only
  17525. * @hidden
  17526. */
  17527. private _property;
  17528. /**
  17529. * Creates a new ValueCondition
  17530. * @param actionManager manager for the action the condition applies to
  17531. * @param target for the action
  17532. * @param propertyPath path to specify the property of the target the conditional operator uses
  17533. * @param value the value compared by the conditional operator against the current value of the property
  17534. * @param operator the conditional operator, default ValueCondition.IsEqual
  17535. */
  17536. constructor(actionManager: ActionManager, target: any,
  17537. /** path to specify the property of the target the conditional operator uses */
  17538. propertyPath: string,
  17539. /** the value compared by the conditional operator against the current value of the property */
  17540. value: any,
  17541. /** the conditional operator, default ValueCondition.IsEqual */
  17542. operator?: number);
  17543. /**
  17544. * Compares the given value with the property value for the specified conditional operator
  17545. * @returns the result of the comparison
  17546. */
  17547. isValid(): boolean;
  17548. /**
  17549. * Serialize the ValueCondition into a JSON compatible object
  17550. * @returns serialization object
  17551. */
  17552. serialize(): any;
  17553. /**
  17554. * Gets the name of the conditional operator for the ValueCondition
  17555. * @param operator the conditional operator
  17556. * @returns the name
  17557. */
  17558. static GetOperatorName(operator: number): string;
  17559. }
  17560. /**
  17561. * Defines a predicate condition as an extension of Condition
  17562. */
  17563. export class PredicateCondition extends Condition {
  17564. /** defines the predicate function used to validate the condition */
  17565. predicate: () => boolean;
  17566. /**
  17567. * Internal only - manager for action
  17568. * @hidden
  17569. */
  17570. _actionManager: ActionManager;
  17571. /**
  17572. * Creates a new PredicateCondition
  17573. * @param actionManager manager for the action the condition applies to
  17574. * @param predicate defines the predicate function used to validate the condition
  17575. */
  17576. constructor(actionManager: ActionManager,
  17577. /** defines the predicate function used to validate the condition */
  17578. predicate: () => boolean);
  17579. /**
  17580. * @returns the validity of the predicate condition
  17581. */
  17582. isValid(): boolean;
  17583. }
  17584. /**
  17585. * Defines a state condition as an extension of Condition
  17586. */
  17587. export class StateCondition extends Condition {
  17588. /** Value to compare with target state */
  17589. value: string;
  17590. /**
  17591. * Internal only - manager for action
  17592. * @hidden
  17593. */
  17594. _actionManager: ActionManager;
  17595. /**
  17596. * Internal only
  17597. * @hidden
  17598. */
  17599. private _target;
  17600. /**
  17601. * Creates a new StateCondition
  17602. * @param actionManager manager for the action the condition applies to
  17603. * @param target of the condition
  17604. * @param value to compare with target state
  17605. */
  17606. constructor(actionManager: ActionManager, target: any,
  17607. /** Value to compare with target state */
  17608. value: string);
  17609. /**
  17610. * Gets a boolean indicating if the current condition is met
  17611. * @returns the validity of the state
  17612. */
  17613. isValid(): boolean;
  17614. /**
  17615. * Serialize the StateCondition into a JSON compatible object
  17616. * @returns serialization object
  17617. */
  17618. serialize(): any;
  17619. }
  17620. }
  17621. declare module BABYLON {
  17622. /**
  17623. * This defines an action responsible to toggle a boolean once triggered.
  17624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17625. */
  17626. export class SwitchBooleanAction extends Action {
  17627. /**
  17628. * The path to the boolean property in the target object
  17629. */
  17630. propertyPath: string;
  17631. private _target;
  17632. private _effectiveTarget;
  17633. private _property;
  17634. /**
  17635. * Instantiate the action
  17636. * @param triggerOptions defines the trigger options
  17637. * @param target defines the object containing the boolean
  17638. * @param propertyPath defines the path to the boolean property in the target object
  17639. * @param condition defines the trigger related conditions
  17640. */
  17641. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17642. /** @hidden */
  17643. _prepare(): void;
  17644. /**
  17645. * Execute the action toggle the boolean value.
  17646. */
  17647. execute(): void;
  17648. /**
  17649. * Serializes the actions and its related information.
  17650. * @param parent defines the object to serialize in
  17651. * @returns the serialized object
  17652. */
  17653. serialize(parent: any): any;
  17654. }
  17655. /**
  17656. * This defines an action responsible to set a the state field of the target
  17657. * to a desired value once triggered.
  17658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17659. */
  17660. export class SetStateAction extends Action {
  17661. /**
  17662. * The value to store in the state field.
  17663. */
  17664. value: string;
  17665. private _target;
  17666. /**
  17667. * Instantiate the action
  17668. * @param triggerOptions defines the trigger options
  17669. * @param target defines the object containing the state property
  17670. * @param value defines the value to store in the state field
  17671. * @param condition defines the trigger related conditions
  17672. */
  17673. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17674. /**
  17675. * Execute the action and store the value on the target state property.
  17676. */
  17677. execute(): void;
  17678. /**
  17679. * Serializes the actions and its related information.
  17680. * @param parent defines the object to serialize in
  17681. * @returns the serialized object
  17682. */
  17683. serialize(parent: any): any;
  17684. }
  17685. /**
  17686. * This defines an action responsible to set a property of the target
  17687. * to a desired value once triggered.
  17688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17689. */
  17690. export class SetValueAction extends Action {
  17691. /**
  17692. * The path of the property to set in the target.
  17693. */
  17694. propertyPath: string;
  17695. /**
  17696. * The value to set in the property
  17697. */
  17698. value: any;
  17699. private _target;
  17700. private _effectiveTarget;
  17701. private _property;
  17702. /**
  17703. * Instantiate the action
  17704. * @param triggerOptions defines the trigger options
  17705. * @param target defines the object containing the property
  17706. * @param propertyPath defines the path of the property to set in the target
  17707. * @param value defines the value to set in the property
  17708. * @param condition defines the trigger related conditions
  17709. */
  17710. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17711. /** @hidden */
  17712. _prepare(): void;
  17713. /**
  17714. * Execute the action and set the targetted property to the desired value.
  17715. */
  17716. execute(): void;
  17717. /**
  17718. * Serializes the actions and its related information.
  17719. * @param parent defines the object to serialize in
  17720. * @returns the serialized object
  17721. */
  17722. serialize(parent: any): any;
  17723. }
  17724. /**
  17725. * This defines an action responsible to increment the target value
  17726. * to a desired value once triggered.
  17727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17728. */
  17729. export class IncrementValueAction extends Action {
  17730. /**
  17731. * The path of the property to increment in the target.
  17732. */
  17733. propertyPath: string;
  17734. /**
  17735. * The value we should increment the property by.
  17736. */
  17737. value: any;
  17738. private _target;
  17739. private _effectiveTarget;
  17740. private _property;
  17741. /**
  17742. * Instantiate the action
  17743. * @param triggerOptions defines the trigger options
  17744. * @param target defines the object containing the property
  17745. * @param propertyPath defines the path of the property to increment in the target
  17746. * @param value defines the value value we should increment the property by
  17747. * @param condition defines the trigger related conditions
  17748. */
  17749. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17750. /** @hidden */
  17751. _prepare(): void;
  17752. /**
  17753. * Execute the action and increment the target of the value amount.
  17754. */
  17755. execute(): void;
  17756. /**
  17757. * Serializes the actions and its related information.
  17758. * @param parent defines the object to serialize in
  17759. * @returns the serialized object
  17760. */
  17761. serialize(parent: any): any;
  17762. }
  17763. /**
  17764. * This defines an action responsible to start an animation once triggered.
  17765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17766. */
  17767. export class PlayAnimationAction extends Action {
  17768. /**
  17769. * Where the animation should start (animation frame)
  17770. */
  17771. from: number;
  17772. /**
  17773. * Where the animation should stop (animation frame)
  17774. */
  17775. to: number;
  17776. /**
  17777. * Define if the animation should loop or stop after the first play.
  17778. */
  17779. loop?: boolean;
  17780. private _target;
  17781. /**
  17782. * Instantiate the action
  17783. * @param triggerOptions defines the trigger options
  17784. * @param target defines the target animation or animation name
  17785. * @param from defines from where the animation should start (animation frame)
  17786. * @param end defines where the animation should stop (animation frame)
  17787. * @param loop defines if the animation should loop or stop after the first play
  17788. * @param condition defines the trigger related conditions
  17789. */
  17790. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17791. /** @hidden */
  17792. _prepare(): void;
  17793. /**
  17794. * Execute the action and play the animation.
  17795. */
  17796. execute(): void;
  17797. /**
  17798. * Serializes the actions and its related information.
  17799. * @param parent defines the object to serialize in
  17800. * @returns the serialized object
  17801. */
  17802. serialize(parent: any): any;
  17803. }
  17804. /**
  17805. * This defines an action responsible to stop an animation once triggered.
  17806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17807. */
  17808. export class StopAnimationAction extends Action {
  17809. private _target;
  17810. /**
  17811. * Instantiate the action
  17812. * @param triggerOptions defines the trigger options
  17813. * @param target defines the target animation or animation name
  17814. * @param condition defines the trigger related conditions
  17815. */
  17816. constructor(triggerOptions: any, target: any, condition?: Condition);
  17817. /** @hidden */
  17818. _prepare(): void;
  17819. /**
  17820. * Execute the action and stop the animation.
  17821. */
  17822. execute(): void;
  17823. /**
  17824. * Serializes the actions and its related information.
  17825. * @param parent defines the object to serialize in
  17826. * @returns the serialized object
  17827. */
  17828. serialize(parent: any): any;
  17829. }
  17830. /**
  17831. * This defines an action responsible that does nothing once triggered.
  17832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17833. */
  17834. export class DoNothingAction extends Action {
  17835. /**
  17836. * Instantiate the action
  17837. * @param triggerOptions defines the trigger options
  17838. * @param condition defines the trigger related conditions
  17839. */
  17840. constructor(triggerOptions?: any, condition?: Condition);
  17841. /**
  17842. * Execute the action and do nothing.
  17843. */
  17844. execute(): void;
  17845. /**
  17846. * Serializes the actions and its related information.
  17847. * @param parent defines the object to serialize in
  17848. * @returns the serialized object
  17849. */
  17850. serialize(parent: any): any;
  17851. }
  17852. /**
  17853. * This defines an action responsible to trigger several actions once triggered.
  17854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17855. */
  17856. export class CombineAction extends Action {
  17857. /**
  17858. * The list of aggregated animations to run.
  17859. */
  17860. children: Action[];
  17861. /**
  17862. * Instantiate the action
  17863. * @param triggerOptions defines the trigger options
  17864. * @param children defines the list of aggregated animations to run
  17865. * @param condition defines the trigger related conditions
  17866. */
  17867. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17868. /** @hidden */
  17869. _prepare(): void;
  17870. /**
  17871. * Execute the action and executes all the aggregated actions.
  17872. */
  17873. execute(evt: ActionEvent): void;
  17874. /**
  17875. * Serializes the actions and its related information.
  17876. * @param parent defines the object to serialize in
  17877. * @returns the serialized object
  17878. */
  17879. serialize(parent: any): any;
  17880. }
  17881. /**
  17882. * This defines an action responsible to run code (external event) once triggered.
  17883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17884. */
  17885. export class ExecuteCodeAction extends Action {
  17886. /**
  17887. * The callback function to run.
  17888. */
  17889. func: (evt: ActionEvent) => void;
  17890. /**
  17891. * Instantiate the action
  17892. * @param triggerOptions defines the trigger options
  17893. * @param func defines the callback function to run
  17894. * @param condition defines the trigger related conditions
  17895. */
  17896. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17897. /**
  17898. * Execute the action and run the attached code.
  17899. */
  17900. execute(evt: ActionEvent): void;
  17901. }
  17902. /**
  17903. * This defines an action responsible to set the parent property of the target once triggered.
  17904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17905. */
  17906. export class SetParentAction extends Action {
  17907. private _parent;
  17908. private _target;
  17909. /**
  17910. * Instantiate the action
  17911. * @param triggerOptions defines the trigger options
  17912. * @param target defines the target containing the parent property
  17913. * @param parent defines from where the animation should start (animation frame)
  17914. * @param condition defines the trigger related conditions
  17915. */
  17916. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17917. /** @hidden */
  17918. _prepare(): void;
  17919. /**
  17920. * Execute the action and set the parent property.
  17921. */
  17922. execute(): void;
  17923. /**
  17924. * Serializes the actions and its related information.
  17925. * @param parent defines the object to serialize in
  17926. * @returns the serialized object
  17927. */
  17928. serialize(parent: any): any;
  17929. }
  17930. }
  17931. declare module BABYLON {
  17932. /**
  17933. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17934. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17936. */
  17937. export class ActionManager extends AbstractActionManager {
  17938. /**
  17939. * Nothing
  17940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17941. */
  17942. static readonly NothingTrigger: number;
  17943. /**
  17944. * On pick
  17945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17946. */
  17947. static readonly OnPickTrigger: number;
  17948. /**
  17949. * On left pick
  17950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17951. */
  17952. static readonly OnLeftPickTrigger: number;
  17953. /**
  17954. * On right pick
  17955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17956. */
  17957. static readonly OnRightPickTrigger: number;
  17958. /**
  17959. * On center pick
  17960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17961. */
  17962. static readonly OnCenterPickTrigger: number;
  17963. /**
  17964. * On pick down
  17965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17966. */
  17967. static readonly OnPickDownTrigger: number;
  17968. /**
  17969. * On double pick
  17970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17971. */
  17972. static readonly OnDoublePickTrigger: number;
  17973. /**
  17974. * On pick up
  17975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17976. */
  17977. static readonly OnPickUpTrigger: number;
  17978. /**
  17979. * On pick out.
  17980. * This trigger will only be raised if you also declared a OnPickDown
  17981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17982. */
  17983. static readonly OnPickOutTrigger: number;
  17984. /**
  17985. * On long press
  17986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17987. */
  17988. static readonly OnLongPressTrigger: number;
  17989. /**
  17990. * On pointer over
  17991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17992. */
  17993. static readonly OnPointerOverTrigger: number;
  17994. /**
  17995. * On pointer out
  17996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17997. */
  17998. static readonly OnPointerOutTrigger: number;
  17999. /**
  18000. * On every frame
  18001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18002. */
  18003. static readonly OnEveryFrameTrigger: number;
  18004. /**
  18005. * On intersection enter
  18006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18007. */
  18008. static readonly OnIntersectionEnterTrigger: number;
  18009. /**
  18010. * On intersection exit
  18011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18012. */
  18013. static readonly OnIntersectionExitTrigger: number;
  18014. /**
  18015. * On key down
  18016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18017. */
  18018. static readonly OnKeyDownTrigger: number;
  18019. /**
  18020. * On key up
  18021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18022. */
  18023. static readonly OnKeyUpTrigger: number;
  18024. private _scene;
  18025. /**
  18026. * Creates a new action manager
  18027. * @param scene defines the hosting scene
  18028. */
  18029. constructor(scene: Scene);
  18030. /**
  18031. * Releases all associated resources
  18032. */
  18033. dispose(): void;
  18034. /**
  18035. * Gets hosting scene
  18036. * @returns the hosting scene
  18037. */
  18038. getScene(): Scene;
  18039. /**
  18040. * Does this action manager handles actions of any of the given triggers
  18041. * @param triggers defines the triggers to be tested
  18042. * @return a boolean indicating whether one (or more) of the triggers is handled
  18043. */
  18044. hasSpecificTriggers(triggers: number[]): boolean;
  18045. /**
  18046. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18047. * speed.
  18048. * @param triggerA defines the trigger to be tested
  18049. * @param triggerB defines the trigger to be tested
  18050. * @return a boolean indicating whether one (or more) of the triggers is handled
  18051. */
  18052. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18053. /**
  18054. * Does this action manager handles actions of a given trigger
  18055. * @param trigger defines the trigger to be tested
  18056. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18057. * @return whether the trigger is handled
  18058. */
  18059. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18060. /**
  18061. * Does this action manager has pointer triggers
  18062. */
  18063. get hasPointerTriggers(): boolean;
  18064. /**
  18065. * Does this action manager has pick triggers
  18066. */
  18067. get hasPickTriggers(): boolean;
  18068. /**
  18069. * Registers an action to this action manager
  18070. * @param action defines the action to be registered
  18071. * @return the action amended (prepared) after registration
  18072. */
  18073. registerAction(action: IAction): Nullable<IAction>;
  18074. /**
  18075. * Unregisters an action to this action manager
  18076. * @param action defines the action to be unregistered
  18077. * @return a boolean indicating whether the action has been unregistered
  18078. */
  18079. unregisterAction(action: IAction): Boolean;
  18080. /**
  18081. * Process a specific trigger
  18082. * @param trigger defines the trigger to process
  18083. * @param evt defines the event details to be processed
  18084. */
  18085. processTrigger(trigger: number, evt?: IActionEvent): void;
  18086. /** @hidden */
  18087. _getEffectiveTarget(target: any, propertyPath: string): any;
  18088. /** @hidden */
  18089. _getProperty(propertyPath: string): string;
  18090. /**
  18091. * Serialize this manager to a JSON object
  18092. * @param name defines the property name to store this manager
  18093. * @returns a JSON representation of this manager
  18094. */
  18095. serialize(name: string): any;
  18096. /**
  18097. * Creates a new ActionManager from a JSON data
  18098. * @param parsedActions defines the JSON data to read from
  18099. * @param object defines the hosting mesh
  18100. * @param scene defines the hosting scene
  18101. */
  18102. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18103. /**
  18104. * Get a trigger name by index
  18105. * @param trigger defines the trigger index
  18106. * @returns a trigger name
  18107. */
  18108. static GetTriggerName(trigger: number): string;
  18109. }
  18110. }
  18111. declare module BABYLON {
  18112. /**
  18113. * Class used to represent a sprite
  18114. * @see http://doc.babylonjs.com/babylon101/sprites
  18115. */
  18116. export class Sprite {
  18117. /** defines the name */
  18118. name: string;
  18119. /** Gets or sets the current world position */
  18120. position: Vector3;
  18121. /** Gets or sets the main color */
  18122. color: Color4;
  18123. /** Gets or sets the width */
  18124. width: number;
  18125. /** Gets or sets the height */
  18126. height: number;
  18127. /** Gets or sets rotation angle */
  18128. angle: number;
  18129. /** Gets or sets the cell index in the sprite sheet */
  18130. cellIndex: number;
  18131. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18132. cellRef: string;
  18133. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18134. invertU: number;
  18135. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18136. invertV: number;
  18137. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18138. disposeWhenFinishedAnimating: boolean;
  18139. /** Gets the list of attached animations */
  18140. animations: Animation[];
  18141. /** Gets or sets a boolean indicating if the sprite can be picked */
  18142. isPickable: boolean;
  18143. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18144. useAlphaForPicking: boolean;
  18145. /** @hidden */
  18146. _xOffset: number;
  18147. /** @hidden */
  18148. _yOffset: number;
  18149. /** @hidden */
  18150. _xSize: number;
  18151. /** @hidden */
  18152. _ySize: number;
  18153. /**
  18154. * Gets or sets the associated action manager
  18155. */
  18156. actionManager: Nullable<ActionManager>;
  18157. private _animationStarted;
  18158. private _loopAnimation;
  18159. private _fromIndex;
  18160. private _toIndex;
  18161. private _delay;
  18162. private _direction;
  18163. private _manager;
  18164. private _time;
  18165. private _onAnimationEnd;
  18166. /**
  18167. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18168. */
  18169. isVisible: boolean;
  18170. /**
  18171. * Gets or sets the sprite size
  18172. */
  18173. get size(): number;
  18174. set size(value: number);
  18175. /**
  18176. * Creates a new Sprite
  18177. * @param name defines the name
  18178. * @param manager defines the manager
  18179. */
  18180. constructor(
  18181. /** defines the name */
  18182. name: string, manager: ISpriteManager);
  18183. /**
  18184. * Starts an animation
  18185. * @param from defines the initial key
  18186. * @param to defines the end key
  18187. * @param loop defines if the animation must loop
  18188. * @param delay defines the start delay (in ms)
  18189. * @param onAnimationEnd defines a callback to call when animation ends
  18190. */
  18191. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18192. /** Stops current animation (if any) */
  18193. stopAnimation(): void;
  18194. /** @hidden */
  18195. _animate(deltaTime: number): void;
  18196. /** Release associated resources */
  18197. dispose(): void;
  18198. }
  18199. }
  18200. declare module BABYLON {
  18201. /**
  18202. * Information about the result of picking within a scene
  18203. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18204. */
  18205. export class PickingInfo {
  18206. /** @hidden */
  18207. _pickingUnavailable: boolean;
  18208. /**
  18209. * If the pick collided with an object
  18210. */
  18211. hit: boolean;
  18212. /**
  18213. * Distance away where the pick collided
  18214. */
  18215. distance: number;
  18216. /**
  18217. * The location of pick collision
  18218. */
  18219. pickedPoint: Nullable<Vector3>;
  18220. /**
  18221. * The mesh corresponding the the pick collision
  18222. */
  18223. pickedMesh: Nullable<AbstractMesh>;
  18224. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18225. bu: number;
  18226. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18227. bv: number;
  18228. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18229. faceId: number;
  18230. /** Id of the the submesh that was picked */
  18231. subMeshId: number;
  18232. /** If a sprite was picked, this will be the sprite the pick collided with */
  18233. pickedSprite: Nullable<Sprite>;
  18234. /**
  18235. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18236. */
  18237. originMesh: Nullable<AbstractMesh>;
  18238. /**
  18239. * The ray that was used to perform the picking.
  18240. */
  18241. ray: Nullable<Ray>;
  18242. /**
  18243. * Gets the normal correspodning to the face the pick collided with
  18244. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18245. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18246. * @returns The normal correspodning to the face the pick collided with
  18247. */
  18248. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18249. /**
  18250. * Gets the texture coordinates of where the pick occured
  18251. * @returns the vector containing the coordnates of the texture
  18252. */
  18253. getTextureCoordinates(): Nullable<Vector2>;
  18254. }
  18255. }
  18256. declare module BABYLON {
  18257. /**
  18258. * Gather the list of pointer event types as constants.
  18259. */
  18260. export class PointerEventTypes {
  18261. /**
  18262. * 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.
  18263. */
  18264. static readonly POINTERDOWN: number;
  18265. /**
  18266. * The pointerup event is fired when a pointer is no longer active.
  18267. */
  18268. static readonly POINTERUP: number;
  18269. /**
  18270. * The pointermove event is fired when a pointer changes coordinates.
  18271. */
  18272. static readonly POINTERMOVE: number;
  18273. /**
  18274. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18275. */
  18276. static readonly POINTERWHEEL: number;
  18277. /**
  18278. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18279. */
  18280. static readonly POINTERPICK: number;
  18281. /**
  18282. * The pointertap event is fired when a the object has been touched and released without drag.
  18283. */
  18284. static readonly POINTERTAP: number;
  18285. /**
  18286. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18287. */
  18288. static readonly POINTERDOUBLETAP: number;
  18289. }
  18290. /**
  18291. * Base class of pointer info types.
  18292. */
  18293. export class PointerInfoBase {
  18294. /**
  18295. * Defines the type of event (PointerEventTypes)
  18296. */
  18297. type: number;
  18298. /**
  18299. * Defines the related dom event
  18300. */
  18301. event: PointerEvent | MouseWheelEvent;
  18302. /**
  18303. * Instantiates the base class of pointers info.
  18304. * @param type Defines the type of event (PointerEventTypes)
  18305. * @param event Defines the related dom event
  18306. */
  18307. constructor(
  18308. /**
  18309. * Defines the type of event (PointerEventTypes)
  18310. */
  18311. type: number,
  18312. /**
  18313. * Defines the related dom event
  18314. */
  18315. event: PointerEvent | MouseWheelEvent);
  18316. }
  18317. /**
  18318. * This class is used to store pointer related info for the onPrePointerObservable event.
  18319. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18320. */
  18321. export class PointerInfoPre extends PointerInfoBase {
  18322. /**
  18323. * Ray from a pointer if availible (eg. 6dof controller)
  18324. */
  18325. ray: Nullable<Ray>;
  18326. /**
  18327. * Defines the local position of the pointer on the canvas.
  18328. */
  18329. localPosition: Vector2;
  18330. /**
  18331. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18332. */
  18333. skipOnPointerObservable: boolean;
  18334. /**
  18335. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18336. * @param type Defines the type of event (PointerEventTypes)
  18337. * @param event Defines the related dom event
  18338. * @param localX Defines the local x coordinates of the pointer when the event occured
  18339. * @param localY Defines the local y coordinates of the pointer when the event occured
  18340. */
  18341. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18342. }
  18343. /**
  18344. * This type contains all the data related to a pointer event in Babylon.js.
  18345. * 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.
  18346. */
  18347. export class PointerInfo extends PointerInfoBase {
  18348. /**
  18349. * Defines the picking info associated to the info (if any)\
  18350. */
  18351. pickInfo: Nullable<PickingInfo>;
  18352. /**
  18353. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18354. * @param type Defines the type of event (PointerEventTypes)
  18355. * @param event Defines the related dom event
  18356. * @param pickInfo Defines the picking info associated to the info (if any)\
  18357. */
  18358. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18359. /**
  18360. * Defines the picking info associated to the info (if any)\
  18361. */
  18362. pickInfo: Nullable<PickingInfo>);
  18363. }
  18364. /**
  18365. * Data relating to a touch event on the screen.
  18366. */
  18367. export interface PointerTouch {
  18368. /**
  18369. * X coordinate of touch.
  18370. */
  18371. x: number;
  18372. /**
  18373. * Y coordinate of touch.
  18374. */
  18375. y: number;
  18376. /**
  18377. * Id of touch. Unique for each finger.
  18378. */
  18379. pointerId: number;
  18380. /**
  18381. * Event type passed from DOM.
  18382. */
  18383. type: any;
  18384. }
  18385. }
  18386. declare module BABYLON {
  18387. /**
  18388. * Manage the mouse inputs to control the movement of a free camera.
  18389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18390. */
  18391. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18392. /**
  18393. * Define if touch is enabled in the mouse input
  18394. */
  18395. touchEnabled: boolean;
  18396. /**
  18397. * Defines the camera the input is attached to.
  18398. */
  18399. camera: FreeCamera;
  18400. /**
  18401. * Defines the buttons associated with the input to handle camera move.
  18402. */
  18403. buttons: number[];
  18404. /**
  18405. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18406. */
  18407. angularSensibility: number;
  18408. private _pointerInput;
  18409. private _onMouseMove;
  18410. private _observer;
  18411. private previousPosition;
  18412. /**
  18413. * Observable for when a pointer move event occurs containing the move offset
  18414. */
  18415. onPointerMovedObservable: Observable<{
  18416. offsetX: number;
  18417. offsetY: number;
  18418. }>;
  18419. /**
  18420. * @hidden
  18421. * If the camera should be rotated automatically based on pointer movement
  18422. */
  18423. _allowCameraRotation: boolean;
  18424. /**
  18425. * Manage the mouse inputs to control the movement of a free camera.
  18426. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18427. * @param touchEnabled Defines if touch is enabled or not
  18428. */
  18429. constructor(
  18430. /**
  18431. * Define if touch is enabled in the mouse input
  18432. */
  18433. touchEnabled?: boolean);
  18434. /**
  18435. * Attach the input controls to a specific dom element to get the input from.
  18436. * @param element Defines the element the controls should be listened from
  18437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18438. */
  18439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18440. /**
  18441. * Called on JS contextmenu event.
  18442. * Override this method to provide functionality.
  18443. */
  18444. protected onContextMenu(evt: PointerEvent): void;
  18445. /**
  18446. * Detach the current controls from the specified dom element.
  18447. * @param element Defines the element to stop listening the inputs from
  18448. */
  18449. detachControl(element: Nullable<HTMLElement>): void;
  18450. /**
  18451. * Gets the class name of the current intput.
  18452. * @returns the class name
  18453. */
  18454. getClassName(): string;
  18455. /**
  18456. * Get the friendly name associated with the input class.
  18457. * @returns the input friendly name
  18458. */
  18459. getSimpleName(): string;
  18460. }
  18461. }
  18462. declare module BABYLON {
  18463. /**
  18464. * Manage the touch inputs to control the movement of a free camera.
  18465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18466. */
  18467. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18468. /**
  18469. * Defines the camera the input is attached to.
  18470. */
  18471. camera: FreeCamera;
  18472. /**
  18473. * Defines the touch sensibility for rotation.
  18474. * The higher the faster.
  18475. */
  18476. touchAngularSensibility: number;
  18477. /**
  18478. * Defines the touch sensibility for move.
  18479. * The higher the faster.
  18480. */
  18481. touchMoveSensibility: number;
  18482. private _offsetX;
  18483. private _offsetY;
  18484. private _pointerPressed;
  18485. private _pointerInput;
  18486. private _observer;
  18487. private _onLostFocus;
  18488. /**
  18489. * Attach the input controls to a specific dom element to get the input from.
  18490. * @param element Defines the element the controls should be listened from
  18491. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18492. */
  18493. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18494. /**
  18495. * Detach the current controls from the specified dom element.
  18496. * @param element Defines the element to stop listening the inputs from
  18497. */
  18498. detachControl(element: Nullable<HTMLElement>): void;
  18499. /**
  18500. * Update the current camera state depending on the inputs that have been used this frame.
  18501. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18502. */
  18503. checkInputs(): void;
  18504. /**
  18505. * Gets the class name of the current intput.
  18506. * @returns the class name
  18507. */
  18508. getClassName(): string;
  18509. /**
  18510. * Get the friendly name associated with the input class.
  18511. * @returns the input friendly name
  18512. */
  18513. getSimpleName(): string;
  18514. }
  18515. }
  18516. declare module BABYLON {
  18517. /**
  18518. * Default Inputs manager for the FreeCamera.
  18519. * It groups all the default supported inputs for ease of use.
  18520. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18521. */
  18522. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18523. /**
  18524. * @hidden
  18525. */
  18526. _mouseInput: Nullable<FreeCameraMouseInput>;
  18527. /**
  18528. * Instantiates a new FreeCameraInputsManager.
  18529. * @param camera Defines the camera the inputs belong to
  18530. */
  18531. constructor(camera: FreeCamera);
  18532. /**
  18533. * Add keyboard input support to the input manager.
  18534. * @returns the current input manager
  18535. */
  18536. addKeyboard(): FreeCameraInputsManager;
  18537. /**
  18538. * Add mouse input support to the input manager.
  18539. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18540. * @returns the current input manager
  18541. */
  18542. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18543. /**
  18544. * Removes the mouse input support from the manager
  18545. * @returns the current input manager
  18546. */
  18547. removeMouse(): FreeCameraInputsManager;
  18548. /**
  18549. * Add touch input support to the input manager.
  18550. * @returns the current input manager
  18551. */
  18552. addTouch(): FreeCameraInputsManager;
  18553. /**
  18554. * Remove all attached input methods from a camera
  18555. */
  18556. clear(): void;
  18557. }
  18558. }
  18559. declare module BABYLON {
  18560. /**
  18561. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18562. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18563. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18564. */
  18565. export class FreeCamera extends TargetCamera {
  18566. /**
  18567. * Define the collision ellipsoid of the camera.
  18568. * This is helpful to simulate a camera body like the player body around the camera
  18569. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18570. */
  18571. ellipsoid: Vector3;
  18572. /**
  18573. * Define an offset for the position of the ellipsoid around the camera.
  18574. * This can be helpful to determine the center of the body near the gravity center of the body
  18575. * instead of its head.
  18576. */
  18577. ellipsoidOffset: Vector3;
  18578. /**
  18579. * Enable or disable collisions of the camera with the rest of the scene objects.
  18580. */
  18581. checkCollisions: boolean;
  18582. /**
  18583. * Enable or disable gravity on the camera.
  18584. */
  18585. applyGravity: boolean;
  18586. /**
  18587. * Define the input manager associated to the camera.
  18588. */
  18589. inputs: FreeCameraInputsManager;
  18590. /**
  18591. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18592. * Higher values reduce sensitivity.
  18593. */
  18594. get angularSensibility(): number;
  18595. /**
  18596. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18597. * Higher values reduce sensitivity.
  18598. */
  18599. set angularSensibility(value: number);
  18600. /**
  18601. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18602. */
  18603. get keysUp(): number[];
  18604. set keysUp(value: number[]);
  18605. /**
  18606. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18607. */
  18608. get keysUpward(): number[];
  18609. set keysUpward(value: number[]);
  18610. /**
  18611. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18612. */
  18613. get keysDown(): number[];
  18614. set keysDown(value: number[]);
  18615. /**
  18616. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18617. */
  18618. get keysDownward(): number[];
  18619. set keysDownward(value: number[]);
  18620. /**
  18621. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18622. */
  18623. get keysLeft(): number[];
  18624. set keysLeft(value: number[]);
  18625. /**
  18626. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18627. */
  18628. get keysRight(): number[];
  18629. set keysRight(value: number[]);
  18630. /**
  18631. * Event raised when the camera collide with a mesh in the scene.
  18632. */
  18633. onCollide: (collidedMesh: AbstractMesh) => void;
  18634. private _collider;
  18635. private _needMoveForGravity;
  18636. private _oldPosition;
  18637. private _diffPosition;
  18638. private _newPosition;
  18639. /** @hidden */
  18640. _localDirection: Vector3;
  18641. /** @hidden */
  18642. _transformedDirection: Vector3;
  18643. /**
  18644. * Instantiates a Free Camera.
  18645. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18646. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18647. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18648. * @param name Define the name of the camera in the scene
  18649. * @param position Define the start position of the camera in the scene
  18650. * @param scene Define the scene the camera belongs to
  18651. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18652. */
  18653. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18654. /**
  18655. * Attached controls to the current camera.
  18656. * @param element Defines the element the controls should be listened from
  18657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18658. */
  18659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18660. /**
  18661. * Detach the current controls from the camera.
  18662. * The camera will stop reacting to inputs.
  18663. * @param element Defines the element to stop listening the inputs from
  18664. */
  18665. detachControl(element: HTMLElement): void;
  18666. private _collisionMask;
  18667. /**
  18668. * Define a collision mask to limit the list of object the camera can collide with
  18669. */
  18670. get collisionMask(): number;
  18671. set collisionMask(mask: number);
  18672. /** @hidden */
  18673. _collideWithWorld(displacement: Vector3): void;
  18674. private _onCollisionPositionChange;
  18675. /** @hidden */
  18676. _checkInputs(): void;
  18677. /** @hidden */
  18678. _decideIfNeedsToMove(): boolean;
  18679. /** @hidden */
  18680. _updatePosition(): void;
  18681. /**
  18682. * Destroy the camera and release the current resources hold by it.
  18683. */
  18684. dispose(): void;
  18685. /**
  18686. * Gets the current object class name.
  18687. * @return the class name
  18688. */
  18689. getClassName(): string;
  18690. }
  18691. }
  18692. declare module BABYLON {
  18693. /**
  18694. * Represents a gamepad control stick position
  18695. */
  18696. export class StickValues {
  18697. /**
  18698. * The x component of the control stick
  18699. */
  18700. x: number;
  18701. /**
  18702. * The y component of the control stick
  18703. */
  18704. y: number;
  18705. /**
  18706. * Initializes the gamepad x and y control stick values
  18707. * @param x The x component of the gamepad control stick value
  18708. * @param y The y component of the gamepad control stick value
  18709. */
  18710. constructor(
  18711. /**
  18712. * The x component of the control stick
  18713. */
  18714. x: number,
  18715. /**
  18716. * The y component of the control stick
  18717. */
  18718. y: number);
  18719. }
  18720. /**
  18721. * An interface which manages callbacks for gamepad button changes
  18722. */
  18723. export interface GamepadButtonChanges {
  18724. /**
  18725. * Called when a gamepad has been changed
  18726. */
  18727. changed: boolean;
  18728. /**
  18729. * Called when a gamepad press event has been triggered
  18730. */
  18731. pressChanged: boolean;
  18732. /**
  18733. * Called when a touch event has been triggered
  18734. */
  18735. touchChanged: boolean;
  18736. /**
  18737. * Called when a value has changed
  18738. */
  18739. valueChanged: boolean;
  18740. }
  18741. /**
  18742. * Represents a gamepad
  18743. */
  18744. export class Gamepad {
  18745. /**
  18746. * The id of the gamepad
  18747. */
  18748. id: string;
  18749. /**
  18750. * The index of the gamepad
  18751. */
  18752. index: number;
  18753. /**
  18754. * The browser gamepad
  18755. */
  18756. browserGamepad: any;
  18757. /**
  18758. * Specifies what type of gamepad this represents
  18759. */
  18760. type: number;
  18761. private _leftStick;
  18762. private _rightStick;
  18763. /** @hidden */
  18764. _isConnected: boolean;
  18765. private _leftStickAxisX;
  18766. private _leftStickAxisY;
  18767. private _rightStickAxisX;
  18768. private _rightStickAxisY;
  18769. /**
  18770. * Triggered when the left control stick has been changed
  18771. */
  18772. private _onleftstickchanged;
  18773. /**
  18774. * Triggered when the right control stick has been changed
  18775. */
  18776. private _onrightstickchanged;
  18777. /**
  18778. * Represents a gamepad controller
  18779. */
  18780. static GAMEPAD: number;
  18781. /**
  18782. * Represents a generic controller
  18783. */
  18784. static GENERIC: number;
  18785. /**
  18786. * Represents an XBox controller
  18787. */
  18788. static XBOX: number;
  18789. /**
  18790. * Represents a pose-enabled controller
  18791. */
  18792. static POSE_ENABLED: number;
  18793. /**
  18794. * Represents an Dual Shock controller
  18795. */
  18796. static DUALSHOCK: number;
  18797. /**
  18798. * Specifies whether the left control stick should be Y-inverted
  18799. */
  18800. protected _invertLeftStickY: boolean;
  18801. /**
  18802. * Specifies if the gamepad has been connected
  18803. */
  18804. get isConnected(): boolean;
  18805. /**
  18806. * Initializes the gamepad
  18807. * @param id The id of the gamepad
  18808. * @param index The index of the gamepad
  18809. * @param browserGamepad The browser gamepad
  18810. * @param leftStickX The x component of the left joystick
  18811. * @param leftStickY The y component of the left joystick
  18812. * @param rightStickX The x component of the right joystick
  18813. * @param rightStickY The y component of the right joystick
  18814. */
  18815. constructor(
  18816. /**
  18817. * The id of the gamepad
  18818. */
  18819. id: string,
  18820. /**
  18821. * The index of the gamepad
  18822. */
  18823. index: number,
  18824. /**
  18825. * The browser gamepad
  18826. */
  18827. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18828. /**
  18829. * Callback triggered when the left joystick has changed
  18830. * @param callback
  18831. */
  18832. onleftstickchanged(callback: (values: StickValues) => void): void;
  18833. /**
  18834. * Callback triggered when the right joystick has changed
  18835. * @param callback
  18836. */
  18837. onrightstickchanged(callback: (values: StickValues) => void): void;
  18838. /**
  18839. * Gets the left joystick
  18840. */
  18841. get leftStick(): StickValues;
  18842. /**
  18843. * Sets the left joystick values
  18844. */
  18845. set leftStick(newValues: StickValues);
  18846. /**
  18847. * Gets the right joystick
  18848. */
  18849. get rightStick(): StickValues;
  18850. /**
  18851. * Sets the right joystick value
  18852. */
  18853. set rightStick(newValues: StickValues);
  18854. /**
  18855. * Updates the gamepad joystick positions
  18856. */
  18857. update(): void;
  18858. /**
  18859. * Disposes the gamepad
  18860. */
  18861. dispose(): void;
  18862. }
  18863. /**
  18864. * Represents a generic gamepad
  18865. */
  18866. export class GenericPad extends Gamepad {
  18867. private _buttons;
  18868. private _onbuttondown;
  18869. private _onbuttonup;
  18870. /**
  18871. * Observable triggered when a button has been pressed
  18872. */
  18873. onButtonDownObservable: Observable<number>;
  18874. /**
  18875. * Observable triggered when a button has been released
  18876. */
  18877. onButtonUpObservable: Observable<number>;
  18878. /**
  18879. * Callback triggered when a button has been pressed
  18880. * @param callback Called when a button has been pressed
  18881. */
  18882. onbuttondown(callback: (buttonPressed: number) => void): void;
  18883. /**
  18884. * Callback triggered when a button has been released
  18885. * @param callback Called when a button has been released
  18886. */
  18887. onbuttonup(callback: (buttonReleased: number) => void): void;
  18888. /**
  18889. * Initializes the generic gamepad
  18890. * @param id The id of the generic gamepad
  18891. * @param index The index of the generic gamepad
  18892. * @param browserGamepad The browser gamepad
  18893. */
  18894. constructor(id: string, index: number, browserGamepad: any);
  18895. private _setButtonValue;
  18896. /**
  18897. * Updates the generic gamepad
  18898. */
  18899. update(): void;
  18900. /**
  18901. * Disposes the generic gamepad
  18902. */
  18903. dispose(): void;
  18904. }
  18905. }
  18906. declare module BABYLON {
  18907. /**
  18908. * Defines the types of pose enabled controllers that are supported
  18909. */
  18910. export enum PoseEnabledControllerType {
  18911. /**
  18912. * HTC Vive
  18913. */
  18914. VIVE = 0,
  18915. /**
  18916. * Oculus Rift
  18917. */
  18918. OCULUS = 1,
  18919. /**
  18920. * Windows mixed reality
  18921. */
  18922. WINDOWS = 2,
  18923. /**
  18924. * Samsung gear VR
  18925. */
  18926. GEAR_VR = 3,
  18927. /**
  18928. * Google Daydream
  18929. */
  18930. DAYDREAM = 4,
  18931. /**
  18932. * Generic
  18933. */
  18934. GENERIC = 5
  18935. }
  18936. /**
  18937. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18938. */
  18939. export interface MutableGamepadButton {
  18940. /**
  18941. * Value of the button/trigger
  18942. */
  18943. value: number;
  18944. /**
  18945. * If the button/trigger is currently touched
  18946. */
  18947. touched: boolean;
  18948. /**
  18949. * If the button/trigger is currently pressed
  18950. */
  18951. pressed: boolean;
  18952. }
  18953. /**
  18954. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18955. * @hidden
  18956. */
  18957. export interface ExtendedGamepadButton extends GamepadButton {
  18958. /**
  18959. * If the button/trigger is currently pressed
  18960. */
  18961. readonly pressed: boolean;
  18962. /**
  18963. * If the button/trigger is currently touched
  18964. */
  18965. readonly touched: boolean;
  18966. /**
  18967. * Value of the button/trigger
  18968. */
  18969. readonly value: number;
  18970. }
  18971. /** @hidden */
  18972. export interface _GamePadFactory {
  18973. /**
  18974. * Returns whether or not the current gamepad can be created for this type of controller.
  18975. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18976. * @returns true if it can be created, otherwise false
  18977. */
  18978. canCreate(gamepadInfo: any): boolean;
  18979. /**
  18980. * Creates a new instance of the Gamepad.
  18981. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18982. * @returns the new gamepad instance
  18983. */
  18984. create(gamepadInfo: any): Gamepad;
  18985. }
  18986. /**
  18987. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18988. */
  18989. export class PoseEnabledControllerHelper {
  18990. /** @hidden */
  18991. static _ControllerFactories: _GamePadFactory[];
  18992. /** @hidden */
  18993. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18994. /**
  18995. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18996. * @param vrGamepad the gamepad to initialized
  18997. * @returns a vr controller of the type the gamepad identified as
  18998. */
  18999. static InitiateController(vrGamepad: any): Gamepad;
  19000. }
  19001. /**
  19002. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19003. */
  19004. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19005. /**
  19006. * If the controller is used in a webXR session
  19007. */
  19008. isXR: boolean;
  19009. private _deviceRoomPosition;
  19010. private _deviceRoomRotationQuaternion;
  19011. /**
  19012. * The device position in babylon space
  19013. */
  19014. devicePosition: Vector3;
  19015. /**
  19016. * The device rotation in babylon space
  19017. */
  19018. deviceRotationQuaternion: Quaternion;
  19019. /**
  19020. * The scale factor of the device in babylon space
  19021. */
  19022. deviceScaleFactor: number;
  19023. /**
  19024. * (Likely devicePosition should be used instead) The device position in its room space
  19025. */
  19026. position: Vector3;
  19027. /**
  19028. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19029. */
  19030. rotationQuaternion: Quaternion;
  19031. /**
  19032. * The type of controller (Eg. Windows mixed reality)
  19033. */
  19034. controllerType: PoseEnabledControllerType;
  19035. protected _calculatedPosition: Vector3;
  19036. private _calculatedRotation;
  19037. /**
  19038. * The raw pose from the device
  19039. */
  19040. rawPose: DevicePose;
  19041. private _trackPosition;
  19042. private _maxRotationDistFromHeadset;
  19043. private _draggedRoomRotation;
  19044. /**
  19045. * @hidden
  19046. */
  19047. _disableTrackPosition(fixedPosition: Vector3): void;
  19048. /**
  19049. * Internal, the mesh attached to the controller
  19050. * @hidden
  19051. */
  19052. _mesh: Nullable<AbstractMesh>;
  19053. private _poseControlledCamera;
  19054. private _leftHandSystemQuaternion;
  19055. /**
  19056. * Internal, matrix used to convert room space to babylon space
  19057. * @hidden
  19058. */
  19059. _deviceToWorld: Matrix;
  19060. /**
  19061. * Node to be used when casting a ray from the controller
  19062. * @hidden
  19063. */
  19064. _pointingPoseNode: Nullable<TransformNode>;
  19065. /**
  19066. * Name of the child mesh that can be used to cast a ray from the controller
  19067. */
  19068. static readonly POINTING_POSE: string;
  19069. /**
  19070. * Creates a new PoseEnabledController from a gamepad
  19071. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19072. */
  19073. constructor(browserGamepad: any);
  19074. private _workingMatrix;
  19075. /**
  19076. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19077. */
  19078. update(): void;
  19079. /**
  19080. * Updates only the pose device and mesh without doing any button event checking
  19081. */
  19082. protected _updatePoseAndMesh(): void;
  19083. /**
  19084. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19085. * @param poseData raw pose fromthe device
  19086. */
  19087. updateFromDevice(poseData: DevicePose): void;
  19088. /**
  19089. * @hidden
  19090. */
  19091. _meshAttachedObservable: Observable<AbstractMesh>;
  19092. /**
  19093. * Attaches a mesh to the controller
  19094. * @param mesh the mesh to be attached
  19095. */
  19096. attachToMesh(mesh: AbstractMesh): void;
  19097. /**
  19098. * Attaches the controllers mesh to a camera
  19099. * @param camera the camera the mesh should be attached to
  19100. */
  19101. attachToPoseControlledCamera(camera: TargetCamera): void;
  19102. /**
  19103. * Disposes of the controller
  19104. */
  19105. dispose(): void;
  19106. /**
  19107. * The mesh that is attached to the controller
  19108. */
  19109. get mesh(): Nullable<AbstractMesh>;
  19110. /**
  19111. * Gets the ray of the controller in the direction the controller is pointing
  19112. * @param length the length the resulting ray should be
  19113. * @returns a ray in the direction the controller is pointing
  19114. */
  19115. getForwardRay(length?: number): Ray;
  19116. }
  19117. }
  19118. declare module BABYLON {
  19119. /**
  19120. * Defines the WebVRController object that represents controllers tracked in 3D space
  19121. */
  19122. export abstract class WebVRController extends PoseEnabledController {
  19123. /**
  19124. * Internal, the default controller model for the controller
  19125. */
  19126. protected _defaultModel: Nullable<AbstractMesh>;
  19127. /**
  19128. * Fired when the trigger state has changed
  19129. */
  19130. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19131. /**
  19132. * Fired when the main button state has changed
  19133. */
  19134. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19135. /**
  19136. * Fired when the secondary button state has changed
  19137. */
  19138. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19139. /**
  19140. * Fired when the pad state has changed
  19141. */
  19142. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19143. /**
  19144. * Fired when controllers stick values have changed
  19145. */
  19146. onPadValuesChangedObservable: Observable<StickValues>;
  19147. /**
  19148. * Array of button availible on the controller
  19149. */
  19150. protected _buttons: Array<MutableGamepadButton>;
  19151. private _onButtonStateChange;
  19152. /**
  19153. * Fired when a controller button's state has changed
  19154. * @param callback the callback containing the button that was modified
  19155. */
  19156. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19157. /**
  19158. * X and Y axis corresponding to the controllers joystick
  19159. */
  19160. pad: StickValues;
  19161. /**
  19162. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19163. */
  19164. hand: string;
  19165. /**
  19166. * The default controller model for the controller
  19167. */
  19168. get defaultModel(): Nullable<AbstractMesh>;
  19169. /**
  19170. * Creates a new WebVRController from a gamepad
  19171. * @param vrGamepad the gamepad that the WebVRController should be created from
  19172. */
  19173. constructor(vrGamepad: any);
  19174. /**
  19175. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19176. */
  19177. update(): void;
  19178. /**
  19179. * Function to be called when a button is modified
  19180. */
  19181. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19182. /**
  19183. * Loads a mesh and attaches it to the controller
  19184. * @param scene the scene the mesh should be added to
  19185. * @param meshLoaded callback for when the mesh has been loaded
  19186. */
  19187. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19188. private _setButtonValue;
  19189. private _changes;
  19190. private _checkChanges;
  19191. /**
  19192. * Disposes of th webVRCOntroller
  19193. */
  19194. dispose(): void;
  19195. }
  19196. }
  19197. declare module BABYLON {
  19198. /**
  19199. * The HemisphericLight simulates the ambient environment light,
  19200. * so the passed direction is the light reflection direction, not the incoming direction.
  19201. */
  19202. export class HemisphericLight extends Light {
  19203. /**
  19204. * The groundColor is the light in the opposite direction to the one specified during creation.
  19205. * 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.
  19206. */
  19207. groundColor: Color3;
  19208. /**
  19209. * The light reflection direction, not the incoming direction.
  19210. */
  19211. direction: Vector3;
  19212. /**
  19213. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19214. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19215. * The HemisphericLight can't cast shadows.
  19216. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19217. * @param name The friendly name of the light
  19218. * @param direction The direction of the light reflection
  19219. * @param scene The scene the light belongs to
  19220. */
  19221. constructor(name: string, direction: Vector3, scene: Scene);
  19222. protected _buildUniformLayout(): void;
  19223. /**
  19224. * Returns the string "HemisphericLight".
  19225. * @return The class name
  19226. */
  19227. getClassName(): string;
  19228. /**
  19229. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19230. * Returns the updated direction.
  19231. * @param target The target the direction should point to
  19232. * @return The computed direction
  19233. */
  19234. setDirectionToTarget(target: Vector3): Vector3;
  19235. /**
  19236. * Returns the shadow generator associated to the light.
  19237. * @returns Always null for hemispheric lights because it does not support shadows.
  19238. */
  19239. getShadowGenerator(): Nullable<IShadowGenerator>;
  19240. /**
  19241. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19242. * @param effect The effect to update
  19243. * @param lightIndex The index of the light in the effect to update
  19244. * @returns The hemispheric light
  19245. */
  19246. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19247. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19248. /**
  19249. * Computes the world matrix of the node
  19250. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19251. * @param useWasUpdatedFlag defines a reserved property
  19252. * @returns the world matrix
  19253. */
  19254. computeWorldMatrix(): Matrix;
  19255. /**
  19256. * Returns the integer 3.
  19257. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19258. */
  19259. getTypeID(): number;
  19260. /**
  19261. * Prepares the list of defines specific to the light type.
  19262. * @param defines the list of defines
  19263. * @param lightIndex defines the index of the light for the effect
  19264. */
  19265. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19266. }
  19267. }
  19268. declare module BABYLON {
  19269. /** @hidden */
  19270. export var vrMultiviewToSingleviewPixelShader: {
  19271. name: string;
  19272. shader: string;
  19273. };
  19274. }
  19275. declare module BABYLON {
  19276. /**
  19277. * Renders to multiple views with a single draw call
  19278. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19279. */
  19280. export class MultiviewRenderTarget extends RenderTargetTexture {
  19281. /**
  19282. * Creates a multiview render target
  19283. * @param scene scene used with the render target
  19284. * @param size the size of the render target (used for each view)
  19285. */
  19286. constructor(scene: Scene, size?: number | {
  19287. width: number;
  19288. height: number;
  19289. } | {
  19290. ratio: number;
  19291. });
  19292. /**
  19293. * @hidden
  19294. * @param faceIndex the face index, if its a cube texture
  19295. */
  19296. _bindFrameBuffer(faceIndex?: number): void;
  19297. /**
  19298. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19299. * @returns the view count
  19300. */
  19301. getViewCount(): number;
  19302. }
  19303. }
  19304. declare module BABYLON {
  19305. /**
  19306. * Represents a camera frustum
  19307. */
  19308. export class Frustum {
  19309. /**
  19310. * Gets the planes representing the frustum
  19311. * @param transform matrix to be applied to the returned planes
  19312. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19313. */
  19314. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19315. /**
  19316. * Gets the near frustum plane transformed by the transform matrix
  19317. * @param transform transformation matrix to be applied to the resulting frustum plane
  19318. * @param frustumPlane the resuling frustum plane
  19319. */
  19320. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19321. /**
  19322. * Gets the far frustum plane transformed by the transform matrix
  19323. * @param transform transformation matrix to be applied to the resulting frustum plane
  19324. * @param frustumPlane the resuling frustum plane
  19325. */
  19326. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19327. /**
  19328. * Gets the left frustum plane transformed by the transform matrix
  19329. * @param transform transformation matrix to be applied to the resulting frustum plane
  19330. * @param frustumPlane the resuling frustum plane
  19331. */
  19332. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19333. /**
  19334. * Gets the right frustum plane transformed by the transform matrix
  19335. * @param transform transformation matrix to be applied to the resulting frustum plane
  19336. * @param frustumPlane the resuling frustum plane
  19337. */
  19338. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19339. /**
  19340. * Gets the top frustum plane transformed by the transform matrix
  19341. * @param transform transformation matrix to be applied to the resulting frustum plane
  19342. * @param frustumPlane the resuling frustum plane
  19343. */
  19344. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19345. /**
  19346. * Gets the bottom frustum plane transformed by the transform matrix
  19347. * @param transform transformation matrix to be applied to the resulting frustum plane
  19348. * @param frustumPlane the resuling frustum plane
  19349. */
  19350. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19351. /**
  19352. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19353. * @param transform transformation matrix to be applied to the resulting frustum planes
  19354. * @param frustumPlanes the resuling frustum planes
  19355. */
  19356. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19357. }
  19358. }
  19359. declare module BABYLON {
  19360. interface Engine {
  19361. /**
  19362. * Creates a new multiview render target
  19363. * @param width defines the width of the texture
  19364. * @param height defines the height of the texture
  19365. * @returns the created multiview texture
  19366. */
  19367. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19368. /**
  19369. * Binds a multiview framebuffer to be drawn to
  19370. * @param multiviewTexture texture to bind
  19371. */
  19372. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19373. }
  19374. interface Camera {
  19375. /**
  19376. * @hidden
  19377. * 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)
  19378. */
  19379. _useMultiviewToSingleView: boolean;
  19380. /**
  19381. * @hidden
  19382. * 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)
  19383. */
  19384. _multiviewTexture: Nullable<RenderTargetTexture>;
  19385. /**
  19386. * @hidden
  19387. * ensures the multiview texture of the camera exists and has the specified width/height
  19388. * @param width height to set on the multiview texture
  19389. * @param height width to set on the multiview texture
  19390. */
  19391. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19392. }
  19393. interface Scene {
  19394. /** @hidden */
  19395. _transformMatrixR: Matrix;
  19396. /** @hidden */
  19397. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19398. /** @hidden */
  19399. _createMultiviewUbo(): void;
  19400. /** @hidden */
  19401. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19402. /** @hidden */
  19403. _renderMultiviewToSingleView(camera: Camera): void;
  19404. }
  19405. }
  19406. declare module BABYLON {
  19407. /**
  19408. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19409. * This will not be used for webXR as it supports displaying texture arrays directly
  19410. */
  19411. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19412. /**
  19413. * Initializes a VRMultiviewToSingleview
  19414. * @param name name of the post process
  19415. * @param camera camera to be applied to
  19416. * @param scaleFactor scaling factor to the size of the output texture
  19417. */
  19418. constructor(name: string, camera: Camera, scaleFactor: number);
  19419. }
  19420. }
  19421. declare module BABYLON {
  19422. /**
  19423. * Interface used to define additional presentation attributes
  19424. */
  19425. export interface IVRPresentationAttributes {
  19426. /**
  19427. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19428. */
  19429. highRefreshRate: boolean;
  19430. /**
  19431. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19432. */
  19433. foveationLevel: number;
  19434. }
  19435. interface Engine {
  19436. /** @hidden */
  19437. _vrDisplay: any;
  19438. /** @hidden */
  19439. _vrSupported: boolean;
  19440. /** @hidden */
  19441. _oldSize: Size;
  19442. /** @hidden */
  19443. _oldHardwareScaleFactor: number;
  19444. /** @hidden */
  19445. _vrExclusivePointerMode: boolean;
  19446. /** @hidden */
  19447. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19448. /** @hidden */
  19449. _onVRDisplayPointerRestricted: () => void;
  19450. /** @hidden */
  19451. _onVRDisplayPointerUnrestricted: () => void;
  19452. /** @hidden */
  19453. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19454. /** @hidden */
  19455. _onVrDisplayDisconnect: Nullable<() => void>;
  19456. /** @hidden */
  19457. _onVrDisplayPresentChange: Nullable<() => void>;
  19458. /**
  19459. * Observable signaled when VR display mode changes
  19460. */
  19461. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19462. /**
  19463. * Observable signaled when VR request present is complete
  19464. */
  19465. onVRRequestPresentComplete: Observable<boolean>;
  19466. /**
  19467. * Observable signaled when VR request present starts
  19468. */
  19469. onVRRequestPresentStart: Observable<Engine>;
  19470. /**
  19471. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19472. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19473. */
  19474. isInVRExclusivePointerMode: boolean;
  19475. /**
  19476. * Gets a boolean indicating if a webVR device was detected
  19477. * @returns true if a webVR device was detected
  19478. */
  19479. isVRDevicePresent(): boolean;
  19480. /**
  19481. * Gets the current webVR device
  19482. * @returns the current webVR device (or null)
  19483. */
  19484. getVRDevice(): any;
  19485. /**
  19486. * Initializes a webVR display and starts listening to display change events
  19487. * The onVRDisplayChangedObservable will be notified upon these changes
  19488. * @returns A promise containing a VRDisplay and if vr is supported
  19489. */
  19490. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19491. /** @hidden */
  19492. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19493. /**
  19494. * Gets or sets the presentation attributes used to configure VR rendering
  19495. */
  19496. vrPresentationAttributes?: IVRPresentationAttributes;
  19497. /**
  19498. * Call this function to switch to webVR mode
  19499. * Will do nothing if webVR is not supported or if there is no webVR device
  19500. * @param options the webvr options provided to the camera. mainly used for multiview
  19501. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19502. */
  19503. enableVR(options: WebVROptions): void;
  19504. /** @hidden */
  19505. _onVRFullScreenTriggered(): void;
  19506. }
  19507. }
  19508. declare module BABYLON {
  19509. /**
  19510. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19511. * IMPORTANT!! The data is right-hand data.
  19512. * @export
  19513. * @interface DevicePose
  19514. */
  19515. export interface DevicePose {
  19516. /**
  19517. * The position of the device, values in array are [x,y,z].
  19518. */
  19519. readonly position: Nullable<Float32Array>;
  19520. /**
  19521. * The linearVelocity of the device, values in array are [x,y,z].
  19522. */
  19523. readonly linearVelocity: Nullable<Float32Array>;
  19524. /**
  19525. * The linearAcceleration of the device, values in array are [x,y,z].
  19526. */
  19527. readonly linearAcceleration: Nullable<Float32Array>;
  19528. /**
  19529. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19530. */
  19531. readonly orientation: Nullable<Float32Array>;
  19532. /**
  19533. * The angularVelocity of the device, values in array are [x,y,z].
  19534. */
  19535. readonly angularVelocity: Nullable<Float32Array>;
  19536. /**
  19537. * The angularAcceleration of the device, values in array are [x,y,z].
  19538. */
  19539. readonly angularAcceleration: Nullable<Float32Array>;
  19540. }
  19541. /**
  19542. * Interface representing a pose controlled object in Babylon.
  19543. * A pose controlled object has both regular pose values as well as pose values
  19544. * from an external device such as a VR head mounted display
  19545. */
  19546. export interface PoseControlled {
  19547. /**
  19548. * The position of the object in babylon space.
  19549. */
  19550. position: Vector3;
  19551. /**
  19552. * The rotation quaternion of the object in babylon space.
  19553. */
  19554. rotationQuaternion: Quaternion;
  19555. /**
  19556. * The position of the device in babylon space.
  19557. */
  19558. devicePosition?: Vector3;
  19559. /**
  19560. * The rotation quaternion of the device in babylon space.
  19561. */
  19562. deviceRotationQuaternion: Quaternion;
  19563. /**
  19564. * The raw pose coming from the device.
  19565. */
  19566. rawPose: Nullable<DevicePose>;
  19567. /**
  19568. * The scale of the device to be used when translating from device space to babylon space.
  19569. */
  19570. deviceScaleFactor: number;
  19571. /**
  19572. * Updates the poseControlled values based on the input device pose.
  19573. * @param poseData the pose data to update the object with
  19574. */
  19575. updateFromDevice(poseData: DevicePose): void;
  19576. }
  19577. /**
  19578. * Set of options to customize the webVRCamera
  19579. */
  19580. export interface WebVROptions {
  19581. /**
  19582. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19583. */
  19584. trackPosition?: boolean;
  19585. /**
  19586. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19587. */
  19588. positionScale?: number;
  19589. /**
  19590. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19591. */
  19592. displayName?: string;
  19593. /**
  19594. * Should the native controller meshes be initialized. (default: true)
  19595. */
  19596. controllerMeshes?: boolean;
  19597. /**
  19598. * Creating a default HemiLight only on controllers. (default: true)
  19599. */
  19600. defaultLightingOnControllers?: boolean;
  19601. /**
  19602. * If you don't want to use the default VR button of the helper. (default: false)
  19603. */
  19604. useCustomVRButton?: boolean;
  19605. /**
  19606. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19607. */
  19608. customVRButton?: HTMLButtonElement;
  19609. /**
  19610. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19611. */
  19612. rayLength?: number;
  19613. /**
  19614. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19615. */
  19616. defaultHeight?: number;
  19617. /**
  19618. * If multiview should be used if availible (default: false)
  19619. */
  19620. useMultiview?: boolean;
  19621. }
  19622. /**
  19623. * This represents a WebVR camera.
  19624. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19625. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19626. */
  19627. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19628. private webVROptions;
  19629. /**
  19630. * @hidden
  19631. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19632. */
  19633. _vrDevice: any;
  19634. /**
  19635. * The rawPose of the vrDevice.
  19636. */
  19637. rawPose: Nullable<DevicePose>;
  19638. private _onVREnabled;
  19639. private _specsVersion;
  19640. private _attached;
  19641. private _frameData;
  19642. protected _descendants: Array<Node>;
  19643. private _deviceRoomPosition;
  19644. /** @hidden */
  19645. _deviceRoomRotationQuaternion: Quaternion;
  19646. private _standingMatrix;
  19647. /**
  19648. * Represents device position in babylon space.
  19649. */
  19650. devicePosition: Vector3;
  19651. /**
  19652. * Represents device rotation in babylon space.
  19653. */
  19654. deviceRotationQuaternion: Quaternion;
  19655. /**
  19656. * The scale of the device to be used when translating from device space to babylon space.
  19657. */
  19658. deviceScaleFactor: number;
  19659. private _deviceToWorld;
  19660. private _worldToDevice;
  19661. /**
  19662. * References to the webVR controllers for the vrDevice.
  19663. */
  19664. controllers: Array<WebVRController>;
  19665. /**
  19666. * Emits an event when a controller is attached.
  19667. */
  19668. onControllersAttachedObservable: Observable<WebVRController[]>;
  19669. /**
  19670. * Emits an event when a controller's mesh has been loaded;
  19671. */
  19672. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19673. /**
  19674. * Emits an event when the HMD's pose has been updated.
  19675. */
  19676. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19677. private _poseSet;
  19678. /**
  19679. * If the rig cameras be used as parent instead of this camera.
  19680. */
  19681. rigParenting: boolean;
  19682. private _lightOnControllers;
  19683. private _defaultHeight?;
  19684. /**
  19685. * Instantiates a WebVRFreeCamera.
  19686. * @param name The name of the WebVRFreeCamera
  19687. * @param position The starting anchor position for the camera
  19688. * @param scene The scene the camera belongs to
  19689. * @param webVROptions a set of customizable options for the webVRCamera
  19690. */
  19691. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19692. /**
  19693. * Gets the device distance from the ground in meters.
  19694. * @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.
  19695. */
  19696. deviceDistanceToRoomGround(): number;
  19697. /**
  19698. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19699. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19700. */
  19701. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19702. /**
  19703. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19704. * @returns A promise with a boolean set to if the standing matrix is supported.
  19705. */
  19706. useStandingMatrixAsync(): Promise<boolean>;
  19707. /**
  19708. * Disposes the camera
  19709. */
  19710. dispose(): void;
  19711. /**
  19712. * Gets a vrController by name.
  19713. * @param name The name of the controller to retreive
  19714. * @returns the controller matching the name specified or null if not found
  19715. */
  19716. getControllerByName(name: string): Nullable<WebVRController>;
  19717. private _leftController;
  19718. /**
  19719. * The controller corresponding to the users left hand.
  19720. */
  19721. get leftController(): Nullable<WebVRController>;
  19722. private _rightController;
  19723. /**
  19724. * The controller corresponding to the users right hand.
  19725. */
  19726. get rightController(): Nullable<WebVRController>;
  19727. /**
  19728. * Casts a ray forward from the vrCamera's gaze.
  19729. * @param length Length of the ray (default: 100)
  19730. * @returns the ray corresponding to the gaze
  19731. */
  19732. getForwardRay(length?: number): Ray;
  19733. /**
  19734. * @hidden
  19735. * Updates the camera based on device's frame data
  19736. */
  19737. _checkInputs(): void;
  19738. /**
  19739. * Updates the poseControlled values based on the input device pose.
  19740. * @param poseData Pose coming from the device
  19741. */
  19742. updateFromDevice(poseData: DevicePose): void;
  19743. private _htmlElementAttached;
  19744. private _detachIfAttached;
  19745. /**
  19746. * WebVR's attach control will start broadcasting frames to the device.
  19747. * Note that in certain browsers (chrome for example) this function must be called
  19748. * within a user-interaction callback. Example:
  19749. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19750. *
  19751. * @param element html element to attach the vrDevice to
  19752. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19753. */
  19754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19755. /**
  19756. * Detaches the camera from the html element and disables VR
  19757. *
  19758. * @param element html element to detach from
  19759. */
  19760. detachControl(element: HTMLElement): void;
  19761. /**
  19762. * @returns the name of this class
  19763. */
  19764. getClassName(): string;
  19765. /**
  19766. * Calls resetPose on the vrDisplay
  19767. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19768. */
  19769. resetToCurrentRotation(): void;
  19770. /**
  19771. * @hidden
  19772. * Updates the rig cameras (left and right eye)
  19773. */
  19774. _updateRigCameras(): void;
  19775. private _workingVector;
  19776. private _oneVector;
  19777. private _workingMatrix;
  19778. private updateCacheCalled;
  19779. private _correctPositionIfNotTrackPosition;
  19780. /**
  19781. * @hidden
  19782. * Updates the cached values of the camera
  19783. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19784. */
  19785. _updateCache(ignoreParentClass?: boolean): void;
  19786. /**
  19787. * @hidden
  19788. * Get current device position in babylon world
  19789. */
  19790. _computeDevicePosition(): void;
  19791. /**
  19792. * Updates the current device position and rotation in the babylon world
  19793. */
  19794. update(): void;
  19795. /**
  19796. * @hidden
  19797. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19798. * @returns an identity matrix
  19799. */
  19800. _getViewMatrix(): Matrix;
  19801. private _tmpMatrix;
  19802. /**
  19803. * This function is called by the two RIG cameras.
  19804. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19805. * @hidden
  19806. */
  19807. _getWebVRViewMatrix(): Matrix;
  19808. /** @hidden */
  19809. _getWebVRProjectionMatrix(): Matrix;
  19810. private _onGamepadConnectedObserver;
  19811. private _onGamepadDisconnectedObserver;
  19812. private _updateCacheWhenTrackingDisabledObserver;
  19813. /**
  19814. * Initializes the controllers and their meshes
  19815. */
  19816. initControllers(): void;
  19817. }
  19818. }
  19819. declare module BABYLON {
  19820. /**
  19821. * Size options for a post process
  19822. */
  19823. export type PostProcessOptions = {
  19824. width: number;
  19825. height: number;
  19826. };
  19827. /**
  19828. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19829. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19830. */
  19831. export class PostProcess {
  19832. /** Name of the PostProcess. */
  19833. name: string;
  19834. /**
  19835. * Gets or sets the unique id of the post process
  19836. */
  19837. uniqueId: number;
  19838. /**
  19839. * Width of the texture to apply the post process on
  19840. */
  19841. width: number;
  19842. /**
  19843. * Height of the texture to apply the post process on
  19844. */
  19845. height: number;
  19846. /**
  19847. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19848. * @hidden
  19849. */
  19850. _outputTexture: Nullable<InternalTexture>;
  19851. /**
  19852. * Sampling mode used by the shader
  19853. * See https://doc.babylonjs.com/classes/3.1/texture
  19854. */
  19855. renderTargetSamplingMode: number;
  19856. /**
  19857. * Clear color to use when screen clearing
  19858. */
  19859. clearColor: Color4;
  19860. /**
  19861. * If the buffer needs to be cleared before applying the post process. (default: true)
  19862. * Should be set to false if shader will overwrite all previous pixels.
  19863. */
  19864. autoClear: boolean;
  19865. /**
  19866. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19867. */
  19868. alphaMode: number;
  19869. /**
  19870. * Sets the setAlphaBlendConstants of the babylon engine
  19871. */
  19872. alphaConstants: Color4;
  19873. /**
  19874. * Animations to be used for the post processing
  19875. */
  19876. animations: Animation[];
  19877. /**
  19878. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19879. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19880. */
  19881. enablePixelPerfectMode: boolean;
  19882. /**
  19883. * Force the postprocess to be applied without taking in account viewport
  19884. */
  19885. forceFullscreenViewport: boolean;
  19886. /**
  19887. * List of inspectable custom properties (used by the Inspector)
  19888. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19889. */
  19890. inspectableCustomProperties: IInspectable[];
  19891. /**
  19892. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19893. *
  19894. * | Value | Type | Description |
  19895. * | ----- | ----------------------------------- | ----------- |
  19896. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19897. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19898. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19899. *
  19900. */
  19901. scaleMode: number;
  19902. /**
  19903. * Force textures to be a power of two (default: false)
  19904. */
  19905. alwaysForcePOT: boolean;
  19906. private _samples;
  19907. /**
  19908. * Number of sample textures (default: 1)
  19909. */
  19910. get samples(): number;
  19911. set samples(n: number);
  19912. /**
  19913. * Modify the scale of the post process to be the same as the viewport (default: false)
  19914. */
  19915. adaptScaleToCurrentViewport: boolean;
  19916. private _camera;
  19917. private _scene;
  19918. private _engine;
  19919. private _options;
  19920. private _reusable;
  19921. private _textureType;
  19922. private _textureFormat;
  19923. /**
  19924. * Smart array of input and output textures for the post process.
  19925. * @hidden
  19926. */
  19927. _textures: SmartArray<InternalTexture>;
  19928. /**
  19929. * The index in _textures that corresponds to the output texture.
  19930. * @hidden
  19931. */
  19932. _currentRenderTextureInd: number;
  19933. private _effect;
  19934. private _samplers;
  19935. private _fragmentUrl;
  19936. private _vertexUrl;
  19937. private _parameters;
  19938. private _scaleRatio;
  19939. protected _indexParameters: any;
  19940. private _shareOutputWithPostProcess;
  19941. private _texelSize;
  19942. private _forcedOutputTexture;
  19943. /**
  19944. * Returns the fragment url or shader name used in the post process.
  19945. * @returns the fragment url or name in the shader store.
  19946. */
  19947. getEffectName(): string;
  19948. /**
  19949. * An event triggered when the postprocess is activated.
  19950. */
  19951. onActivateObservable: Observable<Camera>;
  19952. private _onActivateObserver;
  19953. /**
  19954. * A function that is added to the onActivateObservable
  19955. */
  19956. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19957. /**
  19958. * An event triggered when the postprocess changes its size.
  19959. */
  19960. onSizeChangedObservable: Observable<PostProcess>;
  19961. private _onSizeChangedObserver;
  19962. /**
  19963. * A function that is added to the onSizeChangedObservable
  19964. */
  19965. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19966. /**
  19967. * An event triggered when the postprocess applies its effect.
  19968. */
  19969. onApplyObservable: Observable<Effect>;
  19970. private _onApplyObserver;
  19971. /**
  19972. * A function that is added to the onApplyObservable
  19973. */
  19974. set onApply(callback: (effect: Effect) => void);
  19975. /**
  19976. * An event triggered before rendering the postprocess
  19977. */
  19978. onBeforeRenderObservable: Observable<Effect>;
  19979. private _onBeforeRenderObserver;
  19980. /**
  19981. * A function that is added to the onBeforeRenderObservable
  19982. */
  19983. set onBeforeRender(callback: (effect: Effect) => void);
  19984. /**
  19985. * An event triggered after rendering the postprocess
  19986. */
  19987. onAfterRenderObservable: Observable<Effect>;
  19988. private _onAfterRenderObserver;
  19989. /**
  19990. * A function that is added to the onAfterRenderObservable
  19991. */
  19992. set onAfterRender(callback: (efect: Effect) => void);
  19993. /**
  19994. * 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
  19995. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19996. */
  19997. get inputTexture(): InternalTexture;
  19998. set inputTexture(value: InternalTexture);
  19999. /**
  20000. * Gets the camera which post process is applied to.
  20001. * @returns The camera the post process is applied to.
  20002. */
  20003. getCamera(): Camera;
  20004. /**
  20005. * Gets the texel size of the postprocess.
  20006. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20007. */
  20008. get texelSize(): Vector2;
  20009. /**
  20010. * Creates a new instance PostProcess
  20011. * @param name The name of the PostProcess.
  20012. * @param fragmentUrl The url of the fragment shader to be used.
  20013. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20014. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20015. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20016. * @param camera The camera to apply the render pass to.
  20017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20018. * @param engine The engine which the post process will be applied. (default: current engine)
  20019. * @param reusable If the post process can be reused on the same frame. (default: false)
  20020. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20021. * @param textureType Type of textures used when performing the post process. (default: 0)
  20022. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20023. * @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
  20024. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20025. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20026. */
  20027. constructor(
  20028. /** Name of the PostProcess. */
  20029. 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);
  20030. /**
  20031. * Gets a string idenfifying the name of the class
  20032. * @returns "PostProcess" string
  20033. */
  20034. getClassName(): string;
  20035. /**
  20036. * Gets the engine which this post process belongs to.
  20037. * @returns The engine the post process was enabled with.
  20038. */
  20039. getEngine(): Engine;
  20040. /**
  20041. * The effect that is created when initializing the post process.
  20042. * @returns The created effect corresponding the the postprocess.
  20043. */
  20044. getEffect(): Effect;
  20045. /**
  20046. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20047. * @param postProcess The post process to share the output with.
  20048. * @returns This post process.
  20049. */
  20050. shareOutputWith(postProcess: PostProcess): PostProcess;
  20051. /**
  20052. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20053. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20054. */
  20055. useOwnOutput(): void;
  20056. /**
  20057. * Updates the effect with the current post process compile time values and recompiles the shader.
  20058. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20059. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20060. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20061. * @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
  20062. * @param onCompiled Called when the shader has been compiled.
  20063. * @param onError Called if there is an error when compiling a shader.
  20064. */
  20065. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20066. /**
  20067. * The post process is reusable if it can be used multiple times within one frame.
  20068. * @returns If the post process is reusable
  20069. */
  20070. isReusable(): boolean;
  20071. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20072. markTextureDirty(): void;
  20073. /**
  20074. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20075. * 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.
  20076. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20077. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20078. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20079. * @returns The target texture that was bound to be written to.
  20080. */
  20081. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20082. /**
  20083. * If the post process is supported.
  20084. */
  20085. get isSupported(): boolean;
  20086. /**
  20087. * The aspect ratio of the output texture.
  20088. */
  20089. get aspectRatio(): number;
  20090. /**
  20091. * Get a value indicating if the post-process is ready to be used
  20092. * @returns true if the post-process is ready (shader is compiled)
  20093. */
  20094. isReady(): boolean;
  20095. /**
  20096. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20097. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20098. */
  20099. apply(): Nullable<Effect>;
  20100. private _disposeTextures;
  20101. /**
  20102. * Disposes the post process.
  20103. * @param camera The camera to dispose the post process on.
  20104. */
  20105. dispose(camera?: Camera): void;
  20106. }
  20107. }
  20108. declare module BABYLON {
  20109. /** @hidden */
  20110. export var kernelBlurVaryingDeclaration: {
  20111. name: string;
  20112. shader: string;
  20113. };
  20114. }
  20115. declare module BABYLON {
  20116. /** @hidden */
  20117. export var kernelBlurFragment: {
  20118. name: string;
  20119. shader: string;
  20120. };
  20121. }
  20122. declare module BABYLON {
  20123. /** @hidden */
  20124. export var kernelBlurFragment2: {
  20125. name: string;
  20126. shader: string;
  20127. };
  20128. }
  20129. declare module BABYLON {
  20130. /** @hidden */
  20131. export var kernelBlurPixelShader: {
  20132. name: string;
  20133. shader: string;
  20134. };
  20135. }
  20136. declare module BABYLON {
  20137. /** @hidden */
  20138. export var kernelBlurVertex: {
  20139. name: string;
  20140. shader: string;
  20141. };
  20142. }
  20143. declare module BABYLON {
  20144. /** @hidden */
  20145. export var kernelBlurVertexShader: {
  20146. name: string;
  20147. shader: string;
  20148. };
  20149. }
  20150. declare module BABYLON {
  20151. /**
  20152. * The Blur Post Process which blurs an image based on a kernel and direction.
  20153. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20154. */
  20155. export class BlurPostProcess extends PostProcess {
  20156. /** The direction in which to blur the image. */
  20157. direction: Vector2;
  20158. private blockCompilation;
  20159. protected _kernel: number;
  20160. protected _idealKernel: number;
  20161. protected _packedFloat: boolean;
  20162. private _staticDefines;
  20163. /**
  20164. * Sets the length in pixels of the blur sample region
  20165. */
  20166. set kernel(v: number);
  20167. /**
  20168. * Gets the length in pixels of the blur sample region
  20169. */
  20170. get kernel(): number;
  20171. /**
  20172. * Sets wether or not the blur needs to unpack/repack floats
  20173. */
  20174. set packedFloat(v: boolean);
  20175. /**
  20176. * Gets wether or not the blur is unpacking/repacking floats
  20177. */
  20178. get packedFloat(): boolean;
  20179. /**
  20180. * Creates a new instance BlurPostProcess
  20181. * @param name The name of the effect.
  20182. * @param direction The direction in which to blur the image.
  20183. * @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.
  20184. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20185. * @param camera The camera to apply the render pass to.
  20186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20187. * @param engine The engine which the post process will be applied. (default: current engine)
  20188. * @param reusable If the post process can be reused on the same frame. (default: false)
  20189. * @param textureType Type of textures used when performing the post process. (default: 0)
  20190. * @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)
  20191. */
  20192. constructor(name: string,
  20193. /** The direction in which to blur the image. */
  20194. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20195. /**
  20196. * Updates the effect with the current post process compile time values and recompiles the shader.
  20197. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20198. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20199. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20200. * @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
  20201. * @param onCompiled Called when the shader has been compiled.
  20202. * @param onError Called if there is an error when compiling a shader.
  20203. */
  20204. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20205. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20206. /**
  20207. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20208. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20209. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20210. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20211. * The gaps between physical kernels are compensated for in the weighting of the samples
  20212. * @param idealKernel Ideal blur kernel.
  20213. * @return Nearest best kernel.
  20214. */
  20215. protected _nearestBestKernel(idealKernel: number): number;
  20216. /**
  20217. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20218. * @param x The point on the Gaussian distribution to sample.
  20219. * @return the value of the Gaussian function at x.
  20220. */
  20221. protected _gaussianWeight(x: number): number;
  20222. /**
  20223. * Generates a string that can be used as a floating point number in GLSL.
  20224. * @param x Value to print.
  20225. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20226. * @return GLSL float string.
  20227. */
  20228. protected _glslFloat(x: number, decimalFigures?: number): string;
  20229. }
  20230. }
  20231. declare module BABYLON {
  20232. /**
  20233. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20234. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20235. * You can then easily use it as a reflectionTexture on a flat surface.
  20236. * In case the surface is not a plane, please consider relying on reflection probes.
  20237. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20238. */
  20239. export class MirrorTexture extends RenderTargetTexture {
  20240. private scene;
  20241. /**
  20242. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20243. * 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.
  20244. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20245. */
  20246. mirrorPlane: Plane;
  20247. /**
  20248. * Define the blur ratio used to blur the reflection if needed.
  20249. */
  20250. set blurRatio(value: number);
  20251. get blurRatio(): number;
  20252. /**
  20253. * Define the adaptive blur kernel used to blur the reflection if needed.
  20254. * This will autocompute the closest best match for the `blurKernel`
  20255. */
  20256. set adaptiveBlurKernel(value: number);
  20257. /**
  20258. * Define the blur kernel used to blur the reflection if needed.
  20259. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20260. */
  20261. set blurKernel(value: number);
  20262. /**
  20263. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20264. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20265. */
  20266. set blurKernelX(value: number);
  20267. get blurKernelX(): number;
  20268. /**
  20269. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20270. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20271. */
  20272. set blurKernelY(value: number);
  20273. get blurKernelY(): number;
  20274. private _autoComputeBlurKernel;
  20275. protected _onRatioRescale(): void;
  20276. private _updateGammaSpace;
  20277. private _imageProcessingConfigChangeObserver;
  20278. private _transformMatrix;
  20279. private _mirrorMatrix;
  20280. private _savedViewMatrix;
  20281. private _blurX;
  20282. private _blurY;
  20283. private _adaptiveBlurKernel;
  20284. private _blurKernelX;
  20285. private _blurKernelY;
  20286. private _blurRatio;
  20287. /**
  20288. * Instantiates a Mirror Texture.
  20289. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20290. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20291. * You can then easily use it as a reflectionTexture on a flat surface.
  20292. * In case the surface is not a plane, please consider relying on reflection probes.
  20293. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20294. * @param name
  20295. * @param size
  20296. * @param scene
  20297. * @param generateMipMaps
  20298. * @param type
  20299. * @param samplingMode
  20300. * @param generateDepthBuffer
  20301. */
  20302. constructor(name: string, size: number | {
  20303. width: number;
  20304. height: number;
  20305. } | {
  20306. ratio: number;
  20307. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20308. private _preparePostProcesses;
  20309. /**
  20310. * Clone the mirror texture.
  20311. * @returns the cloned texture
  20312. */
  20313. clone(): MirrorTexture;
  20314. /**
  20315. * Serialize the texture to a JSON representation you could use in Parse later on
  20316. * @returns the serialized JSON representation
  20317. */
  20318. serialize(): any;
  20319. /**
  20320. * Dispose the texture and release its associated resources.
  20321. */
  20322. dispose(): void;
  20323. }
  20324. }
  20325. declare module BABYLON {
  20326. /**
  20327. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20328. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20329. */
  20330. export class Texture extends BaseTexture {
  20331. /**
  20332. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20333. */
  20334. static SerializeBuffers: boolean;
  20335. /** @hidden */
  20336. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20337. /** @hidden */
  20338. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20339. /** @hidden */
  20340. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20341. /** nearest is mag = nearest and min = nearest and mip = linear */
  20342. static readonly NEAREST_SAMPLINGMODE: number;
  20343. /** nearest is mag = nearest and min = nearest and mip = linear */
  20344. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20345. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20346. static readonly BILINEAR_SAMPLINGMODE: number;
  20347. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20348. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20349. /** Trilinear is mag = linear and min = linear and mip = linear */
  20350. static readonly TRILINEAR_SAMPLINGMODE: number;
  20351. /** Trilinear is mag = linear and min = linear and mip = linear */
  20352. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20353. /** mag = nearest and min = nearest and mip = nearest */
  20354. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20355. /** mag = nearest and min = linear and mip = nearest */
  20356. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20357. /** mag = nearest and min = linear and mip = linear */
  20358. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20359. /** mag = nearest and min = linear and mip = none */
  20360. static readonly NEAREST_LINEAR: number;
  20361. /** mag = nearest and min = nearest and mip = none */
  20362. static readonly NEAREST_NEAREST: number;
  20363. /** mag = linear and min = nearest and mip = nearest */
  20364. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20365. /** mag = linear and min = nearest and mip = linear */
  20366. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20367. /** mag = linear and min = linear and mip = none */
  20368. static readonly LINEAR_LINEAR: number;
  20369. /** mag = linear and min = nearest and mip = none */
  20370. static readonly LINEAR_NEAREST: number;
  20371. /** Explicit coordinates mode */
  20372. static readonly EXPLICIT_MODE: number;
  20373. /** Spherical coordinates mode */
  20374. static readonly SPHERICAL_MODE: number;
  20375. /** Planar coordinates mode */
  20376. static readonly PLANAR_MODE: number;
  20377. /** Cubic coordinates mode */
  20378. static readonly CUBIC_MODE: number;
  20379. /** Projection coordinates mode */
  20380. static readonly PROJECTION_MODE: number;
  20381. /** Inverse Cubic coordinates mode */
  20382. static readonly SKYBOX_MODE: number;
  20383. /** Inverse Cubic coordinates mode */
  20384. static readonly INVCUBIC_MODE: number;
  20385. /** Equirectangular coordinates mode */
  20386. static readonly EQUIRECTANGULAR_MODE: number;
  20387. /** Equirectangular Fixed coordinates mode */
  20388. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20389. /** Equirectangular Fixed Mirrored coordinates mode */
  20390. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20391. /** Texture is not repeating outside of 0..1 UVs */
  20392. static readonly CLAMP_ADDRESSMODE: number;
  20393. /** Texture is repeating outside of 0..1 UVs */
  20394. static readonly WRAP_ADDRESSMODE: number;
  20395. /** Texture is repeating and mirrored */
  20396. static readonly MIRROR_ADDRESSMODE: number;
  20397. /**
  20398. * 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
  20399. */
  20400. static UseSerializedUrlIfAny: boolean;
  20401. /**
  20402. * Define the url of the texture.
  20403. */
  20404. url: Nullable<string>;
  20405. /**
  20406. * Define an offset on the texture to offset the u coordinates of the UVs
  20407. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20408. */
  20409. uOffset: number;
  20410. /**
  20411. * Define an offset on the texture to offset the v coordinates of the UVs
  20412. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20413. */
  20414. vOffset: number;
  20415. /**
  20416. * Define an offset on the texture to scale the u coordinates of the UVs
  20417. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20418. */
  20419. uScale: number;
  20420. /**
  20421. * Define an offset on the texture to scale the v coordinates of the UVs
  20422. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20423. */
  20424. vScale: number;
  20425. /**
  20426. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20427. * @see http://doc.babylonjs.com/how_to/more_materials
  20428. */
  20429. uAng: number;
  20430. /**
  20431. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20432. * @see http://doc.babylonjs.com/how_to/more_materials
  20433. */
  20434. vAng: number;
  20435. /**
  20436. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20437. * @see http://doc.babylonjs.com/how_to/more_materials
  20438. */
  20439. wAng: number;
  20440. /**
  20441. * Defines the center of rotation (U)
  20442. */
  20443. uRotationCenter: number;
  20444. /**
  20445. * Defines the center of rotation (V)
  20446. */
  20447. vRotationCenter: number;
  20448. /**
  20449. * Defines the center of rotation (W)
  20450. */
  20451. wRotationCenter: number;
  20452. /**
  20453. * Are mip maps generated for this texture or not.
  20454. */
  20455. get noMipmap(): boolean;
  20456. /**
  20457. * List of inspectable custom properties (used by the Inspector)
  20458. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20459. */
  20460. inspectableCustomProperties: Nullable<IInspectable[]>;
  20461. private _noMipmap;
  20462. /** @hidden */
  20463. _invertY: boolean;
  20464. private _rowGenerationMatrix;
  20465. private _cachedTextureMatrix;
  20466. private _projectionModeMatrix;
  20467. private _t0;
  20468. private _t1;
  20469. private _t2;
  20470. private _cachedUOffset;
  20471. private _cachedVOffset;
  20472. private _cachedUScale;
  20473. private _cachedVScale;
  20474. private _cachedUAng;
  20475. private _cachedVAng;
  20476. private _cachedWAng;
  20477. private _cachedProjectionMatrixId;
  20478. private _cachedCoordinatesMode;
  20479. /** @hidden */
  20480. protected _initialSamplingMode: number;
  20481. /** @hidden */
  20482. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20483. private _deleteBuffer;
  20484. protected _format: Nullable<number>;
  20485. private _delayedOnLoad;
  20486. private _delayedOnError;
  20487. private _mimeType?;
  20488. /**
  20489. * Observable triggered once the texture has been loaded.
  20490. */
  20491. onLoadObservable: Observable<Texture>;
  20492. protected _isBlocking: boolean;
  20493. /**
  20494. * Is the texture preventing material to render while loading.
  20495. * If false, a default texture will be used instead of the loading one during the preparation step.
  20496. */
  20497. set isBlocking(value: boolean);
  20498. get isBlocking(): boolean;
  20499. /**
  20500. * Get the current sampling mode associated with the texture.
  20501. */
  20502. get samplingMode(): number;
  20503. /**
  20504. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20505. */
  20506. get invertY(): boolean;
  20507. /**
  20508. * Instantiates a new texture.
  20509. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20510. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20511. * @param url defines the url of the picture to load as a texture
  20512. * @param scene defines the scene or engine the texture will belong to
  20513. * @param noMipmap defines if the texture will require mip maps or not
  20514. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20515. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20516. * @param onLoad defines a callback triggered when the texture has been loaded
  20517. * @param onError defines a callback triggered when an error occurred during the loading session
  20518. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20519. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20520. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20521. * @param mimeType defines an optional mime type information
  20522. */
  20523. 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);
  20524. /**
  20525. * Update the url (and optional buffer) of this texture if url was null during construction.
  20526. * @param url the url of the texture
  20527. * @param buffer the buffer of the texture (defaults to null)
  20528. * @param onLoad callback called when the texture is loaded (defaults to null)
  20529. */
  20530. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20531. /**
  20532. * Finish the loading sequence of a texture flagged as delayed load.
  20533. * @hidden
  20534. */
  20535. delayLoad(): void;
  20536. private _prepareRowForTextureGeneration;
  20537. /**
  20538. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20539. * @returns the transform matrix of the texture.
  20540. */
  20541. getTextureMatrix(uBase?: number): Matrix;
  20542. /**
  20543. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20544. * @returns The reflection texture transform
  20545. */
  20546. getReflectionTextureMatrix(): Matrix;
  20547. /**
  20548. * Clones the texture.
  20549. * @returns the cloned texture
  20550. */
  20551. clone(): Texture;
  20552. /**
  20553. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20554. * @returns The JSON representation of the texture
  20555. */
  20556. serialize(): any;
  20557. /**
  20558. * Get the current class name of the texture useful for serialization or dynamic coding.
  20559. * @returns "Texture"
  20560. */
  20561. getClassName(): string;
  20562. /**
  20563. * Dispose the texture and release its associated resources.
  20564. */
  20565. dispose(): void;
  20566. /**
  20567. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20568. * @param parsedTexture Define the JSON representation of the texture
  20569. * @param scene Define the scene the parsed texture should be instantiated in
  20570. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20571. * @returns The parsed texture if successful
  20572. */
  20573. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20574. /**
  20575. * Creates a texture from its base 64 representation.
  20576. * @param data Define the base64 payload without the data: prefix
  20577. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20578. * @param scene Define the scene the texture should belong to
  20579. * @param noMipmap Forces the texture to not create mip map information if true
  20580. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20581. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20582. * @param onLoad define a callback triggered when the texture has been loaded
  20583. * @param onError define a callback triggered when an error occurred during the loading session
  20584. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20585. * @returns the created texture
  20586. */
  20587. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20588. /**
  20589. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20590. * @param data Define the base64 payload without the data: prefix
  20591. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20592. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20593. * @param scene Define the scene the texture should belong to
  20594. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20595. * @param noMipmap Forces the texture to not create mip map information if true
  20596. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20597. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20598. * @param onLoad define a callback triggered when the texture has been loaded
  20599. * @param onError define a callback triggered when an error occurred during the loading session
  20600. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20601. * @returns the created texture
  20602. */
  20603. 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;
  20604. }
  20605. }
  20606. declare module BABYLON {
  20607. /**
  20608. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20609. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20610. */
  20611. export class PostProcessManager {
  20612. private _scene;
  20613. private _indexBuffer;
  20614. private _vertexBuffers;
  20615. /**
  20616. * Creates a new instance PostProcess
  20617. * @param scene The scene that the post process is associated with.
  20618. */
  20619. constructor(scene: Scene);
  20620. private _prepareBuffers;
  20621. private _buildIndexBuffer;
  20622. /**
  20623. * Rebuilds the vertex buffers of the manager.
  20624. * @hidden
  20625. */
  20626. _rebuild(): void;
  20627. /**
  20628. * Prepares a frame to be run through a post process.
  20629. * @param sourceTexture The input texture to the post procesess. (default: null)
  20630. * @param postProcesses An array of post processes to be run. (default: null)
  20631. * @returns True if the post processes were able to be run.
  20632. * @hidden
  20633. */
  20634. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20635. /**
  20636. * Manually render a set of post processes to a texture.
  20637. * @param postProcesses An array of post processes to be run.
  20638. * @param targetTexture The target texture to render to.
  20639. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20640. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20641. * @param lodLevel defines which lod of the texture to render to
  20642. */
  20643. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20644. /**
  20645. * Finalize the result of the output of the postprocesses.
  20646. * @param doNotPresent If true the result will not be displayed to the screen.
  20647. * @param targetTexture The target texture to render to.
  20648. * @param faceIndex The index of the face to bind the target texture to.
  20649. * @param postProcesses The array of post processes to render.
  20650. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20651. * @hidden
  20652. */
  20653. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20654. /**
  20655. * Disposes of the post process manager.
  20656. */
  20657. dispose(): void;
  20658. }
  20659. }
  20660. declare module BABYLON {
  20661. /**
  20662. * This Helps creating a texture that will be created from a camera in your scene.
  20663. * It is basically a dynamic texture that could be used to create special effects for instance.
  20664. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20665. */
  20666. export class RenderTargetTexture extends Texture {
  20667. isCube: boolean;
  20668. /**
  20669. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20670. */
  20671. static readonly REFRESHRATE_RENDER_ONCE: number;
  20672. /**
  20673. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20674. */
  20675. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20676. /**
  20677. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20678. * the central point of your effect and can save a lot of performances.
  20679. */
  20680. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20681. /**
  20682. * Use this predicate to dynamically define the list of mesh you want to render.
  20683. * If set, the renderList property will be overwritten.
  20684. */
  20685. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20686. private _renderList;
  20687. /**
  20688. * Use this list to define the list of mesh you want to render.
  20689. */
  20690. get renderList(): Nullable<Array<AbstractMesh>>;
  20691. set renderList(value: Nullable<Array<AbstractMesh>>);
  20692. /**
  20693. * Use this function to overload the renderList array at rendering time.
  20694. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20695. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20696. * the cube (if the RTT is a cube, else layerOrFace=0).
  20697. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20698. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20699. * hold dummy elements!
  20700. */
  20701. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20702. private _hookArray;
  20703. /**
  20704. * Define if particles should be rendered in your texture.
  20705. */
  20706. renderParticles: boolean;
  20707. /**
  20708. * Define if sprites should be rendered in your texture.
  20709. */
  20710. renderSprites: boolean;
  20711. /**
  20712. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20713. */
  20714. coordinatesMode: number;
  20715. /**
  20716. * Define the camera used to render the texture.
  20717. */
  20718. activeCamera: Nullable<Camera>;
  20719. /**
  20720. * Override the mesh isReady function with your own one.
  20721. */
  20722. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20723. /**
  20724. * Override the render function of the texture with your own one.
  20725. */
  20726. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20727. /**
  20728. * Define if camera post processes should be use while rendering the texture.
  20729. */
  20730. useCameraPostProcesses: boolean;
  20731. /**
  20732. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20733. */
  20734. ignoreCameraViewport: boolean;
  20735. private _postProcessManager;
  20736. private _postProcesses;
  20737. private _resizeObserver;
  20738. /**
  20739. * An event triggered when the texture is unbind.
  20740. */
  20741. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20742. /**
  20743. * An event triggered when the texture is unbind.
  20744. */
  20745. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20746. private _onAfterUnbindObserver;
  20747. /**
  20748. * Set a after unbind callback in the texture.
  20749. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20750. */
  20751. set onAfterUnbind(callback: () => void);
  20752. /**
  20753. * An event triggered before rendering the texture
  20754. */
  20755. onBeforeRenderObservable: Observable<number>;
  20756. private _onBeforeRenderObserver;
  20757. /**
  20758. * Set a before render callback in the texture.
  20759. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20760. */
  20761. set onBeforeRender(callback: (faceIndex: number) => void);
  20762. /**
  20763. * An event triggered after rendering the texture
  20764. */
  20765. onAfterRenderObservable: Observable<number>;
  20766. private _onAfterRenderObserver;
  20767. /**
  20768. * Set a after render callback in the texture.
  20769. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20770. */
  20771. set onAfterRender(callback: (faceIndex: number) => void);
  20772. /**
  20773. * An event triggered after the texture clear
  20774. */
  20775. onClearObservable: Observable<Engine>;
  20776. private _onClearObserver;
  20777. /**
  20778. * Set a clear callback in the texture.
  20779. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20780. */
  20781. set onClear(callback: (Engine: Engine) => void);
  20782. /**
  20783. * An event triggered when the texture is resized.
  20784. */
  20785. onResizeObservable: Observable<RenderTargetTexture>;
  20786. /**
  20787. * Define the clear color of the Render Target if it should be different from the scene.
  20788. */
  20789. clearColor: Color4;
  20790. protected _size: number | {
  20791. width: number;
  20792. height: number;
  20793. layers?: number;
  20794. };
  20795. protected _initialSizeParameter: number | {
  20796. width: number;
  20797. height: number;
  20798. } | {
  20799. ratio: number;
  20800. };
  20801. protected _sizeRatio: Nullable<number>;
  20802. /** @hidden */
  20803. _generateMipMaps: boolean;
  20804. protected _renderingManager: RenderingManager;
  20805. /** @hidden */
  20806. _waitingRenderList: string[];
  20807. protected _doNotChangeAspectRatio: boolean;
  20808. protected _currentRefreshId: number;
  20809. protected _refreshRate: number;
  20810. protected _textureMatrix: Matrix;
  20811. protected _samples: number;
  20812. protected _renderTargetOptions: RenderTargetCreationOptions;
  20813. /**
  20814. * Gets render target creation options that were used.
  20815. */
  20816. get renderTargetOptions(): RenderTargetCreationOptions;
  20817. protected _engine: Engine;
  20818. protected _onRatioRescale(): void;
  20819. /**
  20820. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20821. * It must define where the camera used to render the texture is set
  20822. */
  20823. boundingBoxPosition: Vector3;
  20824. private _boundingBoxSize;
  20825. /**
  20826. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20827. * When defined, the cubemap will switch to local mode
  20828. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20829. * @example https://www.babylonjs-playground.com/#RNASML
  20830. */
  20831. set boundingBoxSize(value: Vector3);
  20832. get boundingBoxSize(): Vector3;
  20833. /**
  20834. * In case the RTT has been created with a depth texture, get the associated
  20835. * depth texture.
  20836. * Otherwise, return null.
  20837. */
  20838. get depthStencilTexture(): Nullable<InternalTexture>;
  20839. /**
  20840. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20841. * or used a shadow, depth texture...
  20842. * @param name The friendly name of the texture
  20843. * @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)
  20844. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20845. * @param generateMipMaps True if mip maps need to be generated after render.
  20846. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20847. * @param type The type of the buffer in the RTT (int, half float, float...)
  20848. * @param isCube True if a cube texture needs to be created
  20849. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20850. * @param generateDepthBuffer True to generate a depth buffer
  20851. * @param generateStencilBuffer True to generate a stencil buffer
  20852. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20853. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20854. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20855. */
  20856. constructor(name: string, size: number | {
  20857. width: number;
  20858. height: number;
  20859. layers?: number;
  20860. } | {
  20861. ratio: number;
  20862. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20863. /**
  20864. * Creates a depth stencil texture.
  20865. * This is only available in WebGL 2 or with the depth texture extension available.
  20866. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20867. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20868. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20869. */
  20870. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20871. private _processSizeParameter;
  20872. /**
  20873. * Define the number of samples to use in case of MSAA.
  20874. * It defaults to one meaning no MSAA has been enabled.
  20875. */
  20876. get samples(): number;
  20877. set samples(value: number);
  20878. /**
  20879. * Resets the refresh counter of the texture and start bak from scratch.
  20880. * Could be useful to regenerate the texture if it is setup to render only once.
  20881. */
  20882. resetRefreshCounter(): void;
  20883. /**
  20884. * Define the refresh rate of the texture or the rendering frequency.
  20885. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20886. */
  20887. get refreshRate(): number;
  20888. set refreshRate(value: number);
  20889. /**
  20890. * Adds a post process to the render target rendering passes.
  20891. * @param postProcess define the post process to add
  20892. */
  20893. addPostProcess(postProcess: PostProcess): void;
  20894. /**
  20895. * Clear all the post processes attached to the render target
  20896. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20897. */
  20898. clearPostProcesses(dispose?: boolean): void;
  20899. /**
  20900. * Remove one of the post process from the list of attached post processes to the texture
  20901. * @param postProcess define the post process to remove from the list
  20902. */
  20903. removePostProcess(postProcess: PostProcess): void;
  20904. /** @hidden */
  20905. _shouldRender(): boolean;
  20906. /**
  20907. * Gets the actual render size of the texture.
  20908. * @returns the width of the render size
  20909. */
  20910. getRenderSize(): number;
  20911. /**
  20912. * Gets the actual render width of the texture.
  20913. * @returns the width of the render size
  20914. */
  20915. getRenderWidth(): number;
  20916. /**
  20917. * Gets the actual render height of the texture.
  20918. * @returns the height of the render size
  20919. */
  20920. getRenderHeight(): number;
  20921. /**
  20922. * Gets the actual number of layers of the texture.
  20923. * @returns the number of layers
  20924. */
  20925. getRenderLayers(): number;
  20926. /**
  20927. * Get if the texture can be rescaled or not.
  20928. */
  20929. get canRescale(): boolean;
  20930. /**
  20931. * Resize the texture using a ratio.
  20932. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20933. */
  20934. scale(ratio: number): void;
  20935. /**
  20936. * Get the texture reflection matrix used to rotate/transform the reflection.
  20937. * @returns the reflection matrix
  20938. */
  20939. getReflectionTextureMatrix(): Matrix;
  20940. /**
  20941. * Resize the texture to a new desired size.
  20942. * Be carrefull as it will recreate all the data in the new texture.
  20943. * @param size Define the new size. It can be:
  20944. * - a number for squared texture,
  20945. * - an object containing { width: number, height: number }
  20946. * - or an object containing a ratio { ratio: number }
  20947. */
  20948. resize(size: number | {
  20949. width: number;
  20950. height: number;
  20951. } | {
  20952. ratio: number;
  20953. }): void;
  20954. private _defaultRenderListPrepared;
  20955. /**
  20956. * Renders all the objects from the render list into the texture.
  20957. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20958. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20959. */
  20960. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20961. private _bestReflectionRenderTargetDimension;
  20962. private _prepareRenderingManager;
  20963. /**
  20964. * @hidden
  20965. * @param faceIndex face index to bind to if this is a cubetexture
  20966. * @param layer defines the index of the texture to bind in the array
  20967. */
  20968. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20969. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20970. private renderToTarget;
  20971. /**
  20972. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20973. * This allowed control for front to back rendering or reversly depending of the special needs.
  20974. *
  20975. * @param renderingGroupId The rendering group id corresponding to its index
  20976. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20977. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20978. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20979. */
  20980. 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;
  20981. /**
  20982. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20983. *
  20984. * @param renderingGroupId The rendering group id corresponding to its index
  20985. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20986. */
  20987. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20988. /**
  20989. * Clones the texture.
  20990. * @returns the cloned texture
  20991. */
  20992. clone(): RenderTargetTexture;
  20993. /**
  20994. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20995. * @returns The JSON representation of the texture
  20996. */
  20997. serialize(): any;
  20998. /**
  20999. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21000. */
  21001. disposeFramebufferObjects(): void;
  21002. /**
  21003. * Dispose the texture and release its associated resources.
  21004. */
  21005. dispose(): void;
  21006. /** @hidden */
  21007. _rebuild(): void;
  21008. /**
  21009. * Clear the info related to rendering groups preventing retention point in material dispose.
  21010. */
  21011. freeRenderingGroups(): void;
  21012. /**
  21013. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21014. * @returns the view count
  21015. */
  21016. getViewCount(): number;
  21017. }
  21018. }
  21019. declare module BABYLON {
  21020. /**
  21021. * Class used to manipulate GUIDs
  21022. */
  21023. export class GUID {
  21024. /**
  21025. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21026. * Be aware Math.random() could cause collisions, but:
  21027. * "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"
  21028. * @returns a pseudo random id
  21029. */
  21030. static RandomId(): string;
  21031. }
  21032. }
  21033. declare module BABYLON {
  21034. /**
  21035. * Options to be used when creating a shadow depth material
  21036. */
  21037. export interface IIOptionShadowDepthMaterial {
  21038. /** Variables in the vertex shader code that need to have their names remapped.
  21039. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21040. * "var_name" should be either: worldPos or vNormalW
  21041. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21042. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21043. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21044. */
  21045. remappedVariables?: string[];
  21046. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21047. standalone?: boolean;
  21048. }
  21049. /**
  21050. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21051. */
  21052. export class ShadowDepthWrapper {
  21053. private _scene;
  21054. private _options?;
  21055. private _baseMaterial;
  21056. private _onEffectCreatedObserver;
  21057. private _subMeshToEffect;
  21058. private _subMeshToDepthEffect;
  21059. private _meshes;
  21060. /** @hidden */
  21061. _matriceNames: any;
  21062. /** Gets the standalone status of the wrapper */
  21063. get standalone(): boolean;
  21064. /** Gets the base material the wrapper is built upon */
  21065. get baseMaterial(): Material;
  21066. /**
  21067. * Instantiate a new shadow depth wrapper.
  21068. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21069. * generate the shadow depth map. For more information, please refer to the documentation:
  21070. * https://doc.babylonjs.com/babylon101/shadows
  21071. * @param baseMaterial Material to wrap
  21072. * @param scene Define the scene the material belongs to
  21073. * @param options Options used to create the wrapper
  21074. */
  21075. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21076. /**
  21077. * Gets the effect to use to generate the depth map
  21078. * @param subMesh subMesh to get the effect for
  21079. * @param shadowGenerator shadow generator to get the effect for
  21080. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21081. */
  21082. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21083. /**
  21084. * Specifies that the submesh is ready to be used for depth rendering
  21085. * @param subMesh submesh to check
  21086. * @param defines the list of defines to take into account when checking the effect
  21087. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21088. * @param useInstances specifies that instances should be used
  21089. * @returns a boolean indicating that the submesh is ready or not
  21090. */
  21091. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21092. /**
  21093. * Disposes the resources
  21094. */
  21095. dispose(): void;
  21096. private _makeEffect;
  21097. }
  21098. }
  21099. declare module BABYLON {
  21100. /**
  21101. * Options for compiling materials.
  21102. */
  21103. export interface IMaterialCompilationOptions {
  21104. /**
  21105. * Defines whether clip planes are enabled.
  21106. */
  21107. clipPlane: boolean;
  21108. /**
  21109. * Defines whether instances are enabled.
  21110. */
  21111. useInstances: boolean;
  21112. }
  21113. /**
  21114. * Base class for the main features of a material in Babylon.js
  21115. */
  21116. export class Material implements IAnimatable {
  21117. /**
  21118. * Returns the triangle fill mode
  21119. */
  21120. static readonly TriangleFillMode: number;
  21121. /**
  21122. * Returns the wireframe mode
  21123. */
  21124. static readonly WireFrameFillMode: number;
  21125. /**
  21126. * Returns the point fill mode
  21127. */
  21128. static readonly PointFillMode: number;
  21129. /**
  21130. * Returns the point list draw mode
  21131. */
  21132. static readonly PointListDrawMode: number;
  21133. /**
  21134. * Returns the line list draw mode
  21135. */
  21136. static readonly LineListDrawMode: number;
  21137. /**
  21138. * Returns the line loop draw mode
  21139. */
  21140. static readonly LineLoopDrawMode: number;
  21141. /**
  21142. * Returns the line strip draw mode
  21143. */
  21144. static readonly LineStripDrawMode: number;
  21145. /**
  21146. * Returns the triangle strip draw mode
  21147. */
  21148. static readonly TriangleStripDrawMode: number;
  21149. /**
  21150. * Returns the triangle fan draw mode
  21151. */
  21152. static readonly TriangleFanDrawMode: number;
  21153. /**
  21154. * Stores the clock-wise side orientation
  21155. */
  21156. static readonly ClockWiseSideOrientation: number;
  21157. /**
  21158. * Stores the counter clock-wise side orientation
  21159. */
  21160. static readonly CounterClockWiseSideOrientation: number;
  21161. /**
  21162. * The dirty texture flag value
  21163. */
  21164. static readonly TextureDirtyFlag: number;
  21165. /**
  21166. * The dirty light flag value
  21167. */
  21168. static readonly LightDirtyFlag: number;
  21169. /**
  21170. * The dirty fresnel flag value
  21171. */
  21172. static readonly FresnelDirtyFlag: number;
  21173. /**
  21174. * The dirty attribute flag value
  21175. */
  21176. static readonly AttributesDirtyFlag: number;
  21177. /**
  21178. * The dirty misc flag value
  21179. */
  21180. static readonly MiscDirtyFlag: number;
  21181. /**
  21182. * The all dirty flag value
  21183. */
  21184. static readonly AllDirtyFlag: number;
  21185. /**
  21186. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21187. */
  21188. static readonly MATERIAL_OPAQUE: number;
  21189. /**
  21190. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21191. */
  21192. static readonly MATERIAL_ALPHATEST: number;
  21193. /**
  21194. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21195. */
  21196. static readonly MATERIAL_ALPHABLEND: number;
  21197. /**
  21198. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21199. * They are also discarded below the alpha cutoff threshold to improve performances.
  21200. */
  21201. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21202. /**
  21203. * Custom callback helping to override the default shader used in the material.
  21204. */
  21205. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21206. /**
  21207. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21208. */
  21209. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21210. /**
  21211. * The ID of the material
  21212. */
  21213. id: string;
  21214. /**
  21215. * Gets or sets the unique id of the material
  21216. */
  21217. uniqueId: number;
  21218. /**
  21219. * The name of the material
  21220. */
  21221. name: string;
  21222. /**
  21223. * Gets or sets user defined metadata
  21224. */
  21225. metadata: any;
  21226. /**
  21227. * For internal use only. Please do not use.
  21228. */
  21229. reservedDataStore: any;
  21230. /**
  21231. * Specifies if the ready state should be checked on each call
  21232. */
  21233. checkReadyOnEveryCall: boolean;
  21234. /**
  21235. * Specifies if the ready state should be checked once
  21236. */
  21237. checkReadyOnlyOnce: boolean;
  21238. /**
  21239. * The state of the material
  21240. */
  21241. state: string;
  21242. /**
  21243. * The alpha value of the material
  21244. */
  21245. protected _alpha: number;
  21246. /**
  21247. * List of inspectable custom properties (used by the Inspector)
  21248. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21249. */
  21250. inspectableCustomProperties: IInspectable[];
  21251. /**
  21252. * Sets the alpha value of the material
  21253. */
  21254. set alpha(value: number);
  21255. /**
  21256. * Gets the alpha value of the material
  21257. */
  21258. get alpha(): number;
  21259. /**
  21260. * Specifies if back face culling is enabled
  21261. */
  21262. protected _backFaceCulling: boolean;
  21263. /**
  21264. * Sets the back-face culling state
  21265. */
  21266. set backFaceCulling(value: boolean);
  21267. /**
  21268. * Gets the back-face culling state
  21269. */
  21270. get backFaceCulling(): boolean;
  21271. /**
  21272. * Stores the value for side orientation
  21273. */
  21274. sideOrientation: number;
  21275. /**
  21276. * Callback triggered when the material is compiled
  21277. */
  21278. onCompiled: Nullable<(effect: Effect) => void>;
  21279. /**
  21280. * Callback triggered when an error occurs
  21281. */
  21282. onError: Nullable<(effect: Effect, errors: string) => void>;
  21283. /**
  21284. * Callback triggered to get the render target textures
  21285. */
  21286. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21287. /**
  21288. * Gets a boolean indicating that current material needs to register RTT
  21289. */
  21290. get hasRenderTargetTextures(): boolean;
  21291. /**
  21292. * Specifies if the material should be serialized
  21293. */
  21294. doNotSerialize: boolean;
  21295. /**
  21296. * @hidden
  21297. */
  21298. _storeEffectOnSubMeshes: boolean;
  21299. /**
  21300. * Stores the animations for the material
  21301. */
  21302. animations: Nullable<Array<Animation>>;
  21303. /**
  21304. * An event triggered when the material is disposed
  21305. */
  21306. onDisposeObservable: Observable<Material>;
  21307. /**
  21308. * An observer which watches for dispose events
  21309. */
  21310. private _onDisposeObserver;
  21311. private _onUnBindObservable;
  21312. /**
  21313. * Called during a dispose event
  21314. */
  21315. set onDispose(callback: () => void);
  21316. private _onBindObservable;
  21317. /**
  21318. * An event triggered when the material is bound
  21319. */
  21320. get onBindObservable(): Observable<AbstractMesh>;
  21321. /**
  21322. * An observer which watches for bind events
  21323. */
  21324. private _onBindObserver;
  21325. /**
  21326. * Called during a bind event
  21327. */
  21328. set onBind(callback: (Mesh: AbstractMesh) => void);
  21329. /**
  21330. * An event triggered when the material is unbound
  21331. */
  21332. get onUnBindObservable(): Observable<Material>;
  21333. protected _onEffectCreatedObservable: Nullable<Observable<{
  21334. effect: Effect;
  21335. subMesh: Nullable<SubMesh>;
  21336. }>>;
  21337. /**
  21338. * An event triggered when the effect is (re)created
  21339. */
  21340. get onEffectCreatedObservable(): Observable<{
  21341. effect: Effect;
  21342. subMesh: Nullable<SubMesh>;
  21343. }>;
  21344. /**
  21345. * Stores the value of the alpha mode
  21346. */
  21347. private _alphaMode;
  21348. /**
  21349. * Sets the value of the alpha mode.
  21350. *
  21351. * | Value | Type | Description |
  21352. * | --- | --- | --- |
  21353. * | 0 | ALPHA_DISABLE | |
  21354. * | 1 | ALPHA_ADD | |
  21355. * | 2 | ALPHA_COMBINE | |
  21356. * | 3 | ALPHA_SUBTRACT | |
  21357. * | 4 | ALPHA_MULTIPLY | |
  21358. * | 5 | ALPHA_MAXIMIZED | |
  21359. * | 6 | ALPHA_ONEONE | |
  21360. * | 7 | ALPHA_PREMULTIPLIED | |
  21361. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21362. * | 9 | ALPHA_INTERPOLATE | |
  21363. * | 10 | ALPHA_SCREENMODE | |
  21364. *
  21365. */
  21366. set alphaMode(value: number);
  21367. /**
  21368. * Gets the value of the alpha mode
  21369. */
  21370. get alphaMode(): number;
  21371. /**
  21372. * Stores the state of the need depth pre-pass value
  21373. */
  21374. private _needDepthPrePass;
  21375. /**
  21376. * Sets the need depth pre-pass value
  21377. */
  21378. set needDepthPrePass(value: boolean);
  21379. /**
  21380. * Gets the depth pre-pass value
  21381. */
  21382. get needDepthPrePass(): boolean;
  21383. /**
  21384. * Specifies if depth writing should be disabled
  21385. */
  21386. disableDepthWrite: boolean;
  21387. /**
  21388. * Specifies if color writing should be disabled
  21389. */
  21390. disableColorWrite: boolean;
  21391. /**
  21392. * Specifies if depth writing should be forced
  21393. */
  21394. forceDepthWrite: boolean;
  21395. /**
  21396. * Specifies the depth function that should be used. 0 means the default engine function
  21397. */
  21398. depthFunction: number;
  21399. /**
  21400. * Specifies if there should be a separate pass for culling
  21401. */
  21402. separateCullingPass: boolean;
  21403. /**
  21404. * Stores the state specifing if fog should be enabled
  21405. */
  21406. private _fogEnabled;
  21407. /**
  21408. * Sets the state for enabling fog
  21409. */
  21410. set fogEnabled(value: boolean);
  21411. /**
  21412. * Gets the value of the fog enabled state
  21413. */
  21414. get fogEnabled(): boolean;
  21415. /**
  21416. * Stores the size of points
  21417. */
  21418. pointSize: number;
  21419. /**
  21420. * Stores the z offset value
  21421. */
  21422. zOffset: number;
  21423. get wireframe(): boolean;
  21424. /**
  21425. * Sets the state of wireframe mode
  21426. */
  21427. set wireframe(value: boolean);
  21428. /**
  21429. * Gets the value specifying if point clouds are enabled
  21430. */
  21431. get pointsCloud(): boolean;
  21432. /**
  21433. * Sets the state of point cloud mode
  21434. */
  21435. set pointsCloud(value: boolean);
  21436. /**
  21437. * Gets the material fill mode
  21438. */
  21439. get fillMode(): number;
  21440. /**
  21441. * Sets the material fill mode
  21442. */
  21443. set fillMode(value: number);
  21444. /**
  21445. * @hidden
  21446. * Stores the effects for the material
  21447. */
  21448. _effect: Nullable<Effect>;
  21449. /**
  21450. * Specifies if uniform buffers should be used
  21451. */
  21452. private _useUBO;
  21453. /**
  21454. * Stores a reference to the scene
  21455. */
  21456. private _scene;
  21457. /**
  21458. * Stores the fill mode state
  21459. */
  21460. private _fillMode;
  21461. /**
  21462. * Specifies if the depth write state should be cached
  21463. */
  21464. private _cachedDepthWriteState;
  21465. /**
  21466. * Specifies if the color write state should be cached
  21467. */
  21468. private _cachedColorWriteState;
  21469. /**
  21470. * Specifies if the depth function state should be cached
  21471. */
  21472. private _cachedDepthFunctionState;
  21473. /**
  21474. * Stores the uniform buffer
  21475. */
  21476. protected _uniformBuffer: UniformBuffer;
  21477. /** @hidden */
  21478. _indexInSceneMaterialArray: number;
  21479. /** @hidden */
  21480. meshMap: Nullable<{
  21481. [id: string]: AbstractMesh | undefined;
  21482. }>;
  21483. /**
  21484. * Creates a material instance
  21485. * @param name defines the name of the material
  21486. * @param scene defines the scene to reference
  21487. * @param doNotAdd specifies if the material should be added to the scene
  21488. */
  21489. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21490. /**
  21491. * Returns a string representation of the current material
  21492. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21493. * @returns a string with material information
  21494. */
  21495. toString(fullDetails?: boolean): string;
  21496. /**
  21497. * Gets the class name of the material
  21498. * @returns a string with the class name of the material
  21499. */
  21500. getClassName(): string;
  21501. /**
  21502. * Specifies if updates for the material been locked
  21503. */
  21504. get isFrozen(): boolean;
  21505. /**
  21506. * Locks updates for the material
  21507. */
  21508. freeze(): void;
  21509. /**
  21510. * Unlocks updates for the material
  21511. */
  21512. unfreeze(): void;
  21513. /**
  21514. * Specifies if the material is ready to be used
  21515. * @param mesh defines the mesh to check
  21516. * @param useInstances specifies if instances should be used
  21517. * @returns a boolean indicating if the material is ready to be used
  21518. */
  21519. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21520. /**
  21521. * Specifies that the submesh is ready to be used
  21522. * @param mesh defines the mesh to check
  21523. * @param subMesh defines which submesh to check
  21524. * @param useInstances specifies that instances should be used
  21525. * @returns a boolean indicating that the submesh is ready or not
  21526. */
  21527. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21528. /**
  21529. * Returns the material effect
  21530. * @returns the effect associated with the material
  21531. */
  21532. getEffect(): Nullable<Effect>;
  21533. /**
  21534. * Returns the current scene
  21535. * @returns a Scene
  21536. */
  21537. getScene(): Scene;
  21538. /**
  21539. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21540. */
  21541. protected _forceAlphaTest: boolean;
  21542. /**
  21543. * The transparency mode of the material.
  21544. */
  21545. protected _transparencyMode: Nullable<number>;
  21546. /**
  21547. * Gets the current transparency mode.
  21548. */
  21549. get transparencyMode(): Nullable<number>;
  21550. /**
  21551. * Sets the transparency mode of the material.
  21552. *
  21553. * | Value | Type | Description |
  21554. * | ----- | ----------------------------------- | ----------- |
  21555. * | 0 | OPAQUE | |
  21556. * | 1 | ALPHATEST | |
  21557. * | 2 | ALPHABLEND | |
  21558. * | 3 | ALPHATESTANDBLEND | |
  21559. *
  21560. */
  21561. set transparencyMode(value: Nullable<number>);
  21562. /**
  21563. * Returns true if alpha blending should be disabled.
  21564. */
  21565. protected get _disableAlphaBlending(): boolean;
  21566. /**
  21567. * Specifies whether or not this material should be rendered in alpha blend mode.
  21568. * @returns a boolean specifying if alpha blending is needed
  21569. */
  21570. needAlphaBlending(): boolean;
  21571. /**
  21572. * Specifies if the mesh will require alpha blending
  21573. * @param mesh defines the mesh to check
  21574. * @returns a boolean specifying if alpha blending is needed for the mesh
  21575. */
  21576. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21577. /**
  21578. * Specifies whether or not this material should be rendered in alpha test mode.
  21579. * @returns a boolean specifying if an alpha test is needed.
  21580. */
  21581. needAlphaTesting(): boolean;
  21582. /**
  21583. * Specifies if material alpha testing should be turned on for the mesh
  21584. * @param mesh defines the mesh to check
  21585. */
  21586. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21587. /**
  21588. * Gets the texture used for the alpha test
  21589. * @returns the texture to use for alpha testing
  21590. */
  21591. getAlphaTestTexture(): Nullable<BaseTexture>;
  21592. /**
  21593. * Marks the material to indicate that it needs to be re-calculated
  21594. */
  21595. markDirty(): void;
  21596. /** @hidden */
  21597. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21598. /**
  21599. * Binds the material to the mesh
  21600. * @param world defines the world transformation matrix
  21601. * @param mesh defines the mesh to bind the material to
  21602. */
  21603. bind(world: Matrix, mesh?: Mesh): void;
  21604. /**
  21605. * Binds the submesh to the material
  21606. * @param world defines the world transformation matrix
  21607. * @param mesh defines the mesh containing the submesh
  21608. * @param subMesh defines the submesh to bind the material to
  21609. */
  21610. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21611. /**
  21612. * Binds the world matrix to the material
  21613. * @param world defines the world transformation matrix
  21614. */
  21615. bindOnlyWorldMatrix(world: Matrix): void;
  21616. /**
  21617. * Binds the scene's uniform buffer to the effect.
  21618. * @param effect defines the effect to bind to the scene uniform buffer
  21619. * @param sceneUbo defines the uniform buffer storing scene data
  21620. */
  21621. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21622. /**
  21623. * Binds the view matrix to the effect
  21624. * @param effect defines the effect to bind the view matrix to
  21625. */
  21626. bindView(effect: Effect): void;
  21627. /**
  21628. * Binds the view projection matrix to the effect
  21629. * @param effect defines the effect to bind the view projection matrix to
  21630. */
  21631. bindViewProjection(effect: Effect): void;
  21632. /**
  21633. * Processes to execute after binding the material to a mesh
  21634. * @param mesh defines the rendered mesh
  21635. */
  21636. protected _afterBind(mesh?: Mesh): void;
  21637. /**
  21638. * Unbinds the material from the mesh
  21639. */
  21640. unbind(): void;
  21641. /**
  21642. * Gets the active textures from the material
  21643. * @returns an array of textures
  21644. */
  21645. getActiveTextures(): BaseTexture[];
  21646. /**
  21647. * Specifies if the material uses a texture
  21648. * @param texture defines the texture to check against the material
  21649. * @returns a boolean specifying if the material uses the texture
  21650. */
  21651. hasTexture(texture: BaseTexture): boolean;
  21652. /**
  21653. * Makes a duplicate of the material, and gives it a new name
  21654. * @param name defines the new name for the duplicated material
  21655. * @returns the cloned material
  21656. */
  21657. clone(name: string): Nullable<Material>;
  21658. /**
  21659. * Gets the meshes bound to the material
  21660. * @returns an array of meshes bound to the material
  21661. */
  21662. getBindedMeshes(): AbstractMesh[];
  21663. /**
  21664. * Force shader compilation
  21665. * @param mesh defines the mesh associated with this material
  21666. * @param onCompiled defines a function to execute once the material is compiled
  21667. * @param options defines the options to configure the compilation
  21668. * @param onError defines a function to execute if the material fails compiling
  21669. */
  21670. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21671. /**
  21672. * Force shader compilation
  21673. * @param mesh defines the mesh that will use this material
  21674. * @param options defines additional options for compiling the shaders
  21675. * @returns a promise that resolves when the compilation completes
  21676. */
  21677. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21678. private static readonly _AllDirtyCallBack;
  21679. private static readonly _ImageProcessingDirtyCallBack;
  21680. private static readonly _TextureDirtyCallBack;
  21681. private static readonly _FresnelDirtyCallBack;
  21682. private static readonly _MiscDirtyCallBack;
  21683. private static readonly _LightsDirtyCallBack;
  21684. private static readonly _AttributeDirtyCallBack;
  21685. private static _FresnelAndMiscDirtyCallBack;
  21686. private static _TextureAndMiscDirtyCallBack;
  21687. private static readonly _DirtyCallbackArray;
  21688. private static readonly _RunDirtyCallBacks;
  21689. /**
  21690. * Marks a define in the material to indicate that it needs to be re-computed
  21691. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21692. */
  21693. markAsDirty(flag: number): void;
  21694. /**
  21695. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21696. * @param func defines a function which checks material defines against the submeshes
  21697. */
  21698. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21699. /**
  21700. * Indicates that we need to re-calculated for all submeshes
  21701. */
  21702. protected _markAllSubMeshesAsAllDirty(): void;
  21703. /**
  21704. * Indicates that image processing needs to be re-calculated for all submeshes
  21705. */
  21706. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21707. /**
  21708. * Indicates that textures need to be re-calculated for all submeshes
  21709. */
  21710. protected _markAllSubMeshesAsTexturesDirty(): void;
  21711. /**
  21712. * Indicates that fresnel needs to be re-calculated for all submeshes
  21713. */
  21714. protected _markAllSubMeshesAsFresnelDirty(): void;
  21715. /**
  21716. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21717. */
  21718. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21719. /**
  21720. * Indicates that lights need to be re-calculated for all submeshes
  21721. */
  21722. protected _markAllSubMeshesAsLightsDirty(): void;
  21723. /**
  21724. * Indicates that attributes need to be re-calculated for all submeshes
  21725. */
  21726. protected _markAllSubMeshesAsAttributesDirty(): void;
  21727. /**
  21728. * Indicates that misc needs to be re-calculated for all submeshes
  21729. */
  21730. protected _markAllSubMeshesAsMiscDirty(): void;
  21731. /**
  21732. * Indicates that textures and misc need to be re-calculated for all submeshes
  21733. */
  21734. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21735. /**
  21736. * Disposes the material
  21737. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21738. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21739. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21740. */
  21741. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21742. /** @hidden */
  21743. private releaseVertexArrayObject;
  21744. /**
  21745. * Serializes this material
  21746. * @returns the serialized material object
  21747. */
  21748. serialize(): any;
  21749. /**
  21750. * Creates a material from parsed material data
  21751. * @param parsedMaterial defines parsed material data
  21752. * @param scene defines the hosting scene
  21753. * @param rootUrl defines the root URL to use to load textures
  21754. * @returns a new material
  21755. */
  21756. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21757. }
  21758. }
  21759. declare module BABYLON {
  21760. /**
  21761. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21762. * separate meshes. This can be use to improve performances.
  21763. * @see http://doc.babylonjs.com/how_to/multi_materials
  21764. */
  21765. export class MultiMaterial extends Material {
  21766. private _subMaterials;
  21767. /**
  21768. * Gets or Sets the list of Materials used within the multi material.
  21769. * They need to be ordered according to the submeshes order in the associated mesh
  21770. */
  21771. get subMaterials(): Nullable<Material>[];
  21772. set subMaterials(value: Nullable<Material>[]);
  21773. /**
  21774. * Function used to align with Node.getChildren()
  21775. * @returns the list of Materials used within the multi material
  21776. */
  21777. getChildren(): Nullable<Material>[];
  21778. /**
  21779. * Instantiates a new Multi Material
  21780. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21781. * separate meshes. This can be use to improve performances.
  21782. * @see http://doc.babylonjs.com/how_to/multi_materials
  21783. * @param name Define the name in the scene
  21784. * @param scene Define the scene the material belongs to
  21785. */
  21786. constructor(name: string, scene: Scene);
  21787. private _hookArray;
  21788. /**
  21789. * Get one of the submaterial by its index in the submaterials array
  21790. * @param index The index to look the sub material at
  21791. * @returns The Material if the index has been defined
  21792. */
  21793. getSubMaterial(index: number): Nullable<Material>;
  21794. /**
  21795. * Get the list of active textures for the whole sub materials list.
  21796. * @returns All the textures that will be used during the rendering
  21797. */
  21798. getActiveTextures(): BaseTexture[];
  21799. /**
  21800. * Gets the current class name of the material e.g. "MultiMaterial"
  21801. * Mainly use in serialization.
  21802. * @returns the class name
  21803. */
  21804. getClassName(): string;
  21805. /**
  21806. * Checks if the material is ready to render the requested sub mesh
  21807. * @param mesh Define the mesh the submesh belongs to
  21808. * @param subMesh Define the sub mesh to look readyness for
  21809. * @param useInstances Define whether or not the material is used with instances
  21810. * @returns true if ready, otherwise false
  21811. */
  21812. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21813. /**
  21814. * Clones the current material and its related sub materials
  21815. * @param name Define the name of the newly cloned material
  21816. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21817. * @returns the cloned material
  21818. */
  21819. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21820. /**
  21821. * Serializes the materials into a JSON representation.
  21822. * @returns the JSON representation
  21823. */
  21824. serialize(): any;
  21825. /**
  21826. * Dispose the material and release its associated resources
  21827. * @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)
  21828. * @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)
  21829. * @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)
  21830. */
  21831. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21832. /**
  21833. * Creates a MultiMaterial from parsed MultiMaterial data.
  21834. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21835. * @param scene defines the hosting scene
  21836. * @returns a new MultiMaterial
  21837. */
  21838. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21839. }
  21840. }
  21841. declare module BABYLON {
  21842. /**
  21843. * Base class for submeshes
  21844. */
  21845. export class BaseSubMesh {
  21846. /** @hidden */
  21847. _materialDefines: Nullable<MaterialDefines>;
  21848. /** @hidden */
  21849. _materialEffect: Nullable<Effect>;
  21850. /** @hidden */
  21851. _effectOverride: Nullable<Effect>;
  21852. /**
  21853. * Gets material defines used by the effect associated to the sub mesh
  21854. */
  21855. get materialDefines(): Nullable<MaterialDefines>;
  21856. /**
  21857. * Sets material defines used by the effect associated to the sub mesh
  21858. */
  21859. set materialDefines(defines: Nullable<MaterialDefines>);
  21860. /**
  21861. * Gets associated effect
  21862. */
  21863. get effect(): Nullable<Effect>;
  21864. /**
  21865. * Sets associated effect (effect used to render this submesh)
  21866. * @param effect defines the effect to associate with
  21867. * @param defines defines the set of defines used to compile this effect
  21868. */
  21869. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21870. }
  21871. /**
  21872. * Defines a subdivision inside a mesh
  21873. */
  21874. export class SubMesh extends BaseSubMesh implements ICullable {
  21875. /** the material index to use */
  21876. materialIndex: number;
  21877. /** vertex index start */
  21878. verticesStart: number;
  21879. /** vertices count */
  21880. verticesCount: number;
  21881. /** index start */
  21882. indexStart: number;
  21883. /** indices count */
  21884. indexCount: number;
  21885. /** @hidden */
  21886. _linesIndexCount: number;
  21887. private _mesh;
  21888. private _renderingMesh;
  21889. private _boundingInfo;
  21890. private _linesIndexBuffer;
  21891. /** @hidden */
  21892. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21893. /** @hidden */
  21894. _trianglePlanes: Plane[];
  21895. /** @hidden */
  21896. _lastColliderTransformMatrix: Nullable<Matrix>;
  21897. /** @hidden */
  21898. _renderId: number;
  21899. /** @hidden */
  21900. _alphaIndex: number;
  21901. /** @hidden */
  21902. _distanceToCamera: number;
  21903. /** @hidden */
  21904. _id: number;
  21905. private _currentMaterial;
  21906. /**
  21907. * Add a new submesh to a mesh
  21908. * @param materialIndex defines the material index to use
  21909. * @param verticesStart defines vertex index start
  21910. * @param verticesCount defines vertices count
  21911. * @param indexStart defines index start
  21912. * @param indexCount defines indices count
  21913. * @param mesh defines the parent mesh
  21914. * @param renderingMesh defines an optional rendering mesh
  21915. * @param createBoundingBox defines if bounding box should be created for this submesh
  21916. * @returns the new submesh
  21917. */
  21918. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21919. /**
  21920. * Creates a new submesh
  21921. * @param materialIndex defines the material index to use
  21922. * @param verticesStart defines vertex index start
  21923. * @param verticesCount defines vertices count
  21924. * @param indexStart defines index start
  21925. * @param indexCount defines indices count
  21926. * @param mesh defines the parent mesh
  21927. * @param renderingMesh defines an optional rendering mesh
  21928. * @param createBoundingBox defines if bounding box should be created for this submesh
  21929. */
  21930. constructor(
  21931. /** the material index to use */
  21932. materialIndex: number,
  21933. /** vertex index start */
  21934. verticesStart: number,
  21935. /** vertices count */
  21936. verticesCount: number,
  21937. /** index start */
  21938. indexStart: number,
  21939. /** indices count */
  21940. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21941. /**
  21942. * Returns true if this submesh covers the entire parent mesh
  21943. * @ignorenaming
  21944. */
  21945. get IsGlobal(): boolean;
  21946. /**
  21947. * Returns the submesh BoudingInfo object
  21948. * @returns current bounding info (or mesh's one if the submesh is global)
  21949. */
  21950. getBoundingInfo(): BoundingInfo;
  21951. /**
  21952. * Sets the submesh BoundingInfo
  21953. * @param boundingInfo defines the new bounding info to use
  21954. * @returns the SubMesh
  21955. */
  21956. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21957. /**
  21958. * Returns the mesh of the current submesh
  21959. * @return the parent mesh
  21960. */
  21961. getMesh(): AbstractMesh;
  21962. /**
  21963. * Returns the rendering mesh of the submesh
  21964. * @returns the rendering mesh (could be different from parent mesh)
  21965. */
  21966. getRenderingMesh(): Mesh;
  21967. /**
  21968. * Returns the submesh material
  21969. * @returns null or the current material
  21970. */
  21971. getMaterial(): Nullable<Material>;
  21972. /**
  21973. * Sets a new updated BoundingInfo object to the submesh
  21974. * @param data defines an optional position array to use to determine the bounding info
  21975. * @returns the SubMesh
  21976. */
  21977. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21978. /** @hidden */
  21979. _checkCollision(collider: Collider): boolean;
  21980. /**
  21981. * Updates the submesh BoundingInfo
  21982. * @param world defines the world matrix to use to update the bounding info
  21983. * @returns the submesh
  21984. */
  21985. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21986. /**
  21987. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21988. * @param frustumPlanes defines the frustum planes
  21989. * @returns true if the submesh is intersecting with the frustum
  21990. */
  21991. isInFrustum(frustumPlanes: Plane[]): boolean;
  21992. /**
  21993. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21994. * @param frustumPlanes defines the frustum planes
  21995. * @returns true if the submesh is inside the frustum
  21996. */
  21997. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21998. /**
  21999. * Renders the submesh
  22000. * @param enableAlphaMode defines if alpha needs to be used
  22001. * @returns the submesh
  22002. */
  22003. render(enableAlphaMode: boolean): SubMesh;
  22004. /**
  22005. * @hidden
  22006. */
  22007. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22008. /**
  22009. * Checks if the submesh intersects with a ray
  22010. * @param ray defines the ray to test
  22011. * @returns true is the passed ray intersects the submesh bounding box
  22012. */
  22013. canIntersects(ray: Ray): boolean;
  22014. /**
  22015. * Intersects current submesh with a ray
  22016. * @param ray defines the ray to test
  22017. * @param positions defines mesh's positions array
  22018. * @param indices defines mesh's indices array
  22019. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22020. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22021. * @returns intersection info or null if no intersection
  22022. */
  22023. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22024. /** @hidden */
  22025. private _intersectLines;
  22026. /** @hidden */
  22027. private _intersectUnIndexedLines;
  22028. /** @hidden */
  22029. private _intersectTriangles;
  22030. /** @hidden */
  22031. private _intersectUnIndexedTriangles;
  22032. /** @hidden */
  22033. _rebuild(): void;
  22034. /**
  22035. * Creates a new submesh from the passed mesh
  22036. * @param newMesh defines the new hosting mesh
  22037. * @param newRenderingMesh defines an optional rendering mesh
  22038. * @returns the new submesh
  22039. */
  22040. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22041. /**
  22042. * Release associated resources
  22043. */
  22044. dispose(): void;
  22045. /**
  22046. * Gets the class name
  22047. * @returns the string "SubMesh".
  22048. */
  22049. getClassName(): string;
  22050. /**
  22051. * Creates a new submesh from indices data
  22052. * @param materialIndex the index of the main mesh material
  22053. * @param startIndex the index where to start the copy in the mesh indices array
  22054. * @param indexCount the number of indices to copy then from the startIndex
  22055. * @param mesh the main mesh to create the submesh from
  22056. * @param renderingMesh the optional rendering mesh
  22057. * @returns a new submesh
  22058. */
  22059. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22060. }
  22061. }
  22062. declare module BABYLON {
  22063. /**
  22064. * Class used to represent data loading progression
  22065. */
  22066. export class SceneLoaderFlags {
  22067. private static _ForceFullSceneLoadingForIncremental;
  22068. private static _ShowLoadingScreen;
  22069. private static _CleanBoneMatrixWeights;
  22070. private static _loggingLevel;
  22071. /**
  22072. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22073. */
  22074. static get ForceFullSceneLoadingForIncremental(): boolean;
  22075. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22076. /**
  22077. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22078. */
  22079. static get ShowLoadingScreen(): boolean;
  22080. static set ShowLoadingScreen(value: boolean);
  22081. /**
  22082. * Defines the current logging level (while loading the scene)
  22083. * @ignorenaming
  22084. */
  22085. static get loggingLevel(): number;
  22086. static set loggingLevel(value: number);
  22087. /**
  22088. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22089. */
  22090. static get CleanBoneMatrixWeights(): boolean;
  22091. static set CleanBoneMatrixWeights(value: boolean);
  22092. }
  22093. }
  22094. declare module BABYLON {
  22095. /**
  22096. * Class used to store geometry data (vertex buffers + index buffer)
  22097. */
  22098. export class Geometry implements IGetSetVerticesData {
  22099. /**
  22100. * Gets or sets the ID of the geometry
  22101. */
  22102. id: string;
  22103. /**
  22104. * Gets or sets the unique ID of the geometry
  22105. */
  22106. uniqueId: number;
  22107. /**
  22108. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22109. */
  22110. delayLoadState: number;
  22111. /**
  22112. * Gets the file containing the data to load when running in delay load state
  22113. */
  22114. delayLoadingFile: Nullable<string>;
  22115. /**
  22116. * Callback called when the geometry is updated
  22117. */
  22118. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22119. private _scene;
  22120. private _engine;
  22121. private _meshes;
  22122. private _totalVertices;
  22123. /** @hidden */
  22124. _indices: IndicesArray;
  22125. /** @hidden */
  22126. _vertexBuffers: {
  22127. [key: string]: VertexBuffer;
  22128. };
  22129. private _isDisposed;
  22130. private _extend;
  22131. private _boundingBias;
  22132. /** @hidden */
  22133. _delayInfo: Array<string>;
  22134. private _indexBuffer;
  22135. private _indexBufferIsUpdatable;
  22136. /** @hidden */
  22137. _boundingInfo: Nullable<BoundingInfo>;
  22138. /** @hidden */
  22139. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22140. /** @hidden */
  22141. _softwareSkinningFrameId: number;
  22142. private _vertexArrayObjects;
  22143. private _updatable;
  22144. /** @hidden */
  22145. _positions: Nullable<Vector3[]>;
  22146. /**
  22147. * 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
  22148. */
  22149. get boundingBias(): Vector2;
  22150. /**
  22151. * 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
  22152. */
  22153. set boundingBias(value: Vector2);
  22154. /**
  22155. * Static function used to attach a new empty geometry to a mesh
  22156. * @param mesh defines the mesh to attach the geometry to
  22157. * @returns the new Geometry
  22158. */
  22159. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22160. /** Get the list of meshes using this geometry */
  22161. get meshes(): Mesh[];
  22162. /**
  22163. * Creates a new geometry
  22164. * @param id defines the unique ID
  22165. * @param scene defines the hosting scene
  22166. * @param vertexData defines the VertexData used to get geometry data
  22167. * @param updatable defines if geometry must be updatable (false by default)
  22168. * @param mesh defines the mesh that will be associated with the geometry
  22169. */
  22170. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22171. /**
  22172. * Gets the current extend of the geometry
  22173. */
  22174. get extend(): {
  22175. minimum: Vector3;
  22176. maximum: Vector3;
  22177. };
  22178. /**
  22179. * Gets the hosting scene
  22180. * @returns the hosting Scene
  22181. */
  22182. getScene(): Scene;
  22183. /**
  22184. * Gets the hosting engine
  22185. * @returns the hosting Engine
  22186. */
  22187. getEngine(): Engine;
  22188. /**
  22189. * Defines if the geometry is ready to use
  22190. * @returns true if the geometry is ready to be used
  22191. */
  22192. isReady(): boolean;
  22193. /**
  22194. * Gets a value indicating that the geometry should not be serialized
  22195. */
  22196. get doNotSerialize(): boolean;
  22197. /** @hidden */
  22198. _rebuild(): void;
  22199. /**
  22200. * Affects all geometry data in one call
  22201. * @param vertexData defines the geometry data
  22202. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22203. */
  22204. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22205. /**
  22206. * Set specific vertex data
  22207. * @param kind defines the data kind (Position, normal, etc...)
  22208. * @param data defines the vertex data to use
  22209. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22210. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22211. */
  22212. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22213. /**
  22214. * Removes a specific vertex data
  22215. * @param kind defines the data kind (Position, normal, etc...)
  22216. */
  22217. removeVerticesData(kind: string): void;
  22218. /**
  22219. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22220. * @param buffer defines the vertex buffer to use
  22221. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22222. */
  22223. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22224. /**
  22225. * Update a specific vertex buffer
  22226. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22227. * It will do nothing if the buffer is not updatable
  22228. * @param kind defines the data kind (Position, normal, etc...)
  22229. * @param data defines the data to use
  22230. * @param offset defines the offset in the target buffer where to store the data
  22231. * @param useBytes set to true if the offset is in bytes
  22232. */
  22233. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22234. /**
  22235. * Update a specific vertex buffer
  22236. * This function will create a new buffer if the current one is not updatable
  22237. * @param kind defines the data kind (Position, normal, etc...)
  22238. * @param data defines the data to use
  22239. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22240. */
  22241. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22242. private _updateBoundingInfo;
  22243. /** @hidden */
  22244. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22245. /**
  22246. * Gets total number of vertices
  22247. * @returns the total number of vertices
  22248. */
  22249. getTotalVertices(): number;
  22250. /**
  22251. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22252. * @param kind defines the data kind (Position, normal, etc...)
  22253. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22254. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22255. * @returns a float array containing vertex data
  22256. */
  22257. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22258. /**
  22259. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22260. * @param kind defines the data kind (Position, normal, etc...)
  22261. * @returns true if the vertex buffer with the specified kind is updatable
  22262. */
  22263. isVertexBufferUpdatable(kind: string): boolean;
  22264. /**
  22265. * Gets a specific vertex buffer
  22266. * @param kind defines the data kind (Position, normal, etc...)
  22267. * @returns a VertexBuffer
  22268. */
  22269. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22270. /**
  22271. * Returns all vertex buffers
  22272. * @return an object holding all vertex buffers indexed by kind
  22273. */
  22274. getVertexBuffers(): Nullable<{
  22275. [key: string]: VertexBuffer;
  22276. }>;
  22277. /**
  22278. * Gets a boolean indicating if specific vertex buffer is present
  22279. * @param kind defines the data kind (Position, normal, etc...)
  22280. * @returns true if data is present
  22281. */
  22282. isVerticesDataPresent(kind: string): boolean;
  22283. /**
  22284. * Gets a list of all attached data kinds (Position, normal, etc...)
  22285. * @returns a list of string containing all kinds
  22286. */
  22287. getVerticesDataKinds(): string[];
  22288. /**
  22289. * Update index buffer
  22290. * @param indices defines the indices to store in the index buffer
  22291. * @param offset defines the offset in the target buffer where to store the data
  22292. * @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)
  22293. */
  22294. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22295. /**
  22296. * Creates a new index buffer
  22297. * @param indices defines the indices to store in the index buffer
  22298. * @param totalVertices defines the total number of vertices (could be null)
  22299. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22300. */
  22301. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22302. /**
  22303. * Return the total number of indices
  22304. * @returns the total number of indices
  22305. */
  22306. getTotalIndices(): number;
  22307. /**
  22308. * Gets the index buffer array
  22309. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22310. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22311. * @returns the index buffer array
  22312. */
  22313. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22314. /**
  22315. * Gets the index buffer
  22316. * @return the index buffer
  22317. */
  22318. getIndexBuffer(): Nullable<DataBuffer>;
  22319. /** @hidden */
  22320. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22321. /**
  22322. * Release the associated resources for a specific mesh
  22323. * @param mesh defines the source mesh
  22324. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22325. */
  22326. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22327. /**
  22328. * Apply current geometry to a given mesh
  22329. * @param mesh defines the mesh to apply geometry to
  22330. */
  22331. applyToMesh(mesh: Mesh): void;
  22332. private _updateExtend;
  22333. private _applyToMesh;
  22334. private notifyUpdate;
  22335. /**
  22336. * Load the geometry if it was flagged as delay loaded
  22337. * @param scene defines the hosting scene
  22338. * @param onLoaded defines a callback called when the geometry is loaded
  22339. */
  22340. load(scene: Scene, onLoaded?: () => void): void;
  22341. private _queueLoad;
  22342. /**
  22343. * Invert the geometry to move from a right handed system to a left handed one.
  22344. */
  22345. toLeftHanded(): void;
  22346. /** @hidden */
  22347. _resetPointsArrayCache(): void;
  22348. /** @hidden */
  22349. _generatePointsArray(): boolean;
  22350. /**
  22351. * Gets a value indicating if the geometry is disposed
  22352. * @returns true if the geometry was disposed
  22353. */
  22354. isDisposed(): boolean;
  22355. private _disposeVertexArrayObjects;
  22356. /**
  22357. * Free all associated resources
  22358. */
  22359. dispose(): void;
  22360. /**
  22361. * Clone the current geometry into a new geometry
  22362. * @param id defines the unique ID of the new geometry
  22363. * @returns a new geometry object
  22364. */
  22365. copy(id: string): Geometry;
  22366. /**
  22367. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22368. * @return a JSON representation of the current geometry data (without the vertices data)
  22369. */
  22370. serialize(): any;
  22371. private toNumberArray;
  22372. /**
  22373. * Serialize all vertices data into a JSON oject
  22374. * @returns a JSON representation of the current geometry data
  22375. */
  22376. serializeVerticeData(): any;
  22377. /**
  22378. * Extracts a clone of a mesh geometry
  22379. * @param mesh defines the source mesh
  22380. * @param id defines the unique ID of the new geometry object
  22381. * @returns the new geometry object
  22382. */
  22383. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22384. /**
  22385. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22386. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22387. * Be aware Math.random() could cause collisions, but:
  22388. * "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"
  22389. * @returns a string containing a new GUID
  22390. */
  22391. static RandomId(): string;
  22392. /** @hidden */
  22393. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22394. private static _CleanMatricesWeights;
  22395. /**
  22396. * Create a new geometry from persisted data (Using .babylon file format)
  22397. * @param parsedVertexData defines the persisted data
  22398. * @param scene defines the hosting scene
  22399. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22400. * @returns the new geometry object
  22401. */
  22402. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22403. }
  22404. }
  22405. declare module BABYLON {
  22406. /**
  22407. * Define an interface for all classes that will get and set the data on vertices
  22408. */
  22409. export interface IGetSetVerticesData {
  22410. /**
  22411. * Gets a boolean indicating if specific vertex data is present
  22412. * @param kind defines the vertex data kind to use
  22413. * @returns true is data kind is present
  22414. */
  22415. isVerticesDataPresent(kind: string): boolean;
  22416. /**
  22417. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22418. * @param kind defines the data kind (Position, normal, etc...)
  22419. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22420. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22421. * @returns a float array containing vertex data
  22422. */
  22423. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22424. /**
  22425. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22426. * @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.
  22427. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22428. * @returns the indices array or an empty array if the mesh has no geometry
  22429. */
  22430. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22431. /**
  22432. * Set specific vertex data
  22433. * @param kind defines the data kind (Position, normal, etc...)
  22434. * @param data defines the vertex data to use
  22435. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22436. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22437. */
  22438. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22439. /**
  22440. * Update a specific associated vertex buffer
  22441. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22442. * - VertexBuffer.PositionKind
  22443. * - VertexBuffer.UVKind
  22444. * - VertexBuffer.UV2Kind
  22445. * - VertexBuffer.UV3Kind
  22446. * - VertexBuffer.UV4Kind
  22447. * - VertexBuffer.UV5Kind
  22448. * - VertexBuffer.UV6Kind
  22449. * - VertexBuffer.ColorKind
  22450. * - VertexBuffer.MatricesIndicesKind
  22451. * - VertexBuffer.MatricesIndicesExtraKind
  22452. * - VertexBuffer.MatricesWeightsKind
  22453. * - VertexBuffer.MatricesWeightsExtraKind
  22454. * @param data defines the data source
  22455. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22456. * @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)
  22457. */
  22458. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22459. /**
  22460. * Creates a new index buffer
  22461. * @param indices defines the indices to store in the index buffer
  22462. * @param totalVertices defines the total number of vertices (could be null)
  22463. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22464. */
  22465. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22466. }
  22467. /**
  22468. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22469. */
  22470. export class VertexData {
  22471. /**
  22472. * Mesh side orientation : usually the external or front surface
  22473. */
  22474. static readonly FRONTSIDE: number;
  22475. /**
  22476. * Mesh side orientation : usually the internal or back surface
  22477. */
  22478. static readonly BACKSIDE: number;
  22479. /**
  22480. * Mesh side orientation : both internal and external or front and back surfaces
  22481. */
  22482. static readonly DOUBLESIDE: number;
  22483. /**
  22484. * Mesh side orientation : by default, `FRONTSIDE`
  22485. */
  22486. static readonly DEFAULTSIDE: number;
  22487. /**
  22488. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22489. */
  22490. positions: Nullable<FloatArray>;
  22491. /**
  22492. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22493. */
  22494. normals: Nullable<FloatArray>;
  22495. /**
  22496. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22497. */
  22498. tangents: Nullable<FloatArray>;
  22499. /**
  22500. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22501. */
  22502. uvs: Nullable<FloatArray>;
  22503. /**
  22504. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22505. */
  22506. uvs2: Nullable<FloatArray>;
  22507. /**
  22508. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22509. */
  22510. uvs3: Nullable<FloatArray>;
  22511. /**
  22512. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22513. */
  22514. uvs4: Nullable<FloatArray>;
  22515. /**
  22516. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22517. */
  22518. uvs5: Nullable<FloatArray>;
  22519. /**
  22520. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22521. */
  22522. uvs6: Nullable<FloatArray>;
  22523. /**
  22524. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22525. */
  22526. colors: Nullable<FloatArray>;
  22527. /**
  22528. * 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).
  22529. */
  22530. matricesIndices: Nullable<FloatArray>;
  22531. /**
  22532. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22533. */
  22534. matricesWeights: Nullable<FloatArray>;
  22535. /**
  22536. * An array extending the number of possible indices
  22537. */
  22538. matricesIndicesExtra: Nullable<FloatArray>;
  22539. /**
  22540. * An array extending the number of possible weights when the number of indices is extended
  22541. */
  22542. matricesWeightsExtra: Nullable<FloatArray>;
  22543. /**
  22544. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22545. */
  22546. indices: Nullable<IndicesArray>;
  22547. /**
  22548. * Uses the passed data array to set the set the values for the specified kind of data
  22549. * @param data a linear array of floating numbers
  22550. * @param kind the type of data that is being set, eg positions, colors etc
  22551. */
  22552. set(data: FloatArray, kind: string): void;
  22553. /**
  22554. * Associates the vertexData to the passed Mesh.
  22555. * Sets it as updatable or not (default `false`)
  22556. * @param mesh the mesh the vertexData is applied to
  22557. * @param updatable when used and having the value true allows new data to update the vertexData
  22558. * @returns the VertexData
  22559. */
  22560. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22561. /**
  22562. * Associates the vertexData to the passed Geometry.
  22563. * Sets it as updatable or not (default `false`)
  22564. * @param geometry the geometry the vertexData is applied to
  22565. * @param updatable when used and having the value true allows new data to update the vertexData
  22566. * @returns VertexData
  22567. */
  22568. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22569. /**
  22570. * Updates the associated mesh
  22571. * @param mesh the mesh to be updated
  22572. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22573. * @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
  22574. * @returns VertexData
  22575. */
  22576. updateMesh(mesh: Mesh): VertexData;
  22577. /**
  22578. * Updates the associated geometry
  22579. * @param geometry the geometry to be updated
  22580. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22581. * @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
  22582. * @returns VertexData.
  22583. */
  22584. updateGeometry(geometry: Geometry): VertexData;
  22585. private _applyTo;
  22586. private _update;
  22587. /**
  22588. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22589. * @param matrix the transforming matrix
  22590. * @returns the VertexData
  22591. */
  22592. transform(matrix: Matrix): VertexData;
  22593. /**
  22594. * Merges the passed VertexData into the current one
  22595. * @param other the VertexData to be merged into the current one
  22596. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22597. * @returns the modified VertexData
  22598. */
  22599. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22600. private _mergeElement;
  22601. private _validate;
  22602. /**
  22603. * Serializes the VertexData
  22604. * @returns a serialized object
  22605. */
  22606. serialize(): any;
  22607. /**
  22608. * Extracts the vertexData from a mesh
  22609. * @param mesh the mesh from which to extract the VertexData
  22610. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22611. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22612. * @returns the object VertexData associated to the passed mesh
  22613. */
  22614. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22615. /**
  22616. * Extracts the vertexData from the geometry
  22617. * @param geometry the geometry from which to extract the VertexData
  22618. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22619. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22620. * @returns the object VertexData associated to the passed mesh
  22621. */
  22622. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22623. private static _ExtractFrom;
  22624. /**
  22625. * Creates the VertexData for a Ribbon
  22626. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22627. * * pathArray array of paths, each of which an array of successive Vector3
  22628. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22629. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22630. * * 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
  22631. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22632. * * 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)
  22633. * * 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)
  22634. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22635. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22636. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22637. * @returns the VertexData of the ribbon
  22638. */
  22639. static CreateRibbon(options: {
  22640. pathArray: Vector3[][];
  22641. closeArray?: boolean;
  22642. closePath?: boolean;
  22643. offset?: number;
  22644. sideOrientation?: number;
  22645. frontUVs?: Vector4;
  22646. backUVs?: Vector4;
  22647. invertUV?: boolean;
  22648. uvs?: Vector2[];
  22649. colors?: Color4[];
  22650. }): VertexData;
  22651. /**
  22652. * Creates the VertexData for a box
  22653. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22654. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22655. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22656. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22657. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22658. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22659. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22660. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22661. * * 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)
  22662. * * 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)
  22663. * @returns the VertexData of the box
  22664. */
  22665. static CreateBox(options: {
  22666. size?: number;
  22667. width?: number;
  22668. height?: number;
  22669. depth?: number;
  22670. faceUV?: Vector4[];
  22671. faceColors?: Color4[];
  22672. sideOrientation?: number;
  22673. frontUVs?: Vector4;
  22674. backUVs?: Vector4;
  22675. }): VertexData;
  22676. /**
  22677. * Creates the VertexData for a tiled box
  22678. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22679. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22680. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22681. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22682. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22683. * @returns the VertexData of the box
  22684. */
  22685. static CreateTiledBox(options: {
  22686. pattern?: number;
  22687. width?: number;
  22688. height?: number;
  22689. depth?: number;
  22690. tileSize?: number;
  22691. tileWidth?: number;
  22692. tileHeight?: number;
  22693. alignHorizontal?: number;
  22694. alignVertical?: number;
  22695. faceUV?: Vector4[];
  22696. faceColors?: Color4[];
  22697. sideOrientation?: number;
  22698. }): VertexData;
  22699. /**
  22700. * Creates the VertexData for a tiled plane
  22701. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22702. * * pattern a limited pattern arrangement depending on the number
  22703. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22704. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22705. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22706. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22707. * * 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)
  22708. * * 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)
  22709. * @returns the VertexData of the tiled plane
  22710. */
  22711. static CreateTiledPlane(options: {
  22712. pattern?: number;
  22713. tileSize?: number;
  22714. tileWidth?: number;
  22715. tileHeight?: number;
  22716. size?: number;
  22717. width?: number;
  22718. height?: number;
  22719. alignHorizontal?: number;
  22720. alignVertical?: number;
  22721. sideOrientation?: number;
  22722. frontUVs?: Vector4;
  22723. backUVs?: Vector4;
  22724. }): VertexData;
  22725. /**
  22726. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22727. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22728. * * segments sets the number of horizontal strips optional, default 32
  22729. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22730. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22731. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22732. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22733. * * 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
  22734. * * 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
  22735. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22736. * * 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)
  22737. * * 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)
  22738. * @returns the VertexData of the ellipsoid
  22739. */
  22740. static CreateSphere(options: {
  22741. segments?: number;
  22742. diameter?: number;
  22743. diameterX?: number;
  22744. diameterY?: number;
  22745. diameterZ?: number;
  22746. arc?: number;
  22747. slice?: number;
  22748. sideOrientation?: number;
  22749. frontUVs?: Vector4;
  22750. backUVs?: Vector4;
  22751. }): VertexData;
  22752. /**
  22753. * Creates the VertexData for a cylinder, cone or prism
  22754. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22755. * * height sets the height (y direction) of the cylinder, optional, default 2
  22756. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22757. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22758. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22759. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22760. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22761. * * 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
  22762. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22763. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22764. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22765. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22766. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22767. * * 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)
  22768. * * 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)
  22769. * @returns the VertexData of the cylinder, cone or prism
  22770. */
  22771. static CreateCylinder(options: {
  22772. height?: number;
  22773. diameterTop?: number;
  22774. diameterBottom?: number;
  22775. diameter?: number;
  22776. tessellation?: number;
  22777. subdivisions?: number;
  22778. arc?: number;
  22779. faceColors?: Color4[];
  22780. faceUV?: Vector4[];
  22781. hasRings?: boolean;
  22782. enclose?: boolean;
  22783. sideOrientation?: number;
  22784. frontUVs?: Vector4;
  22785. backUVs?: Vector4;
  22786. }): VertexData;
  22787. /**
  22788. * Creates the VertexData for a torus
  22789. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22790. * * diameter the diameter of the torus, optional default 1
  22791. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22792. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22793. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22794. * * 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)
  22795. * * 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)
  22796. * @returns the VertexData of the torus
  22797. */
  22798. static CreateTorus(options: {
  22799. diameter?: number;
  22800. thickness?: number;
  22801. tessellation?: number;
  22802. sideOrientation?: number;
  22803. frontUVs?: Vector4;
  22804. backUVs?: Vector4;
  22805. }): VertexData;
  22806. /**
  22807. * Creates the VertexData of the LineSystem
  22808. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22809. * - lines an array of lines, each line being an array of successive Vector3
  22810. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22811. * @returns the VertexData of the LineSystem
  22812. */
  22813. static CreateLineSystem(options: {
  22814. lines: Vector3[][];
  22815. colors?: Nullable<Color4[][]>;
  22816. }): VertexData;
  22817. /**
  22818. * Create the VertexData for a DashedLines
  22819. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22820. * - points an array successive Vector3
  22821. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22822. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22823. * - dashNb the intended total number of dashes, optional, default 200
  22824. * @returns the VertexData for the DashedLines
  22825. */
  22826. static CreateDashedLines(options: {
  22827. points: Vector3[];
  22828. dashSize?: number;
  22829. gapSize?: number;
  22830. dashNb?: number;
  22831. }): VertexData;
  22832. /**
  22833. * Creates the VertexData for a Ground
  22834. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22835. * - width the width (x direction) of the ground, optional, default 1
  22836. * - height the height (z direction) of the ground, optional, default 1
  22837. * - subdivisions the number of subdivisions per side, optional, default 1
  22838. * @returns the VertexData of the Ground
  22839. */
  22840. static CreateGround(options: {
  22841. width?: number;
  22842. height?: number;
  22843. subdivisions?: number;
  22844. subdivisionsX?: number;
  22845. subdivisionsY?: number;
  22846. }): VertexData;
  22847. /**
  22848. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22849. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22850. * * xmin the ground minimum X coordinate, optional, default -1
  22851. * * zmin the ground minimum Z coordinate, optional, default -1
  22852. * * xmax the ground maximum X coordinate, optional, default 1
  22853. * * zmax the ground maximum Z coordinate, optional, default 1
  22854. * * 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}
  22855. * * 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}
  22856. * @returns the VertexData of the TiledGround
  22857. */
  22858. static CreateTiledGround(options: {
  22859. xmin: number;
  22860. zmin: number;
  22861. xmax: number;
  22862. zmax: number;
  22863. subdivisions?: {
  22864. w: number;
  22865. h: number;
  22866. };
  22867. precision?: {
  22868. w: number;
  22869. h: number;
  22870. };
  22871. }): VertexData;
  22872. /**
  22873. * Creates the VertexData of the Ground designed from a heightmap
  22874. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22875. * * width the width (x direction) of the ground
  22876. * * height the height (z direction) of the ground
  22877. * * subdivisions the number of subdivisions per side
  22878. * * minHeight the minimum altitude on the ground, optional, default 0
  22879. * * maxHeight the maximum altitude on the ground, optional default 1
  22880. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22881. * * buffer the array holding the image color data
  22882. * * bufferWidth the width of image
  22883. * * bufferHeight the height of image
  22884. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22885. * @returns the VertexData of the Ground designed from a heightmap
  22886. */
  22887. static CreateGroundFromHeightMap(options: {
  22888. width: number;
  22889. height: number;
  22890. subdivisions: number;
  22891. minHeight: number;
  22892. maxHeight: number;
  22893. colorFilter: Color3;
  22894. buffer: Uint8Array;
  22895. bufferWidth: number;
  22896. bufferHeight: number;
  22897. alphaFilter: number;
  22898. }): VertexData;
  22899. /**
  22900. * Creates the VertexData for a Plane
  22901. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22902. * * size sets the width and height of the plane to the value of size, optional default 1
  22903. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22904. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22905. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22906. * * 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)
  22907. * * 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)
  22908. * @returns the VertexData of the box
  22909. */
  22910. static CreatePlane(options: {
  22911. size?: number;
  22912. width?: number;
  22913. height?: number;
  22914. sideOrientation?: number;
  22915. frontUVs?: Vector4;
  22916. backUVs?: Vector4;
  22917. }): VertexData;
  22918. /**
  22919. * Creates the VertexData of the Disc or regular Polygon
  22920. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22921. * * radius the radius of the disc, optional default 0.5
  22922. * * tessellation the number of polygon sides, optional, default 64
  22923. * * 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
  22924. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22925. * * 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)
  22926. * * 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)
  22927. * @returns the VertexData of the box
  22928. */
  22929. static CreateDisc(options: {
  22930. radius?: number;
  22931. tessellation?: number;
  22932. arc?: number;
  22933. sideOrientation?: number;
  22934. frontUVs?: Vector4;
  22935. backUVs?: Vector4;
  22936. }): VertexData;
  22937. /**
  22938. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22939. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22940. * @param polygon a mesh built from polygonTriangulation.build()
  22941. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22942. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22943. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22944. * @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)
  22945. * @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)
  22946. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  22947. * @returns the VertexData of the Polygon
  22948. */
  22949. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  22950. /**
  22951. * Creates the VertexData of the IcoSphere
  22952. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22953. * * radius the radius of the IcoSphere, optional default 1
  22954. * * radiusX allows stretching in the x direction, optional, default radius
  22955. * * radiusY allows stretching in the y direction, optional, default radius
  22956. * * radiusZ allows stretching in the z direction, optional, default radius
  22957. * * flat when true creates a flat shaded mesh, optional, default true
  22958. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22959. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22960. * * 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)
  22961. * * 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)
  22962. * @returns the VertexData of the IcoSphere
  22963. */
  22964. static CreateIcoSphere(options: {
  22965. radius?: number;
  22966. radiusX?: number;
  22967. radiusY?: number;
  22968. radiusZ?: number;
  22969. flat?: boolean;
  22970. subdivisions?: number;
  22971. sideOrientation?: number;
  22972. frontUVs?: Vector4;
  22973. backUVs?: Vector4;
  22974. }): VertexData;
  22975. /**
  22976. * Creates the VertexData for a Polyhedron
  22977. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22978. * * type provided types are:
  22979. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22980. * * 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)
  22981. * * size the size of the IcoSphere, optional default 1
  22982. * * sizeX allows stretching in the x direction, optional, default size
  22983. * * sizeY allows stretching in the y direction, optional, default size
  22984. * * sizeZ allows stretching in the z direction, optional, default size
  22985. * * 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
  22986. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22987. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22988. * * flat when true creates a flat shaded mesh, optional, default true
  22989. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22990. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22991. * * 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)
  22992. * * 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)
  22993. * @returns the VertexData of the Polyhedron
  22994. */
  22995. static CreatePolyhedron(options: {
  22996. type?: number;
  22997. size?: number;
  22998. sizeX?: number;
  22999. sizeY?: number;
  23000. sizeZ?: number;
  23001. custom?: any;
  23002. faceUV?: Vector4[];
  23003. faceColors?: Color4[];
  23004. flat?: boolean;
  23005. sideOrientation?: number;
  23006. frontUVs?: Vector4;
  23007. backUVs?: Vector4;
  23008. }): VertexData;
  23009. /**
  23010. * Creates the VertexData for a TorusKnot
  23011. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23012. * * radius the radius of the torus knot, optional, default 2
  23013. * * tube the thickness of the tube, optional, default 0.5
  23014. * * radialSegments the number of sides on each tube segments, optional, default 32
  23015. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23016. * * p the number of windings around the z axis, optional, default 2
  23017. * * q the number of windings around the x axis, optional, default 3
  23018. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23019. * * 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)
  23020. * * 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)
  23021. * @returns the VertexData of the Torus Knot
  23022. */
  23023. static CreateTorusKnot(options: {
  23024. radius?: number;
  23025. tube?: number;
  23026. radialSegments?: number;
  23027. tubularSegments?: number;
  23028. p?: number;
  23029. q?: number;
  23030. sideOrientation?: number;
  23031. frontUVs?: Vector4;
  23032. backUVs?: Vector4;
  23033. }): VertexData;
  23034. /**
  23035. * Compute normals for given positions and indices
  23036. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23037. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23038. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23039. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23040. * * facetNormals : optional array of facet normals (vector3)
  23041. * * facetPositions : optional array of facet positions (vector3)
  23042. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23043. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23044. * * bInfo : optional bounding info, required for facetPartitioning computation
  23045. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23046. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23047. * * useRightHandedSystem: optional boolean to for right handed system computation
  23048. * * depthSort : optional boolean to enable the facet depth sort computation
  23049. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23050. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23051. */
  23052. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23053. facetNormals?: any;
  23054. facetPositions?: any;
  23055. facetPartitioning?: any;
  23056. ratio?: number;
  23057. bInfo?: any;
  23058. bbSize?: Vector3;
  23059. subDiv?: any;
  23060. useRightHandedSystem?: boolean;
  23061. depthSort?: boolean;
  23062. distanceTo?: Vector3;
  23063. depthSortedFacets?: any;
  23064. }): void;
  23065. /** @hidden */
  23066. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23067. /**
  23068. * Applies VertexData created from the imported parameters to the geometry
  23069. * @param parsedVertexData the parsed data from an imported file
  23070. * @param geometry the geometry to apply the VertexData to
  23071. */
  23072. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23073. }
  23074. }
  23075. declare module BABYLON {
  23076. /**
  23077. * Defines a target to use with MorphTargetManager
  23078. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23079. */
  23080. export class MorphTarget implements IAnimatable {
  23081. /** defines the name of the target */
  23082. name: string;
  23083. /**
  23084. * Gets or sets the list of animations
  23085. */
  23086. animations: Animation[];
  23087. private _scene;
  23088. private _positions;
  23089. private _normals;
  23090. private _tangents;
  23091. private _uvs;
  23092. private _influence;
  23093. private _uniqueId;
  23094. /**
  23095. * Observable raised when the influence changes
  23096. */
  23097. onInfluenceChanged: Observable<boolean>;
  23098. /** @hidden */
  23099. _onDataLayoutChanged: Observable<void>;
  23100. /**
  23101. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23102. */
  23103. get influence(): number;
  23104. set influence(influence: number);
  23105. /**
  23106. * Gets or sets the id of the morph Target
  23107. */
  23108. id: string;
  23109. private _animationPropertiesOverride;
  23110. /**
  23111. * Gets or sets the animation properties override
  23112. */
  23113. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23114. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23115. /**
  23116. * Creates a new MorphTarget
  23117. * @param name defines the name of the target
  23118. * @param influence defines the influence to use
  23119. * @param scene defines the scene the morphtarget belongs to
  23120. */
  23121. constructor(
  23122. /** defines the name of the target */
  23123. name: string, influence?: number, scene?: Nullable<Scene>);
  23124. /**
  23125. * Gets the unique ID of this manager
  23126. */
  23127. get uniqueId(): number;
  23128. /**
  23129. * Gets a boolean defining if the target contains position data
  23130. */
  23131. get hasPositions(): boolean;
  23132. /**
  23133. * Gets a boolean defining if the target contains normal data
  23134. */
  23135. get hasNormals(): boolean;
  23136. /**
  23137. * Gets a boolean defining if the target contains tangent data
  23138. */
  23139. get hasTangents(): boolean;
  23140. /**
  23141. * Gets a boolean defining if the target contains texture coordinates data
  23142. */
  23143. get hasUVs(): boolean;
  23144. /**
  23145. * Affects position data to this target
  23146. * @param data defines the position data to use
  23147. */
  23148. setPositions(data: Nullable<FloatArray>): void;
  23149. /**
  23150. * Gets the position data stored in this target
  23151. * @returns a FloatArray containing the position data (or null if not present)
  23152. */
  23153. getPositions(): Nullable<FloatArray>;
  23154. /**
  23155. * Affects normal data to this target
  23156. * @param data defines the normal data to use
  23157. */
  23158. setNormals(data: Nullable<FloatArray>): void;
  23159. /**
  23160. * Gets the normal data stored in this target
  23161. * @returns a FloatArray containing the normal data (or null if not present)
  23162. */
  23163. getNormals(): Nullable<FloatArray>;
  23164. /**
  23165. * Affects tangent data to this target
  23166. * @param data defines the tangent data to use
  23167. */
  23168. setTangents(data: Nullable<FloatArray>): void;
  23169. /**
  23170. * Gets the tangent data stored in this target
  23171. * @returns a FloatArray containing the tangent data (or null if not present)
  23172. */
  23173. getTangents(): Nullable<FloatArray>;
  23174. /**
  23175. * Affects texture coordinates data to this target
  23176. * @param data defines the texture coordinates data to use
  23177. */
  23178. setUVs(data: Nullable<FloatArray>): void;
  23179. /**
  23180. * Gets the texture coordinates data stored in this target
  23181. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23182. */
  23183. getUVs(): Nullable<FloatArray>;
  23184. /**
  23185. * Clone the current target
  23186. * @returns a new MorphTarget
  23187. */
  23188. clone(): MorphTarget;
  23189. /**
  23190. * Serializes the current target into a Serialization object
  23191. * @returns the serialized object
  23192. */
  23193. serialize(): any;
  23194. /**
  23195. * Returns the string "MorphTarget"
  23196. * @returns "MorphTarget"
  23197. */
  23198. getClassName(): string;
  23199. /**
  23200. * Creates a new target from serialized data
  23201. * @param serializationObject defines the serialized data to use
  23202. * @returns a new MorphTarget
  23203. */
  23204. static Parse(serializationObject: any): MorphTarget;
  23205. /**
  23206. * Creates a MorphTarget from mesh data
  23207. * @param mesh defines the source mesh
  23208. * @param name defines the name to use for the new target
  23209. * @param influence defines the influence to attach to the target
  23210. * @returns a new MorphTarget
  23211. */
  23212. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23213. }
  23214. }
  23215. declare module BABYLON {
  23216. /**
  23217. * This class is used to deform meshes using morphing between different targets
  23218. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23219. */
  23220. export class MorphTargetManager {
  23221. private _targets;
  23222. private _targetInfluenceChangedObservers;
  23223. private _targetDataLayoutChangedObservers;
  23224. private _activeTargets;
  23225. private _scene;
  23226. private _influences;
  23227. private _supportsNormals;
  23228. private _supportsTangents;
  23229. private _supportsUVs;
  23230. private _vertexCount;
  23231. private _uniqueId;
  23232. private _tempInfluences;
  23233. /**
  23234. * Gets or sets a boolean indicating if normals must be morphed
  23235. */
  23236. enableNormalMorphing: boolean;
  23237. /**
  23238. * Gets or sets a boolean indicating if tangents must be morphed
  23239. */
  23240. enableTangentMorphing: boolean;
  23241. /**
  23242. * Gets or sets a boolean indicating if UV must be morphed
  23243. */
  23244. enableUVMorphing: boolean;
  23245. /**
  23246. * Creates a new MorphTargetManager
  23247. * @param scene defines the current scene
  23248. */
  23249. constructor(scene?: Nullable<Scene>);
  23250. /**
  23251. * Gets the unique ID of this manager
  23252. */
  23253. get uniqueId(): number;
  23254. /**
  23255. * Gets the number of vertices handled by this manager
  23256. */
  23257. get vertexCount(): number;
  23258. /**
  23259. * Gets a boolean indicating if this manager supports morphing of normals
  23260. */
  23261. get supportsNormals(): boolean;
  23262. /**
  23263. * Gets a boolean indicating if this manager supports morphing of tangents
  23264. */
  23265. get supportsTangents(): boolean;
  23266. /**
  23267. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23268. */
  23269. get supportsUVs(): boolean;
  23270. /**
  23271. * Gets the number of targets stored in this manager
  23272. */
  23273. get numTargets(): number;
  23274. /**
  23275. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23276. */
  23277. get numInfluencers(): number;
  23278. /**
  23279. * Gets the list of influences (one per target)
  23280. */
  23281. get influences(): Float32Array;
  23282. /**
  23283. * Gets the active target at specified index. An active target is a target with an influence > 0
  23284. * @param index defines the index to check
  23285. * @returns the requested target
  23286. */
  23287. getActiveTarget(index: number): MorphTarget;
  23288. /**
  23289. * Gets the target at specified index
  23290. * @param index defines the index to check
  23291. * @returns the requested target
  23292. */
  23293. getTarget(index: number): MorphTarget;
  23294. /**
  23295. * Add a new target to this manager
  23296. * @param target defines the target to add
  23297. */
  23298. addTarget(target: MorphTarget): void;
  23299. /**
  23300. * Removes a target from the manager
  23301. * @param target defines the target to remove
  23302. */
  23303. removeTarget(target: MorphTarget): void;
  23304. /**
  23305. * Clone the current manager
  23306. * @returns a new MorphTargetManager
  23307. */
  23308. clone(): MorphTargetManager;
  23309. /**
  23310. * Serializes the current manager into a Serialization object
  23311. * @returns the serialized object
  23312. */
  23313. serialize(): any;
  23314. private _syncActiveTargets;
  23315. /**
  23316. * Syncrhonize the targets with all the meshes using this morph target manager
  23317. */
  23318. synchronize(): void;
  23319. /**
  23320. * Creates a new MorphTargetManager from serialized data
  23321. * @param serializationObject defines the serialized data
  23322. * @param scene defines the hosting scene
  23323. * @returns the new MorphTargetManager
  23324. */
  23325. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23326. }
  23327. }
  23328. declare module BABYLON {
  23329. /**
  23330. * Class used to represent a specific level of detail of a mesh
  23331. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23332. */
  23333. export class MeshLODLevel {
  23334. /** Defines the distance where this level should start being displayed */
  23335. distance: number;
  23336. /** Defines the mesh to use to render this level */
  23337. mesh: Nullable<Mesh>;
  23338. /**
  23339. * Creates a new LOD level
  23340. * @param distance defines the distance where this level should star being displayed
  23341. * @param mesh defines the mesh to use to render this level
  23342. */
  23343. constructor(
  23344. /** Defines the distance where this level should start being displayed */
  23345. distance: number,
  23346. /** Defines the mesh to use to render this level */
  23347. mesh: Nullable<Mesh>);
  23348. }
  23349. }
  23350. declare module BABYLON {
  23351. /**
  23352. * Mesh representing the gorund
  23353. */
  23354. export class GroundMesh extends Mesh {
  23355. /** If octree should be generated */
  23356. generateOctree: boolean;
  23357. private _heightQuads;
  23358. /** @hidden */
  23359. _subdivisionsX: number;
  23360. /** @hidden */
  23361. _subdivisionsY: number;
  23362. /** @hidden */
  23363. _width: number;
  23364. /** @hidden */
  23365. _height: number;
  23366. /** @hidden */
  23367. _minX: number;
  23368. /** @hidden */
  23369. _maxX: number;
  23370. /** @hidden */
  23371. _minZ: number;
  23372. /** @hidden */
  23373. _maxZ: number;
  23374. constructor(name: string, scene: Scene);
  23375. /**
  23376. * "GroundMesh"
  23377. * @returns "GroundMesh"
  23378. */
  23379. getClassName(): string;
  23380. /**
  23381. * The minimum of x and y subdivisions
  23382. */
  23383. get subdivisions(): number;
  23384. /**
  23385. * X subdivisions
  23386. */
  23387. get subdivisionsX(): number;
  23388. /**
  23389. * Y subdivisions
  23390. */
  23391. get subdivisionsY(): number;
  23392. /**
  23393. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23394. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23395. * @param chunksCount the number of subdivisions for x and y
  23396. * @param octreeBlocksSize (Default: 32)
  23397. */
  23398. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23399. /**
  23400. * Returns a height (y) value in the Worl system :
  23401. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23402. * @param x x coordinate
  23403. * @param z z coordinate
  23404. * @returns the ground y position if (x, z) are outside the ground surface.
  23405. */
  23406. getHeightAtCoordinates(x: number, z: number): number;
  23407. /**
  23408. * Returns a normalized vector (Vector3) orthogonal to the ground
  23409. * at the ground coordinates (x, z) expressed in the World system.
  23410. * @param x x coordinate
  23411. * @param z z coordinate
  23412. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23413. */
  23414. getNormalAtCoordinates(x: number, z: number): Vector3;
  23415. /**
  23416. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23417. * at the ground coordinates (x, z) expressed in the World system.
  23418. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23419. * @param x x coordinate
  23420. * @param z z coordinate
  23421. * @param ref vector to store the result
  23422. * @returns the GroundMesh.
  23423. */
  23424. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23425. /**
  23426. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23427. * if the ground has been updated.
  23428. * This can be used in the render loop.
  23429. * @returns the GroundMesh.
  23430. */
  23431. updateCoordinateHeights(): GroundMesh;
  23432. private _getFacetAt;
  23433. private _initHeightQuads;
  23434. private _computeHeightQuads;
  23435. /**
  23436. * Serializes this ground mesh
  23437. * @param serializationObject object to write serialization to
  23438. */
  23439. serialize(serializationObject: any): void;
  23440. /**
  23441. * Parses a serialized ground mesh
  23442. * @param parsedMesh the serialized mesh
  23443. * @param scene the scene to create the ground mesh in
  23444. * @returns the created ground mesh
  23445. */
  23446. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23447. }
  23448. }
  23449. declare module BABYLON {
  23450. /**
  23451. * Interface for Physics-Joint data
  23452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23453. */
  23454. export interface PhysicsJointData {
  23455. /**
  23456. * The main pivot of the joint
  23457. */
  23458. mainPivot?: Vector3;
  23459. /**
  23460. * The connected pivot of the joint
  23461. */
  23462. connectedPivot?: Vector3;
  23463. /**
  23464. * The main axis of the joint
  23465. */
  23466. mainAxis?: Vector3;
  23467. /**
  23468. * The connected axis of the joint
  23469. */
  23470. connectedAxis?: Vector3;
  23471. /**
  23472. * The collision of the joint
  23473. */
  23474. collision?: boolean;
  23475. /**
  23476. * Native Oimo/Cannon/Energy data
  23477. */
  23478. nativeParams?: any;
  23479. }
  23480. /**
  23481. * This is a holder class for the physics joint created by the physics plugin
  23482. * It holds a set of functions to control the underlying joint
  23483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23484. */
  23485. export class PhysicsJoint {
  23486. /**
  23487. * The type of the physics joint
  23488. */
  23489. type: number;
  23490. /**
  23491. * The data for the physics joint
  23492. */
  23493. jointData: PhysicsJointData;
  23494. private _physicsJoint;
  23495. protected _physicsPlugin: IPhysicsEnginePlugin;
  23496. /**
  23497. * Initializes the physics joint
  23498. * @param type The type of the physics joint
  23499. * @param jointData The data for the physics joint
  23500. */
  23501. constructor(
  23502. /**
  23503. * The type of the physics joint
  23504. */
  23505. type: number,
  23506. /**
  23507. * The data for the physics joint
  23508. */
  23509. jointData: PhysicsJointData);
  23510. /**
  23511. * Gets the physics joint
  23512. */
  23513. get physicsJoint(): any;
  23514. /**
  23515. * Sets the physics joint
  23516. */
  23517. set physicsJoint(newJoint: any);
  23518. /**
  23519. * Sets the physics plugin
  23520. */
  23521. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23522. /**
  23523. * Execute a function that is physics-plugin specific.
  23524. * @param {Function} func the function that will be executed.
  23525. * It accepts two parameters: the physics world and the physics joint
  23526. */
  23527. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23528. /**
  23529. * Distance-Joint type
  23530. */
  23531. static DistanceJoint: number;
  23532. /**
  23533. * Hinge-Joint type
  23534. */
  23535. static HingeJoint: number;
  23536. /**
  23537. * Ball-and-Socket joint type
  23538. */
  23539. static BallAndSocketJoint: number;
  23540. /**
  23541. * Wheel-Joint type
  23542. */
  23543. static WheelJoint: number;
  23544. /**
  23545. * Slider-Joint type
  23546. */
  23547. static SliderJoint: number;
  23548. /**
  23549. * Prismatic-Joint type
  23550. */
  23551. static PrismaticJoint: number;
  23552. /**
  23553. * Universal-Joint type
  23554. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23555. */
  23556. static UniversalJoint: number;
  23557. /**
  23558. * Hinge-Joint 2 type
  23559. */
  23560. static Hinge2Joint: number;
  23561. /**
  23562. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23563. */
  23564. static PointToPointJoint: number;
  23565. /**
  23566. * Spring-Joint type
  23567. */
  23568. static SpringJoint: number;
  23569. /**
  23570. * Lock-Joint type
  23571. */
  23572. static LockJoint: number;
  23573. }
  23574. /**
  23575. * A class representing a physics distance joint
  23576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23577. */
  23578. export class DistanceJoint extends PhysicsJoint {
  23579. /**
  23580. *
  23581. * @param jointData The data for the Distance-Joint
  23582. */
  23583. constructor(jointData: DistanceJointData);
  23584. /**
  23585. * Update the predefined distance.
  23586. * @param maxDistance The maximum preferred distance
  23587. * @param minDistance The minimum preferred distance
  23588. */
  23589. updateDistance(maxDistance: number, minDistance?: number): void;
  23590. }
  23591. /**
  23592. * Represents a Motor-Enabled Joint
  23593. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23594. */
  23595. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23596. /**
  23597. * Initializes the Motor-Enabled Joint
  23598. * @param type The type of the joint
  23599. * @param jointData The physica joint data for the joint
  23600. */
  23601. constructor(type: number, jointData: PhysicsJointData);
  23602. /**
  23603. * Set the motor values.
  23604. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23605. * @param force the force to apply
  23606. * @param maxForce max force for this motor.
  23607. */
  23608. setMotor(force?: number, maxForce?: number): void;
  23609. /**
  23610. * Set the motor's limits.
  23611. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23612. * @param upperLimit The upper limit of the motor
  23613. * @param lowerLimit The lower limit of the motor
  23614. */
  23615. setLimit(upperLimit: number, lowerLimit?: number): void;
  23616. }
  23617. /**
  23618. * This class represents a single physics Hinge-Joint
  23619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23620. */
  23621. export class HingeJoint extends MotorEnabledJoint {
  23622. /**
  23623. * Initializes the Hinge-Joint
  23624. * @param jointData The joint data for the Hinge-Joint
  23625. */
  23626. constructor(jointData: PhysicsJointData);
  23627. /**
  23628. * Set the motor values.
  23629. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23630. * @param {number} force the force to apply
  23631. * @param {number} maxForce max force for this motor.
  23632. */
  23633. setMotor(force?: number, maxForce?: number): void;
  23634. /**
  23635. * Set the motor's limits.
  23636. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23637. * @param upperLimit The upper limit of the motor
  23638. * @param lowerLimit The lower limit of the motor
  23639. */
  23640. setLimit(upperLimit: number, lowerLimit?: number): void;
  23641. }
  23642. /**
  23643. * This class represents a dual hinge physics joint (same as wheel joint)
  23644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23645. */
  23646. export class Hinge2Joint extends MotorEnabledJoint {
  23647. /**
  23648. * Initializes the Hinge2-Joint
  23649. * @param jointData The joint data for the Hinge2-Joint
  23650. */
  23651. constructor(jointData: PhysicsJointData);
  23652. /**
  23653. * Set the motor values.
  23654. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23655. * @param {number} targetSpeed the speed the motor is to reach
  23656. * @param {number} maxForce max force for this motor.
  23657. * @param {motorIndex} the motor's index, 0 or 1.
  23658. */
  23659. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23660. /**
  23661. * Set the motor limits.
  23662. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23663. * @param {number} upperLimit the upper limit
  23664. * @param {number} lowerLimit lower limit
  23665. * @param {motorIndex} the motor's index, 0 or 1.
  23666. */
  23667. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23668. }
  23669. /**
  23670. * Interface for a motor enabled joint
  23671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23672. */
  23673. export interface IMotorEnabledJoint {
  23674. /**
  23675. * Physics joint
  23676. */
  23677. physicsJoint: any;
  23678. /**
  23679. * Sets the motor of the motor-enabled joint
  23680. * @param force The force of the motor
  23681. * @param maxForce The maximum force of the motor
  23682. * @param motorIndex The index of the motor
  23683. */
  23684. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23685. /**
  23686. * Sets the limit of the motor
  23687. * @param upperLimit The upper limit of the motor
  23688. * @param lowerLimit The lower limit of the motor
  23689. * @param motorIndex The index of the motor
  23690. */
  23691. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23692. }
  23693. /**
  23694. * Joint data for a Distance-Joint
  23695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23696. */
  23697. export interface DistanceJointData extends PhysicsJointData {
  23698. /**
  23699. * Max distance the 2 joint objects can be apart
  23700. */
  23701. maxDistance: number;
  23702. }
  23703. /**
  23704. * Joint data from a spring joint
  23705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23706. */
  23707. export interface SpringJointData extends PhysicsJointData {
  23708. /**
  23709. * Length of the spring
  23710. */
  23711. length: number;
  23712. /**
  23713. * Stiffness of the spring
  23714. */
  23715. stiffness: number;
  23716. /**
  23717. * Damping of the spring
  23718. */
  23719. damping: number;
  23720. /** this callback will be called when applying the force to the impostors. */
  23721. forceApplicationCallback: () => void;
  23722. }
  23723. }
  23724. declare module BABYLON {
  23725. /**
  23726. * Holds the data for the raycast result
  23727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23728. */
  23729. export class PhysicsRaycastResult {
  23730. private _hasHit;
  23731. private _hitDistance;
  23732. private _hitNormalWorld;
  23733. private _hitPointWorld;
  23734. private _rayFromWorld;
  23735. private _rayToWorld;
  23736. /**
  23737. * Gets if there was a hit
  23738. */
  23739. get hasHit(): boolean;
  23740. /**
  23741. * Gets the distance from the hit
  23742. */
  23743. get hitDistance(): number;
  23744. /**
  23745. * Gets the hit normal/direction in the world
  23746. */
  23747. get hitNormalWorld(): Vector3;
  23748. /**
  23749. * Gets the hit point in the world
  23750. */
  23751. get hitPointWorld(): Vector3;
  23752. /**
  23753. * Gets the ray "start point" of the ray in the world
  23754. */
  23755. get rayFromWorld(): Vector3;
  23756. /**
  23757. * Gets the ray "end point" of the ray in the world
  23758. */
  23759. get rayToWorld(): Vector3;
  23760. /**
  23761. * Sets the hit data (normal & point in world space)
  23762. * @param hitNormalWorld defines the normal in world space
  23763. * @param hitPointWorld defines the point in world space
  23764. */
  23765. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23766. /**
  23767. * Sets the distance from the start point to the hit point
  23768. * @param distance
  23769. */
  23770. setHitDistance(distance: number): void;
  23771. /**
  23772. * Calculates the distance manually
  23773. */
  23774. calculateHitDistance(): void;
  23775. /**
  23776. * Resets all the values to default
  23777. * @param from The from point on world space
  23778. * @param to The to point on world space
  23779. */
  23780. reset(from?: Vector3, to?: Vector3): void;
  23781. }
  23782. /**
  23783. * Interface for the size containing width and height
  23784. */
  23785. interface IXYZ {
  23786. /**
  23787. * X
  23788. */
  23789. x: number;
  23790. /**
  23791. * Y
  23792. */
  23793. y: number;
  23794. /**
  23795. * Z
  23796. */
  23797. z: number;
  23798. }
  23799. }
  23800. declare module BABYLON {
  23801. /**
  23802. * Interface used to describe a physics joint
  23803. */
  23804. export interface PhysicsImpostorJoint {
  23805. /** Defines the main impostor to which the joint is linked */
  23806. mainImpostor: PhysicsImpostor;
  23807. /** Defines the impostor that is connected to the main impostor using this joint */
  23808. connectedImpostor: PhysicsImpostor;
  23809. /** Defines the joint itself */
  23810. joint: PhysicsJoint;
  23811. }
  23812. /** @hidden */
  23813. export interface IPhysicsEnginePlugin {
  23814. world: any;
  23815. name: string;
  23816. setGravity(gravity: Vector3): void;
  23817. setTimeStep(timeStep: number): void;
  23818. getTimeStep(): number;
  23819. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23820. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23821. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23822. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23823. removePhysicsBody(impostor: PhysicsImpostor): void;
  23824. generateJoint(joint: PhysicsImpostorJoint): void;
  23825. removeJoint(joint: PhysicsImpostorJoint): void;
  23826. isSupported(): boolean;
  23827. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23828. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23829. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23830. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23831. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23832. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23833. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23834. getBodyMass(impostor: PhysicsImpostor): number;
  23835. getBodyFriction(impostor: PhysicsImpostor): number;
  23836. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23837. getBodyRestitution(impostor: PhysicsImpostor): number;
  23838. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23839. getBodyPressure?(impostor: PhysicsImpostor): number;
  23840. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23841. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23842. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23843. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23844. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23845. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23846. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23847. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23848. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23849. sleepBody(impostor: PhysicsImpostor): void;
  23850. wakeUpBody(impostor: PhysicsImpostor): void;
  23851. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23852. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23853. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23854. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23855. getRadius(impostor: PhysicsImpostor): number;
  23856. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23857. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23858. dispose(): void;
  23859. }
  23860. /**
  23861. * Interface used to define a physics engine
  23862. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23863. */
  23864. export interface IPhysicsEngine {
  23865. /**
  23866. * Gets the gravity vector used by the simulation
  23867. */
  23868. gravity: Vector3;
  23869. /**
  23870. * Sets the gravity vector used by the simulation
  23871. * @param gravity defines the gravity vector to use
  23872. */
  23873. setGravity(gravity: Vector3): void;
  23874. /**
  23875. * Set the time step of the physics engine.
  23876. * Default is 1/60.
  23877. * To slow it down, enter 1/600 for example.
  23878. * To speed it up, 1/30
  23879. * @param newTimeStep the new timestep to apply to this world.
  23880. */
  23881. setTimeStep(newTimeStep: number): void;
  23882. /**
  23883. * Get the time step of the physics engine.
  23884. * @returns the current time step
  23885. */
  23886. getTimeStep(): number;
  23887. /**
  23888. * Set the sub time step of the physics engine.
  23889. * Default is 0 meaning there is no sub steps
  23890. * To increase physics resolution precision, set a small value (like 1 ms)
  23891. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23892. */
  23893. setSubTimeStep(subTimeStep: number): void;
  23894. /**
  23895. * Get the sub time step of the physics engine.
  23896. * @returns the current sub time step
  23897. */
  23898. getSubTimeStep(): number;
  23899. /**
  23900. * Release all resources
  23901. */
  23902. dispose(): void;
  23903. /**
  23904. * Gets the name of the current physics plugin
  23905. * @returns the name of the plugin
  23906. */
  23907. getPhysicsPluginName(): string;
  23908. /**
  23909. * Adding a new impostor for the impostor tracking.
  23910. * This will be done by the impostor itself.
  23911. * @param impostor the impostor to add
  23912. */
  23913. addImpostor(impostor: PhysicsImpostor): void;
  23914. /**
  23915. * Remove an impostor from the engine.
  23916. * This impostor and its mesh will not longer be updated by the physics engine.
  23917. * @param impostor the impostor to remove
  23918. */
  23919. removeImpostor(impostor: PhysicsImpostor): void;
  23920. /**
  23921. * Add a joint to the physics engine
  23922. * @param mainImpostor defines the main impostor to which the joint is added.
  23923. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23924. * @param joint defines the joint that will connect both impostors.
  23925. */
  23926. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23927. /**
  23928. * Removes a joint from the simulation
  23929. * @param mainImpostor defines the impostor used with the joint
  23930. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23931. * @param joint defines the joint to remove
  23932. */
  23933. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23934. /**
  23935. * Gets the current plugin used to run the simulation
  23936. * @returns current plugin
  23937. */
  23938. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23939. /**
  23940. * Gets the list of physic impostors
  23941. * @returns an array of PhysicsImpostor
  23942. */
  23943. getImpostors(): Array<PhysicsImpostor>;
  23944. /**
  23945. * Gets the impostor for a physics enabled object
  23946. * @param object defines the object impersonated by the impostor
  23947. * @returns the PhysicsImpostor or null if not found
  23948. */
  23949. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23950. /**
  23951. * Gets the impostor for a physics body object
  23952. * @param body defines physics body used by the impostor
  23953. * @returns the PhysicsImpostor or null if not found
  23954. */
  23955. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23956. /**
  23957. * Does a raycast in the physics world
  23958. * @param from when should the ray start?
  23959. * @param to when should the ray end?
  23960. * @returns PhysicsRaycastResult
  23961. */
  23962. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23963. /**
  23964. * Called by the scene. No need to call it.
  23965. * @param delta defines the timespam between frames
  23966. */
  23967. _step(delta: number): void;
  23968. }
  23969. }
  23970. declare module BABYLON {
  23971. /**
  23972. * The interface for the physics imposter parameters
  23973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23974. */
  23975. export interface PhysicsImpostorParameters {
  23976. /**
  23977. * The mass of the physics imposter
  23978. */
  23979. mass: number;
  23980. /**
  23981. * The friction of the physics imposter
  23982. */
  23983. friction?: number;
  23984. /**
  23985. * The coefficient of restitution of the physics imposter
  23986. */
  23987. restitution?: number;
  23988. /**
  23989. * The native options of the physics imposter
  23990. */
  23991. nativeOptions?: any;
  23992. /**
  23993. * Specifies if the parent should be ignored
  23994. */
  23995. ignoreParent?: boolean;
  23996. /**
  23997. * Specifies if bi-directional transformations should be disabled
  23998. */
  23999. disableBidirectionalTransformation?: boolean;
  24000. /**
  24001. * The pressure inside the physics imposter, soft object only
  24002. */
  24003. pressure?: number;
  24004. /**
  24005. * The stiffness the physics imposter, soft object only
  24006. */
  24007. stiffness?: number;
  24008. /**
  24009. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24010. */
  24011. velocityIterations?: number;
  24012. /**
  24013. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24014. */
  24015. positionIterations?: number;
  24016. /**
  24017. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24018. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24019. * Add to fix multiple points
  24020. */
  24021. fixedPoints?: number;
  24022. /**
  24023. * The collision margin around a soft object
  24024. */
  24025. margin?: number;
  24026. /**
  24027. * The collision margin around a soft object
  24028. */
  24029. damping?: number;
  24030. /**
  24031. * The path for a rope based on an extrusion
  24032. */
  24033. path?: any;
  24034. /**
  24035. * The shape of an extrusion used for a rope based on an extrusion
  24036. */
  24037. shape?: any;
  24038. }
  24039. /**
  24040. * Interface for a physics-enabled object
  24041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24042. */
  24043. export interface IPhysicsEnabledObject {
  24044. /**
  24045. * The position of the physics-enabled object
  24046. */
  24047. position: Vector3;
  24048. /**
  24049. * The rotation of the physics-enabled object
  24050. */
  24051. rotationQuaternion: Nullable<Quaternion>;
  24052. /**
  24053. * The scale of the physics-enabled object
  24054. */
  24055. scaling: Vector3;
  24056. /**
  24057. * The rotation of the physics-enabled object
  24058. */
  24059. rotation?: Vector3;
  24060. /**
  24061. * The parent of the physics-enabled object
  24062. */
  24063. parent?: any;
  24064. /**
  24065. * The bounding info of the physics-enabled object
  24066. * @returns The bounding info of the physics-enabled object
  24067. */
  24068. getBoundingInfo(): BoundingInfo;
  24069. /**
  24070. * Computes the world matrix
  24071. * @param force Specifies if the world matrix should be computed by force
  24072. * @returns A world matrix
  24073. */
  24074. computeWorldMatrix(force: boolean): Matrix;
  24075. /**
  24076. * Gets the world matrix
  24077. * @returns A world matrix
  24078. */
  24079. getWorldMatrix?(): Matrix;
  24080. /**
  24081. * Gets the child meshes
  24082. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24083. * @returns An array of abstract meshes
  24084. */
  24085. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24086. /**
  24087. * Gets the vertex data
  24088. * @param kind The type of vertex data
  24089. * @returns A nullable array of numbers, or a float32 array
  24090. */
  24091. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24092. /**
  24093. * Gets the indices from the mesh
  24094. * @returns A nullable array of index arrays
  24095. */
  24096. getIndices?(): Nullable<IndicesArray>;
  24097. /**
  24098. * Gets the scene from the mesh
  24099. * @returns the indices array or null
  24100. */
  24101. getScene?(): Scene;
  24102. /**
  24103. * Gets the absolute position from the mesh
  24104. * @returns the absolute position
  24105. */
  24106. getAbsolutePosition(): Vector3;
  24107. /**
  24108. * Gets the absolute pivot point from the mesh
  24109. * @returns the absolute pivot point
  24110. */
  24111. getAbsolutePivotPoint(): Vector3;
  24112. /**
  24113. * Rotates the mesh
  24114. * @param axis The axis of rotation
  24115. * @param amount The amount of rotation
  24116. * @param space The space of the rotation
  24117. * @returns The rotation transform node
  24118. */
  24119. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24120. /**
  24121. * Translates the mesh
  24122. * @param axis The axis of translation
  24123. * @param distance The distance of translation
  24124. * @param space The space of the translation
  24125. * @returns The transform node
  24126. */
  24127. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24128. /**
  24129. * Sets the absolute position of the mesh
  24130. * @param absolutePosition The absolute position of the mesh
  24131. * @returns The transform node
  24132. */
  24133. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24134. /**
  24135. * Gets the class name of the mesh
  24136. * @returns The class name
  24137. */
  24138. getClassName(): string;
  24139. }
  24140. /**
  24141. * Represents a physics imposter
  24142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24143. */
  24144. export class PhysicsImpostor {
  24145. /**
  24146. * The physics-enabled object used as the physics imposter
  24147. */
  24148. object: IPhysicsEnabledObject;
  24149. /**
  24150. * The type of the physics imposter
  24151. */
  24152. type: number;
  24153. private _options;
  24154. private _scene?;
  24155. /**
  24156. * The default object size of the imposter
  24157. */
  24158. static DEFAULT_OBJECT_SIZE: Vector3;
  24159. /**
  24160. * The identity quaternion of the imposter
  24161. */
  24162. static IDENTITY_QUATERNION: Quaternion;
  24163. /** @hidden */
  24164. _pluginData: any;
  24165. private _physicsEngine;
  24166. private _physicsBody;
  24167. private _bodyUpdateRequired;
  24168. private _onBeforePhysicsStepCallbacks;
  24169. private _onAfterPhysicsStepCallbacks;
  24170. /** @hidden */
  24171. _onPhysicsCollideCallbacks: Array<{
  24172. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24173. otherImpostors: Array<PhysicsImpostor>;
  24174. }>;
  24175. private _deltaPosition;
  24176. private _deltaRotation;
  24177. private _deltaRotationConjugated;
  24178. /** @hidden */
  24179. _isFromLine: boolean;
  24180. private _parent;
  24181. private _isDisposed;
  24182. private static _tmpVecs;
  24183. private static _tmpQuat;
  24184. /**
  24185. * Specifies if the physics imposter is disposed
  24186. */
  24187. get isDisposed(): boolean;
  24188. /**
  24189. * Gets the mass of the physics imposter
  24190. */
  24191. get mass(): number;
  24192. set mass(value: number);
  24193. /**
  24194. * Gets the coefficient of friction
  24195. */
  24196. get friction(): number;
  24197. /**
  24198. * Sets the coefficient of friction
  24199. */
  24200. set friction(value: number);
  24201. /**
  24202. * Gets the coefficient of restitution
  24203. */
  24204. get restitution(): number;
  24205. /**
  24206. * Sets the coefficient of restitution
  24207. */
  24208. set restitution(value: number);
  24209. /**
  24210. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24211. */
  24212. get pressure(): number;
  24213. /**
  24214. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24215. */
  24216. set pressure(value: number);
  24217. /**
  24218. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24219. */
  24220. get stiffness(): number;
  24221. /**
  24222. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24223. */
  24224. set stiffness(value: number);
  24225. /**
  24226. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24227. */
  24228. get velocityIterations(): number;
  24229. /**
  24230. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24231. */
  24232. set velocityIterations(value: number);
  24233. /**
  24234. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24235. */
  24236. get positionIterations(): number;
  24237. /**
  24238. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24239. */
  24240. set positionIterations(value: number);
  24241. /**
  24242. * The unique id of the physics imposter
  24243. * set by the physics engine when adding this impostor to the array
  24244. */
  24245. uniqueId: number;
  24246. /**
  24247. * @hidden
  24248. */
  24249. soft: boolean;
  24250. /**
  24251. * @hidden
  24252. */
  24253. segments: number;
  24254. private _joints;
  24255. /**
  24256. * Initializes the physics imposter
  24257. * @param object The physics-enabled object used as the physics imposter
  24258. * @param type The type of the physics imposter
  24259. * @param _options The options for the physics imposter
  24260. * @param _scene The Babylon scene
  24261. */
  24262. constructor(
  24263. /**
  24264. * The physics-enabled object used as the physics imposter
  24265. */
  24266. object: IPhysicsEnabledObject,
  24267. /**
  24268. * The type of the physics imposter
  24269. */
  24270. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24271. /**
  24272. * This function will completly initialize this impostor.
  24273. * It will create a new body - but only if this mesh has no parent.
  24274. * If it has, this impostor will not be used other than to define the impostor
  24275. * of the child mesh.
  24276. * @hidden
  24277. */
  24278. _init(): void;
  24279. private _getPhysicsParent;
  24280. /**
  24281. * Should a new body be generated.
  24282. * @returns boolean specifying if body initialization is required
  24283. */
  24284. isBodyInitRequired(): boolean;
  24285. /**
  24286. * Sets the updated scaling
  24287. * @param updated Specifies if the scaling is updated
  24288. */
  24289. setScalingUpdated(): void;
  24290. /**
  24291. * Force a regeneration of this or the parent's impostor's body.
  24292. * Use under cautious - This will remove all joints already implemented.
  24293. */
  24294. forceUpdate(): void;
  24295. /**
  24296. * Gets the body that holds this impostor. Either its own, or its parent.
  24297. */
  24298. get physicsBody(): any;
  24299. /**
  24300. * Get the parent of the physics imposter
  24301. * @returns Physics imposter or null
  24302. */
  24303. get parent(): Nullable<PhysicsImpostor>;
  24304. /**
  24305. * Sets the parent of the physics imposter
  24306. */
  24307. set parent(value: Nullable<PhysicsImpostor>);
  24308. /**
  24309. * Set the physics body. Used mainly by the physics engine/plugin
  24310. */
  24311. set physicsBody(physicsBody: any);
  24312. /**
  24313. * Resets the update flags
  24314. */
  24315. resetUpdateFlags(): void;
  24316. /**
  24317. * Gets the object extend size
  24318. * @returns the object extend size
  24319. */
  24320. getObjectExtendSize(): Vector3;
  24321. /**
  24322. * Gets the object center
  24323. * @returns The object center
  24324. */
  24325. getObjectCenter(): Vector3;
  24326. /**
  24327. * Get a specific parameter from the options parameters
  24328. * @param paramName The object parameter name
  24329. * @returns The object parameter
  24330. */
  24331. getParam(paramName: string): any;
  24332. /**
  24333. * Sets a specific parameter in the options given to the physics plugin
  24334. * @param paramName The parameter name
  24335. * @param value The value of the parameter
  24336. */
  24337. setParam(paramName: string, value: number): void;
  24338. /**
  24339. * Specifically change the body's mass option. Won't recreate the physics body object
  24340. * @param mass The mass of the physics imposter
  24341. */
  24342. setMass(mass: number): void;
  24343. /**
  24344. * Gets the linear velocity
  24345. * @returns linear velocity or null
  24346. */
  24347. getLinearVelocity(): Nullable<Vector3>;
  24348. /**
  24349. * Sets the linear velocity
  24350. * @param velocity linear velocity or null
  24351. */
  24352. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24353. /**
  24354. * Gets the angular velocity
  24355. * @returns angular velocity or null
  24356. */
  24357. getAngularVelocity(): Nullable<Vector3>;
  24358. /**
  24359. * Sets the angular velocity
  24360. * @param velocity The velocity or null
  24361. */
  24362. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24363. /**
  24364. * Execute a function with the physics plugin native code
  24365. * Provide a function the will have two variables - the world object and the physics body object
  24366. * @param func The function to execute with the physics plugin native code
  24367. */
  24368. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24369. /**
  24370. * Register a function that will be executed before the physics world is stepping forward
  24371. * @param func The function to execute before the physics world is stepped forward
  24372. */
  24373. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24374. /**
  24375. * Unregister a function that will be executed before the physics world is stepping forward
  24376. * @param func The function to execute before the physics world is stepped forward
  24377. */
  24378. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24379. /**
  24380. * Register a function that will be executed after the physics step
  24381. * @param func The function to execute after physics step
  24382. */
  24383. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24384. /**
  24385. * Unregisters a function that will be executed after the physics step
  24386. * @param func The function to execute after physics step
  24387. */
  24388. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24389. /**
  24390. * register a function that will be executed when this impostor collides against a different body
  24391. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24392. * @param func Callback that is executed on collision
  24393. */
  24394. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24395. /**
  24396. * Unregisters the physics imposter on contact
  24397. * @param collideAgainst The physics object to collide against
  24398. * @param func Callback to execute on collision
  24399. */
  24400. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24401. private _tmpQuat;
  24402. private _tmpQuat2;
  24403. /**
  24404. * Get the parent rotation
  24405. * @returns The parent rotation
  24406. */
  24407. getParentsRotation(): Quaternion;
  24408. /**
  24409. * this function is executed by the physics engine.
  24410. */
  24411. beforeStep: () => void;
  24412. /**
  24413. * this function is executed by the physics engine
  24414. */
  24415. afterStep: () => void;
  24416. /**
  24417. * Legacy collision detection event support
  24418. */
  24419. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24420. /**
  24421. * event and body object due to cannon's event-based architecture.
  24422. */
  24423. onCollide: (e: {
  24424. body: any;
  24425. }) => void;
  24426. /**
  24427. * Apply a force
  24428. * @param force The force to apply
  24429. * @param contactPoint The contact point for the force
  24430. * @returns The physics imposter
  24431. */
  24432. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24433. /**
  24434. * Apply an impulse
  24435. * @param force The impulse force
  24436. * @param contactPoint The contact point for the impulse force
  24437. * @returns The physics imposter
  24438. */
  24439. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24440. /**
  24441. * A help function to create a joint
  24442. * @param otherImpostor A physics imposter used to create a joint
  24443. * @param jointType The type of joint
  24444. * @param jointData The data for the joint
  24445. * @returns The physics imposter
  24446. */
  24447. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24448. /**
  24449. * Add a joint to this impostor with a different impostor
  24450. * @param otherImpostor A physics imposter used to add a joint
  24451. * @param joint The joint to add
  24452. * @returns The physics imposter
  24453. */
  24454. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24455. /**
  24456. * Add an anchor to a cloth impostor
  24457. * @param otherImpostor rigid impostor to anchor to
  24458. * @param width ratio across width from 0 to 1
  24459. * @param height ratio up height from 0 to 1
  24460. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24461. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24462. * @returns impostor the soft imposter
  24463. */
  24464. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24465. /**
  24466. * Add a hook to a rope impostor
  24467. * @param otherImpostor rigid impostor to anchor to
  24468. * @param length ratio across rope from 0 to 1
  24469. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24470. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24471. * @returns impostor the rope imposter
  24472. */
  24473. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24474. /**
  24475. * Will keep this body still, in a sleep mode.
  24476. * @returns the physics imposter
  24477. */
  24478. sleep(): PhysicsImpostor;
  24479. /**
  24480. * Wake the body up.
  24481. * @returns The physics imposter
  24482. */
  24483. wakeUp(): PhysicsImpostor;
  24484. /**
  24485. * Clones the physics imposter
  24486. * @param newObject The physics imposter clones to this physics-enabled object
  24487. * @returns A nullable physics imposter
  24488. */
  24489. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24490. /**
  24491. * Disposes the physics imposter
  24492. */
  24493. dispose(): void;
  24494. /**
  24495. * Sets the delta position
  24496. * @param position The delta position amount
  24497. */
  24498. setDeltaPosition(position: Vector3): void;
  24499. /**
  24500. * Sets the delta rotation
  24501. * @param rotation The delta rotation amount
  24502. */
  24503. setDeltaRotation(rotation: Quaternion): void;
  24504. /**
  24505. * Gets the box size of the physics imposter and stores the result in the input parameter
  24506. * @param result Stores the box size
  24507. * @returns The physics imposter
  24508. */
  24509. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24510. /**
  24511. * Gets the radius of the physics imposter
  24512. * @returns Radius of the physics imposter
  24513. */
  24514. getRadius(): number;
  24515. /**
  24516. * Sync a bone with this impostor
  24517. * @param bone The bone to sync to the impostor.
  24518. * @param boneMesh The mesh that the bone is influencing.
  24519. * @param jointPivot The pivot of the joint / bone in local space.
  24520. * @param distToJoint Optional distance from the impostor to the joint.
  24521. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24522. */
  24523. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24524. /**
  24525. * Sync impostor to a bone
  24526. * @param bone The bone that the impostor will be synced to.
  24527. * @param boneMesh The mesh that the bone is influencing.
  24528. * @param jointPivot The pivot of the joint / bone in local space.
  24529. * @param distToJoint Optional distance from the impostor to the joint.
  24530. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24531. * @param boneAxis Optional vector3 axis the bone is aligned with
  24532. */
  24533. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24534. /**
  24535. * No-Imposter type
  24536. */
  24537. static NoImpostor: number;
  24538. /**
  24539. * Sphere-Imposter type
  24540. */
  24541. static SphereImpostor: number;
  24542. /**
  24543. * Box-Imposter type
  24544. */
  24545. static BoxImpostor: number;
  24546. /**
  24547. * Plane-Imposter type
  24548. */
  24549. static PlaneImpostor: number;
  24550. /**
  24551. * Mesh-imposter type
  24552. */
  24553. static MeshImpostor: number;
  24554. /**
  24555. * Capsule-Impostor type (Ammo.js plugin only)
  24556. */
  24557. static CapsuleImpostor: number;
  24558. /**
  24559. * Cylinder-Imposter type
  24560. */
  24561. static CylinderImpostor: number;
  24562. /**
  24563. * Particle-Imposter type
  24564. */
  24565. static ParticleImpostor: number;
  24566. /**
  24567. * Heightmap-Imposter type
  24568. */
  24569. static HeightmapImpostor: number;
  24570. /**
  24571. * ConvexHull-Impostor type (Ammo.js plugin only)
  24572. */
  24573. static ConvexHullImpostor: number;
  24574. /**
  24575. * Custom-Imposter type (Ammo.js plugin only)
  24576. */
  24577. static CustomImpostor: number;
  24578. /**
  24579. * Rope-Imposter type
  24580. */
  24581. static RopeImpostor: number;
  24582. /**
  24583. * Cloth-Imposter type
  24584. */
  24585. static ClothImpostor: number;
  24586. /**
  24587. * Softbody-Imposter type
  24588. */
  24589. static SoftbodyImpostor: number;
  24590. }
  24591. }
  24592. declare module BABYLON {
  24593. /**
  24594. * @hidden
  24595. **/
  24596. export class _CreationDataStorage {
  24597. closePath?: boolean;
  24598. closeArray?: boolean;
  24599. idx: number[];
  24600. dashSize: number;
  24601. gapSize: number;
  24602. path3D: Path3D;
  24603. pathArray: Vector3[][];
  24604. arc: number;
  24605. radius: number;
  24606. cap: number;
  24607. tessellation: number;
  24608. }
  24609. /**
  24610. * @hidden
  24611. **/
  24612. class _InstanceDataStorage {
  24613. visibleInstances: any;
  24614. batchCache: _InstancesBatch;
  24615. instancesBufferSize: number;
  24616. instancesBuffer: Nullable<Buffer>;
  24617. instancesData: Float32Array;
  24618. overridenInstanceCount: number;
  24619. isFrozen: boolean;
  24620. previousBatch: Nullable<_InstancesBatch>;
  24621. hardwareInstancedRendering: boolean;
  24622. sideOrientation: number;
  24623. manualUpdate: boolean;
  24624. }
  24625. /**
  24626. * @hidden
  24627. **/
  24628. export class _InstancesBatch {
  24629. mustReturn: boolean;
  24630. visibleInstances: Nullable<InstancedMesh[]>[];
  24631. renderSelf: boolean[];
  24632. hardwareInstancedRendering: boolean[];
  24633. }
  24634. /**
  24635. * Class used to represent renderable models
  24636. */
  24637. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24638. /**
  24639. * Mesh side orientation : usually the external or front surface
  24640. */
  24641. static readonly FRONTSIDE: number;
  24642. /**
  24643. * Mesh side orientation : usually the internal or back surface
  24644. */
  24645. static readonly BACKSIDE: number;
  24646. /**
  24647. * Mesh side orientation : both internal and external or front and back surfaces
  24648. */
  24649. static readonly DOUBLESIDE: number;
  24650. /**
  24651. * Mesh side orientation : by default, `FRONTSIDE`
  24652. */
  24653. static readonly DEFAULTSIDE: number;
  24654. /**
  24655. * Mesh cap setting : no cap
  24656. */
  24657. static readonly NO_CAP: number;
  24658. /**
  24659. * Mesh cap setting : one cap at the beginning of the mesh
  24660. */
  24661. static readonly CAP_START: number;
  24662. /**
  24663. * Mesh cap setting : one cap at the end of the mesh
  24664. */
  24665. static readonly CAP_END: number;
  24666. /**
  24667. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24668. */
  24669. static readonly CAP_ALL: number;
  24670. /**
  24671. * Mesh pattern setting : no flip or rotate
  24672. */
  24673. static readonly NO_FLIP: number;
  24674. /**
  24675. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24676. */
  24677. static readonly FLIP_TILE: number;
  24678. /**
  24679. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24680. */
  24681. static readonly ROTATE_TILE: number;
  24682. /**
  24683. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24684. */
  24685. static readonly FLIP_ROW: number;
  24686. /**
  24687. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24688. */
  24689. static readonly ROTATE_ROW: number;
  24690. /**
  24691. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24692. */
  24693. static readonly FLIP_N_ROTATE_TILE: number;
  24694. /**
  24695. * Mesh pattern setting : rotate pattern and rotate
  24696. */
  24697. static readonly FLIP_N_ROTATE_ROW: number;
  24698. /**
  24699. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24700. */
  24701. static readonly CENTER: number;
  24702. /**
  24703. * Mesh tile positioning : part tiles on left
  24704. */
  24705. static readonly LEFT: number;
  24706. /**
  24707. * Mesh tile positioning : part tiles on right
  24708. */
  24709. static readonly RIGHT: number;
  24710. /**
  24711. * Mesh tile positioning : part tiles on top
  24712. */
  24713. static readonly TOP: number;
  24714. /**
  24715. * Mesh tile positioning : part tiles on bottom
  24716. */
  24717. static readonly BOTTOM: number;
  24718. /**
  24719. * Gets the default side orientation.
  24720. * @param orientation the orientation to value to attempt to get
  24721. * @returns the default orientation
  24722. * @hidden
  24723. */
  24724. static _GetDefaultSideOrientation(orientation?: number): number;
  24725. private _internalMeshDataInfo;
  24726. /**
  24727. * An event triggered before rendering the mesh
  24728. */
  24729. get onBeforeRenderObservable(): Observable<Mesh>;
  24730. /**
  24731. * An event triggered before binding the mesh
  24732. */
  24733. get onBeforeBindObservable(): Observable<Mesh>;
  24734. /**
  24735. * An event triggered after rendering the mesh
  24736. */
  24737. get onAfterRenderObservable(): Observable<Mesh>;
  24738. /**
  24739. * An event triggered before drawing the mesh
  24740. */
  24741. get onBeforeDrawObservable(): Observable<Mesh>;
  24742. private _onBeforeDrawObserver;
  24743. /**
  24744. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24745. */
  24746. set onBeforeDraw(callback: () => void);
  24747. get hasInstances(): boolean;
  24748. /**
  24749. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24750. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24751. */
  24752. delayLoadState: number;
  24753. /**
  24754. * Gets the list of instances created from this mesh
  24755. * it is not supposed to be modified manually.
  24756. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24757. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24758. */
  24759. instances: InstancedMesh[];
  24760. /**
  24761. * Gets the file containing delay loading data for this mesh
  24762. */
  24763. delayLoadingFile: string;
  24764. /** @hidden */
  24765. _binaryInfo: any;
  24766. /**
  24767. * User defined function used to change how LOD level selection is done
  24768. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24769. */
  24770. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24771. /**
  24772. * Gets or sets the morph target manager
  24773. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24774. */
  24775. get morphTargetManager(): Nullable<MorphTargetManager>;
  24776. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24777. /** @hidden */
  24778. _creationDataStorage: Nullable<_CreationDataStorage>;
  24779. /** @hidden */
  24780. _geometry: Nullable<Geometry>;
  24781. /** @hidden */
  24782. _delayInfo: Array<string>;
  24783. /** @hidden */
  24784. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24785. /** @hidden */
  24786. _instanceDataStorage: _InstanceDataStorage;
  24787. private _effectiveMaterial;
  24788. /** @hidden */
  24789. _shouldGenerateFlatShading: boolean;
  24790. /** @hidden */
  24791. _originalBuilderSideOrientation: number;
  24792. /**
  24793. * Use this property to change the original side orientation defined at construction time
  24794. */
  24795. overrideMaterialSideOrientation: Nullable<number>;
  24796. /**
  24797. * Gets the source mesh (the one used to clone this one from)
  24798. */
  24799. get source(): Nullable<Mesh>;
  24800. /**
  24801. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24802. */
  24803. get isUnIndexed(): boolean;
  24804. set isUnIndexed(value: boolean);
  24805. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24806. get worldMatrixInstancedBuffer(): Float32Array;
  24807. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24808. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24809. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24810. /**
  24811. * @constructor
  24812. * @param name The value used by scene.getMeshByName() to do a lookup.
  24813. * @param scene The scene to add this mesh to.
  24814. * @param parent The parent of this mesh, if it has one
  24815. * @param source An optional Mesh from which geometry is shared, cloned.
  24816. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24817. * When false, achieved by calling a clone(), also passing False.
  24818. * This will make creation of children, recursive.
  24819. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24820. */
  24821. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24822. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24823. doNotInstantiate: boolean;
  24824. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24825. /**
  24826. * Gets the class name
  24827. * @returns the string "Mesh".
  24828. */
  24829. getClassName(): string;
  24830. /** @hidden */
  24831. get _isMesh(): boolean;
  24832. /**
  24833. * Returns a description of this mesh
  24834. * @param fullDetails define if full details about this mesh must be used
  24835. * @returns a descriptive string representing this mesh
  24836. */
  24837. toString(fullDetails?: boolean): string;
  24838. /** @hidden */
  24839. _unBindEffect(): void;
  24840. /**
  24841. * Gets a boolean indicating if this mesh has LOD
  24842. */
  24843. get hasLODLevels(): boolean;
  24844. /**
  24845. * Gets the list of MeshLODLevel associated with the current mesh
  24846. * @returns an array of MeshLODLevel
  24847. */
  24848. getLODLevels(): MeshLODLevel[];
  24849. private _sortLODLevels;
  24850. /**
  24851. * Add a mesh as LOD level triggered at the given distance.
  24852. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24853. * @param distance The distance from the center of the object to show this level
  24854. * @param mesh The mesh to be added as LOD level (can be null)
  24855. * @return This mesh (for chaining)
  24856. */
  24857. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24858. /**
  24859. * Returns the LOD level mesh at the passed distance or null if not found.
  24860. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24861. * @param distance The distance from the center of the object to show this level
  24862. * @returns a Mesh or `null`
  24863. */
  24864. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24865. /**
  24866. * Remove a mesh from the LOD array
  24867. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24868. * @param mesh defines the mesh to be removed
  24869. * @return This mesh (for chaining)
  24870. */
  24871. removeLODLevel(mesh: Mesh): Mesh;
  24872. /**
  24873. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24874. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24875. * @param camera defines the camera to use to compute distance
  24876. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24877. * @return This mesh (for chaining)
  24878. */
  24879. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24880. /**
  24881. * Gets the mesh internal Geometry object
  24882. */
  24883. get geometry(): Nullable<Geometry>;
  24884. /**
  24885. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24886. * @returns the total number of vertices
  24887. */
  24888. getTotalVertices(): number;
  24889. /**
  24890. * Returns the content of an associated vertex buffer
  24891. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24892. * - VertexBuffer.PositionKind
  24893. * - VertexBuffer.UVKind
  24894. * - VertexBuffer.UV2Kind
  24895. * - VertexBuffer.UV3Kind
  24896. * - VertexBuffer.UV4Kind
  24897. * - VertexBuffer.UV5Kind
  24898. * - VertexBuffer.UV6Kind
  24899. * - VertexBuffer.ColorKind
  24900. * - VertexBuffer.MatricesIndicesKind
  24901. * - VertexBuffer.MatricesIndicesExtraKind
  24902. * - VertexBuffer.MatricesWeightsKind
  24903. * - VertexBuffer.MatricesWeightsExtraKind
  24904. * @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
  24905. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24906. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24907. */
  24908. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24909. /**
  24910. * Returns the mesh VertexBuffer object from the requested `kind`
  24911. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24912. * - VertexBuffer.PositionKind
  24913. * - VertexBuffer.NormalKind
  24914. * - VertexBuffer.UVKind
  24915. * - VertexBuffer.UV2Kind
  24916. * - VertexBuffer.UV3Kind
  24917. * - VertexBuffer.UV4Kind
  24918. * - VertexBuffer.UV5Kind
  24919. * - VertexBuffer.UV6Kind
  24920. * - VertexBuffer.ColorKind
  24921. * - VertexBuffer.MatricesIndicesKind
  24922. * - VertexBuffer.MatricesIndicesExtraKind
  24923. * - VertexBuffer.MatricesWeightsKind
  24924. * - VertexBuffer.MatricesWeightsExtraKind
  24925. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24926. */
  24927. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24928. /**
  24929. * Tests if a specific vertex buffer is associated with this mesh
  24930. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24931. * - VertexBuffer.PositionKind
  24932. * - VertexBuffer.NormalKind
  24933. * - VertexBuffer.UVKind
  24934. * - VertexBuffer.UV2Kind
  24935. * - VertexBuffer.UV3Kind
  24936. * - VertexBuffer.UV4Kind
  24937. * - VertexBuffer.UV5Kind
  24938. * - VertexBuffer.UV6Kind
  24939. * - VertexBuffer.ColorKind
  24940. * - VertexBuffer.MatricesIndicesKind
  24941. * - VertexBuffer.MatricesIndicesExtraKind
  24942. * - VertexBuffer.MatricesWeightsKind
  24943. * - VertexBuffer.MatricesWeightsExtraKind
  24944. * @returns a boolean
  24945. */
  24946. isVerticesDataPresent(kind: string): boolean;
  24947. /**
  24948. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24949. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24950. * - VertexBuffer.PositionKind
  24951. * - VertexBuffer.UVKind
  24952. * - VertexBuffer.UV2Kind
  24953. * - VertexBuffer.UV3Kind
  24954. * - VertexBuffer.UV4Kind
  24955. * - VertexBuffer.UV5Kind
  24956. * - VertexBuffer.UV6Kind
  24957. * - VertexBuffer.ColorKind
  24958. * - VertexBuffer.MatricesIndicesKind
  24959. * - VertexBuffer.MatricesIndicesExtraKind
  24960. * - VertexBuffer.MatricesWeightsKind
  24961. * - VertexBuffer.MatricesWeightsExtraKind
  24962. * @returns a boolean
  24963. */
  24964. isVertexBufferUpdatable(kind: string): boolean;
  24965. /**
  24966. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24967. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24968. * - VertexBuffer.PositionKind
  24969. * - VertexBuffer.NormalKind
  24970. * - VertexBuffer.UVKind
  24971. * - VertexBuffer.UV2Kind
  24972. * - VertexBuffer.UV3Kind
  24973. * - VertexBuffer.UV4Kind
  24974. * - VertexBuffer.UV5Kind
  24975. * - VertexBuffer.UV6Kind
  24976. * - VertexBuffer.ColorKind
  24977. * - VertexBuffer.MatricesIndicesKind
  24978. * - VertexBuffer.MatricesIndicesExtraKind
  24979. * - VertexBuffer.MatricesWeightsKind
  24980. * - VertexBuffer.MatricesWeightsExtraKind
  24981. * @returns an array of strings
  24982. */
  24983. getVerticesDataKinds(): string[];
  24984. /**
  24985. * Returns a positive integer : the total number of indices in this mesh geometry.
  24986. * @returns the numner of indices or zero if the mesh has no geometry.
  24987. */
  24988. getTotalIndices(): number;
  24989. /**
  24990. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24991. * @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.
  24992. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24993. * @returns the indices array or an empty array if the mesh has no geometry
  24994. */
  24995. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24996. get isBlocked(): boolean;
  24997. /**
  24998. * Determine if the current mesh is ready to be rendered
  24999. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25000. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25001. * @returns true if all associated assets are ready (material, textures, shaders)
  25002. */
  25003. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25004. /**
  25005. * 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.
  25006. */
  25007. get areNormalsFrozen(): boolean;
  25008. /**
  25009. * 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.
  25010. * @returns the current mesh
  25011. */
  25012. freezeNormals(): Mesh;
  25013. /**
  25014. * 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
  25015. * @returns the current mesh
  25016. */
  25017. unfreezeNormals(): Mesh;
  25018. /**
  25019. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25020. */
  25021. set overridenInstanceCount(count: number);
  25022. /** @hidden */
  25023. _preActivate(): Mesh;
  25024. /** @hidden */
  25025. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25026. /** @hidden */
  25027. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25028. /**
  25029. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25030. * This means the mesh underlying bounding box and sphere are recomputed.
  25031. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25032. * @returns the current mesh
  25033. */
  25034. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25035. /** @hidden */
  25036. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25037. /**
  25038. * This function will subdivide the mesh into multiple submeshes
  25039. * @param count defines the expected number of submeshes
  25040. */
  25041. subdivide(count: number): void;
  25042. /**
  25043. * Copy a FloatArray into a specific associated vertex buffer
  25044. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25045. * - VertexBuffer.PositionKind
  25046. * - VertexBuffer.UVKind
  25047. * - VertexBuffer.UV2Kind
  25048. * - VertexBuffer.UV3Kind
  25049. * - VertexBuffer.UV4Kind
  25050. * - VertexBuffer.UV5Kind
  25051. * - VertexBuffer.UV6Kind
  25052. * - VertexBuffer.ColorKind
  25053. * - VertexBuffer.MatricesIndicesKind
  25054. * - VertexBuffer.MatricesIndicesExtraKind
  25055. * - VertexBuffer.MatricesWeightsKind
  25056. * - VertexBuffer.MatricesWeightsExtraKind
  25057. * @param data defines the data source
  25058. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25059. * @param stride defines the data stride size (can be null)
  25060. * @returns the current mesh
  25061. */
  25062. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25063. /**
  25064. * Delete a vertex buffer associated with this mesh
  25065. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25066. * - VertexBuffer.PositionKind
  25067. * - VertexBuffer.UVKind
  25068. * - VertexBuffer.UV2Kind
  25069. * - VertexBuffer.UV3Kind
  25070. * - VertexBuffer.UV4Kind
  25071. * - VertexBuffer.UV5Kind
  25072. * - VertexBuffer.UV6Kind
  25073. * - VertexBuffer.ColorKind
  25074. * - VertexBuffer.MatricesIndicesKind
  25075. * - VertexBuffer.MatricesIndicesExtraKind
  25076. * - VertexBuffer.MatricesWeightsKind
  25077. * - VertexBuffer.MatricesWeightsExtraKind
  25078. */
  25079. removeVerticesData(kind: string): void;
  25080. /**
  25081. * Flags an associated vertex buffer as updatable
  25082. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25083. * - VertexBuffer.PositionKind
  25084. * - VertexBuffer.UVKind
  25085. * - VertexBuffer.UV2Kind
  25086. * - VertexBuffer.UV3Kind
  25087. * - VertexBuffer.UV4Kind
  25088. * - VertexBuffer.UV5Kind
  25089. * - VertexBuffer.UV6Kind
  25090. * - VertexBuffer.ColorKind
  25091. * - VertexBuffer.MatricesIndicesKind
  25092. * - VertexBuffer.MatricesIndicesExtraKind
  25093. * - VertexBuffer.MatricesWeightsKind
  25094. * - VertexBuffer.MatricesWeightsExtraKind
  25095. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25096. */
  25097. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25098. /**
  25099. * Sets the mesh global Vertex Buffer
  25100. * @param buffer defines the buffer to use
  25101. * @returns the current mesh
  25102. */
  25103. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25104. /**
  25105. * Update a specific associated vertex buffer
  25106. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25107. * - VertexBuffer.PositionKind
  25108. * - VertexBuffer.UVKind
  25109. * - VertexBuffer.UV2Kind
  25110. * - VertexBuffer.UV3Kind
  25111. * - VertexBuffer.UV4Kind
  25112. * - VertexBuffer.UV5Kind
  25113. * - VertexBuffer.UV6Kind
  25114. * - VertexBuffer.ColorKind
  25115. * - VertexBuffer.MatricesIndicesKind
  25116. * - VertexBuffer.MatricesIndicesExtraKind
  25117. * - VertexBuffer.MatricesWeightsKind
  25118. * - VertexBuffer.MatricesWeightsExtraKind
  25119. * @param data defines the data source
  25120. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25121. * @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)
  25122. * @returns the current mesh
  25123. */
  25124. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25125. /**
  25126. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25127. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25128. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25129. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25130. * @returns the current mesh
  25131. */
  25132. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25133. /**
  25134. * Creates a un-shared specific occurence of the geometry for the mesh.
  25135. * @returns the current mesh
  25136. */
  25137. makeGeometryUnique(): Mesh;
  25138. /**
  25139. * Set the index buffer of this mesh
  25140. * @param indices defines the source data
  25141. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25142. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25143. * @returns the current mesh
  25144. */
  25145. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25146. /**
  25147. * Update the current index buffer
  25148. * @param indices defines the source data
  25149. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25150. * @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)
  25151. * @returns the current mesh
  25152. */
  25153. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25154. /**
  25155. * Invert the geometry to move from a right handed system to a left handed one.
  25156. * @returns the current mesh
  25157. */
  25158. toLeftHanded(): Mesh;
  25159. /** @hidden */
  25160. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25161. /** @hidden */
  25162. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25163. /**
  25164. * Registers for this mesh a javascript function called just before the rendering process
  25165. * @param func defines the function to call before rendering this mesh
  25166. * @returns the current mesh
  25167. */
  25168. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25169. /**
  25170. * Disposes a previously registered javascript function called before the rendering
  25171. * @param func defines the function to remove
  25172. * @returns the current mesh
  25173. */
  25174. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25175. /**
  25176. * Registers for this mesh a javascript function called just after the rendering is complete
  25177. * @param func defines the function to call after rendering this mesh
  25178. * @returns the current mesh
  25179. */
  25180. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25181. /**
  25182. * Disposes a previously registered javascript function called after the rendering.
  25183. * @param func defines the function to remove
  25184. * @returns the current mesh
  25185. */
  25186. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25187. /** @hidden */
  25188. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25189. /** @hidden */
  25190. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25191. /** @hidden */
  25192. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25193. /** @hidden */
  25194. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25195. /** @hidden */
  25196. _rebuild(): void;
  25197. /** @hidden */
  25198. _freeze(): void;
  25199. /** @hidden */
  25200. _unFreeze(): void;
  25201. /**
  25202. * 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
  25203. * @param subMesh defines the subMesh to render
  25204. * @param enableAlphaMode defines if alpha mode can be changed
  25205. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25206. * @returns the current mesh
  25207. */
  25208. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25209. private _onBeforeDraw;
  25210. /**
  25211. * Renormalize the mesh and patch it up if there are no weights
  25212. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25213. * However in the case of zero weights then we set just a single influence to 1.
  25214. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25215. */
  25216. cleanMatrixWeights(): void;
  25217. private normalizeSkinFourWeights;
  25218. private normalizeSkinWeightsAndExtra;
  25219. /**
  25220. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25221. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25222. * the user know there was an issue with importing the mesh
  25223. * @returns a validation object with skinned, valid and report string
  25224. */
  25225. validateSkinning(): {
  25226. skinned: boolean;
  25227. valid: boolean;
  25228. report: string;
  25229. };
  25230. /** @hidden */
  25231. _checkDelayState(): Mesh;
  25232. private _queueLoad;
  25233. /**
  25234. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25235. * A mesh is in the frustum if its bounding box intersects the frustum
  25236. * @param frustumPlanes defines the frustum to test
  25237. * @returns true if the mesh is in the frustum planes
  25238. */
  25239. isInFrustum(frustumPlanes: Plane[]): boolean;
  25240. /**
  25241. * Sets the mesh material by the material or multiMaterial `id` property
  25242. * @param id is a string identifying the material or the multiMaterial
  25243. * @returns the current mesh
  25244. */
  25245. setMaterialByID(id: string): Mesh;
  25246. /**
  25247. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25248. * @returns an array of IAnimatable
  25249. */
  25250. getAnimatables(): IAnimatable[];
  25251. /**
  25252. * Modifies the mesh geometry according to the passed transformation matrix.
  25253. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25254. * The mesh normals are modified using the same transformation.
  25255. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25256. * @param transform defines the transform matrix to use
  25257. * @see http://doc.babylonjs.com/resources/baking_transformations
  25258. * @returns the current mesh
  25259. */
  25260. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25261. /**
  25262. * Modifies the mesh geometry according to its own current World Matrix.
  25263. * The mesh World Matrix is then reset.
  25264. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25265. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25266. * @see http://doc.babylonjs.com/resources/baking_transformations
  25267. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25268. * @returns the current mesh
  25269. */
  25270. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25271. /** @hidden */
  25272. get _positions(): Nullable<Vector3[]>;
  25273. /** @hidden */
  25274. _resetPointsArrayCache(): Mesh;
  25275. /** @hidden */
  25276. _generatePointsArray(): boolean;
  25277. /**
  25278. * Returns a new Mesh object generated from the current mesh properties.
  25279. * This method must not get confused with createInstance()
  25280. * @param name is a string, the name given to the new mesh
  25281. * @param newParent can be any Node object (default `null`)
  25282. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25283. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25284. * @returns a new mesh
  25285. */
  25286. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25287. /**
  25288. * Releases resources associated with this mesh.
  25289. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25290. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25291. */
  25292. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25293. /** @hidden */
  25294. _disposeInstanceSpecificData(): void;
  25295. /**
  25296. * Modifies the mesh geometry according to a displacement map.
  25297. * 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.
  25298. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25299. * @param url is a string, the URL from the image file is to be downloaded.
  25300. * @param minHeight is the lower limit of the displacement.
  25301. * @param maxHeight is the upper limit of the displacement.
  25302. * @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.
  25303. * @param uvOffset is an optional vector2 used to offset UV.
  25304. * @param uvScale is an optional vector2 used to scale UV.
  25305. * @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.
  25306. * @returns the Mesh.
  25307. */
  25308. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25309. /**
  25310. * Modifies the mesh geometry according to a displacementMap buffer.
  25311. * 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.
  25312. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25313. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25314. * @param heightMapWidth is the width of the buffer image.
  25315. * @param heightMapHeight is the height of the buffer image.
  25316. * @param minHeight is the lower limit of the displacement.
  25317. * @param maxHeight is the upper limit of the displacement.
  25318. * @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.
  25319. * @param uvOffset is an optional vector2 used to offset UV.
  25320. * @param uvScale is an optional vector2 used to scale UV.
  25321. * @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.
  25322. * @returns the Mesh.
  25323. */
  25324. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25325. /**
  25326. * Modify the mesh to get a flat shading rendering.
  25327. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25328. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25329. * @returns current mesh
  25330. */
  25331. convertToFlatShadedMesh(): Mesh;
  25332. /**
  25333. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25334. * In other words, more vertices, no more indices and a single bigger VBO.
  25335. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25336. * @returns current mesh
  25337. */
  25338. convertToUnIndexedMesh(): Mesh;
  25339. /**
  25340. * Inverses facet orientations.
  25341. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25342. * @param flipNormals will also inverts the normals
  25343. * @returns current mesh
  25344. */
  25345. flipFaces(flipNormals?: boolean): Mesh;
  25346. /**
  25347. * Increase the number of facets and hence vertices in a mesh
  25348. * Vertex normals are interpolated from existing vertex normals
  25349. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25350. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25351. */
  25352. increaseVertices(numberPerEdge: number): void;
  25353. /**
  25354. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25355. * This will undo any application of covertToFlatShadedMesh
  25356. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25357. */
  25358. forceSharedVertices(): void;
  25359. /** @hidden */
  25360. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25361. /** @hidden */
  25362. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25363. /**
  25364. * Creates a new InstancedMesh object from the mesh model.
  25365. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25366. * @param name defines the name of the new instance
  25367. * @returns a new InstancedMesh
  25368. */
  25369. createInstance(name: string): InstancedMesh;
  25370. /**
  25371. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25372. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25373. * @returns the current mesh
  25374. */
  25375. synchronizeInstances(): Mesh;
  25376. /**
  25377. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25378. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25379. * This should be used together with the simplification to avoid disappearing triangles.
  25380. * @param successCallback an optional success callback to be called after the optimization finished.
  25381. * @returns the current mesh
  25382. */
  25383. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25384. /**
  25385. * Serialize current mesh
  25386. * @param serializationObject defines the object which will receive the serialization data
  25387. */
  25388. serialize(serializationObject: any): void;
  25389. /** @hidden */
  25390. _syncGeometryWithMorphTargetManager(): void;
  25391. /** @hidden */
  25392. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25393. /**
  25394. * Returns a new Mesh object parsed from the source provided.
  25395. * @param parsedMesh is the source
  25396. * @param scene defines the hosting scene
  25397. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25398. * @returns a new Mesh
  25399. */
  25400. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25401. /**
  25402. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25403. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25404. * @param name defines the name of the mesh to create
  25405. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25406. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25407. * @param closePath creates a seam between the first and the last points of each path of the path array
  25408. * @param offset is taken in account only if the `pathArray` is containing a single path
  25409. * @param scene defines the hosting scene
  25410. * @param updatable defines if the mesh must be flagged as updatable
  25411. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25412. * @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)
  25413. * @returns a new Mesh
  25414. */
  25415. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25416. /**
  25417. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25418. * @param name defines the name of the mesh to create
  25419. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25420. * @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
  25421. * @param scene defines the hosting scene
  25422. * @param updatable defines if the mesh must be flagged as updatable
  25423. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25424. * @returns a new Mesh
  25425. */
  25426. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25427. /**
  25428. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25429. * @param name defines the name of the mesh to create
  25430. * @param size sets the size (float) of each box side (default 1)
  25431. * @param scene defines the hosting scene
  25432. * @param updatable defines if the mesh must be flagged as updatable
  25433. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25434. * @returns a new Mesh
  25435. */
  25436. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25437. /**
  25438. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25439. * @param name defines the name of the mesh to create
  25440. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25441. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25442. * @param scene defines the hosting scene
  25443. * @param updatable defines if the mesh must be flagged as updatable
  25444. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25445. * @returns a new Mesh
  25446. */
  25447. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25448. /**
  25449. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25450. * @param name defines the name of the mesh to create
  25451. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25452. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25453. * @param scene defines the hosting scene
  25454. * @returns a new Mesh
  25455. */
  25456. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25457. /**
  25458. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25459. * @param name defines the name of the mesh to create
  25460. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25461. * @param diameterTop set the top cap diameter (floats, default 1)
  25462. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25463. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25464. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25465. * @param scene defines the hosting scene
  25466. * @param updatable defines if the mesh must be flagged as updatable
  25467. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25468. * @returns a new Mesh
  25469. */
  25470. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25471. /**
  25472. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25473. * @param name defines the name of the mesh to create
  25474. * @param diameter sets the diameter size (float) of the torus (default 1)
  25475. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25476. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25477. * @param scene defines the hosting scene
  25478. * @param updatable defines if the mesh must be flagged as updatable
  25479. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25480. * @returns a new Mesh
  25481. */
  25482. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25483. /**
  25484. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25485. * @param name defines the name of the mesh to create
  25486. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25487. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25488. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25489. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25490. * @param p the number of windings on X axis (positive integers, default 2)
  25491. * @param q the number of windings on Y axis (positive integers, default 3)
  25492. * @param scene defines the hosting scene
  25493. * @param updatable defines if the mesh must be flagged as updatable
  25494. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25495. * @returns a new Mesh
  25496. */
  25497. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25498. /**
  25499. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25500. * @param name defines the name of the mesh to create
  25501. * @param points is an array successive Vector3
  25502. * @param scene defines the hosting scene
  25503. * @param updatable defines if the mesh must be flagged as updatable
  25504. * @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).
  25505. * @returns a new Mesh
  25506. */
  25507. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25508. /**
  25509. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25510. * @param name defines the name of the mesh to create
  25511. * @param points is an array successive Vector3
  25512. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25513. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25514. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25515. * @param scene defines the hosting scene
  25516. * @param updatable defines if the mesh must be flagged as updatable
  25517. * @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)
  25518. * @returns a new Mesh
  25519. */
  25520. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25521. /**
  25522. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25523. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25524. * 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.
  25525. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25526. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25527. * Remember you can only change the shape positions, not their number when updating a polygon.
  25528. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25529. * @param name defines the name of the mesh to create
  25530. * @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
  25531. * @param scene defines the hosting scene
  25532. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25533. * @param updatable defines if the mesh must be flagged as updatable
  25534. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25535. * @param earcutInjection can be used to inject your own earcut reference
  25536. * @returns a new Mesh
  25537. */
  25538. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25539. /**
  25540. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25541. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25542. * @param name defines the name of the mesh to create
  25543. * @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
  25544. * @param depth defines the height of extrusion
  25545. * @param scene defines the hosting scene
  25546. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25547. * @param updatable defines if the mesh must be flagged as updatable
  25548. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25549. * @param earcutInjection can be used to inject your own earcut reference
  25550. * @returns a new Mesh
  25551. */
  25552. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25553. /**
  25554. * Creates an extruded shape mesh.
  25555. * 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
  25556. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25557. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25558. * @param name defines the name of the mesh to create
  25559. * @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
  25560. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25561. * @param scale is the value to scale the shape
  25562. * @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
  25563. * @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
  25564. * @param scene defines the hosting scene
  25565. * @param updatable defines if the mesh must be flagged as updatable
  25566. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25567. * @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)
  25568. * @returns a new Mesh
  25569. */
  25570. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25571. /**
  25572. * Creates an custom extruded shape mesh.
  25573. * The custom extrusion is a parametric shape.
  25574. * It has no predefined shape. Its final shape will depend on the input parameters.
  25575. * Please consider using the same method from the MeshBuilder class instead
  25576. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25577. * @param name defines the name of the mesh to create
  25578. * @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
  25579. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25580. * @param scaleFunction is a custom Javascript function called on each path point
  25581. * @param rotationFunction is a custom Javascript function called on each path point
  25582. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25583. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25584. * @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
  25585. * @param scene defines the hosting scene
  25586. * @param updatable defines if the mesh must be flagged as updatable
  25587. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25588. * @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)
  25589. * @returns a new Mesh
  25590. */
  25591. 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;
  25592. /**
  25593. * Creates lathe mesh.
  25594. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25595. * Please consider using the same method from the MeshBuilder class instead
  25596. * @param name defines the name of the mesh to create
  25597. * @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
  25598. * @param radius is the radius value of the lathe
  25599. * @param tessellation is the side number of the lathe.
  25600. * @param scene defines the hosting scene
  25601. * @param updatable defines if the mesh must be flagged as updatable
  25602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25603. * @returns a new Mesh
  25604. */
  25605. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25606. /**
  25607. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25608. * @param name defines the name of the mesh to create
  25609. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25610. * @param scene defines the hosting scene
  25611. * @param updatable defines if the mesh must be flagged as updatable
  25612. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25613. * @returns a new Mesh
  25614. */
  25615. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25616. /**
  25617. * Creates a ground mesh.
  25618. * Please consider using the same method from the MeshBuilder class instead
  25619. * @param name defines the name of the mesh to create
  25620. * @param width set the width of the ground
  25621. * @param height set the height of the ground
  25622. * @param subdivisions sets the number of subdivisions per side
  25623. * @param scene defines the hosting scene
  25624. * @param updatable defines if the mesh must be flagged as updatable
  25625. * @returns a new Mesh
  25626. */
  25627. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25628. /**
  25629. * Creates a tiled ground mesh.
  25630. * Please consider using the same method from the MeshBuilder class instead
  25631. * @param name defines the name of the mesh to create
  25632. * @param xmin set the ground minimum X coordinate
  25633. * @param zmin set the ground minimum Y coordinate
  25634. * @param xmax set the ground maximum X coordinate
  25635. * @param zmax set the ground maximum Z coordinate
  25636. * @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
  25637. * @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
  25638. * @param scene defines the hosting scene
  25639. * @param updatable defines if the mesh must be flagged as updatable
  25640. * @returns a new Mesh
  25641. */
  25642. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25643. w: number;
  25644. h: number;
  25645. }, precision: {
  25646. w: number;
  25647. h: number;
  25648. }, scene: Scene, updatable?: boolean): Mesh;
  25649. /**
  25650. * Creates a ground mesh from a height map.
  25651. * Please consider using the same method from the MeshBuilder class instead
  25652. * @see http://doc.babylonjs.com/babylon101/height_map
  25653. * @param name defines the name of the mesh to create
  25654. * @param url sets the URL of the height map image resource
  25655. * @param width set the ground width size
  25656. * @param height set the ground height size
  25657. * @param subdivisions sets the number of subdivision per side
  25658. * @param minHeight is the minimum altitude on the ground
  25659. * @param maxHeight is the maximum altitude on the ground
  25660. * @param scene defines the hosting scene
  25661. * @param updatable defines if the mesh must be flagged as updatable
  25662. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25663. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25664. * @returns a new Mesh
  25665. */
  25666. 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;
  25667. /**
  25668. * Creates a tube mesh.
  25669. * The tube is a parametric shape.
  25670. * It has no predefined shape. Its final shape will depend on the input parameters.
  25671. * Please consider using the same method from the MeshBuilder class instead
  25672. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25673. * @param name defines the name of the mesh to create
  25674. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25675. * @param radius sets the tube radius size
  25676. * @param tessellation is the number of sides on the tubular surface
  25677. * @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
  25678. * @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
  25679. * @param scene defines the hosting scene
  25680. * @param updatable defines if the mesh must be flagged as updatable
  25681. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25682. * @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)
  25683. * @returns a new Mesh
  25684. */
  25685. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25686. (i: number, distance: number): number;
  25687. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25688. /**
  25689. * Creates a polyhedron mesh.
  25690. * Please consider using the same method from the MeshBuilder class instead.
  25691. * * 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
  25692. * * The parameter `size` (positive float, default 1) sets the polygon size
  25693. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25694. * * 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`
  25695. * * 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
  25696. * * 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)`)
  25697. * * 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
  25698. * * 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
  25699. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25700. * * 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
  25701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25702. * @param name defines the name of the mesh to create
  25703. * @param options defines the options used to create the mesh
  25704. * @param scene defines the hosting scene
  25705. * @returns a new Mesh
  25706. */
  25707. static CreatePolyhedron(name: string, options: {
  25708. type?: number;
  25709. size?: number;
  25710. sizeX?: number;
  25711. sizeY?: number;
  25712. sizeZ?: number;
  25713. custom?: any;
  25714. faceUV?: Vector4[];
  25715. faceColors?: Color4[];
  25716. updatable?: boolean;
  25717. sideOrientation?: number;
  25718. }, scene: Scene): Mesh;
  25719. /**
  25720. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25721. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25722. * * 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`)
  25723. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25724. * * 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
  25725. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25726. * * 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
  25727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25728. * @param name defines the name of the mesh
  25729. * @param options defines the options used to create the mesh
  25730. * @param scene defines the hosting scene
  25731. * @returns a new Mesh
  25732. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25733. */
  25734. static CreateIcoSphere(name: string, options: {
  25735. radius?: number;
  25736. flat?: boolean;
  25737. subdivisions?: number;
  25738. sideOrientation?: number;
  25739. updatable?: boolean;
  25740. }, scene: Scene): Mesh;
  25741. /**
  25742. * Creates a decal mesh.
  25743. * Please consider using the same method from the MeshBuilder class instead.
  25744. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25745. * @param name defines the name of the mesh
  25746. * @param sourceMesh defines the mesh receiving the decal
  25747. * @param position sets the position of the decal in world coordinates
  25748. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25749. * @param size sets the decal scaling
  25750. * @param angle sets the angle to rotate the decal
  25751. * @returns a new Mesh
  25752. */
  25753. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25754. /**
  25755. * Prepare internal position array for software CPU skinning
  25756. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25757. */
  25758. setPositionsForCPUSkinning(): Float32Array;
  25759. /**
  25760. * Prepare internal normal array for software CPU skinning
  25761. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25762. */
  25763. setNormalsForCPUSkinning(): Float32Array;
  25764. /**
  25765. * Updates the vertex buffer by applying transformation from the bones
  25766. * @param skeleton defines the skeleton to apply to current mesh
  25767. * @returns the current mesh
  25768. */
  25769. applySkeleton(skeleton: Skeleton): Mesh;
  25770. /**
  25771. * 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
  25772. * @param meshes defines the list of meshes to scan
  25773. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25774. */
  25775. static MinMax(meshes: AbstractMesh[]): {
  25776. min: Vector3;
  25777. max: Vector3;
  25778. };
  25779. /**
  25780. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25781. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25782. * @returns a vector3
  25783. */
  25784. static Center(meshesOrMinMaxVector: {
  25785. min: Vector3;
  25786. max: Vector3;
  25787. } | AbstractMesh[]): Vector3;
  25788. /**
  25789. * Merge the array of meshes into a single mesh for performance reasons.
  25790. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25791. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25792. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25793. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25794. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25795. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25796. * @returns a new mesh
  25797. */
  25798. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25799. /** @hidden */
  25800. addInstance(instance: InstancedMesh): void;
  25801. /** @hidden */
  25802. removeInstance(instance: InstancedMesh): void;
  25803. }
  25804. }
  25805. declare module BABYLON {
  25806. /**
  25807. * This is the base class of all the camera used in the application.
  25808. * @see http://doc.babylonjs.com/features/cameras
  25809. */
  25810. export class Camera extends Node {
  25811. /** @hidden */
  25812. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25813. /**
  25814. * This is the default projection mode used by the cameras.
  25815. * It helps recreating a feeling of perspective and better appreciate depth.
  25816. * This is the best way to simulate real life cameras.
  25817. */
  25818. static readonly PERSPECTIVE_CAMERA: number;
  25819. /**
  25820. * This helps creating camera with an orthographic mode.
  25821. * 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.
  25822. */
  25823. static readonly ORTHOGRAPHIC_CAMERA: number;
  25824. /**
  25825. * This is the default FOV mode for perspective cameras.
  25826. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25827. */
  25828. static readonly FOVMODE_VERTICAL_FIXED: number;
  25829. /**
  25830. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25831. */
  25832. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25833. /**
  25834. * This specifies ther is no need for a camera rig.
  25835. * Basically only one eye is rendered corresponding to the camera.
  25836. */
  25837. static readonly RIG_MODE_NONE: number;
  25838. /**
  25839. * Simulates a camera Rig with one blue eye and one red eye.
  25840. * This can be use with 3d blue and red glasses.
  25841. */
  25842. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25843. /**
  25844. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25845. */
  25846. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25847. /**
  25848. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25849. */
  25850. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25851. /**
  25852. * Defines that both eyes of the camera will be rendered over under each other.
  25853. */
  25854. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25855. /**
  25856. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25857. */
  25858. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25859. /**
  25860. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25861. */
  25862. static readonly RIG_MODE_VR: number;
  25863. /**
  25864. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25865. */
  25866. static readonly RIG_MODE_WEBVR: number;
  25867. /**
  25868. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25869. */
  25870. static readonly RIG_MODE_CUSTOM: number;
  25871. /**
  25872. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25873. */
  25874. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25875. /**
  25876. * Define the input manager associated with the camera.
  25877. */
  25878. inputs: CameraInputsManager<Camera>;
  25879. /** @hidden */
  25880. _position: Vector3;
  25881. /**
  25882. * Define the current local position of the camera in the scene
  25883. */
  25884. get position(): Vector3;
  25885. set position(newPosition: Vector3);
  25886. /**
  25887. * The vector the camera should consider as up.
  25888. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25889. */
  25890. upVector: Vector3;
  25891. /**
  25892. * Define the current limit on the left side for an orthographic camera
  25893. * In scene unit
  25894. */
  25895. orthoLeft: Nullable<number>;
  25896. /**
  25897. * Define the current limit on the right side for an orthographic camera
  25898. * In scene unit
  25899. */
  25900. orthoRight: Nullable<number>;
  25901. /**
  25902. * Define the current limit on the bottom side for an orthographic camera
  25903. * In scene unit
  25904. */
  25905. orthoBottom: Nullable<number>;
  25906. /**
  25907. * Define the current limit on the top side for an orthographic camera
  25908. * In scene unit
  25909. */
  25910. orthoTop: Nullable<number>;
  25911. /**
  25912. * Field Of View is set in Radians. (default is 0.8)
  25913. */
  25914. fov: number;
  25915. /**
  25916. * Define the minimum distance the camera can see from.
  25917. * This is important to note that the depth buffer are not infinite and the closer it starts
  25918. * the more your scene might encounter depth fighting issue.
  25919. */
  25920. minZ: number;
  25921. /**
  25922. * Define the maximum distance the camera can see to.
  25923. * This is important to note that the depth buffer are not infinite and the further it end
  25924. * the more your scene might encounter depth fighting issue.
  25925. */
  25926. maxZ: number;
  25927. /**
  25928. * Define the default inertia of the camera.
  25929. * This helps giving a smooth feeling to the camera movement.
  25930. */
  25931. inertia: number;
  25932. /**
  25933. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25934. */
  25935. mode: number;
  25936. /**
  25937. * Define whether the camera is intermediate.
  25938. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25939. */
  25940. isIntermediate: boolean;
  25941. /**
  25942. * Define the viewport of the camera.
  25943. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25944. */
  25945. viewport: Viewport;
  25946. /**
  25947. * Restricts the camera to viewing objects with the same layerMask.
  25948. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25949. */
  25950. layerMask: number;
  25951. /**
  25952. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25953. */
  25954. fovMode: number;
  25955. /**
  25956. * Rig mode of the camera.
  25957. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25958. * This is normally controlled byt the camera themselves as internal use.
  25959. */
  25960. cameraRigMode: number;
  25961. /**
  25962. * Defines the distance between both "eyes" in case of a RIG
  25963. */
  25964. interaxialDistance: number;
  25965. /**
  25966. * Defines if stereoscopic rendering is done side by side or over under.
  25967. */
  25968. isStereoscopicSideBySide: boolean;
  25969. /**
  25970. * 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
  25971. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25972. * else in the scene. (Eg. security camera)
  25973. *
  25974. * 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)
  25975. */
  25976. customRenderTargets: RenderTargetTexture[];
  25977. /**
  25978. * When set, the camera will render to this render target instead of the default canvas
  25979. *
  25980. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25981. */
  25982. outputRenderTarget: Nullable<RenderTargetTexture>;
  25983. /**
  25984. * Observable triggered when the camera view matrix has changed.
  25985. */
  25986. onViewMatrixChangedObservable: Observable<Camera>;
  25987. /**
  25988. * Observable triggered when the camera Projection matrix has changed.
  25989. */
  25990. onProjectionMatrixChangedObservable: Observable<Camera>;
  25991. /**
  25992. * Observable triggered when the inputs have been processed.
  25993. */
  25994. onAfterCheckInputsObservable: Observable<Camera>;
  25995. /**
  25996. * Observable triggered when reset has been called and applied to the camera.
  25997. */
  25998. onRestoreStateObservable: Observable<Camera>;
  25999. /**
  26000. * Is this camera a part of a rig system?
  26001. */
  26002. isRigCamera: boolean;
  26003. /**
  26004. * If isRigCamera set to true this will be set with the parent camera.
  26005. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26006. */
  26007. rigParent?: Camera;
  26008. /** @hidden */
  26009. _cameraRigParams: any;
  26010. /** @hidden */
  26011. _rigCameras: Camera[];
  26012. /** @hidden */
  26013. _rigPostProcess: Nullable<PostProcess>;
  26014. protected _webvrViewMatrix: Matrix;
  26015. /** @hidden */
  26016. _skipRendering: boolean;
  26017. /** @hidden */
  26018. _projectionMatrix: Matrix;
  26019. /** @hidden */
  26020. _postProcesses: Nullable<PostProcess>[];
  26021. /** @hidden */
  26022. _activeMeshes: SmartArray<AbstractMesh>;
  26023. protected _globalPosition: Vector3;
  26024. /** @hidden */
  26025. _computedViewMatrix: Matrix;
  26026. private _doNotComputeProjectionMatrix;
  26027. private _transformMatrix;
  26028. private _frustumPlanes;
  26029. private _refreshFrustumPlanes;
  26030. private _storedFov;
  26031. private _stateStored;
  26032. /**
  26033. * Instantiates a new camera object.
  26034. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26035. * @see http://doc.babylonjs.com/features/cameras
  26036. * @param name Defines the name of the camera in the scene
  26037. * @param position Defines the position of the camera
  26038. * @param scene Defines the scene the camera belongs too
  26039. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26040. */
  26041. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26042. /**
  26043. * Store current camera state (fov, position, etc..)
  26044. * @returns the camera
  26045. */
  26046. storeState(): Camera;
  26047. /**
  26048. * Restores the camera state values if it has been stored. You must call storeState() first
  26049. */
  26050. protected _restoreStateValues(): boolean;
  26051. /**
  26052. * Restored camera state. You must call storeState() first.
  26053. * @returns true if restored and false otherwise
  26054. */
  26055. restoreState(): boolean;
  26056. /**
  26057. * Gets the class name of the camera.
  26058. * @returns the class name
  26059. */
  26060. getClassName(): string;
  26061. /** @hidden */
  26062. readonly _isCamera: boolean;
  26063. /**
  26064. * Gets a string representation of the camera useful for debug purpose.
  26065. * @param fullDetails Defines that a more verboe level of logging is required
  26066. * @returns the string representation
  26067. */
  26068. toString(fullDetails?: boolean): string;
  26069. /**
  26070. * Gets the current world space position of the camera.
  26071. */
  26072. get globalPosition(): Vector3;
  26073. /**
  26074. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26075. * @returns the active meshe list
  26076. */
  26077. getActiveMeshes(): SmartArray<AbstractMesh>;
  26078. /**
  26079. * Check whether a mesh is part of the current active mesh list of the camera
  26080. * @param mesh Defines the mesh to check
  26081. * @returns true if active, false otherwise
  26082. */
  26083. isActiveMesh(mesh: Mesh): boolean;
  26084. /**
  26085. * Is this camera ready to be used/rendered
  26086. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26087. * @return true if the camera is ready
  26088. */
  26089. isReady(completeCheck?: boolean): boolean;
  26090. /** @hidden */
  26091. _initCache(): void;
  26092. /** @hidden */
  26093. _updateCache(ignoreParentClass?: boolean): void;
  26094. /** @hidden */
  26095. _isSynchronized(): boolean;
  26096. /** @hidden */
  26097. _isSynchronizedViewMatrix(): boolean;
  26098. /** @hidden */
  26099. _isSynchronizedProjectionMatrix(): boolean;
  26100. /**
  26101. * Attach the input controls to a specific dom element to get the input from.
  26102. * @param element Defines the element the controls should be listened from
  26103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26104. */
  26105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26106. /**
  26107. * Detach the current controls from the specified dom element.
  26108. * @param element Defines the element to stop listening the inputs from
  26109. */
  26110. detachControl(element: HTMLElement): void;
  26111. /**
  26112. * Update the camera state according to the different inputs gathered during the frame.
  26113. */
  26114. update(): void;
  26115. /** @hidden */
  26116. _checkInputs(): void;
  26117. /** @hidden */
  26118. get rigCameras(): Camera[];
  26119. /**
  26120. * Gets the post process used by the rig cameras
  26121. */
  26122. get rigPostProcess(): Nullable<PostProcess>;
  26123. /**
  26124. * Internal, gets the first post proces.
  26125. * @returns the first post process to be run on this camera.
  26126. */
  26127. _getFirstPostProcess(): Nullable<PostProcess>;
  26128. private _cascadePostProcessesToRigCams;
  26129. /**
  26130. * Attach a post process to the camera.
  26131. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26132. * @param postProcess The post process to attach to the camera
  26133. * @param insertAt The position of the post process in case several of them are in use in the scene
  26134. * @returns the position the post process has been inserted at
  26135. */
  26136. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26137. /**
  26138. * Detach a post process to the camera.
  26139. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26140. * @param postProcess The post process to detach from the camera
  26141. */
  26142. detachPostProcess(postProcess: PostProcess): void;
  26143. /**
  26144. * Gets the current world matrix of the camera
  26145. */
  26146. getWorldMatrix(): Matrix;
  26147. /** @hidden */
  26148. _getViewMatrix(): Matrix;
  26149. /**
  26150. * Gets the current view matrix of the camera.
  26151. * @param force forces the camera to recompute the matrix without looking at the cached state
  26152. * @returns the view matrix
  26153. */
  26154. getViewMatrix(force?: boolean): Matrix;
  26155. /**
  26156. * Freeze the projection matrix.
  26157. * It will prevent the cache check of the camera projection compute and can speed up perf
  26158. * if no parameter of the camera are meant to change
  26159. * @param projection Defines manually a projection if necessary
  26160. */
  26161. freezeProjectionMatrix(projection?: Matrix): void;
  26162. /**
  26163. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26164. */
  26165. unfreezeProjectionMatrix(): void;
  26166. /**
  26167. * Gets the current projection matrix of the camera.
  26168. * @param force forces the camera to recompute the matrix without looking at the cached state
  26169. * @returns the projection matrix
  26170. */
  26171. getProjectionMatrix(force?: boolean): Matrix;
  26172. /**
  26173. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26174. * @returns a Matrix
  26175. */
  26176. getTransformationMatrix(): Matrix;
  26177. private _updateFrustumPlanes;
  26178. /**
  26179. * Checks if a cullable object (mesh...) is in the camera frustum
  26180. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26181. * @param target The object to check
  26182. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26183. * @returns true if the object is in frustum otherwise false
  26184. */
  26185. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26186. /**
  26187. * Checks if a cullable object (mesh...) is in the camera frustum
  26188. * Unlike isInFrustum this cheks the full bounding box
  26189. * @param target The object to check
  26190. * @returns true if the object is in frustum otherwise false
  26191. */
  26192. isCompletelyInFrustum(target: ICullable): boolean;
  26193. /**
  26194. * Gets a ray in the forward direction from the camera.
  26195. * @param length Defines the length of the ray to create
  26196. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26197. * @param origin Defines the start point of the ray which defaults to the camera position
  26198. * @returns the forward ray
  26199. */
  26200. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26201. /**
  26202. * Releases resources associated with this node.
  26203. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26204. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26205. */
  26206. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26207. /** @hidden */
  26208. _isLeftCamera: boolean;
  26209. /**
  26210. * Gets the left camera of a rig setup in case of Rigged Camera
  26211. */
  26212. get isLeftCamera(): boolean;
  26213. /** @hidden */
  26214. _isRightCamera: boolean;
  26215. /**
  26216. * Gets the right camera of a rig setup in case of Rigged Camera
  26217. */
  26218. get isRightCamera(): boolean;
  26219. /**
  26220. * Gets the left camera of a rig setup in case of Rigged Camera
  26221. */
  26222. get leftCamera(): Nullable<FreeCamera>;
  26223. /**
  26224. * Gets the right camera of a rig setup in case of Rigged Camera
  26225. */
  26226. get rightCamera(): Nullable<FreeCamera>;
  26227. /**
  26228. * Gets the left camera target of a rig setup in case of Rigged Camera
  26229. * @returns the target position
  26230. */
  26231. getLeftTarget(): Nullable<Vector3>;
  26232. /**
  26233. * Gets the right camera target of a rig setup in case of Rigged Camera
  26234. * @returns the target position
  26235. */
  26236. getRightTarget(): Nullable<Vector3>;
  26237. /**
  26238. * @hidden
  26239. */
  26240. setCameraRigMode(mode: number, rigParams: any): void;
  26241. /** @hidden */
  26242. static _setStereoscopicRigMode(camera: Camera): void;
  26243. /** @hidden */
  26244. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26245. /** @hidden */
  26246. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26247. /** @hidden */
  26248. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26249. /** @hidden */
  26250. _getVRProjectionMatrix(): Matrix;
  26251. protected _updateCameraRotationMatrix(): void;
  26252. protected _updateWebVRCameraRotationMatrix(): void;
  26253. /**
  26254. * This function MUST be overwritten by the different WebVR cameras available.
  26255. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26256. * @hidden
  26257. */
  26258. _getWebVRProjectionMatrix(): Matrix;
  26259. /**
  26260. * This function MUST be overwritten by the different WebVR cameras available.
  26261. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26262. * @hidden
  26263. */
  26264. _getWebVRViewMatrix(): Matrix;
  26265. /** @hidden */
  26266. setCameraRigParameter(name: string, value: any): void;
  26267. /**
  26268. * needs to be overridden by children so sub has required properties to be copied
  26269. * @hidden
  26270. */
  26271. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26272. /**
  26273. * May need to be overridden by children
  26274. * @hidden
  26275. */
  26276. _updateRigCameras(): void;
  26277. /** @hidden */
  26278. _setupInputs(): void;
  26279. /**
  26280. * Serialiaze the camera setup to a json represention
  26281. * @returns the JSON representation
  26282. */
  26283. serialize(): any;
  26284. /**
  26285. * Clones the current camera.
  26286. * @param name The cloned camera name
  26287. * @returns the cloned camera
  26288. */
  26289. clone(name: string): Camera;
  26290. /**
  26291. * Gets the direction of the camera relative to a given local axis.
  26292. * @param localAxis Defines the reference axis to provide a relative direction.
  26293. * @return the direction
  26294. */
  26295. getDirection(localAxis: Vector3): Vector3;
  26296. /**
  26297. * Returns the current camera absolute rotation
  26298. */
  26299. get absoluteRotation(): Quaternion;
  26300. /**
  26301. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26302. * @param localAxis Defines the reference axis to provide a relative direction.
  26303. * @param result Defines the vector to store the result in
  26304. */
  26305. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26306. /**
  26307. * Gets a camera constructor for a given camera type
  26308. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26309. * @param name The name of the camera the result will be able to instantiate
  26310. * @param scene The scene the result will construct the camera in
  26311. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26312. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26313. * @returns a factory method to construc the camera
  26314. */
  26315. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26316. /**
  26317. * Compute the world matrix of the camera.
  26318. * @returns the camera world matrix
  26319. */
  26320. computeWorldMatrix(): Matrix;
  26321. /**
  26322. * Parse a JSON and creates the camera from the parsed information
  26323. * @param parsedCamera The JSON to parse
  26324. * @param scene The scene to instantiate the camera in
  26325. * @returns the newly constructed camera
  26326. */
  26327. static Parse(parsedCamera: any, scene: Scene): Camera;
  26328. }
  26329. }
  26330. declare module BABYLON {
  26331. /**
  26332. * Class containing static functions to help procedurally build meshes
  26333. */
  26334. export class DiscBuilder {
  26335. /**
  26336. * Creates a plane polygonal mesh. By default, this is a disc
  26337. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26338. * * 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
  26339. * * 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
  26340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26341. * * 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
  26342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26343. * @param name defines the name of the mesh
  26344. * @param options defines the options used to create the mesh
  26345. * @param scene defines the hosting scene
  26346. * @returns the plane polygonal mesh
  26347. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26348. */
  26349. static CreateDisc(name: string, options: {
  26350. radius?: number;
  26351. tessellation?: number;
  26352. arc?: number;
  26353. updatable?: boolean;
  26354. sideOrientation?: number;
  26355. frontUVs?: Vector4;
  26356. backUVs?: Vector4;
  26357. }, scene?: Nullable<Scene>): Mesh;
  26358. }
  26359. }
  26360. declare module BABYLON {
  26361. /**
  26362. * Options to be used when creating a FresnelParameters.
  26363. */
  26364. export type IFresnelParametersCreationOptions = {
  26365. /**
  26366. * Define the color used on edges (grazing angle)
  26367. */
  26368. leftColor?: Color3;
  26369. /**
  26370. * Define the color used on center
  26371. */
  26372. rightColor?: Color3;
  26373. /**
  26374. * Define bias applied to computed fresnel term
  26375. */
  26376. bias?: number;
  26377. /**
  26378. * Defined the power exponent applied to fresnel term
  26379. */
  26380. power?: number;
  26381. /**
  26382. * Define if the fresnel effect is enable or not.
  26383. */
  26384. isEnabled?: boolean;
  26385. };
  26386. /**
  26387. * Serialized format for FresnelParameters.
  26388. */
  26389. export type IFresnelParametersSerialized = {
  26390. /**
  26391. * Define the color used on edges (grazing angle) [as an array]
  26392. */
  26393. leftColor: number[];
  26394. /**
  26395. * Define the color used on center [as an array]
  26396. */
  26397. rightColor: number[];
  26398. /**
  26399. * Define bias applied to computed fresnel term
  26400. */
  26401. bias: number;
  26402. /**
  26403. * Defined the power exponent applied to fresnel term
  26404. */
  26405. power?: number;
  26406. /**
  26407. * Define if the fresnel effect is enable or not.
  26408. */
  26409. isEnabled: boolean;
  26410. };
  26411. /**
  26412. * This represents all the required information to add a fresnel effect on a material:
  26413. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26414. */
  26415. export class FresnelParameters {
  26416. private _isEnabled;
  26417. /**
  26418. * Define if the fresnel effect is enable or not.
  26419. */
  26420. get isEnabled(): boolean;
  26421. set isEnabled(value: boolean);
  26422. /**
  26423. * Define the color used on edges (grazing angle)
  26424. */
  26425. leftColor: Color3;
  26426. /**
  26427. * Define the color used on center
  26428. */
  26429. rightColor: Color3;
  26430. /**
  26431. * Define bias applied to computed fresnel term
  26432. */
  26433. bias: number;
  26434. /**
  26435. * Defined the power exponent applied to fresnel term
  26436. */
  26437. power: number;
  26438. /**
  26439. * Creates a new FresnelParameters object.
  26440. *
  26441. * @param options provide your own settings to optionally to override defaults
  26442. */
  26443. constructor(options?: IFresnelParametersCreationOptions);
  26444. /**
  26445. * Clones the current fresnel and its valuues
  26446. * @returns a clone fresnel configuration
  26447. */
  26448. clone(): FresnelParameters;
  26449. /**
  26450. * Determines equality between FresnelParameters objects
  26451. * @param otherFresnelParameters defines the second operand
  26452. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26453. */
  26454. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26455. /**
  26456. * Serializes the current fresnel parameters to a JSON representation.
  26457. * @return the JSON serialization
  26458. */
  26459. serialize(): IFresnelParametersSerialized;
  26460. /**
  26461. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26462. * @param parsedFresnelParameters Define the JSON representation
  26463. * @returns the parsed parameters
  26464. */
  26465. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26466. }
  26467. }
  26468. declare module BABYLON {
  26469. /**
  26470. * Base class of materials working in push mode in babylon JS
  26471. * @hidden
  26472. */
  26473. export class PushMaterial extends Material {
  26474. protected _activeEffect: Effect;
  26475. protected _normalMatrix: Matrix;
  26476. /**
  26477. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26478. * This means that the material can keep using a previous shader while a new one is being compiled.
  26479. * This is mostly used when shader parallel compilation is supported (true by default)
  26480. */
  26481. allowShaderHotSwapping: boolean;
  26482. constructor(name: string, scene: Scene);
  26483. getEffect(): Effect;
  26484. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26485. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26486. /**
  26487. * Binds the given world matrix to the active effect
  26488. *
  26489. * @param world the matrix to bind
  26490. */
  26491. bindOnlyWorldMatrix(world: Matrix): void;
  26492. /**
  26493. * Binds the given normal matrix to the active effect
  26494. *
  26495. * @param normalMatrix the matrix to bind
  26496. */
  26497. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26498. bind(world: Matrix, mesh?: Mesh): void;
  26499. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26500. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26501. }
  26502. }
  26503. declare module BABYLON {
  26504. /**
  26505. * This groups all the flags used to control the materials channel.
  26506. */
  26507. export class MaterialFlags {
  26508. private static _DiffuseTextureEnabled;
  26509. /**
  26510. * Are diffuse textures enabled in the application.
  26511. */
  26512. static get DiffuseTextureEnabled(): boolean;
  26513. static set DiffuseTextureEnabled(value: boolean);
  26514. private static _AmbientTextureEnabled;
  26515. /**
  26516. * Are ambient textures enabled in the application.
  26517. */
  26518. static get AmbientTextureEnabled(): boolean;
  26519. static set AmbientTextureEnabled(value: boolean);
  26520. private static _OpacityTextureEnabled;
  26521. /**
  26522. * Are opacity textures enabled in the application.
  26523. */
  26524. static get OpacityTextureEnabled(): boolean;
  26525. static set OpacityTextureEnabled(value: boolean);
  26526. private static _ReflectionTextureEnabled;
  26527. /**
  26528. * Are reflection textures enabled in the application.
  26529. */
  26530. static get ReflectionTextureEnabled(): boolean;
  26531. static set ReflectionTextureEnabled(value: boolean);
  26532. private static _EmissiveTextureEnabled;
  26533. /**
  26534. * Are emissive textures enabled in the application.
  26535. */
  26536. static get EmissiveTextureEnabled(): boolean;
  26537. static set EmissiveTextureEnabled(value: boolean);
  26538. private static _SpecularTextureEnabled;
  26539. /**
  26540. * Are specular textures enabled in the application.
  26541. */
  26542. static get SpecularTextureEnabled(): boolean;
  26543. static set SpecularTextureEnabled(value: boolean);
  26544. private static _BumpTextureEnabled;
  26545. /**
  26546. * Are bump textures enabled in the application.
  26547. */
  26548. static get BumpTextureEnabled(): boolean;
  26549. static set BumpTextureEnabled(value: boolean);
  26550. private static _LightmapTextureEnabled;
  26551. /**
  26552. * Are lightmap textures enabled in the application.
  26553. */
  26554. static get LightmapTextureEnabled(): boolean;
  26555. static set LightmapTextureEnabled(value: boolean);
  26556. private static _RefractionTextureEnabled;
  26557. /**
  26558. * Are refraction textures enabled in the application.
  26559. */
  26560. static get RefractionTextureEnabled(): boolean;
  26561. static set RefractionTextureEnabled(value: boolean);
  26562. private static _ColorGradingTextureEnabled;
  26563. /**
  26564. * Are color grading textures enabled in the application.
  26565. */
  26566. static get ColorGradingTextureEnabled(): boolean;
  26567. static set ColorGradingTextureEnabled(value: boolean);
  26568. private static _FresnelEnabled;
  26569. /**
  26570. * Are fresnels enabled in the application.
  26571. */
  26572. static get FresnelEnabled(): boolean;
  26573. static set FresnelEnabled(value: boolean);
  26574. private static _ClearCoatTextureEnabled;
  26575. /**
  26576. * Are clear coat textures enabled in the application.
  26577. */
  26578. static get ClearCoatTextureEnabled(): boolean;
  26579. static set ClearCoatTextureEnabled(value: boolean);
  26580. private static _ClearCoatBumpTextureEnabled;
  26581. /**
  26582. * Are clear coat bump textures enabled in the application.
  26583. */
  26584. static get ClearCoatBumpTextureEnabled(): boolean;
  26585. static set ClearCoatBumpTextureEnabled(value: boolean);
  26586. private static _ClearCoatTintTextureEnabled;
  26587. /**
  26588. * Are clear coat tint textures enabled in the application.
  26589. */
  26590. static get ClearCoatTintTextureEnabled(): boolean;
  26591. static set ClearCoatTintTextureEnabled(value: boolean);
  26592. private static _SheenTextureEnabled;
  26593. /**
  26594. * Are sheen textures enabled in the application.
  26595. */
  26596. static get SheenTextureEnabled(): boolean;
  26597. static set SheenTextureEnabled(value: boolean);
  26598. private static _AnisotropicTextureEnabled;
  26599. /**
  26600. * Are anisotropic textures enabled in the application.
  26601. */
  26602. static get AnisotropicTextureEnabled(): boolean;
  26603. static set AnisotropicTextureEnabled(value: boolean);
  26604. private static _ThicknessTextureEnabled;
  26605. /**
  26606. * Are thickness textures enabled in the application.
  26607. */
  26608. static get ThicknessTextureEnabled(): boolean;
  26609. static set ThicknessTextureEnabled(value: boolean);
  26610. }
  26611. }
  26612. declare module BABYLON {
  26613. /** @hidden */
  26614. export var defaultFragmentDeclaration: {
  26615. name: string;
  26616. shader: string;
  26617. };
  26618. }
  26619. declare module BABYLON {
  26620. /** @hidden */
  26621. export var defaultUboDeclaration: {
  26622. name: string;
  26623. shader: string;
  26624. };
  26625. }
  26626. declare module BABYLON {
  26627. /** @hidden */
  26628. export var lightFragmentDeclaration: {
  26629. name: string;
  26630. shader: string;
  26631. };
  26632. }
  26633. declare module BABYLON {
  26634. /** @hidden */
  26635. export var lightUboDeclaration: {
  26636. name: string;
  26637. shader: string;
  26638. };
  26639. }
  26640. declare module BABYLON {
  26641. /** @hidden */
  26642. export var lightsFragmentFunctions: {
  26643. name: string;
  26644. shader: string;
  26645. };
  26646. }
  26647. declare module BABYLON {
  26648. /** @hidden */
  26649. export var shadowsFragmentFunctions: {
  26650. name: string;
  26651. shader: string;
  26652. };
  26653. }
  26654. declare module BABYLON {
  26655. /** @hidden */
  26656. export var fresnelFunction: {
  26657. name: string;
  26658. shader: string;
  26659. };
  26660. }
  26661. declare module BABYLON {
  26662. /** @hidden */
  26663. export var reflectionFunction: {
  26664. name: string;
  26665. shader: string;
  26666. };
  26667. }
  26668. declare module BABYLON {
  26669. /** @hidden */
  26670. export var bumpFragmentFunctions: {
  26671. name: string;
  26672. shader: string;
  26673. };
  26674. }
  26675. declare module BABYLON {
  26676. /** @hidden */
  26677. export var logDepthDeclaration: {
  26678. name: string;
  26679. shader: string;
  26680. };
  26681. }
  26682. declare module BABYLON {
  26683. /** @hidden */
  26684. export var bumpFragment: {
  26685. name: string;
  26686. shader: string;
  26687. };
  26688. }
  26689. declare module BABYLON {
  26690. /** @hidden */
  26691. export var depthPrePass: {
  26692. name: string;
  26693. shader: string;
  26694. };
  26695. }
  26696. declare module BABYLON {
  26697. /** @hidden */
  26698. export var lightFragment: {
  26699. name: string;
  26700. shader: string;
  26701. };
  26702. }
  26703. declare module BABYLON {
  26704. /** @hidden */
  26705. export var logDepthFragment: {
  26706. name: string;
  26707. shader: string;
  26708. };
  26709. }
  26710. declare module BABYLON {
  26711. /** @hidden */
  26712. export var defaultPixelShader: {
  26713. name: string;
  26714. shader: string;
  26715. };
  26716. }
  26717. declare module BABYLON {
  26718. /** @hidden */
  26719. export var defaultVertexDeclaration: {
  26720. name: string;
  26721. shader: string;
  26722. };
  26723. }
  26724. declare module BABYLON {
  26725. /** @hidden */
  26726. export var bumpVertexDeclaration: {
  26727. name: string;
  26728. shader: string;
  26729. };
  26730. }
  26731. declare module BABYLON {
  26732. /** @hidden */
  26733. export var bumpVertex: {
  26734. name: string;
  26735. shader: string;
  26736. };
  26737. }
  26738. declare module BABYLON {
  26739. /** @hidden */
  26740. export var fogVertex: {
  26741. name: string;
  26742. shader: string;
  26743. };
  26744. }
  26745. declare module BABYLON {
  26746. /** @hidden */
  26747. export var shadowsVertex: {
  26748. name: string;
  26749. shader: string;
  26750. };
  26751. }
  26752. declare module BABYLON {
  26753. /** @hidden */
  26754. export var pointCloudVertex: {
  26755. name: string;
  26756. shader: string;
  26757. };
  26758. }
  26759. declare module BABYLON {
  26760. /** @hidden */
  26761. export var logDepthVertex: {
  26762. name: string;
  26763. shader: string;
  26764. };
  26765. }
  26766. declare module BABYLON {
  26767. /** @hidden */
  26768. export var defaultVertexShader: {
  26769. name: string;
  26770. shader: string;
  26771. };
  26772. }
  26773. declare module BABYLON {
  26774. /** @hidden */
  26775. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26776. MAINUV1: boolean;
  26777. MAINUV2: boolean;
  26778. DIFFUSE: boolean;
  26779. DIFFUSEDIRECTUV: number;
  26780. AMBIENT: boolean;
  26781. AMBIENTDIRECTUV: number;
  26782. OPACITY: boolean;
  26783. OPACITYDIRECTUV: number;
  26784. OPACITYRGB: boolean;
  26785. REFLECTION: boolean;
  26786. EMISSIVE: boolean;
  26787. EMISSIVEDIRECTUV: number;
  26788. SPECULAR: boolean;
  26789. SPECULARDIRECTUV: number;
  26790. BUMP: boolean;
  26791. BUMPDIRECTUV: number;
  26792. PARALLAX: boolean;
  26793. PARALLAXOCCLUSION: boolean;
  26794. SPECULAROVERALPHA: boolean;
  26795. CLIPPLANE: boolean;
  26796. CLIPPLANE2: boolean;
  26797. CLIPPLANE3: boolean;
  26798. CLIPPLANE4: boolean;
  26799. CLIPPLANE5: boolean;
  26800. CLIPPLANE6: boolean;
  26801. ALPHATEST: boolean;
  26802. DEPTHPREPASS: boolean;
  26803. ALPHAFROMDIFFUSE: boolean;
  26804. POINTSIZE: boolean;
  26805. FOG: boolean;
  26806. SPECULARTERM: boolean;
  26807. DIFFUSEFRESNEL: boolean;
  26808. OPACITYFRESNEL: boolean;
  26809. REFLECTIONFRESNEL: boolean;
  26810. REFRACTIONFRESNEL: boolean;
  26811. EMISSIVEFRESNEL: boolean;
  26812. FRESNEL: boolean;
  26813. NORMAL: boolean;
  26814. UV1: boolean;
  26815. UV2: boolean;
  26816. VERTEXCOLOR: boolean;
  26817. VERTEXALPHA: boolean;
  26818. NUM_BONE_INFLUENCERS: number;
  26819. BonesPerMesh: number;
  26820. BONETEXTURE: boolean;
  26821. INSTANCES: boolean;
  26822. GLOSSINESS: boolean;
  26823. ROUGHNESS: boolean;
  26824. EMISSIVEASILLUMINATION: boolean;
  26825. LINKEMISSIVEWITHDIFFUSE: boolean;
  26826. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26827. LIGHTMAP: boolean;
  26828. LIGHTMAPDIRECTUV: number;
  26829. OBJECTSPACE_NORMALMAP: boolean;
  26830. USELIGHTMAPASSHADOWMAP: boolean;
  26831. REFLECTIONMAP_3D: boolean;
  26832. REFLECTIONMAP_SPHERICAL: boolean;
  26833. REFLECTIONMAP_PLANAR: boolean;
  26834. REFLECTIONMAP_CUBIC: boolean;
  26835. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26836. REFLECTIONMAP_PROJECTION: boolean;
  26837. REFLECTIONMAP_SKYBOX: boolean;
  26838. REFLECTIONMAP_EXPLICIT: boolean;
  26839. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26840. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26841. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26842. INVERTCUBICMAP: boolean;
  26843. LOGARITHMICDEPTH: boolean;
  26844. REFRACTION: boolean;
  26845. REFRACTIONMAP_3D: boolean;
  26846. REFLECTIONOVERALPHA: boolean;
  26847. TWOSIDEDLIGHTING: boolean;
  26848. SHADOWFLOAT: boolean;
  26849. MORPHTARGETS: boolean;
  26850. MORPHTARGETS_NORMAL: boolean;
  26851. MORPHTARGETS_TANGENT: boolean;
  26852. MORPHTARGETS_UV: boolean;
  26853. NUM_MORPH_INFLUENCERS: number;
  26854. NONUNIFORMSCALING: boolean;
  26855. PREMULTIPLYALPHA: boolean;
  26856. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26857. ALPHABLEND: boolean;
  26858. IMAGEPROCESSING: boolean;
  26859. VIGNETTE: boolean;
  26860. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26861. VIGNETTEBLENDMODEOPAQUE: boolean;
  26862. TONEMAPPING: boolean;
  26863. TONEMAPPING_ACES: boolean;
  26864. CONTRAST: boolean;
  26865. COLORCURVES: boolean;
  26866. COLORGRADING: boolean;
  26867. COLORGRADING3D: boolean;
  26868. SAMPLER3DGREENDEPTH: boolean;
  26869. SAMPLER3DBGRMAP: boolean;
  26870. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26871. MULTIVIEW: boolean;
  26872. /**
  26873. * If the reflection texture on this material is in linear color space
  26874. * @hidden
  26875. */
  26876. IS_REFLECTION_LINEAR: boolean;
  26877. /**
  26878. * If the refraction texture on this material is in linear color space
  26879. * @hidden
  26880. */
  26881. IS_REFRACTION_LINEAR: boolean;
  26882. EXPOSURE: boolean;
  26883. constructor();
  26884. setReflectionMode(modeToEnable: string): void;
  26885. }
  26886. /**
  26887. * This is the default material used in Babylon. It is the best trade off between quality
  26888. * and performances.
  26889. * @see http://doc.babylonjs.com/babylon101/materials
  26890. */
  26891. export class StandardMaterial extends PushMaterial {
  26892. private _diffuseTexture;
  26893. /**
  26894. * The basic texture of the material as viewed under a light.
  26895. */
  26896. diffuseTexture: Nullable<BaseTexture>;
  26897. private _ambientTexture;
  26898. /**
  26899. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26900. */
  26901. ambientTexture: Nullable<BaseTexture>;
  26902. private _opacityTexture;
  26903. /**
  26904. * Define the transparency of the material from a texture.
  26905. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26906. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26907. */
  26908. opacityTexture: Nullable<BaseTexture>;
  26909. private _reflectionTexture;
  26910. /**
  26911. * Define the texture used to display the reflection.
  26912. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26913. */
  26914. reflectionTexture: Nullable<BaseTexture>;
  26915. private _emissiveTexture;
  26916. /**
  26917. * Define texture of the material as if self lit.
  26918. * This will be mixed in the final result even in the absence of light.
  26919. */
  26920. emissiveTexture: Nullable<BaseTexture>;
  26921. private _specularTexture;
  26922. /**
  26923. * Define how the color and intensity of the highlight given by the light in the material.
  26924. */
  26925. specularTexture: Nullable<BaseTexture>;
  26926. private _bumpTexture;
  26927. /**
  26928. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26929. * 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.
  26930. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26931. */
  26932. bumpTexture: Nullable<BaseTexture>;
  26933. private _lightmapTexture;
  26934. /**
  26935. * Complex lighting can be computationally expensive to compute at runtime.
  26936. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26937. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26938. */
  26939. lightmapTexture: Nullable<BaseTexture>;
  26940. private _refractionTexture;
  26941. /**
  26942. * Define the texture used to display the refraction.
  26943. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26944. */
  26945. refractionTexture: Nullable<BaseTexture>;
  26946. /**
  26947. * The color of the material lit by the environmental background lighting.
  26948. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26949. */
  26950. ambientColor: Color3;
  26951. /**
  26952. * The basic color of the material as viewed under a light.
  26953. */
  26954. diffuseColor: Color3;
  26955. /**
  26956. * Define how the color and intensity of the highlight given by the light in the material.
  26957. */
  26958. specularColor: Color3;
  26959. /**
  26960. * Define the color of the material as if self lit.
  26961. * This will be mixed in the final result even in the absence of light.
  26962. */
  26963. emissiveColor: Color3;
  26964. /**
  26965. * Defines how sharp are the highlights in the material.
  26966. * The bigger the value the sharper giving a more glossy feeling to the result.
  26967. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26968. */
  26969. specularPower: number;
  26970. private _useAlphaFromDiffuseTexture;
  26971. /**
  26972. * Does the transparency come from the diffuse texture alpha channel.
  26973. */
  26974. useAlphaFromDiffuseTexture: boolean;
  26975. private _useEmissiveAsIllumination;
  26976. /**
  26977. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26978. */
  26979. useEmissiveAsIllumination: boolean;
  26980. private _linkEmissiveWithDiffuse;
  26981. /**
  26982. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26983. * the emissive level when the final color is close to one.
  26984. */
  26985. linkEmissiveWithDiffuse: boolean;
  26986. private _useSpecularOverAlpha;
  26987. /**
  26988. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26989. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26990. */
  26991. useSpecularOverAlpha: boolean;
  26992. private _useReflectionOverAlpha;
  26993. /**
  26994. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26995. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26996. */
  26997. useReflectionOverAlpha: boolean;
  26998. private _disableLighting;
  26999. /**
  27000. * Does lights from the scene impacts this material.
  27001. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27002. */
  27003. disableLighting: boolean;
  27004. private _useObjectSpaceNormalMap;
  27005. /**
  27006. * Allows using an object space normal map (instead of tangent space).
  27007. */
  27008. useObjectSpaceNormalMap: boolean;
  27009. private _useParallax;
  27010. /**
  27011. * Is parallax enabled or not.
  27012. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27013. */
  27014. useParallax: boolean;
  27015. private _useParallaxOcclusion;
  27016. /**
  27017. * Is parallax occlusion enabled or not.
  27018. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27019. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27020. */
  27021. useParallaxOcclusion: boolean;
  27022. /**
  27023. * 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.
  27024. */
  27025. parallaxScaleBias: number;
  27026. private _roughness;
  27027. /**
  27028. * Helps to define how blurry the reflections should appears in the material.
  27029. */
  27030. roughness: number;
  27031. /**
  27032. * In case of refraction, define the value of the index of refraction.
  27033. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27034. */
  27035. indexOfRefraction: number;
  27036. /**
  27037. * Invert the refraction texture alongside the y axis.
  27038. * It can be useful with procedural textures or probe for instance.
  27039. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27040. */
  27041. invertRefractionY: boolean;
  27042. /**
  27043. * Defines the alpha limits in alpha test mode.
  27044. */
  27045. alphaCutOff: number;
  27046. private _useLightmapAsShadowmap;
  27047. /**
  27048. * In case of light mapping, define whether the map contains light or shadow informations.
  27049. */
  27050. useLightmapAsShadowmap: boolean;
  27051. private _diffuseFresnelParameters;
  27052. /**
  27053. * Define the diffuse fresnel parameters of the material.
  27054. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27055. */
  27056. diffuseFresnelParameters: FresnelParameters;
  27057. private _opacityFresnelParameters;
  27058. /**
  27059. * Define the opacity fresnel parameters of the material.
  27060. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27061. */
  27062. opacityFresnelParameters: FresnelParameters;
  27063. private _reflectionFresnelParameters;
  27064. /**
  27065. * Define the reflection fresnel parameters of the material.
  27066. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27067. */
  27068. reflectionFresnelParameters: FresnelParameters;
  27069. private _refractionFresnelParameters;
  27070. /**
  27071. * Define the refraction fresnel parameters of the material.
  27072. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27073. */
  27074. refractionFresnelParameters: FresnelParameters;
  27075. private _emissiveFresnelParameters;
  27076. /**
  27077. * Define the emissive fresnel parameters of the material.
  27078. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27079. */
  27080. emissiveFresnelParameters: FresnelParameters;
  27081. private _useReflectionFresnelFromSpecular;
  27082. /**
  27083. * If true automatically deducts the fresnels values from the material specularity.
  27084. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27085. */
  27086. useReflectionFresnelFromSpecular: boolean;
  27087. private _useGlossinessFromSpecularMapAlpha;
  27088. /**
  27089. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27090. */
  27091. useGlossinessFromSpecularMapAlpha: boolean;
  27092. private _maxSimultaneousLights;
  27093. /**
  27094. * Defines the maximum number of lights that can be used in the material
  27095. */
  27096. maxSimultaneousLights: number;
  27097. private _invertNormalMapX;
  27098. /**
  27099. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27100. */
  27101. invertNormalMapX: boolean;
  27102. private _invertNormalMapY;
  27103. /**
  27104. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27105. */
  27106. invertNormalMapY: boolean;
  27107. private _twoSidedLighting;
  27108. /**
  27109. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27110. */
  27111. twoSidedLighting: boolean;
  27112. /**
  27113. * Default configuration related to image processing available in the standard Material.
  27114. */
  27115. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27116. /**
  27117. * Gets the image processing configuration used either in this material.
  27118. */
  27119. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27120. /**
  27121. * Sets the Default image processing configuration used either in the this material.
  27122. *
  27123. * If sets to null, the scene one is in use.
  27124. */
  27125. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27126. /**
  27127. * Keep track of the image processing observer to allow dispose and replace.
  27128. */
  27129. private _imageProcessingObserver;
  27130. /**
  27131. * Attaches a new image processing configuration to the Standard Material.
  27132. * @param configuration
  27133. */
  27134. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27135. /**
  27136. * Gets wether the color curves effect is enabled.
  27137. */
  27138. get cameraColorCurvesEnabled(): boolean;
  27139. /**
  27140. * Sets wether the color curves effect is enabled.
  27141. */
  27142. set cameraColorCurvesEnabled(value: boolean);
  27143. /**
  27144. * Gets wether the color grading effect is enabled.
  27145. */
  27146. get cameraColorGradingEnabled(): boolean;
  27147. /**
  27148. * Gets wether the color grading effect is enabled.
  27149. */
  27150. set cameraColorGradingEnabled(value: boolean);
  27151. /**
  27152. * Gets wether tonemapping is enabled or not.
  27153. */
  27154. get cameraToneMappingEnabled(): boolean;
  27155. /**
  27156. * Sets wether tonemapping is enabled or not
  27157. */
  27158. set cameraToneMappingEnabled(value: boolean);
  27159. /**
  27160. * The camera exposure used on this material.
  27161. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27162. * This corresponds to a photographic exposure.
  27163. */
  27164. get cameraExposure(): number;
  27165. /**
  27166. * The camera exposure used on this material.
  27167. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27168. * This corresponds to a photographic exposure.
  27169. */
  27170. set cameraExposure(value: number);
  27171. /**
  27172. * Gets The camera contrast used on this material.
  27173. */
  27174. get cameraContrast(): number;
  27175. /**
  27176. * Sets The camera contrast used on this material.
  27177. */
  27178. set cameraContrast(value: number);
  27179. /**
  27180. * Gets the Color Grading 2D Lookup Texture.
  27181. */
  27182. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27183. /**
  27184. * Sets the Color Grading 2D Lookup Texture.
  27185. */
  27186. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27187. /**
  27188. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27189. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27190. * 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;
  27191. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27192. */
  27193. get cameraColorCurves(): Nullable<ColorCurves>;
  27194. /**
  27195. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27196. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27197. * 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;
  27198. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27199. */
  27200. set cameraColorCurves(value: Nullable<ColorCurves>);
  27201. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27202. protected _worldViewProjectionMatrix: Matrix;
  27203. protected _globalAmbientColor: Color3;
  27204. protected _useLogarithmicDepth: boolean;
  27205. protected _rebuildInParallel: boolean;
  27206. /**
  27207. * Instantiates a new standard material.
  27208. * This is the default material used in Babylon. It is the best trade off between quality
  27209. * and performances.
  27210. * @see http://doc.babylonjs.com/babylon101/materials
  27211. * @param name Define the name of the material in the scene
  27212. * @param scene Define the scene the material belong to
  27213. */
  27214. constructor(name: string, scene: Scene);
  27215. /**
  27216. * Gets a boolean indicating that current material needs to register RTT
  27217. */
  27218. get hasRenderTargetTextures(): boolean;
  27219. /**
  27220. * Gets the current class name of the material e.g. "StandardMaterial"
  27221. * Mainly use in serialization.
  27222. * @returns the class name
  27223. */
  27224. getClassName(): string;
  27225. /**
  27226. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27227. * You can try switching to logarithmic depth.
  27228. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27229. */
  27230. get useLogarithmicDepth(): boolean;
  27231. set useLogarithmicDepth(value: boolean);
  27232. /**
  27233. * Specifies if the material will require alpha blending
  27234. * @returns a boolean specifying if alpha blending is needed
  27235. */
  27236. needAlphaBlending(): boolean;
  27237. /**
  27238. * Specifies if this material should be rendered in alpha test mode
  27239. * @returns a boolean specifying if an alpha test is needed.
  27240. */
  27241. needAlphaTesting(): boolean;
  27242. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27243. /**
  27244. * Get the texture used for alpha test purpose.
  27245. * @returns the diffuse texture in case of the standard material.
  27246. */
  27247. getAlphaTestTexture(): Nullable<BaseTexture>;
  27248. /**
  27249. * Get if the submesh is ready to be used and all its information available.
  27250. * Child classes can use it to update shaders
  27251. * @param mesh defines the mesh to check
  27252. * @param subMesh defines which submesh to check
  27253. * @param useInstances specifies that instances should be used
  27254. * @returns a boolean indicating that the submesh is ready or not
  27255. */
  27256. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27257. /**
  27258. * Builds the material UBO layouts.
  27259. * Used internally during the effect preparation.
  27260. */
  27261. buildUniformLayout(): void;
  27262. /**
  27263. * Unbinds the material from the mesh
  27264. */
  27265. unbind(): void;
  27266. /**
  27267. * Binds the submesh to this material by preparing the effect and shader to draw
  27268. * @param world defines the world transformation matrix
  27269. * @param mesh defines the mesh containing the submesh
  27270. * @param subMesh defines the submesh to bind the material to
  27271. */
  27272. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27273. /**
  27274. * Get the list of animatables in the material.
  27275. * @returns the list of animatables object used in the material
  27276. */
  27277. getAnimatables(): IAnimatable[];
  27278. /**
  27279. * Gets the active textures from the material
  27280. * @returns an array of textures
  27281. */
  27282. getActiveTextures(): BaseTexture[];
  27283. /**
  27284. * Specifies if the material uses a texture
  27285. * @param texture defines the texture to check against the material
  27286. * @returns a boolean specifying if the material uses the texture
  27287. */
  27288. hasTexture(texture: BaseTexture): boolean;
  27289. /**
  27290. * Disposes the material
  27291. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27292. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27293. */
  27294. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27295. /**
  27296. * Makes a duplicate of the material, and gives it a new name
  27297. * @param name defines the new name for the duplicated material
  27298. * @returns the cloned material
  27299. */
  27300. clone(name: string): StandardMaterial;
  27301. /**
  27302. * Serializes this material in a JSON representation
  27303. * @returns the serialized material object
  27304. */
  27305. serialize(): any;
  27306. /**
  27307. * Creates a standard material from parsed material data
  27308. * @param source defines the JSON representation of the material
  27309. * @param scene defines the hosting scene
  27310. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27311. * @returns a new standard material
  27312. */
  27313. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27314. /**
  27315. * Are diffuse textures enabled in the application.
  27316. */
  27317. static get DiffuseTextureEnabled(): boolean;
  27318. static set DiffuseTextureEnabled(value: boolean);
  27319. /**
  27320. * Are ambient textures enabled in the application.
  27321. */
  27322. static get AmbientTextureEnabled(): boolean;
  27323. static set AmbientTextureEnabled(value: boolean);
  27324. /**
  27325. * Are opacity textures enabled in the application.
  27326. */
  27327. static get OpacityTextureEnabled(): boolean;
  27328. static set OpacityTextureEnabled(value: boolean);
  27329. /**
  27330. * Are reflection textures enabled in the application.
  27331. */
  27332. static get ReflectionTextureEnabled(): boolean;
  27333. static set ReflectionTextureEnabled(value: boolean);
  27334. /**
  27335. * Are emissive textures enabled in the application.
  27336. */
  27337. static get EmissiveTextureEnabled(): boolean;
  27338. static set EmissiveTextureEnabled(value: boolean);
  27339. /**
  27340. * Are specular textures enabled in the application.
  27341. */
  27342. static get SpecularTextureEnabled(): boolean;
  27343. static set SpecularTextureEnabled(value: boolean);
  27344. /**
  27345. * Are bump textures enabled in the application.
  27346. */
  27347. static get BumpTextureEnabled(): boolean;
  27348. static set BumpTextureEnabled(value: boolean);
  27349. /**
  27350. * Are lightmap textures enabled in the application.
  27351. */
  27352. static get LightmapTextureEnabled(): boolean;
  27353. static set LightmapTextureEnabled(value: boolean);
  27354. /**
  27355. * Are refraction textures enabled in the application.
  27356. */
  27357. static get RefractionTextureEnabled(): boolean;
  27358. static set RefractionTextureEnabled(value: boolean);
  27359. /**
  27360. * Are color grading textures enabled in the application.
  27361. */
  27362. static get ColorGradingTextureEnabled(): boolean;
  27363. static set ColorGradingTextureEnabled(value: boolean);
  27364. /**
  27365. * Are fresnels enabled in the application.
  27366. */
  27367. static get FresnelEnabled(): boolean;
  27368. static set FresnelEnabled(value: boolean);
  27369. }
  27370. }
  27371. declare module BABYLON {
  27372. /**
  27373. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27374. *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.
  27375. * The SPS is also a particle system. It provides some methods to manage the particles.
  27376. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27377. *
  27378. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27379. */
  27380. export class SolidParticleSystem implements IDisposable {
  27381. /**
  27382. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27383. * Example : var p = SPS.particles[i];
  27384. */
  27385. particles: SolidParticle[];
  27386. /**
  27387. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27388. */
  27389. nbParticles: number;
  27390. /**
  27391. * If the particles must ever face the camera (default false). Useful for planar particles.
  27392. */
  27393. billboard: boolean;
  27394. /**
  27395. * Recompute normals when adding a shape
  27396. */
  27397. recomputeNormals: boolean;
  27398. /**
  27399. * This a counter ofr your own usage. It's not set by any SPS functions.
  27400. */
  27401. counter: number;
  27402. /**
  27403. * The SPS name. This name is also given to the underlying mesh.
  27404. */
  27405. name: string;
  27406. /**
  27407. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27408. */
  27409. mesh: Mesh;
  27410. /**
  27411. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27412. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27413. */
  27414. vars: any;
  27415. /**
  27416. * This array is populated when the SPS is set as 'pickable'.
  27417. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27418. * Each element of this array is an object `{idx: int, faceId: int}`.
  27419. * `idx` is the picked particle index in the `SPS.particles` array
  27420. * `faceId` is the picked face index counted within this particle.
  27421. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27422. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27423. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27424. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27425. */
  27426. pickedParticles: {
  27427. idx: number;
  27428. faceId: number;
  27429. }[];
  27430. /**
  27431. * This array is populated when the SPS is set as 'pickable'
  27432. * Each key of this array is a submesh index.
  27433. * Each element of this array is a second array defined like this :
  27434. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27435. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27436. * `idx` is the picked particle index in the `SPS.particles` array
  27437. * `faceId` is the picked face index counted within this particle.
  27438. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27439. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27440. */
  27441. pickedBySubMesh: {
  27442. idx: number;
  27443. faceId: number;
  27444. }[][];
  27445. /**
  27446. * This array is populated when `enableDepthSort` is set to true.
  27447. * Each element of this array is an instance of the class DepthSortedParticle.
  27448. */
  27449. depthSortedParticles: DepthSortedParticle[];
  27450. /**
  27451. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27452. * @hidden
  27453. */
  27454. _bSphereOnly: boolean;
  27455. /**
  27456. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27457. * @hidden
  27458. */
  27459. _bSphereRadiusFactor: number;
  27460. private _scene;
  27461. private _positions;
  27462. private _indices;
  27463. private _normals;
  27464. private _colors;
  27465. private _uvs;
  27466. private _indices32;
  27467. private _positions32;
  27468. private _normals32;
  27469. private _fixedNormal32;
  27470. private _colors32;
  27471. private _uvs32;
  27472. private _index;
  27473. private _updatable;
  27474. private _pickable;
  27475. private _isVisibilityBoxLocked;
  27476. private _alwaysVisible;
  27477. private _depthSort;
  27478. private _expandable;
  27479. private _shapeCounter;
  27480. private _copy;
  27481. private _color;
  27482. private _computeParticleColor;
  27483. private _computeParticleTexture;
  27484. private _computeParticleRotation;
  27485. private _computeParticleVertex;
  27486. private _computeBoundingBox;
  27487. private _depthSortParticles;
  27488. private _camera;
  27489. private _mustUnrotateFixedNormals;
  27490. private _particlesIntersect;
  27491. private _needs32Bits;
  27492. private _isNotBuilt;
  27493. private _lastParticleId;
  27494. private _idxOfId;
  27495. private _multimaterialEnabled;
  27496. private _useModelMaterial;
  27497. private _indicesByMaterial;
  27498. private _materialIndexes;
  27499. private _depthSortFunction;
  27500. private _materialSortFunction;
  27501. private _materials;
  27502. private _multimaterial;
  27503. private _materialIndexesById;
  27504. private _defaultMaterial;
  27505. private _autoUpdateSubMeshes;
  27506. /**
  27507. * Creates a SPS (Solid Particle System) object.
  27508. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27509. * @param scene (Scene) is the scene in which the SPS is added.
  27510. * @param options defines the options of the sps e.g.
  27511. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27512. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27513. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27514. * * 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.
  27515. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27516. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27517. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27518. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27519. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27520. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27521. */
  27522. constructor(name: string, scene: Scene, options?: {
  27523. updatable?: boolean;
  27524. isPickable?: boolean;
  27525. enableDepthSort?: boolean;
  27526. particleIntersection?: boolean;
  27527. boundingSphereOnly?: boolean;
  27528. bSphereRadiusFactor?: number;
  27529. expandable?: boolean;
  27530. useModelMaterial?: boolean;
  27531. enableMultiMaterial?: boolean;
  27532. });
  27533. /**
  27534. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27535. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27536. * @returns the created mesh
  27537. */
  27538. buildMesh(): Mesh;
  27539. /**
  27540. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27541. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27542. * Thus the particles generated from `digest()` have their property `position` set yet.
  27543. * @param mesh ( Mesh ) is the mesh to be digested
  27544. * @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
  27545. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27546. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27547. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27548. * @returns the current SPS
  27549. */
  27550. digest(mesh: Mesh, options?: {
  27551. facetNb?: number;
  27552. number?: number;
  27553. delta?: number;
  27554. storage?: [];
  27555. }): SolidParticleSystem;
  27556. /**
  27557. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27558. * @hidden
  27559. */
  27560. private _unrotateFixedNormals;
  27561. /**
  27562. * Resets the temporary working copy particle
  27563. * @hidden
  27564. */
  27565. private _resetCopy;
  27566. /**
  27567. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27568. * @param p the current index in the positions array to be updated
  27569. * @param ind the current index in the indices array
  27570. * @param shape a Vector3 array, the shape geometry
  27571. * @param positions the positions array to be updated
  27572. * @param meshInd the shape indices array
  27573. * @param indices the indices array to be updated
  27574. * @param meshUV the shape uv array
  27575. * @param uvs the uv array to be updated
  27576. * @param meshCol the shape color array
  27577. * @param colors the color array to be updated
  27578. * @param meshNor the shape normals array
  27579. * @param normals the normals array to be updated
  27580. * @param idx the particle index
  27581. * @param idxInShape the particle index in its shape
  27582. * @param options the addShape() method passed options
  27583. * @model the particle model
  27584. * @hidden
  27585. */
  27586. private _meshBuilder;
  27587. /**
  27588. * Returns a shape Vector3 array from positions float array
  27589. * @param positions float array
  27590. * @returns a vector3 array
  27591. * @hidden
  27592. */
  27593. private _posToShape;
  27594. /**
  27595. * Returns a shapeUV array from a float uvs (array deep copy)
  27596. * @param uvs as a float array
  27597. * @returns a shapeUV array
  27598. * @hidden
  27599. */
  27600. private _uvsToShapeUV;
  27601. /**
  27602. * Adds a new particle object in the particles array
  27603. * @param idx particle index in particles array
  27604. * @param id particle id
  27605. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27606. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27607. * @param model particle ModelShape object
  27608. * @param shapeId model shape identifier
  27609. * @param idxInShape index of the particle in the current model
  27610. * @param bInfo model bounding info object
  27611. * @param storage target storage array, if any
  27612. * @hidden
  27613. */
  27614. private _addParticle;
  27615. /**
  27616. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27617. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27618. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27619. * @param nb (positive integer) the number of particles to be created from this model
  27620. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27621. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27622. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27623. * @returns the number of shapes in the system
  27624. */
  27625. addShape(mesh: Mesh, nb: number, options?: {
  27626. positionFunction?: any;
  27627. vertexFunction?: any;
  27628. storage?: [];
  27629. }): number;
  27630. /**
  27631. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27632. * @hidden
  27633. */
  27634. private _rebuildParticle;
  27635. /**
  27636. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27637. * @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.
  27638. * @returns the SPS.
  27639. */
  27640. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27641. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27642. * Returns an array with the removed particles.
  27643. * 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.
  27644. * The SPS can't be empty so at least one particle needs to remain in place.
  27645. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27646. * @param start index of the first particle to remove
  27647. * @param end index of the last particle to remove (included)
  27648. * @returns an array populated with the removed particles
  27649. */
  27650. removeParticles(start: number, end: number): SolidParticle[];
  27651. /**
  27652. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27653. * @param solidParticleArray an array populated with Solid Particles objects
  27654. * @returns the SPS
  27655. */
  27656. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27657. /**
  27658. * Creates a new particle and modifies the SPS mesh geometry :
  27659. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27660. * - calls _addParticle() to populate the particle array
  27661. * factorized code from addShape() and insertParticlesFromArray()
  27662. * @param idx particle index in the particles array
  27663. * @param i particle index in its shape
  27664. * @param modelShape particle ModelShape object
  27665. * @param shape shape vertex array
  27666. * @param meshInd shape indices array
  27667. * @param meshUV shape uv array
  27668. * @param meshCol shape color array
  27669. * @param meshNor shape normals array
  27670. * @param bbInfo shape bounding info
  27671. * @param storage target particle storage
  27672. * @options addShape() passed options
  27673. * @hidden
  27674. */
  27675. private _insertNewParticle;
  27676. /**
  27677. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27678. * This method calls `updateParticle()` for each particle of the SPS.
  27679. * For an animated SPS, it is usually called within the render loop.
  27680. * 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.
  27681. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27682. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27683. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27684. * @returns the SPS.
  27685. */
  27686. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27687. /**
  27688. * Disposes the SPS.
  27689. */
  27690. dispose(): void;
  27691. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27692. * idx is the particle index in the SPS
  27693. * faceId is the picked face index counted within this particle.
  27694. * Returns null if the pickInfo can't identify a picked particle.
  27695. * @param pickingInfo (PickingInfo object)
  27696. * @returns {idx: number, faceId: number} or null
  27697. */
  27698. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27699. idx: number;
  27700. faceId: number;
  27701. }>;
  27702. /**
  27703. * Returns a SolidParticle object from its identifier : particle.id
  27704. * @param id (integer) the particle Id
  27705. * @returns the searched particle or null if not found in the SPS.
  27706. */
  27707. getParticleById(id: number): Nullable<SolidParticle>;
  27708. /**
  27709. * Returns a new array populated with the particles having the passed shapeId.
  27710. * @param shapeId (integer) the shape identifier
  27711. * @returns a new solid particle array
  27712. */
  27713. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27714. /**
  27715. * Populates the passed array "ref" with the particles having the passed shapeId.
  27716. * @param shapeId the shape identifier
  27717. * @returns the SPS
  27718. * @param ref
  27719. */
  27720. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27721. /**
  27722. * Computes the required SubMeshes according the materials assigned to the particles.
  27723. * @returns the solid particle system.
  27724. * Does nothing if called before the SPS mesh is built.
  27725. */
  27726. computeSubMeshes(): SolidParticleSystem;
  27727. /**
  27728. * Sorts the solid particles by material when MultiMaterial is enabled.
  27729. * Updates the indices32 array.
  27730. * Updates the indicesByMaterial array.
  27731. * Updates the mesh indices array.
  27732. * @returns the SPS
  27733. * @hidden
  27734. */
  27735. private _sortParticlesByMaterial;
  27736. /**
  27737. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27738. * @hidden
  27739. */
  27740. private _setMaterialIndexesById;
  27741. /**
  27742. * Returns an array with unique values of Materials from the passed array
  27743. * @param array the material array to be checked and filtered
  27744. * @hidden
  27745. */
  27746. private _filterUniqueMaterialId;
  27747. /**
  27748. * Sets a new Standard Material as _defaultMaterial if not already set.
  27749. * @hidden
  27750. */
  27751. private _setDefaultMaterial;
  27752. /**
  27753. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27754. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27755. * @returns the SPS.
  27756. */
  27757. refreshVisibleSize(): SolidParticleSystem;
  27758. /**
  27759. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27760. * @param size the size (float) of the visibility box
  27761. * note : this doesn't lock the SPS mesh bounding box.
  27762. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27763. */
  27764. setVisibilityBox(size: number): void;
  27765. /**
  27766. * Gets whether the SPS as always visible or not
  27767. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27768. */
  27769. get isAlwaysVisible(): boolean;
  27770. /**
  27771. * Sets the SPS as always visible or not
  27772. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27773. */
  27774. set isAlwaysVisible(val: boolean);
  27775. /**
  27776. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27777. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27778. */
  27779. set isVisibilityBoxLocked(val: boolean);
  27780. /**
  27781. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27782. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27783. */
  27784. get isVisibilityBoxLocked(): boolean;
  27785. /**
  27786. * Tells to `setParticles()` to compute the particle rotations or not.
  27787. * Default value : true. The SPS is faster when it's set to false.
  27788. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27789. */
  27790. set computeParticleRotation(val: boolean);
  27791. /**
  27792. * Tells to `setParticles()` to compute the particle colors or not.
  27793. * Default value : true. The SPS is faster when it's set to false.
  27794. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27795. */
  27796. set computeParticleColor(val: boolean);
  27797. set computeParticleTexture(val: boolean);
  27798. /**
  27799. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27800. * Default value : false. The SPS is faster when it's set to false.
  27801. * Note : the particle custom vertex positions aren't stored values.
  27802. */
  27803. set computeParticleVertex(val: boolean);
  27804. /**
  27805. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27806. */
  27807. set computeBoundingBox(val: boolean);
  27808. /**
  27809. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27810. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27811. * Default : `true`
  27812. */
  27813. set depthSortParticles(val: boolean);
  27814. /**
  27815. * Gets if `setParticles()` computes the particle rotations or not.
  27816. * Default value : true. The SPS is faster when it's set to false.
  27817. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27818. */
  27819. get computeParticleRotation(): boolean;
  27820. /**
  27821. * Gets if `setParticles()` computes the particle colors or not.
  27822. * Default value : true. The SPS is faster when it's set to false.
  27823. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27824. */
  27825. get computeParticleColor(): boolean;
  27826. /**
  27827. * Gets if `setParticles()` computes the particle textures or not.
  27828. * Default value : true. The SPS is faster when it's set to false.
  27829. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27830. */
  27831. get computeParticleTexture(): boolean;
  27832. /**
  27833. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27834. * Default value : false. The SPS is faster when it's set to false.
  27835. * Note : the particle custom vertex positions aren't stored values.
  27836. */
  27837. get computeParticleVertex(): boolean;
  27838. /**
  27839. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27840. */
  27841. get computeBoundingBox(): boolean;
  27842. /**
  27843. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27844. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27845. * Default : `true`
  27846. */
  27847. get depthSortParticles(): boolean;
  27848. /**
  27849. * Gets if the SPS is created as expandable at construction time.
  27850. * Default : `false`
  27851. */
  27852. get expandable(): boolean;
  27853. /**
  27854. * Gets if the SPS supports the Multi Materials
  27855. */
  27856. get multimaterialEnabled(): boolean;
  27857. /**
  27858. * Gets if the SPS uses the model materials for its own multimaterial.
  27859. */
  27860. get useModelMaterial(): boolean;
  27861. /**
  27862. * The SPS used material array.
  27863. */
  27864. get materials(): Material[];
  27865. /**
  27866. * Sets the SPS MultiMaterial from the passed materials.
  27867. * Note : the passed array is internally copied and not used then by reference.
  27868. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27869. */
  27870. setMultiMaterial(materials: Material[]): void;
  27871. /**
  27872. * The SPS computed multimaterial object
  27873. */
  27874. get multimaterial(): MultiMaterial;
  27875. set multimaterial(mm: MultiMaterial);
  27876. /**
  27877. * If the subMeshes must be updated on the next call to setParticles()
  27878. */
  27879. get autoUpdateSubMeshes(): boolean;
  27880. set autoUpdateSubMeshes(val: boolean);
  27881. /**
  27882. * This function does nothing. It may be overwritten to set all the particle first values.
  27883. * The SPS doesn't call this function, you may have to call it by your own.
  27884. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27885. */
  27886. initParticles(): void;
  27887. /**
  27888. * This function does nothing. It may be overwritten to recycle a particle.
  27889. * The SPS doesn't call this function, you may have to call it by your own.
  27890. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27891. * @param particle The particle to recycle
  27892. * @returns the recycled particle
  27893. */
  27894. recycleParticle(particle: SolidParticle): SolidParticle;
  27895. /**
  27896. * Updates a particle : this function should be overwritten by the user.
  27897. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27898. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27899. * @example : just set a particle position or velocity and recycle conditions
  27900. * @param particle The particle to update
  27901. * @returns the updated particle
  27902. */
  27903. updateParticle(particle: SolidParticle): SolidParticle;
  27904. /**
  27905. * Updates a vertex of a particle : it can be overwritten by the user.
  27906. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27907. * @param particle the current particle
  27908. * @param vertex the current index of the current particle
  27909. * @param pt the index of the current vertex in the particle shape
  27910. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27911. * @example : just set a vertex particle position
  27912. * @returns the updated vertex
  27913. */
  27914. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27915. /**
  27916. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27917. * This does nothing and may be overwritten by the user.
  27918. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27919. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27920. * @param update the boolean update value actually passed to setParticles()
  27921. */
  27922. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27923. /**
  27924. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27925. * This will be passed three parameters.
  27926. * This does nothing and may be overwritten by the user.
  27927. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27928. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27929. * @param update the boolean update value actually passed to setParticles()
  27930. */
  27931. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27932. }
  27933. }
  27934. declare module BABYLON {
  27935. /**
  27936. * Represents one particle of a solid particle system.
  27937. */
  27938. export class SolidParticle {
  27939. /**
  27940. * particle global index
  27941. */
  27942. idx: number;
  27943. /**
  27944. * particle identifier
  27945. */
  27946. id: number;
  27947. /**
  27948. * The color of the particle
  27949. */
  27950. color: Nullable<Color4>;
  27951. /**
  27952. * The world space position of the particle.
  27953. */
  27954. position: Vector3;
  27955. /**
  27956. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27957. */
  27958. rotation: Vector3;
  27959. /**
  27960. * The world space rotation quaternion of the particle.
  27961. */
  27962. rotationQuaternion: Nullable<Quaternion>;
  27963. /**
  27964. * The scaling of the particle.
  27965. */
  27966. scaling: Vector3;
  27967. /**
  27968. * The uvs of the particle.
  27969. */
  27970. uvs: Vector4;
  27971. /**
  27972. * The current speed of the particle.
  27973. */
  27974. velocity: Vector3;
  27975. /**
  27976. * The pivot point in the particle local space.
  27977. */
  27978. pivot: Vector3;
  27979. /**
  27980. * Must the particle be translated from its pivot point in its local space ?
  27981. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27982. * Default : false
  27983. */
  27984. translateFromPivot: boolean;
  27985. /**
  27986. * Is the particle active or not ?
  27987. */
  27988. alive: boolean;
  27989. /**
  27990. * Is the particle visible or not ?
  27991. */
  27992. isVisible: boolean;
  27993. /**
  27994. * Index of this particle in the global "positions" array (Internal use)
  27995. * @hidden
  27996. */
  27997. _pos: number;
  27998. /**
  27999. * @hidden Index of this particle in the global "indices" array (Internal use)
  28000. */
  28001. _ind: number;
  28002. /**
  28003. * @hidden ModelShape of this particle (Internal use)
  28004. */
  28005. _model: ModelShape;
  28006. /**
  28007. * ModelShape id of this particle
  28008. */
  28009. shapeId: number;
  28010. /**
  28011. * Index of the particle in its shape id
  28012. */
  28013. idxInShape: number;
  28014. /**
  28015. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28016. */
  28017. _modelBoundingInfo: BoundingInfo;
  28018. /**
  28019. * @hidden Particle BoundingInfo object (Internal use)
  28020. */
  28021. _boundingInfo: BoundingInfo;
  28022. /**
  28023. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28024. */
  28025. _sps: SolidParticleSystem;
  28026. /**
  28027. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28028. */
  28029. _stillInvisible: boolean;
  28030. /**
  28031. * @hidden Last computed particle rotation matrix
  28032. */
  28033. _rotationMatrix: number[];
  28034. /**
  28035. * Parent particle Id, if any.
  28036. * Default null.
  28037. */
  28038. parentId: Nullable<number>;
  28039. /**
  28040. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28041. */
  28042. materialIndex: Nullable<number>;
  28043. /**
  28044. * Custom object or properties.
  28045. */
  28046. props: Nullable<any>;
  28047. /**
  28048. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28049. * The possible values are :
  28050. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28051. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28052. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28053. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28054. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28055. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28056. * */
  28057. cullingStrategy: number;
  28058. /**
  28059. * @hidden Internal global position in the SPS.
  28060. */
  28061. _globalPosition: Vector3;
  28062. /**
  28063. * Creates a Solid Particle object.
  28064. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28065. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28066. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28067. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28068. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28069. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28070. * @param shapeId (integer) is the model shape identifier in the SPS.
  28071. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28072. * @param sps defines the sps it is associated to
  28073. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28074. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28075. */
  28076. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28077. /**
  28078. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28079. * @param target the particle target
  28080. * @returns the current particle
  28081. */
  28082. copyToRef(target: SolidParticle): SolidParticle;
  28083. /**
  28084. * Legacy support, changed scale to scaling
  28085. */
  28086. get scale(): Vector3;
  28087. /**
  28088. * Legacy support, changed scale to scaling
  28089. */
  28090. set scale(scale: Vector3);
  28091. /**
  28092. * Legacy support, changed quaternion to rotationQuaternion
  28093. */
  28094. get quaternion(): Nullable<Quaternion>;
  28095. /**
  28096. * Legacy support, changed quaternion to rotationQuaternion
  28097. */
  28098. set quaternion(q: Nullable<Quaternion>);
  28099. /**
  28100. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28101. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28102. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28103. * @returns true if it intersects
  28104. */
  28105. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28106. /**
  28107. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28108. * A particle is in the frustum if its bounding box intersects the frustum
  28109. * @param frustumPlanes defines the frustum to test
  28110. * @returns true if the particle is in the frustum planes
  28111. */
  28112. isInFrustum(frustumPlanes: Plane[]): boolean;
  28113. /**
  28114. * get the rotation matrix of the particle
  28115. * @hidden
  28116. */
  28117. getRotationMatrix(m: Matrix): void;
  28118. }
  28119. /**
  28120. * Represents the shape of the model used by one particle of a solid particle system.
  28121. * SPS internal tool, don't use it manually.
  28122. */
  28123. export class ModelShape {
  28124. /**
  28125. * The shape id
  28126. * @hidden
  28127. */
  28128. shapeID: number;
  28129. /**
  28130. * flat array of model positions (internal use)
  28131. * @hidden
  28132. */
  28133. _shape: Vector3[];
  28134. /**
  28135. * flat array of model UVs (internal use)
  28136. * @hidden
  28137. */
  28138. _shapeUV: number[];
  28139. /**
  28140. * color array of the model
  28141. * @hidden
  28142. */
  28143. _shapeColors: number[];
  28144. /**
  28145. * indices array of the model
  28146. * @hidden
  28147. */
  28148. _indices: number[];
  28149. /**
  28150. * normals array of the model
  28151. * @hidden
  28152. */
  28153. _normals: number[];
  28154. /**
  28155. * length of the shape in the model indices array (internal use)
  28156. * @hidden
  28157. */
  28158. _indicesLength: number;
  28159. /**
  28160. * Custom position function (internal use)
  28161. * @hidden
  28162. */
  28163. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28164. /**
  28165. * Custom vertex function (internal use)
  28166. * @hidden
  28167. */
  28168. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28169. /**
  28170. * Model material (internal use)
  28171. * @hidden
  28172. */
  28173. _material: Nullable<Material>;
  28174. /**
  28175. * 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.
  28176. * SPS internal tool, don't use it manually.
  28177. * @hidden
  28178. */
  28179. 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>);
  28180. }
  28181. /**
  28182. * Represents a Depth Sorted Particle in the solid particle system.
  28183. * @hidden
  28184. */
  28185. export class DepthSortedParticle {
  28186. /**
  28187. * Particle index
  28188. */
  28189. idx: number;
  28190. /**
  28191. * Index of the particle in the "indices" array
  28192. */
  28193. ind: number;
  28194. /**
  28195. * Length of the particle shape in the "indices" array
  28196. */
  28197. indicesLength: number;
  28198. /**
  28199. * Squared distance from the particle to the camera
  28200. */
  28201. sqDistance: number;
  28202. /**
  28203. * Material index when used with MultiMaterials
  28204. */
  28205. materialIndex: number;
  28206. /**
  28207. * Creates a new sorted particle
  28208. * @param materialIndex
  28209. */
  28210. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28211. }
  28212. }
  28213. declare module BABYLON {
  28214. /**
  28215. * @hidden
  28216. */
  28217. export class _MeshCollisionData {
  28218. _checkCollisions: boolean;
  28219. _collisionMask: number;
  28220. _collisionGroup: number;
  28221. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28222. _collider: Nullable<Collider>;
  28223. _oldPositionForCollisions: Vector3;
  28224. _diffPositionForCollisions: Vector3;
  28225. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28226. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28227. }
  28228. }
  28229. declare module BABYLON {
  28230. /** @hidden */
  28231. class _FacetDataStorage {
  28232. facetPositions: Vector3[];
  28233. facetNormals: Vector3[];
  28234. facetPartitioning: number[][];
  28235. facetNb: number;
  28236. partitioningSubdivisions: number;
  28237. partitioningBBoxRatio: number;
  28238. facetDataEnabled: boolean;
  28239. facetParameters: any;
  28240. bbSize: Vector3;
  28241. subDiv: {
  28242. max: number;
  28243. X: number;
  28244. Y: number;
  28245. Z: number;
  28246. };
  28247. facetDepthSort: boolean;
  28248. facetDepthSortEnabled: boolean;
  28249. depthSortedIndices: IndicesArray;
  28250. depthSortedFacets: {
  28251. ind: number;
  28252. sqDistance: number;
  28253. }[];
  28254. facetDepthSortFunction: (f1: {
  28255. ind: number;
  28256. sqDistance: number;
  28257. }, f2: {
  28258. ind: number;
  28259. sqDistance: number;
  28260. }) => number;
  28261. facetDepthSortFrom: Vector3;
  28262. facetDepthSortOrigin: Vector3;
  28263. invertedMatrix: Matrix;
  28264. }
  28265. /**
  28266. * @hidden
  28267. **/
  28268. class _InternalAbstractMeshDataInfo {
  28269. _hasVertexAlpha: boolean;
  28270. _useVertexColors: boolean;
  28271. _numBoneInfluencers: number;
  28272. _applyFog: boolean;
  28273. _receiveShadows: boolean;
  28274. _facetData: _FacetDataStorage;
  28275. _visibility: number;
  28276. _skeleton: Nullable<Skeleton>;
  28277. _layerMask: number;
  28278. _computeBonesUsingShaders: boolean;
  28279. _isActive: boolean;
  28280. _onlyForInstances: boolean;
  28281. _isActiveIntermediate: boolean;
  28282. _onlyForInstancesIntermediate: boolean;
  28283. _actAsRegularMesh: boolean;
  28284. }
  28285. /**
  28286. * Class used to store all common mesh properties
  28287. */
  28288. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28289. /** No occlusion */
  28290. static OCCLUSION_TYPE_NONE: number;
  28291. /** Occlusion set to optimisitic */
  28292. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28293. /** Occlusion set to strict */
  28294. static OCCLUSION_TYPE_STRICT: number;
  28295. /** Use an accurante occlusion algorithm */
  28296. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28297. /** Use a conservative occlusion algorithm */
  28298. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28299. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28300. * Test order :
  28301. * Is the bounding sphere outside the frustum ?
  28302. * If not, are the bounding box vertices outside the frustum ?
  28303. * It not, then the cullable object is in the frustum.
  28304. */
  28305. static readonly CULLINGSTRATEGY_STANDARD: number;
  28306. /** Culling strategy : Bounding Sphere Only.
  28307. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28308. * It's also less accurate than the standard because some not visible objects can still be selected.
  28309. * Test : is the bounding sphere outside the frustum ?
  28310. * If not, then the cullable object is in the frustum.
  28311. */
  28312. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28313. /** Culling strategy : Optimistic Inclusion.
  28314. * This in an inclusion test first, then the standard exclusion test.
  28315. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28316. * 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.
  28317. * Anyway, it's as accurate as the standard strategy.
  28318. * Test :
  28319. * Is the cullable object bounding sphere center in the frustum ?
  28320. * If not, apply the default culling strategy.
  28321. */
  28322. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28323. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28324. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28325. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28326. * 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.
  28327. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28328. * Test :
  28329. * Is the cullable object bounding sphere center in the frustum ?
  28330. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28331. */
  28332. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28333. /**
  28334. * No billboard
  28335. */
  28336. static get BILLBOARDMODE_NONE(): number;
  28337. /** Billboard on X axis */
  28338. static get BILLBOARDMODE_X(): number;
  28339. /** Billboard on Y axis */
  28340. static get BILLBOARDMODE_Y(): number;
  28341. /** Billboard on Z axis */
  28342. static get BILLBOARDMODE_Z(): number;
  28343. /** Billboard on all axes */
  28344. static get BILLBOARDMODE_ALL(): number;
  28345. /** Billboard on using position instead of orientation */
  28346. static get BILLBOARDMODE_USE_POSITION(): number;
  28347. /** @hidden */
  28348. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28349. /**
  28350. * The culling strategy to use to check whether the mesh must be rendered or not.
  28351. * This value can be changed at any time and will be used on the next render mesh selection.
  28352. * The possible values are :
  28353. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28354. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28355. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28356. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28357. * Please read each static variable documentation to get details about the culling process.
  28358. * */
  28359. cullingStrategy: number;
  28360. /**
  28361. * Gets the number of facets in the mesh
  28362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28363. */
  28364. get facetNb(): number;
  28365. /**
  28366. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28367. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28368. */
  28369. get partitioningSubdivisions(): number;
  28370. set partitioningSubdivisions(nb: number);
  28371. /**
  28372. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28373. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28375. */
  28376. get partitioningBBoxRatio(): number;
  28377. set partitioningBBoxRatio(ratio: number);
  28378. /**
  28379. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28380. * Works only for updatable meshes.
  28381. * Doesn't work with multi-materials
  28382. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28383. */
  28384. get mustDepthSortFacets(): boolean;
  28385. set mustDepthSortFacets(sort: boolean);
  28386. /**
  28387. * The location (Vector3) where the facet depth sort must be computed from.
  28388. * By default, the active camera position.
  28389. * Used only when facet depth sort is enabled
  28390. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28391. */
  28392. get facetDepthSortFrom(): Vector3;
  28393. set facetDepthSortFrom(location: Vector3);
  28394. /**
  28395. * gets a boolean indicating if facetData is enabled
  28396. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28397. */
  28398. get isFacetDataEnabled(): boolean;
  28399. /** @hidden */
  28400. _updateNonUniformScalingState(value: boolean): boolean;
  28401. /**
  28402. * An event triggered when this mesh collides with another one
  28403. */
  28404. onCollideObservable: Observable<AbstractMesh>;
  28405. /** Set a function to call when this mesh collides with another one */
  28406. set onCollide(callback: () => void);
  28407. /**
  28408. * An event triggered when the collision's position changes
  28409. */
  28410. onCollisionPositionChangeObservable: Observable<Vector3>;
  28411. /** Set a function to call when the collision's position changes */
  28412. set onCollisionPositionChange(callback: () => void);
  28413. /**
  28414. * An event triggered when material is changed
  28415. */
  28416. onMaterialChangedObservable: Observable<AbstractMesh>;
  28417. /**
  28418. * Gets or sets the orientation for POV movement & rotation
  28419. */
  28420. definedFacingForward: boolean;
  28421. /** @hidden */
  28422. _occlusionQuery: Nullable<WebGLQuery>;
  28423. /** @hidden */
  28424. _renderingGroup: Nullable<RenderingGroup>;
  28425. /**
  28426. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28427. */
  28428. get visibility(): number;
  28429. /**
  28430. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28431. */
  28432. set visibility(value: number);
  28433. /** Gets or sets the alpha index used to sort transparent meshes
  28434. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28435. */
  28436. alphaIndex: number;
  28437. /**
  28438. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28439. */
  28440. isVisible: boolean;
  28441. /**
  28442. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28443. */
  28444. isPickable: boolean;
  28445. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28446. showSubMeshesBoundingBox: boolean;
  28447. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28448. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28449. */
  28450. isBlocker: boolean;
  28451. /**
  28452. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28453. */
  28454. enablePointerMoveEvents: boolean;
  28455. /**
  28456. * Specifies the rendering group id for this mesh (0 by default)
  28457. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28458. */
  28459. renderingGroupId: number;
  28460. private _material;
  28461. /** Gets or sets current material */
  28462. get material(): Nullable<Material>;
  28463. set material(value: Nullable<Material>);
  28464. /**
  28465. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28466. * @see http://doc.babylonjs.com/babylon101/shadows
  28467. */
  28468. get receiveShadows(): boolean;
  28469. set receiveShadows(value: boolean);
  28470. /** Defines color to use when rendering outline */
  28471. outlineColor: Color3;
  28472. /** Define width to use when rendering outline */
  28473. outlineWidth: number;
  28474. /** Defines color to use when rendering overlay */
  28475. overlayColor: Color3;
  28476. /** Defines alpha to use when rendering overlay */
  28477. overlayAlpha: number;
  28478. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28479. get hasVertexAlpha(): boolean;
  28480. set hasVertexAlpha(value: boolean);
  28481. /** 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) */
  28482. get useVertexColors(): boolean;
  28483. set useVertexColors(value: boolean);
  28484. /**
  28485. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28486. */
  28487. get computeBonesUsingShaders(): boolean;
  28488. set computeBonesUsingShaders(value: boolean);
  28489. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28490. get numBoneInfluencers(): number;
  28491. set numBoneInfluencers(value: number);
  28492. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28493. get applyFog(): boolean;
  28494. set applyFog(value: boolean);
  28495. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28496. useOctreeForRenderingSelection: boolean;
  28497. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28498. useOctreeForPicking: boolean;
  28499. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28500. useOctreeForCollisions: boolean;
  28501. /**
  28502. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28503. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28504. */
  28505. get layerMask(): number;
  28506. set layerMask(value: number);
  28507. /**
  28508. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28509. */
  28510. alwaysSelectAsActiveMesh: boolean;
  28511. /**
  28512. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28513. */
  28514. doNotSyncBoundingInfo: boolean;
  28515. /**
  28516. * Gets or sets the current action manager
  28517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28518. */
  28519. actionManager: Nullable<AbstractActionManager>;
  28520. private _meshCollisionData;
  28521. /**
  28522. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28523. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28524. */
  28525. ellipsoid: Vector3;
  28526. /**
  28527. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28528. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28529. */
  28530. ellipsoidOffset: Vector3;
  28531. /**
  28532. * Gets or sets a collision mask used to mask collisions (default is -1).
  28533. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28534. */
  28535. get collisionMask(): number;
  28536. set collisionMask(mask: number);
  28537. /**
  28538. * Gets or sets the current collision group mask (-1 by default).
  28539. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28540. */
  28541. get collisionGroup(): number;
  28542. set collisionGroup(mask: number);
  28543. /**
  28544. * Gets or sets current surrounding meshes (null by default).
  28545. *
  28546. * By default collision detection is tested against every mesh in the scene.
  28547. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28548. * meshes will be tested for the collision.
  28549. *
  28550. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28551. */
  28552. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28553. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28554. /**
  28555. * Defines edge width used when edgesRenderer is enabled
  28556. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28557. */
  28558. edgesWidth: number;
  28559. /**
  28560. * Defines edge color used when edgesRenderer is enabled
  28561. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28562. */
  28563. edgesColor: Color4;
  28564. /** @hidden */
  28565. _edgesRenderer: Nullable<IEdgesRenderer>;
  28566. /** @hidden */
  28567. _masterMesh: Nullable<AbstractMesh>;
  28568. /** @hidden */
  28569. _boundingInfo: Nullable<BoundingInfo>;
  28570. /** @hidden */
  28571. _renderId: number;
  28572. /**
  28573. * Gets or sets the list of subMeshes
  28574. * @see http://doc.babylonjs.com/how_to/multi_materials
  28575. */
  28576. subMeshes: SubMesh[];
  28577. /** @hidden */
  28578. _intersectionsInProgress: AbstractMesh[];
  28579. /** @hidden */
  28580. _unIndexed: boolean;
  28581. /** @hidden */
  28582. _lightSources: Light[];
  28583. /** Gets the list of lights affecting that mesh */
  28584. get lightSources(): Light[];
  28585. /** @hidden */
  28586. get _positions(): Nullable<Vector3[]>;
  28587. /** @hidden */
  28588. _waitingData: {
  28589. lods: Nullable<any>;
  28590. actions: Nullable<any>;
  28591. freezeWorldMatrix: Nullable<boolean>;
  28592. };
  28593. /** @hidden */
  28594. _bonesTransformMatrices: Nullable<Float32Array>;
  28595. /** @hidden */
  28596. _transformMatrixTexture: Nullable<RawTexture>;
  28597. /**
  28598. * Gets or sets a skeleton to apply skining transformations
  28599. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28600. */
  28601. set skeleton(value: Nullable<Skeleton>);
  28602. get skeleton(): Nullable<Skeleton>;
  28603. /**
  28604. * An event triggered when the mesh is rebuilt.
  28605. */
  28606. onRebuildObservable: Observable<AbstractMesh>;
  28607. /**
  28608. * Creates a new AbstractMesh
  28609. * @param name defines the name of the mesh
  28610. * @param scene defines the hosting scene
  28611. */
  28612. constructor(name: string, scene?: Nullable<Scene>);
  28613. /**
  28614. * Returns the string "AbstractMesh"
  28615. * @returns "AbstractMesh"
  28616. */
  28617. getClassName(): string;
  28618. /**
  28619. * Gets a string representation of the current mesh
  28620. * @param fullDetails defines a boolean indicating if full details must be included
  28621. * @returns a string representation of the current mesh
  28622. */
  28623. toString(fullDetails?: boolean): string;
  28624. /**
  28625. * @hidden
  28626. */
  28627. protected _getEffectiveParent(): Nullable<Node>;
  28628. /** @hidden */
  28629. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28630. /** @hidden */
  28631. _rebuild(): void;
  28632. /** @hidden */
  28633. _resyncLightSources(): void;
  28634. /** @hidden */
  28635. _resyncLightSource(light: Light): void;
  28636. /** @hidden */
  28637. _unBindEffect(): void;
  28638. /** @hidden */
  28639. _removeLightSource(light: Light, dispose: boolean): void;
  28640. private _markSubMeshesAsDirty;
  28641. /** @hidden */
  28642. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28643. /** @hidden */
  28644. _markSubMeshesAsAttributesDirty(): void;
  28645. /** @hidden */
  28646. _markSubMeshesAsMiscDirty(): void;
  28647. /**
  28648. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28649. */
  28650. get scaling(): Vector3;
  28651. set scaling(newScaling: Vector3);
  28652. /**
  28653. * Returns true if the mesh is blocked. Implemented by child classes
  28654. */
  28655. get isBlocked(): boolean;
  28656. /**
  28657. * Returns the mesh itself by default. Implemented by child classes
  28658. * @param camera defines the camera to use to pick the right LOD level
  28659. * @returns the currentAbstractMesh
  28660. */
  28661. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28662. /**
  28663. * Returns 0 by default. Implemented by child classes
  28664. * @returns an integer
  28665. */
  28666. getTotalVertices(): number;
  28667. /**
  28668. * Returns a positive integer : the total number of indices in this mesh geometry.
  28669. * @returns the numner of indices or zero if the mesh has no geometry.
  28670. */
  28671. getTotalIndices(): number;
  28672. /**
  28673. * Returns null by default. Implemented by child classes
  28674. * @returns null
  28675. */
  28676. getIndices(): Nullable<IndicesArray>;
  28677. /**
  28678. * Returns the array of the requested vertex data kind. Implemented by child classes
  28679. * @param kind defines the vertex data kind to use
  28680. * @returns null
  28681. */
  28682. getVerticesData(kind: string): Nullable<FloatArray>;
  28683. /**
  28684. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28685. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28686. * Note that a new underlying VertexBuffer object is created each call.
  28687. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28688. * @param kind defines vertex data kind:
  28689. * * VertexBuffer.PositionKind
  28690. * * VertexBuffer.UVKind
  28691. * * VertexBuffer.UV2Kind
  28692. * * VertexBuffer.UV3Kind
  28693. * * VertexBuffer.UV4Kind
  28694. * * VertexBuffer.UV5Kind
  28695. * * VertexBuffer.UV6Kind
  28696. * * VertexBuffer.ColorKind
  28697. * * VertexBuffer.MatricesIndicesKind
  28698. * * VertexBuffer.MatricesIndicesExtraKind
  28699. * * VertexBuffer.MatricesWeightsKind
  28700. * * VertexBuffer.MatricesWeightsExtraKind
  28701. * @param data defines the data source
  28702. * @param updatable defines if the data must be flagged as updatable (or static)
  28703. * @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
  28704. * @returns the current mesh
  28705. */
  28706. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28707. /**
  28708. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28709. * If the mesh has no geometry, it is simply returned as it is.
  28710. * @param kind defines vertex data kind:
  28711. * * VertexBuffer.PositionKind
  28712. * * VertexBuffer.UVKind
  28713. * * VertexBuffer.UV2Kind
  28714. * * VertexBuffer.UV3Kind
  28715. * * VertexBuffer.UV4Kind
  28716. * * VertexBuffer.UV5Kind
  28717. * * VertexBuffer.UV6Kind
  28718. * * VertexBuffer.ColorKind
  28719. * * VertexBuffer.MatricesIndicesKind
  28720. * * VertexBuffer.MatricesIndicesExtraKind
  28721. * * VertexBuffer.MatricesWeightsKind
  28722. * * VertexBuffer.MatricesWeightsExtraKind
  28723. * @param data defines the data source
  28724. * @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
  28725. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28726. * @returns the current mesh
  28727. */
  28728. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28729. /**
  28730. * Sets the mesh indices,
  28731. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28732. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28733. * @param totalVertices Defines the total number of vertices
  28734. * @returns the current mesh
  28735. */
  28736. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28737. /**
  28738. * Gets a boolean indicating if specific vertex data is present
  28739. * @param kind defines the vertex data kind to use
  28740. * @returns true is data kind is present
  28741. */
  28742. isVerticesDataPresent(kind: string): boolean;
  28743. /**
  28744. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28745. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28746. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28747. * @returns a BoundingInfo
  28748. */
  28749. getBoundingInfo(): BoundingInfo;
  28750. /**
  28751. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28752. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28753. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28754. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28755. * @returns the current mesh
  28756. */
  28757. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28758. /**
  28759. * Overwrite the current bounding info
  28760. * @param boundingInfo defines the new bounding info
  28761. * @returns the current mesh
  28762. */
  28763. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28764. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28765. get useBones(): boolean;
  28766. /** @hidden */
  28767. _preActivate(): void;
  28768. /** @hidden */
  28769. _preActivateForIntermediateRendering(renderId: number): void;
  28770. /** @hidden */
  28771. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28772. /** @hidden */
  28773. _postActivate(): void;
  28774. /** @hidden */
  28775. _freeze(): void;
  28776. /** @hidden */
  28777. _unFreeze(): void;
  28778. /**
  28779. * Gets the current world matrix
  28780. * @returns a Matrix
  28781. */
  28782. getWorldMatrix(): Matrix;
  28783. /** @hidden */
  28784. _getWorldMatrixDeterminant(): number;
  28785. /**
  28786. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28787. */
  28788. get isAnInstance(): boolean;
  28789. /**
  28790. * Gets a boolean indicating if this mesh has instances
  28791. */
  28792. get hasInstances(): boolean;
  28793. /**
  28794. * Perform relative position change from the point of view of behind the front of the mesh.
  28795. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28796. * Supports definition of mesh facing forward or backward
  28797. * @param amountRight defines the distance on the right axis
  28798. * @param amountUp defines the distance on the up axis
  28799. * @param amountForward defines the distance on the forward axis
  28800. * @returns the current mesh
  28801. */
  28802. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28803. /**
  28804. * Calculate relative position change from the point of view of behind the front of the mesh.
  28805. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28806. * Supports definition of mesh facing forward or backward
  28807. * @param amountRight defines the distance on the right axis
  28808. * @param amountUp defines the distance on the up axis
  28809. * @param amountForward defines the distance on the forward axis
  28810. * @returns the new displacement vector
  28811. */
  28812. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28813. /**
  28814. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28815. * Supports definition of mesh facing forward or backward
  28816. * @param flipBack defines the flip
  28817. * @param twirlClockwise defines the twirl
  28818. * @param tiltRight defines the tilt
  28819. * @returns the current mesh
  28820. */
  28821. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28822. /**
  28823. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28824. * Supports definition of mesh facing forward or backward.
  28825. * @param flipBack defines the flip
  28826. * @param twirlClockwise defines the twirl
  28827. * @param tiltRight defines the tilt
  28828. * @returns the new rotation vector
  28829. */
  28830. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28831. /**
  28832. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28833. * This means the mesh underlying bounding box and sphere are recomputed.
  28834. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28835. * @returns the current mesh
  28836. */
  28837. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28838. /** @hidden */
  28839. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28840. /** @hidden */
  28841. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28842. /** @hidden */
  28843. _updateBoundingInfo(): AbstractMesh;
  28844. /** @hidden */
  28845. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28846. /** @hidden */
  28847. protected _afterComputeWorldMatrix(): void;
  28848. /** @hidden */
  28849. get _effectiveMesh(): AbstractMesh;
  28850. /**
  28851. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28852. * A mesh is in the frustum if its bounding box intersects the frustum
  28853. * @param frustumPlanes defines the frustum to test
  28854. * @returns true if the mesh is in the frustum planes
  28855. */
  28856. isInFrustum(frustumPlanes: Plane[]): boolean;
  28857. /**
  28858. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28859. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28860. * @param frustumPlanes defines the frustum to test
  28861. * @returns true if the mesh is completely in the frustum planes
  28862. */
  28863. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28864. /**
  28865. * True if the mesh intersects another mesh or a SolidParticle object
  28866. * @param mesh defines a target mesh or SolidParticle to test
  28867. * @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)
  28868. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28869. * @returns true if there is an intersection
  28870. */
  28871. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28872. /**
  28873. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28874. * @param point defines the point to test
  28875. * @returns true if there is an intersection
  28876. */
  28877. intersectsPoint(point: Vector3): boolean;
  28878. /**
  28879. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28880. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28881. */
  28882. get checkCollisions(): boolean;
  28883. set checkCollisions(collisionEnabled: boolean);
  28884. /**
  28885. * Gets Collider object used to compute collisions (not physics)
  28886. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28887. */
  28888. get collider(): Nullable<Collider>;
  28889. /**
  28890. * Move the mesh using collision engine
  28891. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28892. * @param displacement defines the requested displacement vector
  28893. * @returns the current mesh
  28894. */
  28895. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28896. private _onCollisionPositionChange;
  28897. /** @hidden */
  28898. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28899. /** @hidden */
  28900. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28901. /** @hidden */
  28902. _checkCollision(collider: Collider): AbstractMesh;
  28903. /** @hidden */
  28904. _generatePointsArray(): boolean;
  28905. /**
  28906. * Checks if the passed Ray intersects with the mesh
  28907. * @param ray defines the ray to use
  28908. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28909. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28910. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  28911. * @returns the picking info
  28912. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28913. */
  28914. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  28915. /**
  28916. * Clones the current mesh
  28917. * @param name defines the mesh name
  28918. * @param newParent defines the new mesh parent
  28919. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28920. * @returns the new mesh
  28921. */
  28922. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28923. /**
  28924. * Disposes all the submeshes of the current meshnp
  28925. * @returns the current mesh
  28926. */
  28927. releaseSubMeshes(): AbstractMesh;
  28928. /**
  28929. * Releases resources associated with this abstract mesh.
  28930. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28931. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28932. */
  28933. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28934. /**
  28935. * Adds the passed mesh as a child to the current mesh
  28936. * @param mesh defines the child mesh
  28937. * @returns the current mesh
  28938. */
  28939. addChild(mesh: AbstractMesh): AbstractMesh;
  28940. /**
  28941. * Removes the passed mesh from the current mesh children list
  28942. * @param mesh defines the child mesh
  28943. * @returns the current mesh
  28944. */
  28945. removeChild(mesh: AbstractMesh): AbstractMesh;
  28946. /** @hidden */
  28947. private _initFacetData;
  28948. /**
  28949. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28950. * This method can be called within the render loop.
  28951. * 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
  28952. * @returns the current mesh
  28953. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28954. */
  28955. updateFacetData(): AbstractMesh;
  28956. /**
  28957. * Returns the facetLocalNormals array.
  28958. * The normals are expressed in the mesh local spac
  28959. * @returns an array of Vector3
  28960. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28961. */
  28962. getFacetLocalNormals(): Vector3[];
  28963. /**
  28964. * Returns the facetLocalPositions array.
  28965. * The facet positions are expressed in the mesh local space
  28966. * @returns an array of Vector3
  28967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28968. */
  28969. getFacetLocalPositions(): Vector3[];
  28970. /**
  28971. * Returns the facetLocalPartioning array
  28972. * @returns an array of array of numbers
  28973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28974. */
  28975. getFacetLocalPartitioning(): number[][];
  28976. /**
  28977. * Returns the i-th facet position in the world system.
  28978. * This method allocates a new Vector3 per call
  28979. * @param i defines the facet index
  28980. * @returns a new Vector3
  28981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28982. */
  28983. getFacetPosition(i: number): Vector3;
  28984. /**
  28985. * Sets the reference Vector3 with the i-th facet position in the world system
  28986. * @param i defines the facet index
  28987. * @param ref defines the target vector
  28988. * @returns the current mesh
  28989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28990. */
  28991. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28992. /**
  28993. * Returns the i-th facet normal in the world system.
  28994. * This method allocates a new Vector3 per call
  28995. * @param i defines the facet index
  28996. * @returns a new Vector3
  28997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28998. */
  28999. getFacetNormal(i: number): Vector3;
  29000. /**
  29001. * Sets the reference Vector3 with the i-th facet normal in the world system
  29002. * @param i defines the facet index
  29003. * @param ref defines the target vector
  29004. * @returns the current mesh
  29005. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29006. */
  29007. getFacetNormalToRef(i: number, ref: Vector3): this;
  29008. /**
  29009. * 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)
  29010. * @param x defines x coordinate
  29011. * @param y defines y coordinate
  29012. * @param z defines z coordinate
  29013. * @returns the array of facet indexes
  29014. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29015. */
  29016. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29017. /**
  29018. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29019. * @param projected sets as the (x,y,z) world projection on the facet
  29020. * @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
  29021. * @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
  29022. * @param x defines x coordinate
  29023. * @param y defines y coordinate
  29024. * @param z defines z coordinate
  29025. * @returns the face index if found (or null instead)
  29026. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29027. */
  29028. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29029. /**
  29030. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29031. * @param projected sets as the (x,y,z) local projection on the facet
  29032. * @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
  29033. * @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
  29034. * @param x defines x coordinate
  29035. * @param y defines y coordinate
  29036. * @param z defines z coordinate
  29037. * @returns the face index if found (or null instead)
  29038. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29039. */
  29040. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29041. /**
  29042. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29043. * @returns the parameters
  29044. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29045. */
  29046. getFacetDataParameters(): any;
  29047. /**
  29048. * Disables the feature FacetData and frees the related memory
  29049. * @returns the current mesh
  29050. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29051. */
  29052. disableFacetData(): AbstractMesh;
  29053. /**
  29054. * Updates the AbstractMesh indices array
  29055. * @param indices defines the data source
  29056. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29057. * @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)
  29058. * @returns the current mesh
  29059. */
  29060. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29061. /**
  29062. * Creates new normals data for the mesh
  29063. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29064. * @returns the current mesh
  29065. */
  29066. createNormals(updatable: boolean): AbstractMesh;
  29067. /**
  29068. * Align the mesh with a normal
  29069. * @param normal defines the normal to use
  29070. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29071. * @returns the current mesh
  29072. */
  29073. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29074. /** @hidden */
  29075. _checkOcclusionQuery(): boolean;
  29076. /**
  29077. * Disables the mesh edge rendering mode
  29078. * @returns the currentAbstractMesh
  29079. */
  29080. disableEdgesRendering(): AbstractMesh;
  29081. /**
  29082. * Enables the edge rendering mode on the mesh.
  29083. * This mode makes the mesh edges visible
  29084. * @param epsilon defines the maximal distance between two angles to detect a face
  29085. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29086. * @returns the currentAbstractMesh
  29087. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29088. */
  29089. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29090. }
  29091. }
  29092. declare module BABYLON {
  29093. /**
  29094. * Interface used to define ActionEvent
  29095. */
  29096. export interface IActionEvent {
  29097. /** The mesh or sprite that triggered the action */
  29098. source: any;
  29099. /** The X mouse cursor position at the time of the event */
  29100. pointerX: number;
  29101. /** The Y mouse cursor position at the time of the event */
  29102. pointerY: number;
  29103. /** The mesh that is currently pointed at (can be null) */
  29104. meshUnderPointer: Nullable<AbstractMesh>;
  29105. /** the original (browser) event that triggered the ActionEvent */
  29106. sourceEvent?: any;
  29107. /** additional data for the event */
  29108. additionalData?: any;
  29109. }
  29110. /**
  29111. * ActionEvent is the event being sent when an action is triggered.
  29112. */
  29113. export class ActionEvent implements IActionEvent {
  29114. /** The mesh or sprite that triggered the action */
  29115. source: any;
  29116. /** The X mouse cursor position at the time of the event */
  29117. pointerX: number;
  29118. /** The Y mouse cursor position at the time of the event */
  29119. pointerY: number;
  29120. /** The mesh that is currently pointed at (can be null) */
  29121. meshUnderPointer: Nullable<AbstractMesh>;
  29122. /** the original (browser) event that triggered the ActionEvent */
  29123. sourceEvent?: any;
  29124. /** additional data for the event */
  29125. additionalData?: any;
  29126. /**
  29127. * Creates a new ActionEvent
  29128. * @param source The mesh or sprite that triggered the action
  29129. * @param pointerX The X mouse cursor position at the time of the event
  29130. * @param pointerY The Y mouse cursor position at the time of the event
  29131. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29132. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29133. * @param additionalData additional data for the event
  29134. */
  29135. constructor(
  29136. /** The mesh or sprite that triggered the action */
  29137. source: any,
  29138. /** The X mouse cursor position at the time of the event */
  29139. pointerX: number,
  29140. /** The Y mouse cursor position at the time of the event */
  29141. pointerY: number,
  29142. /** The mesh that is currently pointed at (can be null) */
  29143. meshUnderPointer: Nullable<AbstractMesh>,
  29144. /** the original (browser) event that triggered the ActionEvent */
  29145. sourceEvent?: any,
  29146. /** additional data for the event */
  29147. additionalData?: any);
  29148. /**
  29149. * Helper function to auto-create an ActionEvent from a source mesh.
  29150. * @param source The source mesh that triggered the event
  29151. * @param evt The original (browser) event
  29152. * @param additionalData additional data for the event
  29153. * @returns the new ActionEvent
  29154. */
  29155. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29156. /**
  29157. * Helper function to auto-create an ActionEvent from a source sprite
  29158. * @param source The source sprite that triggered the event
  29159. * @param scene Scene associated with the sprite
  29160. * @param evt The original (browser) event
  29161. * @param additionalData additional data for the event
  29162. * @returns the new ActionEvent
  29163. */
  29164. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29165. /**
  29166. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29167. * @param scene the scene where the event occurred
  29168. * @param evt The original (browser) event
  29169. * @returns the new ActionEvent
  29170. */
  29171. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29172. /**
  29173. * Helper function to auto-create an ActionEvent from a primitive
  29174. * @param prim defines the target primitive
  29175. * @param pointerPos defines the pointer position
  29176. * @param evt The original (browser) event
  29177. * @param additionalData additional data for the event
  29178. * @returns the new ActionEvent
  29179. */
  29180. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29181. }
  29182. }
  29183. declare module BABYLON {
  29184. /**
  29185. * Abstract class used to decouple action Manager from scene and meshes.
  29186. * Do not instantiate.
  29187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29188. */
  29189. export abstract class AbstractActionManager implements IDisposable {
  29190. /** Gets the list of active triggers */
  29191. static Triggers: {
  29192. [key: string]: number;
  29193. };
  29194. /** Gets the cursor to use when hovering items */
  29195. hoverCursor: string;
  29196. /** Gets the list of actions */
  29197. actions: IAction[];
  29198. /**
  29199. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29200. */
  29201. isRecursive: boolean;
  29202. /**
  29203. * Releases all associated resources
  29204. */
  29205. abstract dispose(): void;
  29206. /**
  29207. * Does this action manager has pointer triggers
  29208. */
  29209. abstract get hasPointerTriggers(): boolean;
  29210. /**
  29211. * Does this action manager has pick triggers
  29212. */
  29213. abstract get hasPickTriggers(): boolean;
  29214. /**
  29215. * Process a specific trigger
  29216. * @param trigger defines the trigger to process
  29217. * @param evt defines the event details to be processed
  29218. */
  29219. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29220. /**
  29221. * Does this action manager handles actions of any of the given triggers
  29222. * @param triggers defines the triggers to be tested
  29223. * @return a boolean indicating whether one (or more) of the triggers is handled
  29224. */
  29225. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29226. /**
  29227. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29228. * speed.
  29229. * @param triggerA defines the trigger to be tested
  29230. * @param triggerB defines the trigger to be tested
  29231. * @return a boolean indicating whether one (or more) of the triggers is handled
  29232. */
  29233. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29234. /**
  29235. * Does this action manager handles actions of a given trigger
  29236. * @param trigger defines the trigger to be tested
  29237. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29238. * @return whether the trigger is handled
  29239. */
  29240. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29241. /**
  29242. * Serialize this manager to a JSON object
  29243. * @param name defines the property name to store this manager
  29244. * @returns a JSON representation of this manager
  29245. */
  29246. abstract serialize(name: string): any;
  29247. /**
  29248. * Registers an action to this action manager
  29249. * @param action defines the action to be registered
  29250. * @return the action amended (prepared) after registration
  29251. */
  29252. abstract registerAction(action: IAction): Nullable<IAction>;
  29253. /**
  29254. * Unregisters an action to this action manager
  29255. * @param action defines the action to be unregistered
  29256. * @return a boolean indicating whether the action has been unregistered
  29257. */
  29258. abstract unregisterAction(action: IAction): Boolean;
  29259. /**
  29260. * Does exist one action manager with at least one trigger
  29261. **/
  29262. static get HasTriggers(): boolean;
  29263. /**
  29264. * Does exist one action manager with at least one pick trigger
  29265. **/
  29266. static get HasPickTriggers(): boolean;
  29267. /**
  29268. * Does exist one action manager that handles actions of a given trigger
  29269. * @param trigger defines the trigger to be tested
  29270. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29271. **/
  29272. static HasSpecificTrigger(trigger: number): boolean;
  29273. }
  29274. }
  29275. declare module BABYLON {
  29276. /**
  29277. * Defines how a node can be built from a string name.
  29278. */
  29279. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29280. /**
  29281. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29282. */
  29283. export class Node implements IBehaviorAware<Node> {
  29284. /** @hidden */
  29285. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29286. private static _NodeConstructors;
  29287. /**
  29288. * Add a new node constructor
  29289. * @param type defines the type name of the node to construct
  29290. * @param constructorFunc defines the constructor function
  29291. */
  29292. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29293. /**
  29294. * Returns a node constructor based on type name
  29295. * @param type defines the type name
  29296. * @param name defines the new node name
  29297. * @param scene defines the hosting scene
  29298. * @param options defines optional options to transmit to constructors
  29299. * @returns the new constructor or null
  29300. */
  29301. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29302. /**
  29303. * Gets or sets the name of the node
  29304. */
  29305. name: string;
  29306. /**
  29307. * Gets or sets the id of the node
  29308. */
  29309. id: string;
  29310. /**
  29311. * Gets or sets the unique id of the node
  29312. */
  29313. uniqueId: number;
  29314. /**
  29315. * Gets or sets a string used to store user defined state for the node
  29316. */
  29317. state: string;
  29318. /**
  29319. * Gets or sets an object used to store user defined information for the node
  29320. */
  29321. metadata: any;
  29322. /**
  29323. * For internal use only. Please do not use.
  29324. */
  29325. reservedDataStore: any;
  29326. /**
  29327. * List of inspectable custom properties (used by the Inspector)
  29328. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29329. */
  29330. inspectableCustomProperties: IInspectable[];
  29331. private _doNotSerialize;
  29332. /**
  29333. * Gets or sets a boolean used to define if the node must be serialized
  29334. */
  29335. get doNotSerialize(): boolean;
  29336. set doNotSerialize(value: boolean);
  29337. /** @hidden */
  29338. _isDisposed: boolean;
  29339. /**
  29340. * Gets a list of Animations associated with the node
  29341. */
  29342. animations: Animation[];
  29343. protected _ranges: {
  29344. [name: string]: Nullable<AnimationRange>;
  29345. };
  29346. /**
  29347. * Callback raised when the node is ready to be used
  29348. */
  29349. onReady: Nullable<(node: Node) => void>;
  29350. private _isEnabled;
  29351. private _isParentEnabled;
  29352. private _isReady;
  29353. /** @hidden */
  29354. _currentRenderId: number;
  29355. private _parentUpdateId;
  29356. /** @hidden */
  29357. _childUpdateId: number;
  29358. /** @hidden */
  29359. _waitingParentId: Nullable<string>;
  29360. /** @hidden */
  29361. _scene: Scene;
  29362. /** @hidden */
  29363. _cache: any;
  29364. private _parentNode;
  29365. private _children;
  29366. /** @hidden */
  29367. _worldMatrix: Matrix;
  29368. /** @hidden */
  29369. _worldMatrixDeterminant: number;
  29370. /** @hidden */
  29371. _worldMatrixDeterminantIsDirty: boolean;
  29372. /** @hidden */
  29373. private _sceneRootNodesIndex;
  29374. /**
  29375. * Gets a boolean indicating if the node has been disposed
  29376. * @returns true if the node was disposed
  29377. */
  29378. isDisposed(): boolean;
  29379. /**
  29380. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29381. * @see https://doc.babylonjs.com/how_to/parenting
  29382. */
  29383. set parent(parent: Nullable<Node>);
  29384. get parent(): Nullable<Node>;
  29385. /** @hidden */
  29386. _addToSceneRootNodes(): void;
  29387. /** @hidden */
  29388. _removeFromSceneRootNodes(): void;
  29389. private _animationPropertiesOverride;
  29390. /**
  29391. * Gets or sets the animation properties override
  29392. */
  29393. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29394. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29395. /**
  29396. * Gets a string idenfifying the name of the class
  29397. * @returns "Node" string
  29398. */
  29399. getClassName(): string;
  29400. /** @hidden */
  29401. readonly _isNode: boolean;
  29402. /**
  29403. * An event triggered when the mesh is disposed
  29404. */
  29405. onDisposeObservable: Observable<Node>;
  29406. private _onDisposeObserver;
  29407. /**
  29408. * Sets a callback that will be raised when the node will be disposed
  29409. */
  29410. set onDispose(callback: () => void);
  29411. /**
  29412. * Creates a new Node
  29413. * @param name the name and id to be given to this node
  29414. * @param scene the scene this node will be added to
  29415. */
  29416. constructor(name: string, scene?: Nullable<Scene>);
  29417. /**
  29418. * Gets the scene of the node
  29419. * @returns a scene
  29420. */
  29421. getScene(): Scene;
  29422. /**
  29423. * Gets the engine of the node
  29424. * @returns a Engine
  29425. */
  29426. getEngine(): Engine;
  29427. private _behaviors;
  29428. /**
  29429. * Attach a behavior to the node
  29430. * @see http://doc.babylonjs.com/features/behaviour
  29431. * @param behavior defines the behavior to attach
  29432. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29433. * @returns the current Node
  29434. */
  29435. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29436. /**
  29437. * Remove an attached behavior
  29438. * @see http://doc.babylonjs.com/features/behaviour
  29439. * @param behavior defines the behavior to attach
  29440. * @returns the current Node
  29441. */
  29442. removeBehavior(behavior: Behavior<Node>): Node;
  29443. /**
  29444. * Gets the list of attached behaviors
  29445. * @see http://doc.babylonjs.com/features/behaviour
  29446. */
  29447. get behaviors(): Behavior<Node>[];
  29448. /**
  29449. * Gets an attached behavior by name
  29450. * @param name defines the name of the behavior to look for
  29451. * @see http://doc.babylonjs.com/features/behaviour
  29452. * @returns null if behavior was not found else the requested behavior
  29453. */
  29454. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29455. /**
  29456. * Returns the latest update of the World matrix
  29457. * @returns a Matrix
  29458. */
  29459. getWorldMatrix(): Matrix;
  29460. /** @hidden */
  29461. _getWorldMatrixDeterminant(): number;
  29462. /**
  29463. * Returns directly the latest state of the mesh World matrix.
  29464. * A Matrix is returned.
  29465. */
  29466. get worldMatrixFromCache(): Matrix;
  29467. /** @hidden */
  29468. _initCache(): void;
  29469. /** @hidden */
  29470. updateCache(force?: boolean): void;
  29471. /** @hidden */
  29472. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29473. /** @hidden */
  29474. _updateCache(ignoreParentClass?: boolean): void;
  29475. /** @hidden */
  29476. _isSynchronized(): boolean;
  29477. /** @hidden */
  29478. _markSyncedWithParent(): void;
  29479. /** @hidden */
  29480. isSynchronizedWithParent(): boolean;
  29481. /** @hidden */
  29482. isSynchronized(): boolean;
  29483. /**
  29484. * Is this node ready to be used/rendered
  29485. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29486. * @return true if the node is ready
  29487. */
  29488. isReady(completeCheck?: boolean): boolean;
  29489. /**
  29490. * Is this node enabled?
  29491. * 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
  29492. * @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
  29493. * @return whether this node (and its parent) is enabled
  29494. */
  29495. isEnabled(checkAncestors?: boolean): boolean;
  29496. /** @hidden */
  29497. protected _syncParentEnabledState(): void;
  29498. /**
  29499. * Set the enabled state of this node
  29500. * @param value defines the new enabled state
  29501. */
  29502. setEnabled(value: boolean): void;
  29503. /**
  29504. * Is this node a descendant of the given node?
  29505. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29506. * @param ancestor defines the parent node to inspect
  29507. * @returns a boolean indicating if this node is a descendant of the given node
  29508. */
  29509. isDescendantOf(ancestor: Node): boolean;
  29510. /** @hidden */
  29511. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29512. /**
  29513. * Will return all nodes that have this node as ascendant
  29514. * @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
  29515. * @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
  29516. * @return all children nodes of all types
  29517. */
  29518. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29519. /**
  29520. * Get all child-meshes of this node
  29521. * @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)
  29522. * @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
  29523. * @returns an array of AbstractMesh
  29524. */
  29525. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29526. /**
  29527. * Get all direct children of this node
  29528. * @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
  29529. * @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)
  29530. * @returns an array of Node
  29531. */
  29532. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29533. /** @hidden */
  29534. _setReady(state: boolean): void;
  29535. /**
  29536. * Get an animation by name
  29537. * @param name defines the name of the animation to look for
  29538. * @returns null if not found else the requested animation
  29539. */
  29540. getAnimationByName(name: string): Nullable<Animation>;
  29541. /**
  29542. * Creates an animation range for this node
  29543. * @param name defines the name of the range
  29544. * @param from defines the starting key
  29545. * @param to defines the end key
  29546. */
  29547. createAnimationRange(name: string, from: number, to: number): void;
  29548. /**
  29549. * Delete a specific animation range
  29550. * @param name defines the name of the range to delete
  29551. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29552. */
  29553. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29554. /**
  29555. * Get an animation range by name
  29556. * @param name defines the name of the animation range to look for
  29557. * @returns null if not found else the requested animation range
  29558. */
  29559. getAnimationRange(name: string): Nullable<AnimationRange>;
  29560. /**
  29561. * Gets the list of all animation ranges defined on this node
  29562. * @returns an array
  29563. */
  29564. getAnimationRanges(): Nullable<AnimationRange>[];
  29565. /**
  29566. * Will start the animation sequence
  29567. * @param name defines the range frames for animation sequence
  29568. * @param loop defines if the animation should loop (false by default)
  29569. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29570. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29571. * @returns the object created for this animation. If range does not exist, it will return null
  29572. */
  29573. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29574. /**
  29575. * Serialize animation ranges into a JSON compatible object
  29576. * @returns serialization object
  29577. */
  29578. serializeAnimationRanges(): any;
  29579. /**
  29580. * Computes the world matrix of the node
  29581. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29582. * @returns the world matrix
  29583. */
  29584. computeWorldMatrix(force?: boolean): Matrix;
  29585. /**
  29586. * Releases resources associated with this node.
  29587. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29588. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29589. */
  29590. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29591. /**
  29592. * Parse animation range data from a serialization object and store them into a given node
  29593. * @param node defines where to store the animation ranges
  29594. * @param parsedNode defines the serialization object to read data from
  29595. * @param scene defines the hosting scene
  29596. */
  29597. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29598. /**
  29599. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29600. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29601. * @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
  29602. * @returns the new bounding vectors
  29603. */
  29604. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29605. min: Vector3;
  29606. max: Vector3;
  29607. };
  29608. }
  29609. }
  29610. declare module BABYLON {
  29611. /**
  29612. * @hidden
  29613. */
  29614. export class _IAnimationState {
  29615. key: number;
  29616. repeatCount: number;
  29617. workValue?: any;
  29618. loopMode?: number;
  29619. offsetValue?: any;
  29620. highLimitValue?: any;
  29621. }
  29622. /**
  29623. * Class used to store any kind of animation
  29624. */
  29625. export class Animation {
  29626. /**Name of the animation */
  29627. name: string;
  29628. /**Property to animate */
  29629. targetProperty: string;
  29630. /**The frames per second of the animation */
  29631. framePerSecond: number;
  29632. /**The data type of the animation */
  29633. dataType: number;
  29634. /**The loop mode of the animation */
  29635. loopMode?: number | undefined;
  29636. /**Specifies if blending should be enabled */
  29637. enableBlending?: boolean | undefined;
  29638. /**
  29639. * Use matrix interpolation instead of using direct key value when animating matrices
  29640. */
  29641. static AllowMatricesInterpolation: boolean;
  29642. /**
  29643. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29644. */
  29645. static AllowMatrixDecomposeForInterpolation: boolean;
  29646. /**
  29647. * Stores the key frames of the animation
  29648. */
  29649. private _keys;
  29650. /**
  29651. * Stores the easing function of the animation
  29652. */
  29653. private _easingFunction;
  29654. /**
  29655. * @hidden Internal use only
  29656. */
  29657. _runtimeAnimations: RuntimeAnimation[];
  29658. /**
  29659. * The set of event that will be linked to this animation
  29660. */
  29661. private _events;
  29662. /**
  29663. * Stores an array of target property paths
  29664. */
  29665. targetPropertyPath: string[];
  29666. /**
  29667. * Stores the blending speed of the animation
  29668. */
  29669. blendingSpeed: number;
  29670. /**
  29671. * Stores the animation ranges for the animation
  29672. */
  29673. private _ranges;
  29674. /**
  29675. * @hidden Internal use
  29676. */
  29677. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29678. /**
  29679. * Sets up an animation
  29680. * @param property The property to animate
  29681. * @param animationType The animation type to apply
  29682. * @param framePerSecond The frames per second of the animation
  29683. * @param easingFunction The easing function used in the animation
  29684. * @returns The created animation
  29685. */
  29686. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29687. /**
  29688. * Create and start an animation on a node
  29689. * @param name defines the name of the global animation that will be run on all nodes
  29690. * @param node defines the root node where the animation will take place
  29691. * @param targetProperty defines property to animate
  29692. * @param framePerSecond defines the number of frame per second yo use
  29693. * @param totalFrame defines the number of frames in total
  29694. * @param from defines the initial value
  29695. * @param to defines the final value
  29696. * @param loopMode defines which loop mode you want to use (off by default)
  29697. * @param easingFunction defines the easing function to use (linear by default)
  29698. * @param onAnimationEnd defines the callback to call when animation end
  29699. * @returns the animatable created for this animation
  29700. */
  29701. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29702. /**
  29703. * Create and start an animation on a node and its descendants
  29704. * @param name defines the name of the global animation that will be run on all nodes
  29705. * @param node defines the root node where the animation will take place
  29706. * @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
  29707. * @param targetProperty defines property to animate
  29708. * @param framePerSecond defines the number of frame per second to use
  29709. * @param totalFrame defines the number of frames in total
  29710. * @param from defines the initial value
  29711. * @param to defines the final value
  29712. * @param loopMode defines which loop mode you want to use (off by default)
  29713. * @param easingFunction defines the easing function to use (linear by default)
  29714. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29715. * @returns the list of animatables created for all nodes
  29716. * @example https://www.babylonjs-playground.com/#MH0VLI
  29717. */
  29718. 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[]>;
  29719. /**
  29720. * Creates a new animation, merges it with the existing animations and starts it
  29721. * @param name Name of the animation
  29722. * @param node Node which contains the scene that begins the animations
  29723. * @param targetProperty Specifies which property to animate
  29724. * @param framePerSecond The frames per second of the animation
  29725. * @param totalFrame The total number of frames
  29726. * @param from The frame at the beginning of the animation
  29727. * @param to The frame at the end of the animation
  29728. * @param loopMode Specifies the loop mode of the animation
  29729. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29730. * @param onAnimationEnd Callback to run once the animation is complete
  29731. * @returns Nullable animation
  29732. */
  29733. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29734. /**
  29735. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29736. * @param sourceAnimation defines the Animation containing keyframes to convert
  29737. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29738. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29739. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29740. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29741. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29742. */
  29743. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29744. /**
  29745. * Transition property of an host to the target Value
  29746. * @param property The property to transition
  29747. * @param targetValue The target Value of the property
  29748. * @param host The object where the property to animate belongs
  29749. * @param scene Scene used to run the animation
  29750. * @param frameRate Framerate (in frame/s) to use
  29751. * @param transition The transition type we want to use
  29752. * @param duration The duration of the animation, in milliseconds
  29753. * @param onAnimationEnd Callback trigger at the end of the animation
  29754. * @returns Nullable animation
  29755. */
  29756. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29757. /**
  29758. * Return the array of runtime animations currently using this animation
  29759. */
  29760. get runtimeAnimations(): RuntimeAnimation[];
  29761. /**
  29762. * Specifies if any of the runtime animations are currently running
  29763. */
  29764. get hasRunningRuntimeAnimations(): boolean;
  29765. /**
  29766. * Initializes the animation
  29767. * @param name Name of the animation
  29768. * @param targetProperty Property to animate
  29769. * @param framePerSecond The frames per second of the animation
  29770. * @param dataType The data type of the animation
  29771. * @param loopMode The loop mode of the animation
  29772. * @param enableBlending Specifies if blending should be enabled
  29773. */
  29774. constructor(
  29775. /**Name of the animation */
  29776. name: string,
  29777. /**Property to animate */
  29778. targetProperty: string,
  29779. /**The frames per second of the animation */
  29780. framePerSecond: number,
  29781. /**The data type of the animation */
  29782. dataType: number,
  29783. /**The loop mode of the animation */
  29784. loopMode?: number | undefined,
  29785. /**Specifies if blending should be enabled */
  29786. enableBlending?: boolean | undefined);
  29787. /**
  29788. * Converts the animation to a string
  29789. * @param fullDetails support for multiple levels of logging within scene loading
  29790. * @returns String form of the animation
  29791. */
  29792. toString(fullDetails?: boolean): string;
  29793. /**
  29794. * Add an event to this animation
  29795. * @param event Event to add
  29796. */
  29797. addEvent(event: AnimationEvent): void;
  29798. /**
  29799. * Remove all events found at the given frame
  29800. * @param frame The frame to remove events from
  29801. */
  29802. removeEvents(frame: number): void;
  29803. /**
  29804. * Retrieves all the events from the animation
  29805. * @returns Events from the animation
  29806. */
  29807. getEvents(): AnimationEvent[];
  29808. /**
  29809. * Creates an animation range
  29810. * @param name Name of the animation range
  29811. * @param from Starting frame of the animation range
  29812. * @param to Ending frame of the animation
  29813. */
  29814. createRange(name: string, from: number, to: number): void;
  29815. /**
  29816. * Deletes an animation range by name
  29817. * @param name Name of the animation range to delete
  29818. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29819. */
  29820. deleteRange(name: string, deleteFrames?: boolean): void;
  29821. /**
  29822. * Gets the animation range by name, or null if not defined
  29823. * @param name Name of the animation range
  29824. * @returns Nullable animation range
  29825. */
  29826. getRange(name: string): Nullable<AnimationRange>;
  29827. /**
  29828. * Gets the key frames from the animation
  29829. * @returns The key frames of the animation
  29830. */
  29831. getKeys(): Array<IAnimationKey>;
  29832. /**
  29833. * Gets the highest frame rate of the animation
  29834. * @returns Highest frame rate of the animation
  29835. */
  29836. getHighestFrame(): number;
  29837. /**
  29838. * Gets the easing function of the animation
  29839. * @returns Easing function of the animation
  29840. */
  29841. getEasingFunction(): IEasingFunction;
  29842. /**
  29843. * Sets the easing function of the animation
  29844. * @param easingFunction A custom mathematical formula for animation
  29845. */
  29846. setEasingFunction(easingFunction: EasingFunction): void;
  29847. /**
  29848. * Interpolates a scalar linearly
  29849. * @param startValue Start value of the animation curve
  29850. * @param endValue End value of the animation curve
  29851. * @param gradient Scalar amount to interpolate
  29852. * @returns Interpolated scalar value
  29853. */
  29854. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29855. /**
  29856. * Interpolates a scalar cubically
  29857. * @param startValue Start value of the animation curve
  29858. * @param outTangent End tangent of the animation
  29859. * @param endValue End value of the animation curve
  29860. * @param inTangent Start tangent of the animation curve
  29861. * @param gradient Scalar amount to interpolate
  29862. * @returns Interpolated scalar value
  29863. */
  29864. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29865. /**
  29866. * Interpolates a quaternion using a spherical linear interpolation
  29867. * @param startValue Start value of the animation curve
  29868. * @param endValue End value of the animation curve
  29869. * @param gradient Scalar amount to interpolate
  29870. * @returns Interpolated quaternion value
  29871. */
  29872. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29873. /**
  29874. * Interpolates a quaternion cubically
  29875. * @param startValue Start value of the animation curve
  29876. * @param outTangent End tangent of the animation curve
  29877. * @param endValue End value of the animation curve
  29878. * @param inTangent Start tangent of the animation curve
  29879. * @param gradient Scalar amount to interpolate
  29880. * @returns Interpolated quaternion value
  29881. */
  29882. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29883. /**
  29884. * Interpolates a Vector3 linearl
  29885. * @param startValue Start value of the animation curve
  29886. * @param endValue End value of the animation curve
  29887. * @param gradient Scalar amount to interpolate
  29888. * @returns Interpolated scalar value
  29889. */
  29890. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29891. /**
  29892. * Interpolates a Vector3 cubically
  29893. * @param startValue Start value of the animation curve
  29894. * @param outTangent End tangent of the animation
  29895. * @param endValue End value of the animation curve
  29896. * @param inTangent Start tangent of the animation curve
  29897. * @param gradient Scalar amount to interpolate
  29898. * @returns InterpolatedVector3 value
  29899. */
  29900. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29901. /**
  29902. * Interpolates a Vector2 linearly
  29903. * @param startValue Start value of the animation curve
  29904. * @param endValue End value of the animation curve
  29905. * @param gradient Scalar amount to interpolate
  29906. * @returns Interpolated Vector2 value
  29907. */
  29908. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29909. /**
  29910. * Interpolates a Vector2 cubically
  29911. * @param startValue Start value of the animation curve
  29912. * @param outTangent End tangent of the animation
  29913. * @param endValue End value of the animation curve
  29914. * @param inTangent Start tangent of the animation curve
  29915. * @param gradient Scalar amount to interpolate
  29916. * @returns Interpolated Vector2 value
  29917. */
  29918. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29919. /**
  29920. * Interpolates a size linearly
  29921. * @param startValue Start value of the animation curve
  29922. * @param endValue End value of the animation curve
  29923. * @param gradient Scalar amount to interpolate
  29924. * @returns Interpolated Size value
  29925. */
  29926. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29927. /**
  29928. * Interpolates a Color3 linearly
  29929. * @param startValue Start value of the animation curve
  29930. * @param endValue End value of the animation curve
  29931. * @param gradient Scalar amount to interpolate
  29932. * @returns Interpolated Color3 value
  29933. */
  29934. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29935. /**
  29936. * Interpolates a Color4 linearly
  29937. * @param startValue Start value of the animation curve
  29938. * @param endValue End value of the animation curve
  29939. * @param gradient Scalar amount to interpolate
  29940. * @returns Interpolated Color3 value
  29941. */
  29942. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29943. /**
  29944. * @hidden Internal use only
  29945. */
  29946. _getKeyValue(value: any): any;
  29947. /**
  29948. * @hidden Internal use only
  29949. */
  29950. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29951. /**
  29952. * Defines the function to use to interpolate matrices
  29953. * @param startValue defines the start matrix
  29954. * @param endValue defines the end matrix
  29955. * @param gradient defines the gradient between both matrices
  29956. * @param result defines an optional target matrix where to store the interpolation
  29957. * @returns the interpolated matrix
  29958. */
  29959. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29960. /**
  29961. * Makes a copy of the animation
  29962. * @returns Cloned animation
  29963. */
  29964. clone(): Animation;
  29965. /**
  29966. * Sets the key frames of the animation
  29967. * @param values The animation key frames to set
  29968. */
  29969. setKeys(values: Array<IAnimationKey>): void;
  29970. /**
  29971. * Serializes the animation to an object
  29972. * @returns Serialized object
  29973. */
  29974. serialize(): any;
  29975. /**
  29976. * Float animation type
  29977. */
  29978. static readonly ANIMATIONTYPE_FLOAT: number;
  29979. /**
  29980. * Vector3 animation type
  29981. */
  29982. static readonly ANIMATIONTYPE_VECTOR3: number;
  29983. /**
  29984. * Quaternion animation type
  29985. */
  29986. static readonly ANIMATIONTYPE_QUATERNION: number;
  29987. /**
  29988. * Matrix animation type
  29989. */
  29990. static readonly ANIMATIONTYPE_MATRIX: number;
  29991. /**
  29992. * Color3 animation type
  29993. */
  29994. static readonly ANIMATIONTYPE_COLOR3: number;
  29995. /**
  29996. * Color3 animation type
  29997. */
  29998. static readonly ANIMATIONTYPE_COLOR4: number;
  29999. /**
  30000. * Vector2 animation type
  30001. */
  30002. static readonly ANIMATIONTYPE_VECTOR2: number;
  30003. /**
  30004. * Size animation type
  30005. */
  30006. static readonly ANIMATIONTYPE_SIZE: number;
  30007. /**
  30008. * Relative Loop Mode
  30009. */
  30010. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30011. /**
  30012. * Cycle Loop Mode
  30013. */
  30014. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30015. /**
  30016. * Constant Loop Mode
  30017. */
  30018. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30019. /** @hidden */
  30020. static _UniversalLerp(left: any, right: any, amount: number): any;
  30021. /**
  30022. * Parses an animation object and creates an animation
  30023. * @param parsedAnimation Parsed animation object
  30024. * @returns Animation object
  30025. */
  30026. static Parse(parsedAnimation: any): Animation;
  30027. /**
  30028. * Appends the serialized animations from the source animations
  30029. * @param source Source containing the animations
  30030. * @param destination Target to store the animations
  30031. */
  30032. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30033. }
  30034. }
  30035. declare module BABYLON {
  30036. /**
  30037. * Interface containing an array of animations
  30038. */
  30039. export interface IAnimatable {
  30040. /**
  30041. * Array of animations
  30042. */
  30043. animations: Nullable<Array<Animation>>;
  30044. }
  30045. }
  30046. declare module BABYLON {
  30047. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30048. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30049. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30050. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30051. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30052. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30053. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30054. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30055. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30056. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30057. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30058. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30059. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30060. /**
  30061. * Decorator used to define property that can be serialized as reference to a camera
  30062. * @param sourceName defines the name of the property to decorate
  30063. */
  30064. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30065. /**
  30066. * Class used to help serialization objects
  30067. */
  30068. export class SerializationHelper {
  30069. /** @hidden */
  30070. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30071. /** @hidden */
  30072. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30073. /** @hidden */
  30074. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30075. /** @hidden */
  30076. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30077. /**
  30078. * Appends the serialized animations from the source animations
  30079. * @param source Source containing the animations
  30080. * @param destination Target to store the animations
  30081. */
  30082. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30083. /**
  30084. * Static function used to serialized a specific entity
  30085. * @param entity defines the entity to serialize
  30086. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30087. * @returns a JSON compatible object representing the serialization of the entity
  30088. */
  30089. static Serialize<T>(entity: T, serializationObject?: any): any;
  30090. /**
  30091. * Creates a new entity from a serialization data object
  30092. * @param creationFunction defines a function used to instanciated the new entity
  30093. * @param source defines the source serialization data
  30094. * @param scene defines the hosting scene
  30095. * @param rootUrl defines the root url for resources
  30096. * @returns a new entity
  30097. */
  30098. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30099. /**
  30100. * Clones an object
  30101. * @param creationFunction defines the function used to instanciate the new object
  30102. * @param source defines the source object
  30103. * @returns the cloned object
  30104. */
  30105. static Clone<T>(creationFunction: () => T, source: T): T;
  30106. /**
  30107. * Instanciates a new object based on a source one (some data will be shared between both object)
  30108. * @param creationFunction defines the function used to instanciate the new object
  30109. * @param source defines the source object
  30110. * @returns the new object
  30111. */
  30112. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30113. }
  30114. }
  30115. declare module BABYLON {
  30116. /**
  30117. * Base class of all the textures in babylon.
  30118. * It groups all the common properties the materials, post process, lights... might need
  30119. * in order to make a correct use of the texture.
  30120. */
  30121. export class BaseTexture implements IAnimatable {
  30122. /**
  30123. * Default anisotropic filtering level for the application.
  30124. * It is set to 4 as a good tradeoff between perf and quality.
  30125. */
  30126. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30127. /**
  30128. * Gets or sets the unique id of the texture
  30129. */
  30130. uniqueId: number;
  30131. /**
  30132. * Define the name of the texture.
  30133. */
  30134. name: string;
  30135. /**
  30136. * Gets or sets an object used to store user defined information.
  30137. */
  30138. metadata: any;
  30139. /**
  30140. * For internal use only. Please do not use.
  30141. */
  30142. reservedDataStore: any;
  30143. private _hasAlpha;
  30144. /**
  30145. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30146. */
  30147. set hasAlpha(value: boolean);
  30148. get hasAlpha(): boolean;
  30149. /**
  30150. * Defines if the alpha value should be determined via the rgb values.
  30151. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30152. */
  30153. getAlphaFromRGB: boolean;
  30154. /**
  30155. * Intensity or strength of the texture.
  30156. * It is commonly used by materials to fine tune the intensity of the texture
  30157. */
  30158. level: number;
  30159. /**
  30160. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30161. * This is part of the texture as textures usually maps to one uv set.
  30162. */
  30163. coordinatesIndex: number;
  30164. private _coordinatesMode;
  30165. /**
  30166. * How a texture is mapped.
  30167. *
  30168. * | Value | Type | Description |
  30169. * | ----- | ----------------------------------- | ----------- |
  30170. * | 0 | EXPLICIT_MODE | |
  30171. * | 1 | SPHERICAL_MODE | |
  30172. * | 2 | PLANAR_MODE | |
  30173. * | 3 | CUBIC_MODE | |
  30174. * | 4 | PROJECTION_MODE | |
  30175. * | 5 | SKYBOX_MODE | |
  30176. * | 6 | INVCUBIC_MODE | |
  30177. * | 7 | EQUIRECTANGULAR_MODE | |
  30178. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30179. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30180. */
  30181. set coordinatesMode(value: number);
  30182. get coordinatesMode(): number;
  30183. /**
  30184. * | Value | Type | Description |
  30185. * | ----- | ------------------ | ----------- |
  30186. * | 0 | CLAMP_ADDRESSMODE | |
  30187. * | 1 | WRAP_ADDRESSMODE | |
  30188. * | 2 | MIRROR_ADDRESSMODE | |
  30189. */
  30190. wrapU: number;
  30191. /**
  30192. * | Value | Type | Description |
  30193. * | ----- | ------------------ | ----------- |
  30194. * | 0 | CLAMP_ADDRESSMODE | |
  30195. * | 1 | WRAP_ADDRESSMODE | |
  30196. * | 2 | MIRROR_ADDRESSMODE | |
  30197. */
  30198. wrapV: number;
  30199. /**
  30200. * | Value | Type | Description |
  30201. * | ----- | ------------------ | ----------- |
  30202. * | 0 | CLAMP_ADDRESSMODE | |
  30203. * | 1 | WRAP_ADDRESSMODE | |
  30204. * | 2 | MIRROR_ADDRESSMODE | |
  30205. */
  30206. wrapR: number;
  30207. /**
  30208. * With compliant hardware and browser (supporting anisotropic filtering)
  30209. * this defines the level of anisotropic filtering in the texture.
  30210. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30211. */
  30212. anisotropicFilteringLevel: number;
  30213. /**
  30214. * Define if the texture is a cube texture or if false a 2d texture.
  30215. */
  30216. get isCube(): boolean;
  30217. set isCube(value: boolean);
  30218. /**
  30219. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30220. */
  30221. get is3D(): boolean;
  30222. set is3D(value: boolean);
  30223. /**
  30224. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30225. */
  30226. get is2DArray(): boolean;
  30227. set is2DArray(value: boolean);
  30228. /**
  30229. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30230. * HDR texture are usually stored in linear space.
  30231. * This only impacts the PBR and Background materials
  30232. */
  30233. gammaSpace: boolean;
  30234. /**
  30235. * Gets or sets whether or not the texture contains RGBD data.
  30236. */
  30237. get isRGBD(): boolean;
  30238. set isRGBD(value: boolean);
  30239. /**
  30240. * Is Z inverted in the texture (useful in a cube texture).
  30241. */
  30242. invertZ: boolean;
  30243. /**
  30244. * Are mip maps generated for this texture or not.
  30245. */
  30246. get noMipmap(): boolean;
  30247. /**
  30248. * @hidden
  30249. */
  30250. lodLevelInAlpha: boolean;
  30251. /**
  30252. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30253. */
  30254. get lodGenerationOffset(): number;
  30255. set lodGenerationOffset(value: number);
  30256. /**
  30257. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30258. */
  30259. get lodGenerationScale(): number;
  30260. set lodGenerationScale(value: number);
  30261. /**
  30262. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30263. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30264. * average roughness values.
  30265. */
  30266. get linearSpecularLOD(): boolean;
  30267. set linearSpecularLOD(value: boolean);
  30268. /**
  30269. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30270. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30271. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30272. */
  30273. get irradianceTexture(): Nullable<BaseTexture>;
  30274. set irradianceTexture(value: Nullable<BaseTexture>);
  30275. /**
  30276. * Define if the texture is a render target.
  30277. */
  30278. isRenderTarget: boolean;
  30279. /**
  30280. * Define the unique id of the texture in the scene.
  30281. */
  30282. get uid(): string;
  30283. /**
  30284. * Return a string representation of the texture.
  30285. * @returns the texture as a string
  30286. */
  30287. toString(): string;
  30288. /**
  30289. * Get the class name of the texture.
  30290. * @returns "BaseTexture"
  30291. */
  30292. getClassName(): string;
  30293. /**
  30294. * Define the list of animation attached to the texture.
  30295. */
  30296. animations: Animation[];
  30297. /**
  30298. * An event triggered when the texture is disposed.
  30299. */
  30300. onDisposeObservable: Observable<BaseTexture>;
  30301. private _onDisposeObserver;
  30302. /**
  30303. * Callback triggered when the texture has been disposed.
  30304. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30305. */
  30306. set onDispose(callback: () => void);
  30307. /**
  30308. * Define the current state of the loading sequence when in delayed load mode.
  30309. */
  30310. delayLoadState: number;
  30311. private _scene;
  30312. /** @hidden */
  30313. _texture: Nullable<InternalTexture>;
  30314. private _uid;
  30315. /**
  30316. * Define if the texture is preventinga material to render or not.
  30317. * If not and the texture is not ready, the engine will use a default black texture instead.
  30318. */
  30319. get isBlocking(): boolean;
  30320. /**
  30321. * Instantiates a new BaseTexture.
  30322. * Base class of all the textures in babylon.
  30323. * It groups all the common properties the materials, post process, lights... might need
  30324. * in order to make a correct use of the texture.
  30325. * @param scene Define the scene the texture blongs to
  30326. */
  30327. constructor(scene: Nullable<Scene>);
  30328. /**
  30329. * Get the scene the texture belongs to.
  30330. * @returns the scene or null if undefined
  30331. */
  30332. getScene(): Nullable<Scene>;
  30333. /**
  30334. * Get the texture transform matrix used to offset tile the texture for istance.
  30335. * @returns the transformation matrix
  30336. */
  30337. getTextureMatrix(): Matrix;
  30338. /**
  30339. * Get the texture reflection matrix used to rotate/transform the reflection.
  30340. * @returns the reflection matrix
  30341. */
  30342. getReflectionTextureMatrix(): Matrix;
  30343. /**
  30344. * Get the underlying lower level texture from Babylon.
  30345. * @returns the insternal texture
  30346. */
  30347. getInternalTexture(): Nullable<InternalTexture>;
  30348. /**
  30349. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30350. * @returns true if ready or not blocking
  30351. */
  30352. isReadyOrNotBlocking(): boolean;
  30353. /**
  30354. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30355. * @returns true if fully ready
  30356. */
  30357. isReady(): boolean;
  30358. private _cachedSize;
  30359. /**
  30360. * Get the size of the texture.
  30361. * @returns the texture size.
  30362. */
  30363. getSize(): ISize;
  30364. /**
  30365. * Get the base size of the texture.
  30366. * It can be different from the size if the texture has been resized for POT for instance
  30367. * @returns the base size
  30368. */
  30369. getBaseSize(): ISize;
  30370. /**
  30371. * Update the sampling mode of the texture.
  30372. * Default is Trilinear mode.
  30373. *
  30374. * | Value | Type | Description |
  30375. * | ----- | ------------------ | ----------- |
  30376. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30377. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30378. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30379. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30380. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30381. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30382. * | 7 | NEAREST_LINEAR | |
  30383. * | 8 | NEAREST_NEAREST | |
  30384. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30385. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30386. * | 11 | LINEAR_LINEAR | |
  30387. * | 12 | LINEAR_NEAREST | |
  30388. *
  30389. * > _mag_: magnification filter (close to the viewer)
  30390. * > _min_: minification filter (far from the viewer)
  30391. * > _mip_: filter used between mip map levels
  30392. *@param samplingMode Define the new sampling mode of the texture
  30393. */
  30394. updateSamplingMode(samplingMode: number): void;
  30395. /**
  30396. * Scales the texture if is `canRescale()`
  30397. * @param ratio the resize factor we want to use to rescale
  30398. */
  30399. scale(ratio: number): void;
  30400. /**
  30401. * Get if the texture can rescale.
  30402. */
  30403. get canRescale(): boolean;
  30404. /** @hidden */
  30405. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30406. /** @hidden */
  30407. _rebuild(): void;
  30408. /**
  30409. * Triggers the load sequence in delayed load mode.
  30410. */
  30411. delayLoad(): void;
  30412. /**
  30413. * Clones the texture.
  30414. * @returns the cloned texture
  30415. */
  30416. clone(): Nullable<BaseTexture>;
  30417. /**
  30418. * Get the texture underlying type (INT, FLOAT...)
  30419. */
  30420. get textureType(): number;
  30421. /**
  30422. * Get the texture underlying format (RGB, RGBA...)
  30423. */
  30424. get textureFormat(): number;
  30425. /**
  30426. * Indicates that textures need to be re-calculated for all materials
  30427. */
  30428. protected _markAllSubMeshesAsTexturesDirty(): void;
  30429. /**
  30430. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30431. * This will returns an RGBA array buffer containing either in values (0-255) or
  30432. * float values (0-1) depending of the underlying buffer type.
  30433. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30434. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30435. * @param buffer defines a user defined buffer to fill with data (can be null)
  30436. * @returns The Array buffer containing the pixels data.
  30437. */
  30438. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30439. /**
  30440. * Release and destroy the underlying lower level texture aka internalTexture.
  30441. */
  30442. releaseInternalTexture(): void;
  30443. /** @hidden */
  30444. get _lodTextureHigh(): Nullable<BaseTexture>;
  30445. /** @hidden */
  30446. get _lodTextureMid(): Nullable<BaseTexture>;
  30447. /** @hidden */
  30448. get _lodTextureLow(): Nullable<BaseTexture>;
  30449. /**
  30450. * Dispose the texture and release its associated resources.
  30451. */
  30452. dispose(): void;
  30453. /**
  30454. * Serialize the texture into a JSON representation that can be parsed later on.
  30455. * @returns the JSON representation of the texture
  30456. */
  30457. serialize(): any;
  30458. /**
  30459. * Helper function to be called back once a list of texture contains only ready textures.
  30460. * @param textures Define the list of textures to wait for
  30461. * @param callback Define the callback triggered once the entire list will be ready
  30462. */
  30463. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30464. }
  30465. }
  30466. declare module BABYLON {
  30467. /**
  30468. * Options to be used when creating an effect.
  30469. */
  30470. export interface IEffectCreationOptions {
  30471. /**
  30472. * Atrributes that will be used in the shader.
  30473. */
  30474. attributes: string[];
  30475. /**
  30476. * Uniform varible names that will be set in the shader.
  30477. */
  30478. uniformsNames: string[];
  30479. /**
  30480. * Uniform buffer variable names that will be set in the shader.
  30481. */
  30482. uniformBuffersNames: string[];
  30483. /**
  30484. * Sampler texture variable names that will be set in the shader.
  30485. */
  30486. samplers: string[];
  30487. /**
  30488. * Define statements that will be set in the shader.
  30489. */
  30490. defines: any;
  30491. /**
  30492. * Possible fallbacks for this effect to improve performance when needed.
  30493. */
  30494. fallbacks: Nullable<IEffectFallbacks>;
  30495. /**
  30496. * Callback that will be called when the shader is compiled.
  30497. */
  30498. onCompiled: Nullable<(effect: Effect) => void>;
  30499. /**
  30500. * Callback that will be called if an error occurs during shader compilation.
  30501. */
  30502. onError: Nullable<(effect: Effect, errors: string) => void>;
  30503. /**
  30504. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30505. */
  30506. indexParameters?: any;
  30507. /**
  30508. * Max number of lights that can be used in the shader.
  30509. */
  30510. maxSimultaneousLights?: number;
  30511. /**
  30512. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30513. */
  30514. transformFeedbackVaryings?: Nullable<string[]>;
  30515. }
  30516. /**
  30517. * Effect containing vertex and fragment shader that can be executed on an object.
  30518. */
  30519. export class Effect implements IDisposable {
  30520. /**
  30521. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30522. */
  30523. static ShadersRepository: string;
  30524. /**
  30525. * Enable logging of the shader code when a compilation error occurs
  30526. */
  30527. static LogShaderCodeOnCompilationError: boolean;
  30528. /**
  30529. * Name of the effect.
  30530. */
  30531. name: any;
  30532. /**
  30533. * String container all the define statements that should be set on the shader.
  30534. */
  30535. defines: string;
  30536. /**
  30537. * Callback that will be called when the shader is compiled.
  30538. */
  30539. onCompiled: Nullable<(effect: Effect) => void>;
  30540. /**
  30541. * Callback that will be called if an error occurs during shader compilation.
  30542. */
  30543. onError: Nullable<(effect: Effect, errors: string) => void>;
  30544. /**
  30545. * Callback that will be called when effect is bound.
  30546. */
  30547. onBind: Nullable<(effect: Effect) => void>;
  30548. /**
  30549. * Unique ID of the effect.
  30550. */
  30551. uniqueId: number;
  30552. /**
  30553. * Observable that will be called when the shader is compiled.
  30554. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30555. */
  30556. onCompileObservable: Observable<Effect>;
  30557. /**
  30558. * Observable that will be called if an error occurs during shader compilation.
  30559. */
  30560. onErrorObservable: Observable<Effect>;
  30561. /** @hidden */
  30562. _onBindObservable: Nullable<Observable<Effect>>;
  30563. /**
  30564. * @hidden
  30565. * Specifies if the effect was previously ready
  30566. */
  30567. _wasPreviouslyReady: boolean;
  30568. /**
  30569. * Observable that will be called when effect is bound.
  30570. */
  30571. get onBindObservable(): Observable<Effect>;
  30572. /** @hidden */
  30573. _bonesComputationForcedToCPU: boolean;
  30574. private static _uniqueIdSeed;
  30575. private _engine;
  30576. private _uniformBuffersNames;
  30577. private _uniformBuffersNamesList;
  30578. private _uniformsNames;
  30579. private _samplerList;
  30580. private _samplers;
  30581. private _isReady;
  30582. private _compilationError;
  30583. private _allFallbacksProcessed;
  30584. private _attributesNames;
  30585. private _attributes;
  30586. private _attributeLocationByName;
  30587. private _uniforms;
  30588. /**
  30589. * Key for the effect.
  30590. * @hidden
  30591. */
  30592. _key: string;
  30593. private _indexParameters;
  30594. private _fallbacks;
  30595. private _vertexSourceCode;
  30596. private _fragmentSourceCode;
  30597. private _vertexSourceCodeOverride;
  30598. private _fragmentSourceCodeOverride;
  30599. private _transformFeedbackVaryings;
  30600. /**
  30601. * Compiled shader to webGL program.
  30602. * @hidden
  30603. */
  30604. _pipelineContext: Nullable<IPipelineContext>;
  30605. private _valueCache;
  30606. private static _baseCache;
  30607. /**
  30608. * Instantiates an effect.
  30609. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30610. * @param baseName Name of the effect.
  30611. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30612. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30613. * @param samplers List of sampler variables that will be passed to the shader.
  30614. * @param engine Engine to be used to render the effect
  30615. * @param defines Define statements to be added to the shader.
  30616. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30617. * @param onCompiled Callback that will be called when the shader is compiled.
  30618. * @param onError Callback that will be called if an error occurs during shader compilation.
  30619. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30620. */
  30621. 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);
  30622. private _useFinalCode;
  30623. /**
  30624. * Unique key for this effect
  30625. */
  30626. get key(): string;
  30627. /**
  30628. * If the effect has been compiled and prepared.
  30629. * @returns if the effect is compiled and prepared.
  30630. */
  30631. isReady(): boolean;
  30632. private _isReadyInternal;
  30633. /**
  30634. * The engine the effect was initialized with.
  30635. * @returns the engine.
  30636. */
  30637. getEngine(): Engine;
  30638. /**
  30639. * The pipeline context for this effect
  30640. * @returns the associated pipeline context
  30641. */
  30642. getPipelineContext(): Nullable<IPipelineContext>;
  30643. /**
  30644. * The set of names of attribute variables for the shader.
  30645. * @returns An array of attribute names.
  30646. */
  30647. getAttributesNames(): string[];
  30648. /**
  30649. * Returns the attribute at the given index.
  30650. * @param index The index of the attribute.
  30651. * @returns The location of the attribute.
  30652. */
  30653. getAttributeLocation(index: number): number;
  30654. /**
  30655. * Returns the attribute based on the name of the variable.
  30656. * @param name of the attribute to look up.
  30657. * @returns the attribute location.
  30658. */
  30659. getAttributeLocationByName(name: string): number;
  30660. /**
  30661. * The number of attributes.
  30662. * @returns the numnber of attributes.
  30663. */
  30664. getAttributesCount(): number;
  30665. /**
  30666. * Gets the index of a uniform variable.
  30667. * @param uniformName of the uniform to look up.
  30668. * @returns the index.
  30669. */
  30670. getUniformIndex(uniformName: string): number;
  30671. /**
  30672. * Returns the attribute based on the name of the variable.
  30673. * @param uniformName of the uniform to look up.
  30674. * @returns the location of the uniform.
  30675. */
  30676. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30677. /**
  30678. * Returns an array of sampler variable names
  30679. * @returns The array of sampler variable names.
  30680. */
  30681. getSamplers(): string[];
  30682. /**
  30683. * Returns an array of uniform variable names
  30684. * @returns The array of uniform variable names.
  30685. */
  30686. getUniformNames(): string[];
  30687. /**
  30688. * Returns an array of uniform buffer variable names
  30689. * @returns The array of uniform buffer variable names.
  30690. */
  30691. getUniformBuffersNames(): string[];
  30692. /**
  30693. * Returns the index parameters used to create the effect
  30694. * @returns The index parameters object
  30695. */
  30696. getIndexParameters(): any;
  30697. /**
  30698. * The error from the last compilation.
  30699. * @returns the error string.
  30700. */
  30701. getCompilationError(): string;
  30702. /**
  30703. * Gets a boolean indicating that all fallbacks were used during compilation
  30704. * @returns true if all fallbacks were used
  30705. */
  30706. allFallbacksProcessed(): boolean;
  30707. /**
  30708. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30709. * @param func The callback to be used.
  30710. */
  30711. executeWhenCompiled(func: (effect: Effect) => void): void;
  30712. private _checkIsReady;
  30713. private _loadShader;
  30714. /**
  30715. * Gets the vertex shader source code of this effect
  30716. */
  30717. get vertexSourceCode(): string;
  30718. /**
  30719. * Gets the fragment shader source code of this effect
  30720. */
  30721. get fragmentSourceCode(): string;
  30722. /**
  30723. * Recompiles the webGL program
  30724. * @param vertexSourceCode The source code for the vertex shader.
  30725. * @param fragmentSourceCode The source code for the fragment shader.
  30726. * @param onCompiled Callback called when completed.
  30727. * @param onError Callback called on error.
  30728. * @hidden
  30729. */
  30730. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30731. /**
  30732. * Prepares the effect
  30733. * @hidden
  30734. */
  30735. _prepareEffect(): void;
  30736. private _getShaderCodeAndErrorLine;
  30737. private _processCompilationErrors;
  30738. /**
  30739. * Checks if the effect is supported. (Must be called after compilation)
  30740. */
  30741. get isSupported(): boolean;
  30742. /**
  30743. * Binds a texture to the engine to be used as output of the shader.
  30744. * @param channel Name of the output variable.
  30745. * @param texture Texture to bind.
  30746. * @hidden
  30747. */
  30748. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30749. /**
  30750. * Sets a texture on the engine to be used in the shader.
  30751. * @param channel Name of the sampler variable.
  30752. * @param texture Texture to set.
  30753. */
  30754. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30755. /**
  30756. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30757. * @param channel Name of the sampler variable.
  30758. * @param texture Texture to set.
  30759. */
  30760. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30761. /**
  30762. * Sets an array of textures on the engine to be used in the shader.
  30763. * @param channel Name of the variable.
  30764. * @param textures Textures to set.
  30765. */
  30766. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30767. /**
  30768. * 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)
  30769. * @param channel Name of the sampler variable.
  30770. * @param postProcess Post process to get the input texture from.
  30771. */
  30772. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30773. /**
  30774. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30775. * 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)
  30776. * @param channel Name of the sampler variable.
  30777. * @param postProcess Post process to get the output texture from.
  30778. */
  30779. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30780. /** @hidden */
  30781. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30782. /** @hidden */
  30783. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30784. /** @hidden */
  30785. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30786. /** @hidden */
  30787. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30788. /**
  30789. * Binds a buffer to a uniform.
  30790. * @param buffer Buffer to bind.
  30791. * @param name Name of the uniform variable to bind to.
  30792. */
  30793. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30794. /**
  30795. * Binds block to a uniform.
  30796. * @param blockName Name of the block to bind.
  30797. * @param index Index to bind.
  30798. */
  30799. bindUniformBlock(blockName: string, index: number): void;
  30800. /**
  30801. * Sets an interger value on a uniform variable.
  30802. * @param uniformName Name of the variable.
  30803. * @param value Value to be set.
  30804. * @returns this effect.
  30805. */
  30806. setInt(uniformName: string, value: number): Effect;
  30807. /**
  30808. * Sets an int array on a uniform variable.
  30809. * @param uniformName Name of the variable.
  30810. * @param array array to be set.
  30811. * @returns this effect.
  30812. */
  30813. setIntArray(uniformName: string, array: Int32Array): Effect;
  30814. /**
  30815. * 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)
  30816. * @param uniformName Name of the variable.
  30817. * @param array array to be set.
  30818. * @returns this effect.
  30819. */
  30820. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30821. /**
  30822. * 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)
  30823. * @param uniformName Name of the variable.
  30824. * @param array array to be set.
  30825. * @returns this effect.
  30826. */
  30827. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30828. /**
  30829. * 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)
  30830. * @param uniformName Name of the variable.
  30831. * @param array array to be set.
  30832. * @returns this effect.
  30833. */
  30834. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30835. /**
  30836. * Sets an float array on a uniform variable.
  30837. * @param uniformName Name of the variable.
  30838. * @param array array to be set.
  30839. * @returns this effect.
  30840. */
  30841. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30842. /**
  30843. * 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)
  30844. * @param uniformName Name of the variable.
  30845. * @param array array to be set.
  30846. * @returns this effect.
  30847. */
  30848. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30849. /**
  30850. * 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)
  30851. * @param uniformName Name of the variable.
  30852. * @param array array to be set.
  30853. * @returns this effect.
  30854. */
  30855. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30856. /**
  30857. * 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)
  30858. * @param uniformName Name of the variable.
  30859. * @param array array to be set.
  30860. * @returns this effect.
  30861. */
  30862. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30863. /**
  30864. * Sets an array on a uniform variable.
  30865. * @param uniformName Name of the variable.
  30866. * @param array array to be set.
  30867. * @returns this effect.
  30868. */
  30869. setArray(uniformName: string, array: number[]): Effect;
  30870. /**
  30871. * 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)
  30872. * @param uniformName Name of the variable.
  30873. * @param array array to be set.
  30874. * @returns this effect.
  30875. */
  30876. setArray2(uniformName: string, array: number[]): Effect;
  30877. /**
  30878. * 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)
  30879. * @param uniformName Name of the variable.
  30880. * @param array array to be set.
  30881. * @returns this effect.
  30882. */
  30883. setArray3(uniformName: string, array: number[]): Effect;
  30884. /**
  30885. * 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)
  30886. * @param uniformName Name of the variable.
  30887. * @param array array to be set.
  30888. * @returns this effect.
  30889. */
  30890. setArray4(uniformName: string, array: number[]): Effect;
  30891. /**
  30892. * Sets matrices on a uniform variable.
  30893. * @param uniformName Name of the variable.
  30894. * @param matrices matrices to be set.
  30895. * @returns this effect.
  30896. */
  30897. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30898. /**
  30899. * Sets matrix on a uniform variable.
  30900. * @param uniformName Name of the variable.
  30901. * @param matrix matrix to be set.
  30902. * @returns this effect.
  30903. */
  30904. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30905. /**
  30906. * 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)
  30907. * @param uniformName Name of the variable.
  30908. * @param matrix matrix to be set.
  30909. * @returns this effect.
  30910. */
  30911. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30912. /**
  30913. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30914. * @param uniformName Name of the variable.
  30915. * @param matrix matrix to be set.
  30916. * @returns this effect.
  30917. */
  30918. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30919. /**
  30920. * Sets a float on a uniform variable.
  30921. * @param uniformName Name of the variable.
  30922. * @param value value to be set.
  30923. * @returns this effect.
  30924. */
  30925. setFloat(uniformName: string, value: number): Effect;
  30926. /**
  30927. * Sets a boolean on a uniform variable.
  30928. * @param uniformName Name of the variable.
  30929. * @param bool value to be set.
  30930. * @returns this effect.
  30931. */
  30932. setBool(uniformName: string, bool: boolean): Effect;
  30933. /**
  30934. * Sets a Vector2 on a uniform variable.
  30935. * @param uniformName Name of the variable.
  30936. * @param vector2 vector2 to be set.
  30937. * @returns this effect.
  30938. */
  30939. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30940. /**
  30941. * Sets a float2 on a uniform variable.
  30942. * @param uniformName Name of the variable.
  30943. * @param x First float in float2.
  30944. * @param y Second float in float2.
  30945. * @returns this effect.
  30946. */
  30947. setFloat2(uniformName: string, x: number, y: number): Effect;
  30948. /**
  30949. * Sets a Vector3 on a uniform variable.
  30950. * @param uniformName Name of the variable.
  30951. * @param vector3 Value to be set.
  30952. * @returns this effect.
  30953. */
  30954. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30955. /**
  30956. * Sets a float3 on a uniform variable.
  30957. * @param uniformName Name of the variable.
  30958. * @param x First float in float3.
  30959. * @param y Second float in float3.
  30960. * @param z Third float in float3.
  30961. * @returns this effect.
  30962. */
  30963. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30964. /**
  30965. * Sets a Vector4 on a uniform variable.
  30966. * @param uniformName Name of the variable.
  30967. * @param vector4 Value to be set.
  30968. * @returns this effect.
  30969. */
  30970. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30971. /**
  30972. * Sets a float4 on a uniform variable.
  30973. * @param uniformName Name of the variable.
  30974. * @param x First float in float4.
  30975. * @param y Second float in float4.
  30976. * @param z Third float in float4.
  30977. * @param w Fourth float in float4.
  30978. * @returns this effect.
  30979. */
  30980. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30981. /**
  30982. * Sets a Color3 on a uniform variable.
  30983. * @param uniformName Name of the variable.
  30984. * @param color3 Value to be set.
  30985. * @returns this effect.
  30986. */
  30987. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30988. /**
  30989. * Sets a Color4 on a uniform variable.
  30990. * @param uniformName Name of the variable.
  30991. * @param color3 Value to be set.
  30992. * @param alpha Alpha value to be set.
  30993. * @returns this effect.
  30994. */
  30995. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30996. /**
  30997. * Sets a Color4 on a uniform variable
  30998. * @param uniformName defines the name of the variable
  30999. * @param color4 defines the value to be set
  31000. * @returns this effect.
  31001. */
  31002. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31003. /** Release all associated resources */
  31004. dispose(): void;
  31005. /**
  31006. * This function will add a new shader to the shader store
  31007. * @param name the name of the shader
  31008. * @param pixelShader optional pixel shader content
  31009. * @param vertexShader optional vertex shader content
  31010. */
  31011. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31012. /**
  31013. * Store of each shader (The can be looked up using effect.key)
  31014. */
  31015. static ShadersStore: {
  31016. [key: string]: string;
  31017. };
  31018. /**
  31019. * Store of each included file for a shader (The can be looked up using effect.key)
  31020. */
  31021. static IncludesShadersStore: {
  31022. [key: string]: string;
  31023. };
  31024. /**
  31025. * Resets the cache of effects.
  31026. */
  31027. static ResetCache(): void;
  31028. }
  31029. }
  31030. declare module BABYLON {
  31031. /**
  31032. * Interface used to describe the capabilities of the engine relatively to the current browser
  31033. */
  31034. export interface EngineCapabilities {
  31035. /** Maximum textures units per fragment shader */
  31036. maxTexturesImageUnits: number;
  31037. /** Maximum texture units per vertex shader */
  31038. maxVertexTextureImageUnits: number;
  31039. /** Maximum textures units in the entire pipeline */
  31040. maxCombinedTexturesImageUnits: number;
  31041. /** Maximum texture size */
  31042. maxTextureSize: number;
  31043. /** Maximum texture samples */
  31044. maxSamples?: number;
  31045. /** Maximum cube texture size */
  31046. maxCubemapTextureSize: number;
  31047. /** Maximum render texture size */
  31048. maxRenderTextureSize: number;
  31049. /** Maximum number of vertex attributes */
  31050. maxVertexAttribs: number;
  31051. /** Maximum number of varyings */
  31052. maxVaryingVectors: number;
  31053. /** Maximum number of uniforms per vertex shader */
  31054. maxVertexUniformVectors: number;
  31055. /** Maximum number of uniforms per fragment shader */
  31056. maxFragmentUniformVectors: number;
  31057. /** Defines if standard derivates (dx/dy) are supported */
  31058. standardDerivatives: boolean;
  31059. /** Defines if s3tc texture compression is supported */
  31060. s3tc?: WEBGL_compressed_texture_s3tc;
  31061. /** Defines if pvrtc texture compression is supported */
  31062. pvrtc: any;
  31063. /** Defines if etc1 texture compression is supported */
  31064. etc1: any;
  31065. /** Defines if etc2 texture compression is supported */
  31066. etc2: any;
  31067. /** Defines if astc texture compression is supported */
  31068. astc: any;
  31069. /** Defines if float textures are supported */
  31070. textureFloat: boolean;
  31071. /** Defines if vertex array objects are supported */
  31072. vertexArrayObject: boolean;
  31073. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31074. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31075. /** Gets the maximum level of anisotropy supported */
  31076. maxAnisotropy: number;
  31077. /** Defines if instancing is supported */
  31078. instancedArrays: boolean;
  31079. /** Defines if 32 bits indices are supported */
  31080. uintIndices: boolean;
  31081. /** Defines if high precision shaders are supported */
  31082. highPrecisionShaderSupported: boolean;
  31083. /** Defines if depth reading in the fragment shader is supported */
  31084. fragmentDepthSupported: boolean;
  31085. /** Defines if float texture linear filtering is supported*/
  31086. textureFloatLinearFiltering: boolean;
  31087. /** Defines if rendering to float textures is supported */
  31088. textureFloatRender: boolean;
  31089. /** Defines if half float textures are supported*/
  31090. textureHalfFloat: boolean;
  31091. /** Defines if half float texture linear filtering is supported*/
  31092. textureHalfFloatLinearFiltering: boolean;
  31093. /** Defines if rendering to half float textures is supported */
  31094. textureHalfFloatRender: boolean;
  31095. /** Defines if textureLOD shader command is supported */
  31096. textureLOD: boolean;
  31097. /** Defines if draw buffers extension is supported */
  31098. drawBuffersExtension: boolean;
  31099. /** Defines if depth textures are supported */
  31100. depthTextureExtension: boolean;
  31101. /** Defines if float color buffer are supported */
  31102. colorBufferFloat: boolean;
  31103. /** Gets disjoint timer query extension (null if not supported) */
  31104. timerQuery?: EXT_disjoint_timer_query;
  31105. /** Defines if timestamp can be used with timer query */
  31106. canUseTimestampForTimerQuery: boolean;
  31107. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31108. multiview?: any;
  31109. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31110. oculusMultiview?: any;
  31111. /** Function used to let the system compiles shaders in background */
  31112. parallelShaderCompile?: {
  31113. COMPLETION_STATUS_KHR: number;
  31114. };
  31115. /** Max number of texture samples for MSAA */
  31116. maxMSAASamples: number;
  31117. /** Defines if the blend min max extension is supported */
  31118. blendMinMax: boolean;
  31119. }
  31120. }
  31121. declare module BABYLON {
  31122. /**
  31123. * @hidden
  31124. **/
  31125. export class DepthCullingState {
  31126. private _isDepthTestDirty;
  31127. private _isDepthMaskDirty;
  31128. private _isDepthFuncDirty;
  31129. private _isCullFaceDirty;
  31130. private _isCullDirty;
  31131. private _isZOffsetDirty;
  31132. private _isFrontFaceDirty;
  31133. private _depthTest;
  31134. private _depthMask;
  31135. private _depthFunc;
  31136. private _cull;
  31137. private _cullFace;
  31138. private _zOffset;
  31139. private _frontFace;
  31140. /**
  31141. * Initializes the state.
  31142. */
  31143. constructor();
  31144. get isDirty(): boolean;
  31145. get zOffset(): number;
  31146. set zOffset(value: number);
  31147. get cullFace(): Nullable<number>;
  31148. set cullFace(value: Nullable<number>);
  31149. get cull(): Nullable<boolean>;
  31150. set cull(value: Nullable<boolean>);
  31151. get depthFunc(): Nullable<number>;
  31152. set depthFunc(value: Nullable<number>);
  31153. get depthMask(): boolean;
  31154. set depthMask(value: boolean);
  31155. get depthTest(): boolean;
  31156. set depthTest(value: boolean);
  31157. get frontFace(): Nullable<number>;
  31158. set frontFace(value: Nullable<number>);
  31159. reset(): void;
  31160. apply(gl: WebGLRenderingContext): void;
  31161. }
  31162. }
  31163. declare module BABYLON {
  31164. /**
  31165. * @hidden
  31166. **/
  31167. export class StencilState {
  31168. /** 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 */
  31169. static readonly ALWAYS: number;
  31170. /** Passed to stencilOperation to specify that stencil value must be kept */
  31171. static readonly KEEP: number;
  31172. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31173. static readonly REPLACE: number;
  31174. private _isStencilTestDirty;
  31175. private _isStencilMaskDirty;
  31176. private _isStencilFuncDirty;
  31177. private _isStencilOpDirty;
  31178. private _stencilTest;
  31179. private _stencilMask;
  31180. private _stencilFunc;
  31181. private _stencilFuncRef;
  31182. private _stencilFuncMask;
  31183. private _stencilOpStencilFail;
  31184. private _stencilOpDepthFail;
  31185. private _stencilOpStencilDepthPass;
  31186. get isDirty(): boolean;
  31187. get stencilFunc(): number;
  31188. set stencilFunc(value: number);
  31189. get stencilFuncRef(): number;
  31190. set stencilFuncRef(value: number);
  31191. get stencilFuncMask(): number;
  31192. set stencilFuncMask(value: number);
  31193. get stencilOpStencilFail(): number;
  31194. set stencilOpStencilFail(value: number);
  31195. get stencilOpDepthFail(): number;
  31196. set stencilOpDepthFail(value: number);
  31197. get stencilOpStencilDepthPass(): number;
  31198. set stencilOpStencilDepthPass(value: number);
  31199. get stencilMask(): number;
  31200. set stencilMask(value: number);
  31201. get stencilTest(): boolean;
  31202. set stencilTest(value: boolean);
  31203. constructor();
  31204. reset(): void;
  31205. apply(gl: WebGLRenderingContext): void;
  31206. }
  31207. }
  31208. declare module BABYLON {
  31209. /**
  31210. * @hidden
  31211. **/
  31212. export class AlphaState {
  31213. private _isAlphaBlendDirty;
  31214. private _isBlendFunctionParametersDirty;
  31215. private _isBlendEquationParametersDirty;
  31216. private _isBlendConstantsDirty;
  31217. private _alphaBlend;
  31218. private _blendFunctionParameters;
  31219. private _blendEquationParameters;
  31220. private _blendConstants;
  31221. /**
  31222. * Initializes the state.
  31223. */
  31224. constructor();
  31225. get isDirty(): boolean;
  31226. get alphaBlend(): boolean;
  31227. set alphaBlend(value: boolean);
  31228. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31229. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31230. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31231. reset(): void;
  31232. apply(gl: WebGLRenderingContext): void;
  31233. }
  31234. }
  31235. declare module BABYLON {
  31236. /** @hidden */
  31237. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31238. attributeProcessor(attribute: string): string;
  31239. varyingProcessor(varying: string, isFragment: boolean): string;
  31240. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31241. }
  31242. }
  31243. declare module BABYLON {
  31244. /**
  31245. * Interface for attribute information associated with buffer instanciation
  31246. */
  31247. export interface InstancingAttributeInfo {
  31248. /**
  31249. * Name of the GLSL attribute
  31250. * if attribute index is not specified, this is used to retrieve the index from the effect
  31251. */
  31252. attributeName: string;
  31253. /**
  31254. * Index/offset of the attribute in the vertex shader
  31255. * if not specified, this will be computes from the name.
  31256. */
  31257. index?: number;
  31258. /**
  31259. * size of the attribute, 1, 2, 3 or 4
  31260. */
  31261. attributeSize: number;
  31262. /**
  31263. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31264. */
  31265. offset: number;
  31266. /**
  31267. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31268. * default to 1
  31269. */
  31270. divisor?: number;
  31271. /**
  31272. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31273. * default is FLOAT
  31274. */
  31275. attributeType?: number;
  31276. /**
  31277. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31278. */
  31279. normalized?: boolean;
  31280. }
  31281. }
  31282. declare module BABYLON {
  31283. interface ThinEngine {
  31284. /**
  31285. * Update a video texture
  31286. * @param texture defines the texture to update
  31287. * @param video defines the video element to use
  31288. * @param invertY defines if data must be stored with Y axis inverted
  31289. */
  31290. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31291. }
  31292. }
  31293. declare module BABYLON {
  31294. /**
  31295. * Settings for finer control over video usage
  31296. */
  31297. export interface VideoTextureSettings {
  31298. /**
  31299. * Applies `autoplay` to video, if specified
  31300. */
  31301. autoPlay?: boolean;
  31302. /**
  31303. * Applies `loop` to video, if specified
  31304. */
  31305. loop?: boolean;
  31306. /**
  31307. * Automatically updates internal texture from video at every frame in the render loop
  31308. */
  31309. autoUpdateTexture: boolean;
  31310. /**
  31311. * Image src displayed during the video loading or until the user interacts with the video.
  31312. */
  31313. poster?: string;
  31314. }
  31315. /**
  31316. * If you want to display a video in your scene, this is the special texture for that.
  31317. * This special texture works similar to other textures, with the exception of a few parameters.
  31318. * @see https://doc.babylonjs.com/how_to/video_texture
  31319. */
  31320. export class VideoTexture extends Texture {
  31321. /**
  31322. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31323. */
  31324. readonly autoUpdateTexture: boolean;
  31325. /**
  31326. * The video instance used by the texture internally
  31327. */
  31328. readonly video: HTMLVideoElement;
  31329. private _onUserActionRequestedObservable;
  31330. /**
  31331. * Event triggerd when a dom action is required by the user to play the video.
  31332. * This happens due to recent changes in browser policies preventing video to auto start.
  31333. */
  31334. get onUserActionRequestedObservable(): Observable<Texture>;
  31335. private _generateMipMaps;
  31336. private _engine;
  31337. private _stillImageCaptured;
  31338. private _displayingPosterTexture;
  31339. private _settings;
  31340. private _createInternalTextureOnEvent;
  31341. private _frameId;
  31342. private _currentSrc;
  31343. /**
  31344. * Creates a video texture.
  31345. * If you want to display a video in your scene, this is the special texture for that.
  31346. * This special texture works similar to other textures, with the exception of a few parameters.
  31347. * @see https://doc.babylonjs.com/how_to/video_texture
  31348. * @param name optional name, will detect from video source, if not defined
  31349. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31350. * @param scene is obviously the current scene.
  31351. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31352. * @param invertY is false by default but can be used to invert video on Y axis
  31353. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31354. * @param settings allows finer control over video usage
  31355. */
  31356. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31357. private _getName;
  31358. private _getVideo;
  31359. private _createInternalTexture;
  31360. private reset;
  31361. /**
  31362. * @hidden Internal method to initiate `update`.
  31363. */
  31364. _rebuild(): void;
  31365. /**
  31366. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31367. */
  31368. update(): void;
  31369. /**
  31370. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31371. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31372. */
  31373. updateTexture(isVisible: boolean): void;
  31374. protected _updateInternalTexture: () => void;
  31375. /**
  31376. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31377. * @param url New url.
  31378. */
  31379. updateURL(url: string): void;
  31380. /**
  31381. * Clones the texture.
  31382. * @returns the cloned texture
  31383. */
  31384. clone(): VideoTexture;
  31385. /**
  31386. * Dispose the texture and release its associated resources.
  31387. */
  31388. dispose(): void;
  31389. /**
  31390. * Creates a video texture straight from a stream.
  31391. * @param scene Define the scene the texture should be created in
  31392. * @param stream Define the stream the texture should be created from
  31393. * @returns The created video texture as a promise
  31394. */
  31395. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31396. /**
  31397. * Creates a video texture straight from your WebCam video feed.
  31398. * @param scene Define the scene the texture should be created in
  31399. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31400. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31401. * @returns The created video texture as a promise
  31402. */
  31403. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31404. minWidth: number;
  31405. maxWidth: number;
  31406. minHeight: number;
  31407. maxHeight: number;
  31408. deviceId: string;
  31409. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31410. /**
  31411. * Creates a video texture straight from your WebCam video feed.
  31412. * @param scene Define the scene the texture should be created in
  31413. * @param onReady Define a callback to triggered once the texture will be ready
  31414. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31415. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31416. */
  31417. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31418. minWidth: number;
  31419. maxWidth: number;
  31420. minHeight: number;
  31421. maxHeight: number;
  31422. deviceId: string;
  31423. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31424. }
  31425. }
  31426. declare module BABYLON {
  31427. /**
  31428. * Defines the interface used by objects working like Scene
  31429. * @hidden
  31430. */
  31431. export interface ISceneLike {
  31432. _addPendingData(data: any): void;
  31433. _removePendingData(data: any): void;
  31434. offlineProvider: IOfflineProvider;
  31435. }
  31436. /** Interface defining initialization parameters for Engine class */
  31437. export interface EngineOptions extends WebGLContextAttributes {
  31438. /**
  31439. * Defines if the engine should no exceed a specified device ratio
  31440. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31441. */
  31442. limitDeviceRatio?: number;
  31443. /**
  31444. * Defines if webvr should be enabled automatically
  31445. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31446. */
  31447. autoEnableWebVR?: boolean;
  31448. /**
  31449. * Defines if webgl2 should be turned off even if supported
  31450. * @see http://doc.babylonjs.com/features/webgl2
  31451. */
  31452. disableWebGL2Support?: boolean;
  31453. /**
  31454. * Defines if webaudio should be initialized as well
  31455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31456. */
  31457. audioEngine?: boolean;
  31458. /**
  31459. * Defines if animations should run using a deterministic lock step
  31460. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31461. */
  31462. deterministicLockstep?: boolean;
  31463. /** Defines the maximum steps to use with deterministic lock step mode */
  31464. lockstepMaxSteps?: number;
  31465. /** Defines the seconds between each deterministic lock step */
  31466. timeStep?: number;
  31467. /**
  31468. * Defines that engine should ignore context lost events
  31469. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31470. */
  31471. doNotHandleContextLost?: boolean;
  31472. /**
  31473. * Defines that engine should ignore modifying touch action attribute and style
  31474. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31475. */
  31476. doNotHandleTouchAction?: boolean;
  31477. /**
  31478. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31479. */
  31480. useHighPrecisionFloats?: boolean;
  31481. }
  31482. /**
  31483. * The base engine class (root of all engines)
  31484. */
  31485. export class ThinEngine {
  31486. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31487. static ExceptionList: ({
  31488. key: string;
  31489. capture: string;
  31490. captureConstraint: number;
  31491. targets: string[];
  31492. } | {
  31493. key: string;
  31494. capture: null;
  31495. captureConstraint: null;
  31496. targets: string[];
  31497. })[];
  31498. /** @hidden */
  31499. static _TextureLoaders: IInternalTextureLoader[];
  31500. /**
  31501. * Returns the current npm package of the sdk
  31502. */
  31503. static get NpmPackage(): string;
  31504. /**
  31505. * Returns the current version of the framework
  31506. */
  31507. static get Version(): string;
  31508. /**
  31509. * Returns a string describing the current engine
  31510. */
  31511. get description(): string;
  31512. /**
  31513. * Gets or sets the epsilon value used by collision engine
  31514. */
  31515. static CollisionsEpsilon: number;
  31516. /**
  31517. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31518. */
  31519. static get ShadersRepository(): string;
  31520. static set ShadersRepository(value: string);
  31521. /** @hidden */
  31522. _shaderProcessor: IShaderProcessor;
  31523. /**
  31524. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31525. */
  31526. forcePOTTextures: boolean;
  31527. /**
  31528. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31529. */
  31530. isFullscreen: boolean;
  31531. /**
  31532. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31533. */
  31534. cullBackFaces: boolean;
  31535. /**
  31536. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31537. */
  31538. renderEvenInBackground: boolean;
  31539. /**
  31540. * Gets or sets a boolean indicating that cache can be kept between frames
  31541. */
  31542. preventCacheWipeBetweenFrames: boolean;
  31543. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31544. validateShaderPrograms: boolean;
  31545. /**
  31546. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31547. * This can provide greater z depth for distant objects.
  31548. */
  31549. useReverseDepthBuffer: boolean;
  31550. /**
  31551. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31552. */
  31553. disableUniformBuffers: boolean;
  31554. /** @hidden */
  31555. _uniformBuffers: UniformBuffer[];
  31556. /**
  31557. * Gets a boolean indicating that the engine supports uniform buffers
  31558. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31559. */
  31560. get supportsUniformBuffers(): boolean;
  31561. /** @hidden */
  31562. _gl: WebGLRenderingContext;
  31563. /** @hidden */
  31564. _webGLVersion: number;
  31565. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31566. protected _windowIsBackground: boolean;
  31567. protected _creationOptions: EngineOptions;
  31568. protected _highPrecisionShadersAllowed: boolean;
  31569. /** @hidden */
  31570. get _shouldUseHighPrecisionShader(): boolean;
  31571. /**
  31572. * Gets a boolean indicating that only power of 2 textures are supported
  31573. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31574. */
  31575. get needPOTTextures(): boolean;
  31576. /** @hidden */
  31577. _badOS: boolean;
  31578. /** @hidden */
  31579. _badDesktopOS: boolean;
  31580. private _hardwareScalingLevel;
  31581. /** @hidden */
  31582. _caps: EngineCapabilities;
  31583. private _isStencilEnable;
  31584. private _glVersion;
  31585. private _glRenderer;
  31586. private _glVendor;
  31587. /** @hidden */
  31588. _videoTextureSupported: boolean;
  31589. protected _renderingQueueLaunched: boolean;
  31590. protected _activeRenderLoops: (() => void)[];
  31591. /**
  31592. * Observable signaled when a context lost event is raised
  31593. */
  31594. onContextLostObservable: Observable<ThinEngine>;
  31595. /**
  31596. * Observable signaled when a context restored event is raised
  31597. */
  31598. onContextRestoredObservable: Observable<ThinEngine>;
  31599. private _onContextLost;
  31600. private _onContextRestored;
  31601. protected _contextWasLost: boolean;
  31602. /** @hidden */
  31603. _doNotHandleContextLost: boolean;
  31604. /**
  31605. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31606. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31607. */
  31608. get doNotHandleContextLost(): boolean;
  31609. set doNotHandleContextLost(value: boolean);
  31610. /**
  31611. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31612. */
  31613. disableVertexArrayObjects: boolean;
  31614. /** @hidden */
  31615. protected _colorWrite: boolean;
  31616. /** @hidden */
  31617. protected _colorWriteChanged: boolean;
  31618. /** @hidden */
  31619. protected _depthCullingState: DepthCullingState;
  31620. /** @hidden */
  31621. protected _stencilState: StencilState;
  31622. /** @hidden */
  31623. _alphaState: AlphaState;
  31624. /** @hidden */
  31625. _alphaMode: number;
  31626. /** @hidden */
  31627. _alphaEquation: number;
  31628. /** @hidden */
  31629. _internalTexturesCache: InternalTexture[];
  31630. /** @hidden */
  31631. protected _activeChannel: number;
  31632. private _currentTextureChannel;
  31633. /** @hidden */
  31634. protected _boundTexturesCache: {
  31635. [key: string]: Nullable<InternalTexture>;
  31636. };
  31637. /** @hidden */
  31638. protected _currentEffect: Nullable<Effect>;
  31639. /** @hidden */
  31640. protected _currentProgram: Nullable<WebGLProgram>;
  31641. private _compiledEffects;
  31642. private _vertexAttribArraysEnabled;
  31643. /** @hidden */
  31644. protected _cachedViewport: Nullable<IViewportLike>;
  31645. private _cachedVertexArrayObject;
  31646. /** @hidden */
  31647. protected _cachedVertexBuffers: any;
  31648. /** @hidden */
  31649. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31650. /** @hidden */
  31651. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31652. /** @hidden */
  31653. _currentRenderTarget: Nullable<InternalTexture>;
  31654. private _uintIndicesCurrentlySet;
  31655. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31656. /** @hidden */
  31657. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31658. private _currentBufferPointers;
  31659. private _currentInstanceLocations;
  31660. private _currentInstanceBuffers;
  31661. private _textureUnits;
  31662. /** @hidden */
  31663. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31664. /** @hidden */
  31665. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31666. /** @hidden */
  31667. _boundRenderFunction: any;
  31668. private _vaoRecordInProgress;
  31669. private _mustWipeVertexAttributes;
  31670. private _emptyTexture;
  31671. private _emptyCubeTexture;
  31672. private _emptyTexture3D;
  31673. private _emptyTexture2DArray;
  31674. /** @hidden */
  31675. _frameHandler: number;
  31676. private _nextFreeTextureSlots;
  31677. private _maxSimultaneousTextures;
  31678. private _activeRequests;
  31679. /** @hidden */
  31680. _transformTextureUrl: Nullable<(url: string) => string>;
  31681. protected get _supportsHardwareTextureRescaling(): boolean;
  31682. private _framebufferDimensionsObject;
  31683. /**
  31684. * sets the object from which width and height will be taken from when getting render width and height
  31685. * Will fallback to the gl object
  31686. * @param dimensions the framebuffer width and height that will be used.
  31687. */
  31688. set framebufferDimensionsObject(dimensions: Nullable<{
  31689. framebufferWidth: number;
  31690. framebufferHeight: number;
  31691. }>);
  31692. /**
  31693. * Gets the current viewport
  31694. */
  31695. get currentViewport(): Nullable<IViewportLike>;
  31696. /**
  31697. * Gets the default empty texture
  31698. */
  31699. get emptyTexture(): InternalTexture;
  31700. /**
  31701. * Gets the default empty 3D texture
  31702. */
  31703. get emptyTexture3D(): InternalTexture;
  31704. /**
  31705. * Gets the default empty 2D array texture
  31706. */
  31707. get emptyTexture2DArray(): InternalTexture;
  31708. /**
  31709. * Gets the default empty cube texture
  31710. */
  31711. get emptyCubeTexture(): InternalTexture;
  31712. /**
  31713. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31714. */
  31715. readonly premultipliedAlpha: boolean;
  31716. /**
  31717. * Observable event triggered before each texture is initialized
  31718. */
  31719. onBeforeTextureInitObservable: Observable<Texture>;
  31720. /**
  31721. * Creates a new engine
  31722. * @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
  31723. * @param antialias defines enable antialiasing (default: false)
  31724. * @param options defines further options to be sent to the getContext() function
  31725. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31726. */
  31727. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31728. private _rebuildInternalTextures;
  31729. private _rebuildEffects;
  31730. /**
  31731. * Gets a boolean indicating if all created effects are ready
  31732. * @returns true if all effects are ready
  31733. */
  31734. areAllEffectsReady(): boolean;
  31735. protected _rebuildBuffers(): void;
  31736. protected _initGLContext(): void;
  31737. /**
  31738. * Gets version of the current webGL context
  31739. */
  31740. get webGLVersion(): number;
  31741. /**
  31742. * Gets a string idenfifying the name of the class
  31743. * @returns "Engine" string
  31744. */
  31745. getClassName(): string;
  31746. /**
  31747. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31748. */
  31749. get isStencilEnable(): boolean;
  31750. /** @hidden */
  31751. _prepareWorkingCanvas(): void;
  31752. /**
  31753. * Reset the texture cache to empty state
  31754. */
  31755. resetTextureCache(): void;
  31756. /**
  31757. * Gets an object containing information about the current webGL context
  31758. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31759. */
  31760. getGlInfo(): {
  31761. vendor: string;
  31762. renderer: string;
  31763. version: string;
  31764. };
  31765. /**
  31766. * Defines the hardware scaling level.
  31767. * By default the hardware scaling level is computed from the window device ratio.
  31768. * 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.
  31769. * @param level defines the level to use
  31770. */
  31771. setHardwareScalingLevel(level: number): void;
  31772. /**
  31773. * Gets the current hardware scaling level.
  31774. * By default the hardware scaling level is computed from the window device ratio.
  31775. * 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.
  31776. * @returns a number indicating the current hardware scaling level
  31777. */
  31778. getHardwareScalingLevel(): number;
  31779. /**
  31780. * Gets the list of loaded textures
  31781. * @returns an array containing all loaded textures
  31782. */
  31783. getLoadedTexturesCache(): InternalTexture[];
  31784. /**
  31785. * Gets the object containing all engine capabilities
  31786. * @returns the EngineCapabilities object
  31787. */
  31788. getCaps(): EngineCapabilities;
  31789. /**
  31790. * stop executing a render loop function and remove it from the execution array
  31791. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31792. */
  31793. stopRenderLoop(renderFunction?: () => void): void;
  31794. /** @hidden */
  31795. _renderLoop(): void;
  31796. /**
  31797. * Gets the HTML canvas attached with the current webGL context
  31798. * @returns a HTML canvas
  31799. */
  31800. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31801. /**
  31802. * Gets host window
  31803. * @returns the host window object
  31804. */
  31805. getHostWindow(): Nullable<Window>;
  31806. /**
  31807. * Gets the current render width
  31808. * @param useScreen defines if screen size must be used (or the current render target if any)
  31809. * @returns a number defining the current render width
  31810. */
  31811. getRenderWidth(useScreen?: boolean): number;
  31812. /**
  31813. * Gets the current render height
  31814. * @param useScreen defines if screen size must be used (or the current render target if any)
  31815. * @returns a number defining the current render height
  31816. */
  31817. getRenderHeight(useScreen?: boolean): number;
  31818. /**
  31819. * Can be used to override the current requestAnimationFrame requester.
  31820. * @hidden
  31821. */
  31822. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31823. /**
  31824. * Register and execute a render loop. The engine can have more than one render function
  31825. * @param renderFunction defines the function to continuously execute
  31826. */
  31827. runRenderLoop(renderFunction: () => void): void;
  31828. /**
  31829. * Clear the current render buffer or the current render target (if any is set up)
  31830. * @param color defines the color to use
  31831. * @param backBuffer defines if the back buffer must be cleared
  31832. * @param depth defines if the depth buffer must be cleared
  31833. * @param stencil defines if the stencil buffer must be cleared
  31834. */
  31835. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31836. private _viewportCached;
  31837. /** @hidden */
  31838. _viewport(x: number, y: number, width: number, height: number): void;
  31839. /**
  31840. * Set the WebGL's viewport
  31841. * @param viewport defines the viewport element to be used
  31842. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31843. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31844. */
  31845. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31846. /**
  31847. * Begin a new frame
  31848. */
  31849. beginFrame(): void;
  31850. /**
  31851. * Enf the current frame
  31852. */
  31853. endFrame(): void;
  31854. /**
  31855. * Resize the view according to the canvas' size
  31856. */
  31857. resize(): void;
  31858. /**
  31859. * Force a specific size of the canvas
  31860. * @param width defines the new canvas' width
  31861. * @param height defines the new canvas' height
  31862. */
  31863. setSize(width: number, height: number): void;
  31864. /**
  31865. * Binds the frame buffer to the specified texture.
  31866. * @param texture The texture to render to or null for the default canvas
  31867. * @param faceIndex The face of the texture to render to in case of cube texture
  31868. * @param requiredWidth The width of the target to render to
  31869. * @param requiredHeight The height of the target to render to
  31870. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31871. * @param lodLevel defines the lod level to bind to the frame buffer
  31872. * @param layer defines the 2d array index to bind to frame buffer to
  31873. */
  31874. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31875. /** @hidden */
  31876. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31877. /**
  31878. * Unbind the current render target texture from the webGL context
  31879. * @param texture defines the render target texture to unbind
  31880. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31881. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31882. */
  31883. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31884. /**
  31885. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31886. */
  31887. flushFramebuffer(): void;
  31888. /**
  31889. * Unbind the current render target and bind the default framebuffer
  31890. */
  31891. restoreDefaultFramebuffer(): void;
  31892. /** @hidden */
  31893. protected _resetVertexBufferBinding(): void;
  31894. /**
  31895. * Creates a vertex buffer
  31896. * @param data the data for the vertex buffer
  31897. * @returns the new WebGL static buffer
  31898. */
  31899. createVertexBuffer(data: DataArray): DataBuffer;
  31900. private _createVertexBuffer;
  31901. /**
  31902. * Creates a dynamic vertex buffer
  31903. * @param data the data for the dynamic vertex buffer
  31904. * @returns the new WebGL dynamic buffer
  31905. */
  31906. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31907. protected _resetIndexBufferBinding(): void;
  31908. /**
  31909. * Creates a new index buffer
  31910. * @param indices defines the content of the index buffer
  31911. * @param updatable defines if the index buffer must be updatable
  31912. * @returns a new webGL buffer
  31913. */
  31914. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31915. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31916. /**
  31917. * Bind a webGL buffer to the webGL context
  31918. * @param buffer defines the buffer to bind
  31919. */
  31920. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31921. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31922. private bindBuffer;
  31923. /**
  31924. * update the bound buffer with the given data
  31925. * @param data defines the data to update
  31926. */
  31927. updateArrayBuffer(data: Float32Array): void;
  31928. private _vertexAttribPointer;
  31929. /** @hidden */
  31930. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31931. private _bindVertexBuffersAttributes;
  31932. /**
  31933. * Records a vertex array object
  31934. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31935. * @param vertexBuffers defines the list of vertex buffers to store
  31936. * @param indexBuffer defines the index buffer to store
  31937. * @param effect defines the effect to store
  31938. * @returns the new vertex array object
  31939. */
  31940. recordVertexArrayObject(vertexBuffers: {
  31941. [key: string]: VertexBuffer;
  31942. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31943. /**
  31944. * Bind a specific vertex array object
  31945. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31946. * @param vertexArrayObject defines the vertex array object to bind
  31947. * @param indexBuffer defines the index buffer to bind
  31948. */
  31949. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31950. /**
  31951. * Bind webGl buffers directly to the webGL context
  31952. * @param vertexBuffer defines the vertex buffer to bind
  31953. * @param indexBuffer defines the index buffer to bind
  31954. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31955. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31956. * @param effect defines the effect associated with the vertex buffer
  31957. */
  31958. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31959. private _unbindVertexArrayObject;
  31960. /**
  31961. * Bind a list of vertex buffers to the webGL context
  31962. * @param vertexBuffers defines the list of vertex buffers to bind
  31963. * @param indexBuffer defines the index buffer to bind
  31964. * @param effect defines the effect associated with the vertex buffers
  31965. */
  31966. bindBuffers(vertexBuffers: {
  31967. [key: string]: Nullable<VertexBuffer>;
  31968. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31969. /**
  31970. * Unbind all instance attributes
  31971. */
  31972. unbindInstanceAttributes(): void;
  31973. /**
  31974. * Release and free the memory of a vertex array object
  31975. * @param vao defines the vertex array object to delete
  31976. */
  31977. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31978. /** @hidden */
  31979. _releaseBuffer(buffer: DataBuffer): boolean;
  31980. protected _deleteBuffer(buffer: DataBuffer): void;
  31981. /**
  31982. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31983. * @param instancesBuffer defines the webGL buffer to update and bind
  31984. * @param data defines the data to store in the buffer
  31985. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31986. */
  31987. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31988. /**
  31989. * Bind the content of a webGL buffer used with instantiation
  31990. * @param instancesBuffer defines the webGL buffer to bind
  31991. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31992. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31993. */
  31994. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31995. /**
  31996. * Disable the instance attribute corresponding to the name in parameter
  31997. * @param name defines the name of the attribute to disable
  31998. */
  31999. disableInstanceAttributeByName(name: string): void;
  32000. /**
  32001. * Disable the instance attribute corresponding to the location in parameter
  32002. * @param attributeLocation defines the attribute location of the attribute to disable
  32003. */
  32004. disableInstanceAttribute(attributeLocation: number): void;
  32005. /**
  32006. * Disable the attribute corresponding to the location in parameter
  32007. * @param attributeLocation defines the attribute location of the attribute to disable
  32008. */
  32009. disableAttributeByIndex(attributeLocation: number): void;
  32010. /**
  32011. * Send a draw order
  32012. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32013. * @param indexStart defines the starting index
  32014. * @param indexCount defines the number of index to draw
  32015. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32016. */
  32017. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32018. /**
  32019. * Draw a list of points
  32020. * @param verticesStart defines the index of first vertex to draw
  32021. * @param verticesCount defines the count of vertices to draw
  32022. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32023. */
  32024. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32025. /**
  32026. * Draw a list of unindexed primitives
  32027. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32028. * @param verticesStart defines the index of first vertex to draw
  32029. * @param verticesCount defines the count of vertices to draw
  32030. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32031. */
  32032. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32033. /**
  32034. * Draw a list of indexed primitives
  32035. * @param fillMode defines the primitive to use
  32036. * @param indexStart defines the starting index
  32037. * @param indexCount defines the number of index to draw
  32038. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32039. */
  32040. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32041. /**
  32042. * Draw a list of unindexed primitives
  32043. * @param fillMode defines the primitive to use
  32044. * @param verticesStart defines the index of first vertex to draw
  32045. * @param verticesCount defines the count of vertices to draw
  32046. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32047. */
  32048. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32049. private _drawMode;
  32050. /** @hidden */
  32051. protected _reportDrawCall(): void;
  32052. /** @hidden */
  32053. _releaseEffect(effect: Effect): void;
  32054. /** @hidden */
  32055. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32056. /**
  32057. * Create a new effect (used to store vertex/fragment shaders)
  32058. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32059. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32060. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32061. * @param samplers defines an array of string used to represent textures
  32062. * @param defines defines the string containing the defines to use to compile the shaders
  32063. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32064. * @param onCompiled defines a function to call when the effect creation is successful
  32065. * @param onError defines a function to call when the effect creation has failed
  32066. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32067. * @returns the new Effect
  32068. */
  32069. 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;
  32070. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32071. private _compileShader;
  32072. private _compileRawShader;
  32073. /** @hidden */
  32074. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32075. /**
  32076. * Directly creates a webGL program
  32077. * @param pipelineContext defines the pipeline context to attach to
  32078. * @param vertexCode defines the vertex shader code to use
  32079. * @param fragmentCode defines the fragment shader code to use
  32080. * @param context defines the webGL context to use (if not set, the current one will be used)
  32081. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32082. * @returns the new webGL program
  32083. */
  32084. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32085. /**
  32086. * Creates a webGL program
  32087. * @param pipelineContext defines the pipeline context to attach to
  32088. * @param vertexCode defines the vertex shader code to use
  32089. * @param fragmentCode defines the fragment shader code to use
  32090. * @param defines defines the string containing the defines to use to compile the shaders
  32091. * @param context defines the webGL context to use (if not set, the current one will be used)
  32092. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32093. * @returns the new webGL program
  32094. */
  32095. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32096. /**
  32097. * Creates a new pipeline context
  32098. * @returns the new pipeline
  32099. */
  32100. createPipelineContext(): IPipelineContext;
  32101. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32102. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32103. /** @hidden */
  32104. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32105. /** @hidden */
  32106. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32107. /** @hidden */
  32108. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32109. /**
  32110. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32111. * @param pipelineContext defines the pipeline context to use
  32112. * @param uniformsNames defines the list of uniform names
  32113. * @returns an array of webGL uniform locations
  32114. */
  32115. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32116. /**
  32117. * Gets the lsit of active attributes for a given webGL program
  32118. * @param pipelineContext defines the pipeline context to use
  32119. * @param attributesNames defines the list of attribute names to get
  32120. * @returns an array of indices indicating the offset of each attribute
  32121. */
  32122. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32123. /**
  32124. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32125. * @param effect defines the effect to activate
  32126. */
  32127. enableEffect(effect: Nullable<Effect>): void;
  32128. /**
  32129. * Set the value of an uniform to a number (int)
  32130. * @param uniform defines the webGL uniform location where to store the value
  32131. * @param value defines the int number to store
  32132. */
  32133. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32134. /**
  32135. * Set the value of an uniform to an array of int32
  32136. * @param uniform defines the webGL uniform location where to store the value
  32137. * @param array defines the array of int32 to store
  32138. */
  32139. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32140. /**
  32141. * Set the value of an uniform to an array of int32 (stored as vec2)
  32142. * @param uniform defines the webGL uniform location where to store the value
  32143. * @param array defines the array of int32 to store
  32144. */
  32145. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32146. /**
  32147. * Set the value of an uniform to an array of int32 (stored as vec3)
  32148. * @param uniform defines the webGL uniform location where to store the value
  32149. * @param array defines the array of int32 to store
  32150. */
  32151. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32152. /**
  32153. * Set the value of an uniform to an array of int32 (stored as vec4)
  32154. * @param uniform defines the webGL uniform location where to store the value
  32155. * @param array defines the array of int32 to store
  32156. */
  32157. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32158. /**
  32159. * Set the value of an uniform to an array of number
  32160. * @param uniform defines the webGL uniform location where to store the value
  32161. * @param array defines the array of number to store
  32162. */
  32163. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32164. /**
  32165. * Set the value of an uniform to an array of number (stored as vec2)
  32166. * @param uniform defines the webGL uniform location where to store the value
  32167. * @param array defines the array of number to store
  32168. */
  32169. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32170. /**
  32171. * Set the value of an uniform to an array of number (stored as vec3)
  32172. * @param uniform defines the webGL uniform location where to store the value
  32173. * @param array defines the array of number to store
  32174. */
  32175. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32176. /**
  32177. * Set the value of an uniform to an array of number (stored as vec4)
  32178. * @param uniform defines the webGL uniform location where to store the value
  32179. * @param array defines the array of number to store
  32180. */
  32181. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32182. /**
  32183. * Set the value of an uniform to an array of float32 (stored as matrices)
  32184. * @param uniform defines the webGL uniform location where to store the value
  32185. * @param matrices defines the array of float32 to store
  32186. */
  32187. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32188. /**
  32189. * Set the value of an uniform to a matrix (3x3)
  32190. * @param uniform defines the webGL uniform location where to store the value
  32191. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32192. */
  32193. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32194. /**
  32195. * Set the value of an uniform to a matrix (2x2)
  32196. * @param uniform defines the webGL uniform location where to store the value
  32197. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32198. */
  32199. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32200. /**
  32201. * Set the value of an uniform to a number (float)
  32202. * @param uniform defines the webGL uniform location where to store the value
  32203. * @param value defines the float number to store
  32204. */
  32205. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32206. /**
  32207. * Set the value of an uniform to a vec2
  32208. * @param uniform defines the webGL uniform location where to store the value
  32209. * @param x defines the 1st component of the value
  32210. * @param y defines the 2nd component of the value
  32211. */
  32212. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32213. /**
  32214. * Set the value of an uniform to a vec3
  32215. * @param uniform defines the webGL uniform location where to store the value
  32216. * @param x defines the 1st component of the value
  32217. * @param y defines the 2nd component of the value
  32218. * @param z defines the 3rd component of the value
  32219. */
  32220. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32221. /**
  32222. * Set the value of an uniform to a vec4
  32223. * @param uniform defines the webGL uniform location where to store the value
  32224. * @param x defines the 1st component of the value
  32225. * @param y defines the 2nd component of the value
  32226. * @param z defines the 3rd component of the value
  32227. * @param w defines the 4th component of the value
  32228. */
  32229. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32230. /**
  32231. * Apply all cached states (depth, culling, stencil and alpha)
  32232. */
  32233. applyStates(): void;
  32234. /**
  32235. * Enable or disable color writing
  32236. * @param enable defines the state to set
  32237. */
  32238. setColorWrite(enable: boolean): void;
  32239. /**
  32240. * Gets a boolean indicating if color writing is enabled
  32241. * @returns the current color writing state
  32242. */
  32243. getColorWrite(): boolean;
  32244. /**
  32245. * Gets the depth culling state manager
  32246. */
  32247. get depthCullingState(): DepthCullingState;
  32248. /**
  32249. * Gets the alpha state manager
  32250. */
  32251. get alphaState(): AlphaState;
  32252. /**
  32253. * Gets the stencil state manager
  32254. */
  32255. get stencilState(): StencilState;
  32256. /**
  32257. * Clears the list of texture accessible through engine.
  32258. * This can help preventing texture load conflict due to name collision.
  32259. */
  32260. clearInternalTexturesCache(): void;
  32261. /**
  32262. * Force the entire cache to be cleared
  32263. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32264. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32265. */
  32266. wipeCaches(bruteForce?: boolean): void;
  32267. /** @hidden */
  32268. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32269. min: number;
  32270. mag: number;
  32271. };
  32272. /** @hidden */
  32273. _createTexture(): WebGLTexture;
  32274. /**
  32275. * Usually called from Texture.ts.
  32276. * Passed information to create a WebGLTexture
  32277. * @param url defines a value which contains one of the following:
  32278. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32279. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32280. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32281. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32282. * @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)
  32283. * @param scene needed for loading to the correct scene
  32284. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32285. * @param onLoad optional callback to be called upon successful completion
  32286. * @param onError optional callback to be called upon failure
  32287. * @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
  32288. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32289. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32290. * @param forcedExtension defines the extension to use to pick the right loader
  32291. * @param mimeType defines an optional mime type
  32292. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32293. */
  32294. createTexture(url: 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;
  32295. /**
  32296. * Loads an image as an HTMLImageElement.
  32297. * @param input url string, ArrayBuffer, or Blob to load
  32298. * @param onLoad callback called when the image successfully loads
  32299. * @param onError callback called when the image fails to load
  32300. * @param offlineProvider offline provider for caching
  32301. * @param mimeType optional mime type
  32302. * @returns the HTMLImageElement of the loaded image
  32303. * @hidden
  32304. */
  32305. 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>;
  32306. /**
  32307. * @hidden
  32308. */
  32309. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32310. private _unpackFlipYCached;
  32311. /**
  32312. * In case you are sharing the context with other applications, it might
  32313. * be interested to not cache the unpack flip y state to ensure a consistent
  32314. * value would be set.
  32315. */
  32316. enableUnpackFlipYCached: boolean;
  32317. /** @hidden */
  32318. _unpackFlipY(value: boolean): void;
  32319. /** @hidden */
  32320. _getUnpackAlignement(): number;
  32321. private _getTextureTarget;
  32322. /**
  32323. * Update the sampling mode of a given texture
  32324. * @param samplingMode defines the required sampling mode
  32325. * @param texture defines the texture to update
  32326. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32327. */
  32328. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32329. /**
  32330. * Update the sampling mode of a given texture
  32331. * @param texture defines the texture to update
  32332. * @param wrapU defines the texture wrap mode of the u coordinates
  32333. * @param wrapV defines the texture wrap mode of the v coordinates
  32334. * @param wrapR defines the texture wrap mode of the r coordinates
  32335. */
  32336. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32337. /** @hidden */
  32338. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32339. width: number;
  32340. height: number;
  32341. layers?: number;
  32342. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32343. /** @hidden */
  32344. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32345. /** @hidden */
  32346. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32347. /**
  32348. * Update a portion of an internal texture
  32349. * @param texture defines the texture to update
  32350. * @param imageData defines the data to store into the texture
  32351. * @param xOffset defines the x coordinates of the update rectangle
  32352. * @param yOffset defines the y coordinates of the update rectangle
  32353. * @param width defines the width of the update rectangle
  32354. * @param height defines the height of the update rectangle
  32355. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32356. * @param lod defines the lod level to update (0 by default)
  32357. */
  32358. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32359. /** @hidden */
  32360. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32361. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32362. private _prepareWebGLTexture;
  32363. /** @hidden */
  32364. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32365. private _getDepthStencilBuffer;
  32366. /** @hidden */
  32367. _releaseFramebufferObjects(texture: InternalTexture): void;
  32368. /** @hidden */
  32369. _releaseTexture(texture: InternalTexture): void;
  32370. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32371. protected _setProgram(program: WebGLProgram): void;
  32372. protected _boundUniforms: {
  32373. [key: number]: WebGLUniformLocation;
  32374. };
  32375. /**
  32376. * Binds an effect to the webGL context
  32377. * @param effect defines the effect to bind
  32378. */
  32379. bindSamplers(effect: Effect): void;
  32380. private _activateCurrentTexture;
  32381. /** @hidden */
  32382. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32383. /** @hidden */
  32384. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32385. /**
  32386. * Unbind all textures from the webGL context
  32387. */
  32388. unbindAllTextures(): void;
  32389. /**
  32390. * Sets a texture to the according uniform.
  32391. * @param channel The texture channel
  32392. * @param uniform The uniform to set
  32393. * @param texture The texture to apply
  32394. */
  32395. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32396. private _bindSamplerUniformToChannel;
  32397. private _getTextureWrapMode;
  32398. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32399. /**
  32400. * Sets an array of texture to the webGL context
  32401. * @param channel defines the channel where the texture array must be set
  32402. * @param uniform defines the associated uniform location
  32403. * @param textures defines the array of textures to bind
  32404. */
  32405. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32406. /** @hidden */
  32407. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32408. private _setTextureParameterFloat;
  32409. private _setTextureParameterInteger;
  32410. /**
  32411. * Unbind all vertex attributes from the webGL context
  32412. */
  32413. unbindAllAttributes(): void;
  32414. /**
  32415. * 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
  32416. */
  32417. releaseEffects(): void;
  32418. /**
  32419. * Dispose and release all associated resources
  32420. */
  32421. dispose(): void;
  32422. /**
  32423. * Attach a new callback raised when context lost event is fired
  32424. * @param callback defines the callback to call
  32425. */
  32426. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32427. /**
  32428. * Attach a new callback raised when context restored event is fired
  32429. * @param callback defines the callback to call
  32430. */
  32431. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32432. /**
  32433. * Get the current error code of the webGL context
  32434. * @returns the error code
  32435. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32436. */
  32437. getError(): number;
  32438. private _canRenderToFloatFramebuffer;
  32439. private _canRenderToHalfFloatFramebuffer;
  32440. private _canRenderToFramebuffer;
  32441. /** @hidden */
  32442. _getWebGLTextureType(type: number): number;
  32443. /** @hidden */
  32444. _getInternalFormat(format: number): number;
  32445. /** @hidden */
  32446. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32447. /** @hidden */
  32448. _getRGBAMultiSampleBufferFormat(type: number): number;
  32449. /** @hidden */
  32450. _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;
  32451. /**
  32452. * Loads a file from a url
  32453. * @param url url to load
  32454. * @param onSuccess callback called when the file successfully loads
  32455. * @param onProgress callback called while file is loading (if the server supports this mode)
  32456. * @param offlineProvider defines the offline provider for caching
  32457. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32458. * @param onError callback called when the file fails to load
  32459. * @returns a file request object
  32460. * @hidden
  32461. */
  32462. 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;
  32463. /**
  32464. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32465. * @param x defines the x coordinate of the rectangle where pixels must be read
  32466. * @param y defines the y coordinate of the rectangle where pixels must be read
  32467. * @param width defines the width of the rectangle where pixels must be read
  32468. * @param height defines the height of the rectangle where pixels must be read
  32469. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32470. * @returns a Uint8Array containing RGBA colors
  32471. */
  32472. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32473. private static _isSupported;
  32474. /**
  32475. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32476. * @returns true if the engine can be created
  32477. * @ignorenaming
  32478. */
  32479. static isSupported(): boolean;
  32480. /**
  32481. * Find the next highest power of two.
  32482. * @param x Number to start search from.
  32483. * @return Next highest power of two.
  32484. */
  32485. static CeilingPOT(x: number): number;
  32486. /**
  32487. * Find the next lowest power of two.
  32488. * @param x Number to start search from.
  32489. * @return Next lowest power of two.
  32490. */
  32491. static FloorPOT(x: number): number;
  32492. /**
  32493. * Find the nearest power of two.
  32494. * @param x Number to start search from.
  32495. * @return Next nearest power of two.
  32496. */
  32497. static NearestPOT(x: number): number;
  32498. /**
  32499. * Get the closest exponent of two
  32500. * @param value defines the value to approximate
  32501. * @param max defines the maximum value to return
  32502. * @param mode defines how to define the closest value
  32503. * @returns closest exponent of two of the given value
  32504. */
  32505. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32506. /**
  32507. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32508. * @param func - the function to be called
  32509. * @param requester - the object that will request the next frame. Falls back to window.
  32510. * @returns frame number
  32511. */
  32512. static QueueNewFrame(func: () => void, requester?: any): number;
  32513. /**
  32514. * Gets host document
  32515. * @returns the host document object
  32516. */
  32517. getHostDocument(): Nullable<Document>;
  32518. }
  32519. }
  32520. declare module BABYLON {
  32521. /**
  32522. * Class representing spherical harmonics coefficients to the 3rd degree
  32523. */
  32524. export class SphericalHarmonics {
  32525. /**
  32526. * Defines whether or not the harmonics have been prescaled for rendering.
  32527. */
  32528. preScaled: boolean;
  32529. /**
  32530. * The l0,0 coefficients of the spherical harmonics
  32531. */
  32532. l00: Vector3;
  32533. /**
  32534. * The l1,-1 coefficients of the spherical harmonics
  32535. */
  32536. l1_1: Vector3;
  32537. /**
  32538. * The l1,0 coefficients of the spherical harmonics
  32539. */
  32540. l10: Vector3;
  32541. /**
  32542. * The l1,1 coefficients of the spherical harmonics
  32543. */
  32544. l11: Vector3;
  32545. /**
  32546. * The l2,-2 coefficients of the spherical harmonics
  32547. */
  32548. l2_2: Vector3;
  32549. /**
  32550. * The l2,-1 coefficients of the spherical harmonics
  32551. */
  32552. l2_1: Vector3;
  32553. /**
  32554. * The l2,0 coefficients of the spherical harmonics
  32555. */
  32556. l20: Vector3;
  32557. /**
  32558. * The l2,1 coefficients of the spherical harmonics
  32559. */
  32560. l21: Vector3;
  32561. /**
  32562. * The l2,2 coefficients of the spherical harmonics
  32563. */
  32564. l22: Vector3;
  32565. /**
  32566. * Adds a light to the spherical harmonics
  32567. * @param direction the direction of the light
  32568. * @param color the color of the light
  32569. * @param deltaSolidAngle the delta solid angle of the light
  32570. */
  32571. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32572. /**
  32573. * Scales the spherical harmonics by the given amount
  32574. * @param scale the amount to scale
  32575. */
  32576. scaleInPlace(scale: number): void;
  32577. /**
  32578. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32579. *
  32580. * ```
  32581. * E_lm = A_l * L_lm
  32582. * ```
  32583. *
  32584. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32585. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32586. * the scaling factors are given in equation 9.
  32587. */
  32588. convertIncidentRadianceToIrradiance(): void;
  32589. /**
  32590. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32591. *
  32592. * ```
  32593. * L = (1/pi) * E * rho
  32594. * ```
  32595. *
  32596. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32597. */
  32598. convertIrradianceToLambertianRadiance(): void;
  32599. /**
  32600. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32601. * required operations at run time.
  32602. *
  32603. * This is simply done by scaling back the SH with Ylm constants parameter.
  32604. * The trigonometric part being applied by the shader at run time.
  32605. */
  32606. preScaleForRendering(): void;
  32607. /**
  32608. * Constructs a spherical harmonics from an array.
  32609. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32610. * @returns the spherical harmonics
  32611. */
  32612. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32613. /**
  32614. * Gets the spherical harmonics from polynomial
  32615. * @param polynomial the spherical polynomial
  32616. * @returns the spherical harmonics
  32617. */
  32618. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32619. }
  32620. /**
  32621. * Class representing spherical polynomial coefficients to the 3rd degree
  32622. */
  32623. export class SphericalPolynomial {
  32624. private _harmonics;
  32625. /**
  32626. * The spherical harmonics used to create the polynomials.
  32627. */
  32628. get preScaledHarmonics(): SphericalHarmonics;
  32629. /**
  32630. * The x coefficients of the spherical polynomial
  32631. */
  32632. x: Vector3;
  32633. /**
  32634. * The y coefficients of the spherical polynomial
  32635. */
  32636. y: Vector3;
  32637. /**
  32638. * The z coefficients of the spherical polynomial
  32639. */
  32640. z: Vector3;
  32641. /**
  32642. * The xx coefficients of the spherical polynomial
  32643. */
  32644. xx: Vector3;
  32645. /**
  32646. * The yy coefficients of the spherical polynomial
  32647. */
  32648. yy: Vector3;
  32649. /**
  32650. * The zz coefficients of the spherical polynomial
  32651. */
  32652. zz: Vector3;
  32653. /**
  32654. * The xy coefficients of the spherical polynomial
  32655. */
  32656. xy: Vector3;
  32657. /**
  32658. * The yz coefficients of the spherical polynomial
  32659. */
  32660. yz: Vector3;
  32661. /**
  32662. * The zx coefficients of the spherical polynomial
  32663. */
  32664. zx: Vector3;
  32665. /**
  32666. * Adds an ambient color to the spherical polynomial
  32667. * @param color the color to add
  32668. */
  32669. addAmbient(color: Color3): void;
  32670. /**
  32671. * Scales the spherical polynomial by the given amount
  32672. * @param scale the amount to scale
  32673. */
  32674. scaleInPlace(scale: number): void;
  32675. /**
  32676. * Gets the spherical polynomial from harmonics
  32677. * @param harmonics the spherical harmonics
  32678. * @returns the spherical polynomial
  32679. */
  32680. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32681. /**
  32682. * Constructs a spherical polynomial from an array.
  32683. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32684. * @returns the spherical polynomial
  32685. */
  32686. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32687. }
  32688. }
  32689. declare module BABYLON {
  32690. /**
  32691. * Defines the source of the internal texture
  32692. */
  32693. export enum InternalTextureSource {
  32694. /**
  32695. * The source of the texture data is unknown
  32696. */
  32697. Unknown = 0,
  32698. /**
  32699. * Texture data comes from an URL
  32700. */
  32701. Url = 1,
  32702. /**
  32703. * Texture data is only used for temporary storage
  32704. */
  32705. Temp = 2,
  32706. /**
  32707. * Texture data comes from raw data (ArrayBuffer)
  32708. */
  32709. Raw = 3,
  32710. /**
  32711. * Texture content is dynamic (video or dynamic texture)
  32712. */
  32713. Dynamic = 4,
  32714. /**
  32715. * Texture content is generated by rendering to it
  32716. */
  32717. RenderTarget = 5,
  32718. /**
  32719. * Texture content is part of a multi render target process
  32720. */
  32721. MultiRenderTarget = 6,
  32722. /**
  32723. * Texture data comes from a cube data file
  32724. */
  32725. Cube = 7,
  32726. /**
  32727. * Texture data comes from a raw cube data
  32728. */
  32729. CubeRaw = 8,
  32730. /**
  32731. * Texture data come from a prefiltered cube data file
  32732. */
  32733. CubePrefiltered = 9,
  32734. /**
  32735. * Texture content is raw 3D data
  32736. */
  32737. Raw3D = 10,
  32738. /**
  32739. * Texture content is raw 2D array data
  32740. */
  32741. Raw2DArray = 11,
  32742. /**
  32743. * Texture content is a depth texture
  32744. */
  32745. Depth = 12,
  32746. /**
  32747. * Texture data comes from a raw cube data encoded with RGBD
  32748. */
  32749. CubeRawRGBD = 13
  32750. }
  32751. /**
  32752. * Class used to store data associated with WebGL texture data for the engine
  32753. * This class should not be used directly
  32754. */
  32755. export class InternalTexture {
  32756. /** @hidden */
  32757. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32758. /**
  32759. * Defines if the texture is ready
  32760. */
  32761. isReady: boolean;
  32762. /**
  32763. * Defines if the texture is a cube texture
  32764. */
  32765. isCube: boolean;
  32766. /**
  32767. * Defines if the texture contains 3D data
  32768. */
  32769. is3D: boolean;
  32770. /**
  32771. * Defines if the texture contains 2D array data
  32772. */
  32773. is2DArray: boolean;
  32774. /**
  32775. * Defines if the texture contains multiview data
  32776. */
  32777. isMultiview: boolean;
  32778. /**
  32779. * Gets the URL used to load this texture
  32780. */
  32781. url: string;
  32782. /**
  32783. * Gets the sampling mode of the texture
  32784. */
  32785. samplingMode: number;
  32786. /**
  32787. * Gets a boolean indicating if the texture needs mipmaps generation
  32788. */
  32789. generateMipMaps: boolean;
  32790. /**
  32791. * Gets the number of samples used by the texture (WebGL2+ only)
  32792. */
  32793. samples: number;
  32794. /**
  32795. * Gets the type of the texture (int, float...)
  32796. */
  32797. type: number;
  32798. /**
  32799. * Gets the format of the texture (RGB, RGBA...)
  32800. */
  32801. format: number;
  32802. /**
  32803. * Observable called when the texture is loaded
  32804. */
  32805. onLoadedObservable: Observable<InternalTexture>;
  32806. /**
  32807. * Gets the width of the texture
  32808. */
  32809. width: number;
  32810. /**
  32811. * Gets the height of the texture
  32812. */
  32813. height: number;
  32814. /**
  32815. * Gets the depth of the texture
  32816. */
  32817. depth: number;
  32818. /**
  32819. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32820. */
  32821. baseWidth: number;
  32822. /**
  32823. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32824. */
  32825. baseHeight: number;
  32826. /**
  32827. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32828. */
  32829. baseDepth: number;
  32830. /**
  32831. * Gets a boolean indicating if the texture is inverted on Y axis
  32832. */
  32833. invertY: boolean;
  32834. /** @hidden */
  32835. _invertVScale: boolean;
  32836. /** @hidden */
  32837. _associatedChannel: number;
  32838. /** @hidden */
  32839. _source: InternalTextureSource;
  32840. /** @hidden */
  32841. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32842. /** @hidden */
  32843. _bufferView: Nullable<ArrayBufferView>;
  32844. /** @hidden */
  32845. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32846. /** @hidden */
  32847. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32848. /** @hidden */
  32849. _size: number;
  32850. /** @hidden */
  32851. _extension: string;
  32852. /** @hidden */
  32853. _files: Nullable<string[]>;
  32854. /** @hidden */
  32855. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32856. /** @hidden */
  32857. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32858. /** @hidden */
  32859. _framebuffer: Nullable<WebGLFramebuffer>;
  32860. /** @hidden */
  32861. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32862. /** @hidden */
  32863. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32864. /** @hidden */
  32865. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32866. /** @hidden */
  32867. _attachments: Nullable<number[]>;
  32868. /** @hidden */
  32869. _cachedCoordinatesMode: Nullable<number>;
  32870. /** @hidden */
  32871. _cachedWrapU: Nullable<number>;
  32872. /** @hidden */
  32873. _cachedWrapV: Nullable<number>;
  32874. /** @hidden */
  32875. _cachedWrapR: Nullable<number>;
  32876. /** @hidden */
  32877. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32878. /** @hidden */
  32879. _isDisabled: boolean;
  32880. /** @hidden */
  32881. _compression: Nullable<string>;
  32882. /** @hidden */
  32883. _generateStencilBuffer: boolean;
  32884. /** @hidden */
  32885. _generateDepthBuffer: boolean;
  32886. /** @hidden */
  32887. _comparisonFunction: number;
  32888. /** @hidden */
  32889. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32890. /** @hidden */
  32891. _lodGenerationScale: number;
  32892. /** @hidden */
  32893. _lodGenerationOffset: number;
  32894. /** @hidden */
  32895. _depthStencilTexture: Nullable<InternalTexture>;
  32896. /** @hidden */
  32897. _colorTextureArray: Nullable<WebGLTexture>;
  32898. /** @hidden */
  32899. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32900. /** @hidden */
  32901. _lodTextureHigh: Nullable<BaseTexture>;
  32902. /** @hidden */
  32903. _lodTextureMid: Nullable<BaseTexture>;
  32904. /** @hidden */
  32905. _lodTextureLow: Nullable<BaseTexture>;
  32906. /** @hidden */
  32907. _isRGBD: boolean;
  32908. /** @hidden */
  32909. _linearSpecularLOD: boolean;
  32910. /** @hidden */
  32911. _irradianceTexture: Nullable<BaseTexture>;
  32912. /** @hidden */
  32913. _webGLTexture: Nullable<WebGLTexture>;
  32914. /** @hidden */
  32915. _references: number;
  32916. private _engine;
  32917. /**
  32918. * Gets the Engine the texture belongs to.
  32919. * @returns The babylon engine
  32920. */
  32921. getEngine(): ThinEngine;
  32922. /**
  32923. * Gets the data source type of the texture
  32924. */
  32925. get source(): InternalTextureSource;
  32926. /**
  32927. * Creates a new InternalTexture
  32928. * @param engine defines the engine to use
  32929. * @param source defines the type of data that will be used
  32930. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32931. */
  32932. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32933. /**
  32934. * Increments the number of references (ie. the number of Texture that point to it)
  32935. */
  32936. incrementReferences(): void;
  32937. /**
  32938. * Change the size of the texture (not the size of the content)
  32939. * @param width defines the new width
  32940. * @param height defines the new height
  32941. * @param depth defines the new depth (1 by default)
  32942. */
  32943. updateSize(width: int, height: int, depth?: int): void;
  32944. /** @hidden */
  32945. _rebuild(): void;
  32946. /** @hidden */
  32947. _swapAndDie(target: InternalTexture): void;
  32948. /**
  32949. * Dispose the current allocated resources
  32950. */
  32951. dispose(): void;
  32952. }
  32953. }
  32954. declare module BABYLON {
  32955. /**
  32956. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32958. */
  32959. export class Analyser {
  32960. /**
  32961. * Gets or sets the smoothing
  32962. * @ignorenaming
  32963. */
  32964. SMOOTHING: number;
  32965. /**
  32966. * Gets or sets the FFT table size
  32967. * @ignorenaming
  32968. */
  32969. FFT_SIZE: number;
  32970. /**
  32971. * Gets or sets the bar graph amplitude
  32972. * @ignorenaming
  32973. */
  32974. BARGRAPHAMPLITUDE: number;
  32975. /**
  32976. * Gets or sets the position of the debug canvas
  32977. * @ignorenaming
  32978. */
  32979. DEBUGCANVASPOS: {
  32980. x: number;
  32981. y: number;
  32982. };
  32983. /**
  32984. * Gets or sets the debug canvas size
  32985. * @ignorenaming
  32986. */
  32987. DEBUGCANVASSIZE: {
  32988. width: number;
  32989. height: number;
  32990. };
  32991. private _byteFreqs;
  32992. private _byteTime;
  32993. private _floatFreqs;
  32994. private _webAudioAnalyser;
  32995. private _debugCanvas;
  32996. private _debugCanvasContext;
  32997. private _scene;
  32998. private _registerFunc;
  32999. private _audioEngine;
  33000. /**
  33001. * Creates a new analyser
  33002. * @param scene defines hosting scene
  33003. */
  33004. constructor(scene: Scene);
  33005. /**
  33006. * Get the number of data values you will have to play with for the visualization
  33007. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33008. * @returns a number
  33009. */
  33010. getFrequencyBinCount(): number;
  33011. /**
  33012. * Gets the current frequency data as a byte array
  33013. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33014. * @returns a Uint8Array
  33015. */
  33016. getByteFrequencyData(): Uint8Array;
  33017. /**
  33018. * Gets the current waveform as a byte array
  33019. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33020. * @returns a Uint8Array
  33021. */
  33022. getByteTimeDomainData(): Uint8Array;
  33023. /**
  33024. * Gets the current frequency data as a float array
  33025. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33026. * @returns a Float32Array
  33027. */
  33028. getFloatFrequencyData(): Float32Array;
  33029. /**
  33030. * Renders the debug canvas
  33031. */
  33032. drawDebugCanvas(): void;
  33033. /**
  33034. * Stops rendering the debug canvas and removes it
  33035. */
  33036. stopDebugCanvas(): void;
  33037. /**
  33038. * Connects two audio nodes
  33039. * @param inputAudioNode defines first node to connect
  33040. * @param outputAudioNode defines second node to connect
  33041. */
  33042. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33043. /**
  33044. * Releases all associated resources
  33045. */
  33046. dispose(): void;
  33047. }
  33048. }
  33049. declare module BABYLON {
  33050. /**
  33051. * This represents an audio engine and it is responsible
  33052. * to play, synchronize and analyse sounds throughout the application.
  33053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33054. */
  33055. export interface IAudioEngine extends IDisposable {
  33056. /**
  33057. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33058. */
  33059. readonly canUseWebAudio: boolean;
  33060. /**
  33061. * Gets the current AudioContext if available.
  33062. */
  33063. readonly audioContext: Nullable<AudioContext>;
  33064. /**
  33065. * The master gain node defines the global audio volume of your audio engine.
  33066. */
  33067. readonly masterGain: GainNode;
  33068. /**
  33069. * Gets whether or not mp3 are supported by your browser.
  33070. */
  33071. readonly isMP3supported: boolean;
  33072. /**
  33073. * Gets whether or not ogg are supported by your browser.
  33074. */
  33075. readonly isOGGsupported: boolean;
  33076. /**
  33077. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33078. * @ignoreNaming
  33079. */
  33080. WarnedWebAudioUnsupported: boolean;
  33081. /**
  33082. * Defines if the audio engine relies on a custom unlocked button.
  33083. * In this case, the embedded button will not be displayed.
  33084. */
  33085. useCustomUnlockedButton: boolean;
  33086. /**
  33087. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33088. */
  33089. readonly unlocked: boolean;
  33090. /**
  33091. * Event raised when audio has been unlocked on the browser.
  33092. */
  33093. onAudioUnlockedObservable: Observable<AudioEngine>;
  33094. /**
  33095. * Event raised when audio has been locked on the browser.
  33096. */
  33097. onAudioLockedObservable: Observable<AudioEngine>;
  33098. /**
  33099. * Flags the audio engine in Locked state.
  33100. * This happens due to new browser policies preventing audio to autoplay.
  33101. */
  33102. lock(): void;
  33103. /**
  33104. * Unlocks the audio engine once a user action has been done on the dom.
  33105. * This is helpful to resume play once browser policies have been satisfied.
  33106. */
  33107. unlock(): void;
  33108. /**
  33109. * Gets the global volume sets on the master gain.
  33110. * @returns the global volume if set or -1 otherwise
  33111. */
  33112. getGlobalVolume(): number;
  33113. /**
  33114. * Sets the global volume of your experience (sets on the master gain).
  33115. * @param newVolume Defines the new global volume of the application
  33116. */
  33117. setGlobalVolume(newVolume: number): void;
  33118. /**
  33119. * Connect the audio engine to an audio analyser allowing some amazing
  33120. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33121. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33122. * @param analyser The analyser to connect to the engine
  33123. */
  33124. connectToAnalyser(analyser: Analyser): void;
  33125. }
  33126. /**
  33127. * This represents the default audio engine used in babylon.
  33128. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33130. */
  33131. export class AudioEngine implements IAudioEngine {
  33132. private _audioContext;
  33133. private _audioContextInitialized;
  33134. private _muteButton;
  33135. private _hostElement;
  33136. /**
  33137. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33138. */
  33139. canUseWebAudio: boolean;
  33140. /**
  33141. * The master gain node defines the global audio volume of your audio engine.
  33142. */
  33143. masterGain: GainNode;
  33144. /**
  33145. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33146. * @ignoreNaming
  33147. */
  33148. WarnedWebAudioUnsupported: boolean;
  33149. /**
  33150. * Gets whether or not mp3 are supported by your browser.
  33151. */
  33152. isMP3supported: boolean;
  33153. /**
  33154. * Gets whether or not ogg are supported by your browser.
  33155. */
  33156. isOGGsupported: boolean;
  33157. /**
  33158. * Gets whether audio has been unlocked on the device.
  33159. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33160. * a user interaction has happened.
  33161. */
  33162. unlocked: boolean;
  33163. /**
  33164. * Defines if the audio engine relies on a custom unlocked button.
  33165. * In this case, the embedded button will not be displayed.
  33166. */
  33167. useCustomUnlockedButton: boolean;
  33168. /**
  33169. * Event raised when audio has been unlocked on the browser.
  33170. */
  33171. onAudioUnlockedObservable: Observable<AudioEngine>;
  33172. /**
  33173. * Event raised when audio has been locked on the browser.
  33174. */
  33175. onAudioLockedObservable: Observable<AudioEngine>;
  33176. /**
  33177. * Gets the current AudioContext if available.
  33178. */
  33179. get audioContext(): Nullable<AudioContext>;
  33180. private _connectedAnalyser;
  33181. /**
  33182. * Instantiates a new audio engine.
  33183. *
  33184. * There should be only one per page as some browsers restrict the number
  33185. * of audio contexts you can create.
  33186. * @param hostElement defines the host element where to display the mute icon if necessary
  33187. */
  33188. constructor(hostElement?: Nullable<HTMLElement>);
  33189. /**
  33190. * Flags the audio engine in Locked state.
  33191. * This happens due to new browser policies preventing audio to autoplay.
  33192. */
  33193. lock(): void;
  33194. /**
  33195. * Unlocks the audio engine once a user action has been done on the dom.
  33196. * This is helpful to resume play once browser policies have been satisfied.
  33197. */
  33198. unlock(): void;
  33199. private _resumeAudioContext;
  33200. private _initializeAudioContext;
  33201. private _tryToRun;
  33202. private _triggerRunningState;
  33203. private _triggerSuspendedState;
  33204. private _displayMuteButton;
  33205. private _moveButtonToTopLeft;
  33206. private _onResize;
  33207. private _hideMuteButton;
  33208. /**
  33209. * Destroy and release the resources associated with the audio ccontext.
  33210. */
  33211. dispose(): void;
  33212. /**
  33213. * Gets the global volume sets on the master gain.
  33214. * @returns the global volume if set or -1 otherwise
  33215. */
  33216. getGlobalVolume(): number;
  33217. /**
  33218. * Sets the global volume of your experience (sets on the master gain).
  33219. * @param newVolume Defines the new global volume of the application
  33220. */
  33221. setGlobalVolume(newVolume: number): void;
  33222. /**
  33223. * Connect the audio engine to an audio analyser allowing some amazing
  33224. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33226. * @param analyser The analyser to connect to the engine
  33227. */
  33228. connectToAnalyser(analyser: Analyser): void;
  33229. }
  33230. }
  33231. declare module BABYLON {
  33232. /**
  33233. * Interface used to present a loading screen while loading a scene
  33234. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33235. */
  33236. export interface ILoadingScreen {
  33237. /**
  33238. * Function called to display the loading screen
  33239. */
  33240. displayLoadingUI: () => void;
  33241. /**
  33242. * Function called to hide the loading screen
  33243. */
  33244. hideLoadingUI: () => void;
  33245. /**
  33246. * Gets or sets the color to use for the background
  33247. */
  33248. loadingUIBackgroundColor: string;
  33249. /**
  33250. * Gets or sets the text to display while loading
  33251. */
  33252. loadingUIText: string;
  33253. }
  33254. /**
  33255. * Class used for the default loading screen
  33256. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33257. */
  33258. export class DefaultLoadingScreen implements ILoadingScreen {
  33259. private _renderingCanvas;
  33260. private _loadingText;
  33261. private _loadingDivBackgroundColor;
  33262. private _loadingDiv;
  33263. private _loadingTextDiv;
  33264. /** Gets or sets the logo url to use for the default loading screen */
  33265. static DefaultLogoUrl: string;
  33266. /** Gets or sets the spinner url to use for the default loading screen */
  33267. static DefaultSpinnerUrl: string;
  33268. /**
  33269. * Creates a new default loading screen
  33270. * @param _renderingCanvas defines the canvas used to render the scene
  33271. * @param _loadingText defines the default text to display
  33272. * @param _loadingDivBackgroundColor defines the default background color
  33273. */
  33274. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33275. /**
  33276. * Function called to display the loading screen
  33277. */
  33278. displayLoadingUI(): void;
  33279. /**
  33280. * Function called to hide the loading screen
  33281. */
  33282. hideLoadingUI(): void;
  33283. /**
  33284. * Gets or sets the text to display while loading
  33285. */
  33286. set loadingUIText(text: string);
  33287. get loadingUIText(): string;
  33288. /**
  33289. * Gets or sets the color to use for the background
  33290. */
  33291. get loadingUIBackgroundColor(): string;
  33292. set loadingUIBackgroundColor(color: string);
  33293. private _resizeLoadingUI;
  33294. }
  33295. }
  33296. declare module BABYLON {
  33297. /**
  33298. * Interface for any object that can request an animation frame
  33299. */
  33300. export interface ICustomAnimationFrameRequester {
  33301. /**
  33302. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33303. */
  33304. renderFunction?: Function;
  33305. /**
  33306. * Called to request the next frame to render to
  33307. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33308. */
  33309. requestAnimationFrame: Function;
  33310. /**
  33311. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33312. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33313. */
  33314. requestID?: number;
  33315. }
  33316. }
  33317. declare module BABYLON {
  33318. /**
  33319. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33320. */
  33321. export class PerformanceMonitor {
  33322. private _enabled;
  33323. private _rollingFrameTime;
  33324. private _lastFrameTimeMs;
  33325. /**
  33326. * constructor
  33327. * @param frameSampleSize The number of samples required to saturate the sliding window
  33328. */
  33329. constructor(frameSampleSize?: number);
  33330. /**
  33331. * Samples current frame
  33332. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33333. */
  33334. sampleFrame(timeMs?: number): void;
  33335. /**
  33336. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33337. */
  33338. get averageFrameTime(): number;
  33339. /**
  33340. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33341. */
  33342. get averageFrameTimeVariance(): number;
  33343. /**
  33344. * Returns the frame time of the most recent frame
  33345. */
  33346. get instantaneousFrameTime(): number;
  33347. /**
  33348. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33349. */
  33350. get averageFPS(): number;
  33351. /**
  33352. * Returns the average framerate in frames per second using the most recent frame time
  33353. */
  33354. get instantaneousFPS(): number;
  33355. /**
  33356. * Returns true if enough samples have been taken to completely fill the sliding window
  33357. */
  33358. get isSaturated(): boolean;
  33359. /**
  33360. * Enables contributions to the sliding window sample set
  33361. */
  33362. enable(): void;
  33363. /**
  33364. * Disables contributions to the sliding window sample set
  33365. * Samples will not be interpolated over the disabled period
  33366. */
  33367. disable(): void;
  33368. /**
  33369. * Returns true if sampling is enabled
  33370. */
  33371. get isEnabled(): boolean;
  33372. /**
  33373. * Resets performance monitor
  33374. */
  33375. reset(): void;
  33376. }
  33377. /**
  33378. * RollingAverage
  33379. *
  33380. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33381. */
  33382. export class RollingAverage {
  33383. /**
  33384. * Current average
  33385. */
  33386. average: number;
  33387. /**
  33388. * Current variance
  33389. */
  33390. variance: number;
  33391. protected _samples: Array<number>;
  33392. protected _sampleCount: number;
  33393. protected _pos: number;
  33394. protected _m2: number;
  33395. /**
  33396. * constructor
  33397. * @param length The number of samples required to saturate the sliding window
  33398. */
  33399. constructor(length: number);
  33400. /**
  33401. * Adds a sample to the sample set
  33402. * @param v The sample value
  33403. */
  33404. add(v: number): void;
  33405. /**
  33406. * Returns previously added values or null if outside of history or outside the sliding window domain
  33407. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33408. * @return Value previously recorded with add() or null if outside of range
  33409. */
  33410. history(i: number): number;
  33411. /**
  33412. * Returns true if enough samples have been taken to completely fill the sliding window
  33413. * @return true if sample-set saturated
  33414. */
  33415. isSaturated(): boolean;
  33416. /**
  33417. * Resets the rolling average (equivalent to 0 samples taken so far)
  33418. */
  33419. reset(): void;
  33420. /**
  33421. * Wraps a value around the sample range boundaries
  33422. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33423. * @return Wrapped position in sample range
  33424. */
  33425. protected _wrapPosition(i: number): number;
  33426. }
  33427. }
  33428. declare module BABYLON {
  33429. /**
  33430. * This class is used to track a performance counter which is number based.
  33431. * The user has access to many properties which give statistics of different nature.
  33432. *
  33433. * The implementer can track two kinds of Performance Counter: time and count.
  33434. * 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.
  33435. * 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.
  33436. */
  33437. export class PerfCounter {
  33438. /**
  33439. * Gets or sets a global boolean to turn on and off all the counters
  33440. */
  33441. static Enabled: boolean;
  33442. /**
  33443. * Returns the smallest value ever
  33444. */
  33445. get min(): number;
  33446. /**
  33447. * Returns the biggest value ever
  33448. */
  33449. get max(): number;
  33450. /**
  33451. * Returns the average value since the performance counter is running
  33452. */
  33453. get average(): number;
  33454. /**
  33455. * Returns the average value of the last second the counter was monitored
  33456. */
  33457. get lastSecAverage(): number;
  33458. /**
  33459. * Returns the current value
  33460. */
  33461. get current(): number;
  33462. /**
  33463. * Gets the accumulated total
  33464. */
  33465. get total(): number;
  33466. /**
  33467. * Gets the total value count
  33468. */
  33469. get count(): number;
  33470. /**
  33471. * Creates a new counter
  33472. */
  33473. constructor();
  33474. /**
  33475. * Call this method to start monitoring a new frame.
  33476. * 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.
  33477. */
  33478. fetchNewFrame(): void;
  33479. /**
  33480. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33481. * @param newCount the count value to add to the monitored count
  33482. * @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.
  33483. */
  33484. addCount(newCount: number, fetchResult: boolean): void;
  33485. /**
  33486. * Start monitoring this performance counter
  33487. */
  33488. beginMonitoring(): void;
  33489. /**
  33490. * Compute the time lapsed since the previous beginMonitoring() call.
  33491. * @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
  33492. */
  33493. endMonitoring(newFrame?: boolean): void;
  33494. private _fetchResult;
  33495. private _startMonitoringTime;
  33496. private _min;
  33497. private _max;
  33498. private _average;
  33499. private _current;
  33500. private _totalValueCount;
  33501. private _totalAccumulated;
  33502. private _lastSecAverage;
  33503. private _lastSecAccumulated;
  33504. private _lastSecTime;
  33505. private _lastSecValueCount;
  33506. }
  33507. }
  33508. declare module BABYLON {
  33509. interface ThinEngine {
  33510. /**
  33511. * Sets alpha constants used by some alpha blending modes
  33512. * @param r defines the red component
  33513. * @param g defines the green component
  33514. * @param b defines the blue component
  33515. * @param a defines the alpha component
  33516. */
  33517. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33518. /**
  33519. * Sets the current alpha mode
  33520. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33521. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33522. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33523. */
  33524. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33525. /**
  33526. * Gets the current alpha mode
  33527. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33528. * @returns the current alpha mode
  33529. */
  33530. getAlphaMode(): number;
  33531. /**
  33532. * Sets the current alpha equation
  33533. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33534. */
  33535. setAlphaEquation(equation: number): void;
  33536. /**
  33537. * Gets the current alpha equation.
  33538. * @returns the current alpha equation
  33539. */
  33540. getAlphaEquation(): number;
  33541. }
  33542. }
  33543. declare module BABYLON {
  33544. /**
  33545. * Defines the interface used by display changed events
  33546. */
  33547. export interface IDisplayChangedEventArgs {
  33548. /** Gets the vrDisplay object (if any) */
  33549. vrDisplay: Nullable<any>;
  33550. /** Gets a boolean indicating if webVR is supported */
  33551. vrSupported: boolean;
  33552. }
  33553. /**
  33554. * Defines the interface used by objects containing a viewport (like a camera)
  33555. */
  33556. interface IViewportOwnerLike {
  33557. /**
  33558. * Gets or sets the viewport
  33559. */
  33560. viewport: IViewportLike;
  33561. }
  33562. /**
  33563. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33564. */
  33565. export class Engine extends ThinEngine {
  33566. /** Defines that alpha blending is disabled */
  33567. static readonly ALPHA_DISABLE: number;
  33568. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33569. static readonly ALPHA_ADD: number;
  33570. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33571. static readonly ALPHA_COMBINE: number;
  33572. /** Defines that alpha blending to DEST - SRC * DEST */
  33573. static readonly ALPHA_SUBTRACT: number;
  33574. /** Defines that alpha blending to SRC * DEST */
  33575. static readonly ALPHA_MULTIPLY: number;
  33576. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33577. static readonly ALPHA_MAXIMIZED: number;
  33578. /** Defines that alpha blending to SRC + DEST */
  33579. static readonly ALPHA_ONEONE: number;
  33580. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33581. static readonly ALPHA_PREMULTIPLIED: number;
  33582. /**
  33583. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33584. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33585. */
  33586. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33587. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33588. static readonly ALPHA_INTERPOLATE: number;
  33589. /**
  33590. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33591. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33592. */
  33593. static readonly ALPHA_SCREENMODE: number;
  33594. /** Defines that the ressource is not delayed*/
  33595. static readonly DELAYLOADSTATE_NONE: number;
  33596. /** Defines that the ressource was successfully delay loaded */
  33597. static readonly DELAYLOADSTATE_LOADED: number;
  33598. /** Defines that the ressource is currently delay loading */
  33599. static readonly DELAYLOADSTATE_LOADING: number;
  33600. /** Defines that the ressource is delayed and has not started loading */
  33601. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33602. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33603. static readonly NEVER: number;
  33604. /** 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 */
  33605. static readonly ALWAYS: number;
  33606. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33607. static readonly LESS: number;
  33608. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33609. static readonly EQUAL: number;
  33610. /** 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 */
  33611. static readonly LEQUAL: number;
  33612. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33613. static readonly GREATER: number;
  33614. /** 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 */
  33615. static readonly GEQUAL: number;
  33616. /** 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 */
  33617. static readonly NOTEQUAL: number;
  33618. /** Passed to stencilOperation to specify that stencil value must be kept */
  33619. static readonly KEEP: number;
  33620. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33621. static readonly REPLACE: number;
  33622. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33623. static readonly INCR: number;
  33624. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33625. static readonly DECR: number;
  33626. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33627. static readonly INVERT: number;
  33628. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33629. static readonly INCR_WRAP: number;
  33630. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33631. static readonly DECR_WRAP: number;
  33632. /** Texture is not repeating outside of 0..1 UVs */
  33633. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33634. /** Texture is repeating outside of 0..1 UVs */
  33635. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33636. /** Texture is repeating and mirrored */
  33637. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33638. /** ALPHA */
  33639. static readonly TEXTUREFORMAT_ALPHA: number;
  33640. /** LUMINANCE */
  33641. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33642. /** LUMINANCE_ALPHA */
  33643. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33644. /** RGB */
  33645. static readonly TEXTUREFORMAT_RGB: number;
  33646. /** RGBA */
  33647. static readonly TEXTUREFORMAT_RGBA: number;
  33648. /** RED */
  33649. static readonly TEXTUREFORMAT_RED: number;
  33650. /** RED (2nd reference) */
  33651. static readonly TEXTUREFORMAT_R: number;
  33652. /** RG */
  33653. static readonly TEXTUREFORMAT_RG: number;
  33654. /** RED_INTEGER */
  33655. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33656. /** RED_INTEGER (2nd reference) */
  33657. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33658. /** RG_INTEGER */
  33659. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33660. /** RGB_INTEGER */
  33661. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33662. /** RGBA_INTEGER */
  33663. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33664. /** UNSIGNED_BYTE */
  33665. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33666. /** UNSIGNED_BYTE (2nd reference) */
  33667. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33668. /** FLOAT */
  33669. static readonly TEXTURETYPE_FLOAT: number;
  33670. /** HALF_FLOAT */
  33671. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33672. /** BYTE */
  33673. static readonly TEXTURETYPE_BYTE: number;
  33674. /** SHORT */
  33675. static readonly TEXTURETYPE_SHORT: number;
  33676. /** UNSIGNED_SHORT */
  33677. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33678. /** INT */
  33679. static readonly TEXTURETYPE_INT: number;
  33680. /** UNSIGNED_INT */
  33681. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33682. /** UNSIGNED_SHORT_4_4_4_4 */
  33683. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33684. /** UNSIGNED_SHORT_5_5_5_1 */
  33685. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33686. /** UNSIGNED_SHORT_5_6_5 */
  33687. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33688. /** UNSIGNED_INT_2_10_10_10_REV */
  33689. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33690. /** UNSIGNED_INT_24_8 */
  33691. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33692. /** UNSIGNED_INT_10F_11F_11F_REV */
  33693. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33694. /** UNSIGNED_INT_5_9_9_9_REV */
  33695. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33696. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33697. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33698. /** nearest is mag = nearest and min = nearest and mip = linear */
  33699. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33700. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33701. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33702. /** Trilinear is mag = linear and min = linear and mip = linear */
  33703. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33704. /** nearest is mag = nearest and min = nearest and mip = linear */
  33705. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33706. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33707. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33708. /** Trilinear is mag = linear and min = linear and mip = linear */
  33709. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33710. /** mag = nearest and min = nearest and mip = nearest */
  33711. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33712. /** mag = nearest and min = linear and mip = nearest */
  33713. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33714. /** mag = nearest and min = linear and mip = linear */
  33715. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33716. /** mag = nearest and min = linear and mip = none */
  33717. static readonly TEXTURE_NEAREST_LINEAR: number;
  33718. /** mag = nearest and min = nearest and mip = none */
  33719. static readonly TEXTURE_NEAREST_NEAREST: number;
  33720. /** mag = linear and min = nearest and mip = nearest */
  33721. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33722. /** mag = linear and min = nearest and mip = linear */
  33723. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33724. /** mag = linear and min = linear and mip = none */
  33725. static readonly TEXTURE_LINEAR_LINEAR: number;
  33726. /** mag = linear and min = nearest and mip = none */
  33727. static readonly TEXTURE_LINEAR_NEAREST: number;
  33728. /** Explicit coordinates mode */
  33729. static readonly TEXTURE_EXPLICIT_MODE: number;
  33730. /** Spherical coordinates mode */
  33731. static readonly TEXTURE_SPHERICAL_MODE: number;
  33732. /** Planar coordinates mode */
  33733. static readonly TEXTURE_PLANAR_MODE: number;
  33734. /** Cubic coordinates mode */
  33735. static readonly TEXTURE_CUBIC_MODE: number;
  33736. /** Projection coordinates mode */
  33737. static readonly TEXTURE_PROJECTION_MODE: number;
  33738. /** Skybox coordinates mode */
  33739. static readonly TEXTURE_SKYBOX_MODE: number;
  33740. /** Inverse Cubic coordinates mode */
  33741. static readonly TEXTURE_INVCUBIC_MODE: number;
  33742. /** Equirectangular coordinates mode */
  33743. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33744. /** Equirectangular Fixed coordinates mode */
  33745. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33746. /** Equirectangular Fixed Mirrored coordinates mode */
  33747. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33748. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33749. static readonly SCALEMODE_FLOOR: number;
  33750. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33751. static readonly SCALEMODE_NEAREST: number;
  33752. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33753. static readonly SCALEMODE_CEILING: number;
  33754. /**
  33755. * Returns the current npm package of the sdk
  33756. */
  33757. static get NpmPackage(): string;
  33758. /**
  33759. * Returns the current version of the framework
  33760. */
  33761. static get Version(): string;
  33762. /** Gets the list of created engines */
  33763. static get Instances(): Engine[];
  33764. /**
  33765. * Gets the latest created engine
  33766. */
  33767. static get LastCreatedEngine(): Nullable<Engine>;
  33768. /**
  33769. * Gets the latest created scene
  33770. */
  33771. static get LastCreatedScene(): Nullable<Scene>;
  33772. /**
  33773. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33774. * @param flag defines which part of the materials must be marked as dirty
  33775. * @param predicate defines a predicate used to filter which materials should be affected
  33776. */
  33777. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33778. /**
  33779. * Method called to create the default loading screen.
  33780. * This can be overriden in your own app.
  33781. * @param canvas The rendering canvas element
  33782. * @returns The loading screen
  33783. */
  33784. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33785. /**
  33786. * Method called to create the default rescale post process on each engine.
  33787. */
  33788. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33789. /**
  33790. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33791. **/
  33792. enableOfflineSupport: boolean;
  33793. /**
  33794. * 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)
  33795. **/
  33796. disableManifestCheck: boolean;
  33797. /**
  33798. * Gets the list of created scenes
  33799. */
  33800. scenes: Scene[];
  33801. /**
  33802. * Event raised when a new scene is created
  33803. */
  33804. onNewSceneAddedObservable: Observable<Scene>;
  33805. /**
  33806. * Gets the list of created postprocesses
  33807. */
  33808. postProcesses: PostProcess[];
  33809. /**
  33810. * Gets a boolean indicating if the pointer is currently locked
  33811. */
  33812. isPointerLock: boolean;
  33813. /**
  33814. * Observable event triggered each time the rendering canvas is resized
  33815. */
  33816. onResizeObservable: Observable<Engine>;
  33817. /**
  33818. * Observable event triggered each time the canvas loses focus
  33819. */
  33820. onCanvasBlurObservable: Observable<Engine>;
  33821. /**
  33822. * Observable event triggered each time the canvas gains focus
  33823. */
  33824. onCanvasFocusObservable: Observable<Engine>;
  33825. /**
  33826. * Observable event triggered each time the canvas receives pointerout event
  33827. */
  33828. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33829. /**
  33830. * Observable raised when the engine begins a new frame
  33831. */
  33832. onBeginFrameObservable: Observable<Engine>;
  33833. /**
  33834. * If set, will be used to request the next animation frame for the render loop
  33835. */
  33836. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33837. /**
  33838. * Observable raised when the engine ends the current frame
  33839. */
  33840. onEndFrameObservable: Observable<Engine>;
  33841. /**
  33842. * Observable raised when the engine is about to compile a shader
  33843. */
  33844. onBeforeShaderCompilationObservable: Observable<Engine>;
  33845. /**
  33846. * Observable raised when the engine has jsut compiled a shader
  33847. */
  33848. onAfterShaderCompilationObservable: Observable<Engine>;
  33849. /**
  33850. * Gets the audio engine
  33851. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33852. * @ignorenaming
  33853. */
  33854. static audioEngine: IAudioEngine;
  33855. /**
  33856. * Default AudioEngine factory responsible of creating the Audio Engine.
  33857. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33858. */
  33859. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33860. /**
  33861. * Default offline support factory responsible of creating a tool used to store data locally.
  33862. * By default, this will create a Database object if the workload has been embedded.
  33863. */
  33864. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33865. private _loadingScreen;
  33866. private _pointerLockRequested;
  33867. private _dummyFramebuffer;
  33868. private _rescalePostProcess;
  33869. private _deterministicLockstep;
  33870. private _lockstepMaxSteps;
  33871. private _timeStep;
  33872. protected get _supportsHardwareTextureRescaling(): boolean;
  33873. private _fps;
  33874. private _deltaTime;
  33875. /** @hidden */
  33876. _drawCalls: PerfCounter;
  33877. /** 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 */
  33878. canvasTabIndex: number;
  33879. /**
  33880. * Turn this value on if you want to pause FPS computation when in background
  33881. */
  33882. disablePerformanceMonitorInBackground: boolean;
  33883. private _performanceMonitor;
  33884. /**
  33885. * Gets the performance monitor attached to this engine
  33886. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33887. */
  33888. get performanceMonitor(): PerformanceMonitor;
  33889. private _onFocus;
  33890. private _onBlur;
  33891. private _onCanvasPointerOut;
  33892. private _onCanvasBlur;
  33893. private _onCanvasFocus;
  33894. private _onFullscreenChange;
  33895. private _onPointerLockChange;
  33896. /**
  33897. * Gets the HTML element used to attach event listeners
  33898. * @returns a HTML element
  33899. */
  33900. getInputElement(): Nullable<HTMLElement>;
  33901. /**
  33902. * Creates a new engine
  33903. * @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
  33904. * @param antialias defines enable antialiasing (default: false)
  33905. * @param options defines further options to be sent to the getContext() function
  33906. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33907. */
  33908. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33909. /**
  33910. * Gets current aspect ratio
  33911. * @param viewportOwner defines the camera to use to get the aspect ratio
  33912. * @param useScreen defines if screen size must be used (or the current render target if any)
  33913. * @returns a number defining the aspect ratio
  33914. */
  33915. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33916. /**
  33917. * Gets current screen aspect ratio
  33918. * @returns a number defining the aspect ratio
  33919. */
  33920. getScreenAspectRatio(): number;
  33921. /**
  33922. * Gets the client rect of the HTML canvas attached with the current webGL context
  33923. * @returns a client rectanglee
  33924. */
  33925. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33926. /**
  33927. * Gets the client rect of the HTML element used for events
  33928. * @returns a client rectanglee
  33929. */
  33930. getInputElementClientRect(): Nullable<ClientRect>;
  33931. /**
  33932. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33933. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33934. * @returns true if engine is in deterministic lock step mode
  33935. */
  33936. isDeterministicLockStep(): boolean;
  33937. /**
  33938. * Gets the max steps when engine is running in deterministic lock step
  33939. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33940. * @returns the max steps
  33941. */
  33942. getLockstepMaxSteps(): number;
  33943. /**
  33944. * Returns the time in ms between steps when using deterministic lock step.
  33945. * @returns time step in (ms)
  33946. */
  33947. getTimeStep(): number;
  33948. /**
  33949. * Force the mipmap generation for the given render target texture
  33950. * @param texture defines the render target texture to use
  33951. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33952. */
  33953. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33954. /** States */
  33955. /**
  33956. * Set various states to the webGL context
  33957. * @param culling defines backface culling state
  33958. * @param zOffset defines the value to apply to zOffset (0 by default)
  33959. * @param force defines if states must be applied even if cache is up to date
  33960. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33961. */
  33962. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33963. /**
  33964. * Set the z offset to apply to current rendering
  33965. * @param value defines the offset to apply
  33966. */
  33967. setZOffset(value: number): void;
  33968. /**
  33969. * Gets the current value of the zOffset
  33970. * @returns the current zOffset state
  33971. */
  33972. getZOffset(): number;
  33973. /**
  33974. * Enable or disable depth buffering
  33975. * @param enable defines the state to set
  33976. */
  33977. setDepthBuffer(enable: boolean): void;
  33978. /**
  33979. * Gets a boolean indicating if depth writing is enabled
  33980. * @returns the current depth writing state
  33981. */
  33982. getDepthWrite(): boolean;
  33983. /**
  33984. * Enable or disable depth writing
  33985. * @param enable defines the state to set
  33986. */
  33987. setDepthWrite(enable: boolean): void;
  33988. /**
  33989. * Gets a boolean indicating if stencil buffer is enabled
  33990. * @returns the current stencil buffer state
  33991. */
  33992. getStencilBuffer(): boolean;
  33993. /**
  33994. * Enable or disable the stencil buffer
  33995. * @param enable defines if the stencil buffer must be enabled or disabled
  33996. */
  33997. setStencilBuffer(enable: boolean): void;
  33998. /**
  33999. * Gets the current stencil mask
  34000. * @returns a number defining the new stencil mask to use
  34001. */
  34002. getStencilMask(): number;
  34003. /**
  34004. * Sets the current stencil mask
  34005. * @param mask defines the new stencil mask to use
  34006. */
  34007. setStencilMask(mask: number): void;
  34008. /**
  34009. * Gets the current stencil function
  34010. * @returns a number defining the stencil function to use
  34011. */
  34012. getStencilFunction(): number;
  34013. /**
  34014. * Gets the current stencil reference value
  34015. * @returns a number defining the stencil reference value to use
  34016. */
  34017. getStencilFunctionReference(): number;
  34018. /**
  34019. * Gets the current stencil mask
  34020. * @returns a number defining the stencil mask to use
  34021. */
  34022. getStencilFunctionMask(): number;
  34023. /**
  34024. * Sets the current stencil function
  34025. * @param stencilFunc defines the new stencil function to use
  34026. */
  34027. setStencilFunction(stencilFunc: number): void;
  34028. /**
  34029. * Sets the current stencil reference
  34030. * @param reference defines the new stencil reference to use
  34031. */
  34032. setStencilFunctionReference(reference: number): void;
  34033. /**
  34034. * Sets the current stencil mask
  34035. * @param mask defines the new stencil mask to use
  34036. */
  34037. setStencilFunctionMask(mask: number): void;
  34038. /**
  34039. * Gets the current stencil operation when stencil fails
  34040. * @returns a number defining stencil operation to use when stencil fails
  34041. */
  34042. getStencilOperationFail(): number;
  34043. /**
  34044. * Gets the current stencil operation when depth fails
  34045. * @returns a number defining stencil operation to use when depth fails
  34046. */
  34047. getStencilOperationDepthFail(): number;
  34048. /**
  34049. * Gets the current stencil operation when stencil passes
  34050. * @returns a number defining stencil operation to use when stencil passes
  34051. */
  34052. getStencilOperationPass(): number;
  34053. /**
  34054. * Sets the stencil operation to use when stencil fails
  34055. * @param operation defines the stencil operation to use when stencil fails
  34056. */
  34057. setStencilOperationFail(operation: number): void;
  34058. /**
  34059. * Sets the stencil operation to use when depth fails
  34060. * @param operation defines the stencil operation to use when depth fails
  34061. */
  34062. setStencilOperationDepthFail(operation: number): void;
  34063. /**
  34064. * Sets the stencil operation to use when stencil passes
  34065. * @param operation defines the stencil operation to use when stencil passes
  34066. */
  34067. setStencilOperationPass(operation: number): void;
  34068. /**
  34069. * Sets a boolean indicating if the dithering state is enabled or disabled
  34070. * @param value defines the dithering state
  34071. */
  34072. setDitheringState(value: boolean): void;
  34073. /**
  34074. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34075. * @param value defines the rasterizer state
  34076. */
  34077. setRasterizerState(value: boolean): void;
  34078. /**
  34079. * Gets the current depth function
  34080. * @returns a number defining the depth function
  34081. */
  34082. getDepthFunction(): Nullable<number>;
  34083. /**
  34084. * Sets the current depth function
  34085. * @param depthFunc defines the function to use
  34086. */
  34087. setDepthFunction(depthFunc: number): void;
  34088. /**
  34089. * Sets the current depth function to GREATER
  34090. */
  34091. setDepthFunctionToGreater(): void;
  34092. /**
  34093. * Sets the current depth function to GEQUAL
  34094. */
  34095. setDepthFunctionToGreaterOrEqual(): void;
  34096. /**
  34097. * Sets the current depth function to LESS
  34098. */
  34099. setDepthFunctionToLess(): void;
  34100. /**
  34101. * Sets the current depth function to LEQUAL
  34102. */
  34103. setDepthFunctionToLessOrEqual(): void;
  34104. private _cachedStencilBuffer;
  34105. private _cachedStencilFunction;
  34106. private _cachedStencilMask;
  34107. private _cachedStencilOperationPass;
  34108. private _cachedStencilOperationFail;
  34109. private _cachedStencilOperationDepthFail;
  34110. private _cachedStencilReference;
  34111. /**
  34112. * Caches the the state of the stencil buffer
  34113. */
  34114. cacheStencilState(): void;
  34115. /**
  34116. * Restores the state of the stencil buffer
  34117. */
  34118. restoreStencilState(): void;
  34119. /**
  34120. * Directly set the WebGL Viewport
  34121. * @param x defines the x coordinate of the viewport (in screen space)
  34122. * @param y defines the y coordinate of the viewport (in screen space)
  34123. * @param width defines the width of the viewport (in screen space)
  34124. * @param height defines the height of the viewport (in screen space)
  34125. * @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
  34126. */
  34127. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34128. /**
  34129. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34130. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34131. * @param y defines the y-coordinate of the corner of the clear rectangle
  34132. * @param width defines the width of the clear rectangle
  34133. * @param height defines the height of the clear rectangle
  34134. * @param clearColor defines the clear color
  34135. */
  34136. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34137. /**
  34138. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34139. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34140. * @param y defines the y-coordinate of the corner of the clear rectangle
  34141. * @param width defines the width of the clear rectangle
  34142. * @param height defines the height of the clear rectangle
  34143. */
  34144. enableScissor(x: number, y: number, width: number, height: number): void;
  34145. /**
  34146. * Disable previously set scissor test rectangle
  34147. */
  34148. disableScissor(): void;
  34149. protected _reportDrawCall(): void;
  34150. /**
  34151. * Initializes a webVR display and starts listening to display change events
  34152. * The onVRDisplayChangedObservable will be notified upon these changes
  34153. * @returns The onVRDisplayChangedObservable
  34154. */
  34155. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34156. /** @hidden */
  34157. _prepareVRComponent(): void;
  34158. /** @hidden */
  34159. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34160. /** @hidden */
  34161. _submitVRFrame(): void;
  34162. /**
  34163. * Call this function to leave webVR mode
  34164. * Will do nothing if webVR is not supported or if there is no webVR device
  34165. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34166. */
  34167. disableVR(): void;
  34168. /**
  34169. * Gets a boolean indicating that the system is in VR mode and is presenting
  34170. * @returns true if VR mode is engaged
  34171. */
  34172. isVRPresenting(): boolean;
  34173. /** @hidden */
  34174. _requestVRFrame(): void;
  34175. /** @hidden */
  34176. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34177. /**
  34178. * Gets the source code of the vertex shader associated with a specific webGL program
  34179. * @param program defines the program to use
  34180. * @returns a string containing the source code of the vertex shader associated with the program
  34181. */
  34182. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34183. /**
  34184. * Gets the source code of the fragment shader associated with a specific webGL program
  34185. * @param program defines the program to use
  34186. * @returns a string containing the source code of the fragment shader associated with the program
  34187. */
  34188. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34189. /**
  34190. * Sets a depth stencil texture from a render target to the according uniform.
  34191. * @param channel The texture channel
  34192. * @param uniform The uniform to set
  34193. * @param texture The render target texture containing the depth stencil texture to apply
  34194. */
  34195. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34196. /**
  34197. * Sets a texture to the webGL context from a postprocess
  34198. * @param channel defines the channel to use
  34199. * @param postProcess defines the source postprocess
  34200. */
  34201. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34202. /**
  34203. * Binds the output of the passed in post process to the texture channel specified
  34204. * @param channel The channel the texture should be bound to
  34205. * @param postProcess The post process which's output should be bound
  34206. */
  34207. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34208. protected _rebuildBuffers(): void;
  34209. /** @hidden */
  34210. _renderFrame(): void;
  34211. _renderLoop(): void;
  34212. /** @hidden */
  34213. _renderViews(): boolean;
  34214. /**
  34215. * Toggle full screen mode
  34216. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34217. */
  34218. switchFullscreen(requestPointerLock: boolean): void;
  34219. /**
  34220. * Enters full screen mode
  34221. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34222. */
  34223. enterFullscreen(requestPointerLock: boolean): void;
  34224. /**
  34225. * Exits full screen mode
  34226. */
  34227. exitFullscreen(): void;
  34228. /**
  34229. * Enters Pointerlock mode
  34230. */
  34231. enterPointerlock(): void;
  34232. /**
  34233. * Exits Pointerlock mode
  34234. */
  34235. exitPointerlock(): void;
  34236. /**
  34237. * Begin a new frame
  34238. */
  34239. beginFrame(): void;
  34240. /**
  34241. * Enf the current frame
  34242. */
  34243. endFrame(): void;
  34244. resize(): void;
  34245. /**
  34246. * Force a specific size of the canvas
  34247. * @param width defines the new canvas' width
  34248. * @param height defines the new canvas' height
  34249. */
  34250. setSize(width: number, height: number): void;
  34251. /**
  34252. * Updates a dynamic vertex buffer.
  34253. * @param vertexBuffer the vertex buffer to update
  34254. * @param data the data used to update the vertex buffer
  34255. * @param byteOffset the byte offset of the data
  34256. * @param byteLength the byte length of the data
  34257. */
  34258. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34259. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34260. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34261. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34262. _releaseTexture(texture: InternalTexture): void;
  34263. /**
  34264. * @hidden
  34265. * Rescales a texture
  34266. * @param source input texutre
  34267. * @param destination destination texture
  34268. * @param scene scene to use to render the resize
  34269. * @param internalFormat format to use when resizing
  34270. * @param onComplete callback to be called when resize has completed
  34271. */
  34272. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34273. /**
  34274. * Gets the current framerate
  34275. * @returns a number representing the framerate
  34276. */
  34277. getFps(): number;
  34278. /**
  34279. * Gets the time spent between current and previous frame
  34280. * @returns a number representing the delta time in ms
  34281. */
  34282. getDeltaTime(): number;
  34283. private _measureFps;
  34284. /** @hidden */
  34285. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34286. /**
  34287. * Update a dynamic index buffer
  34288. * @param indexBuffer defines the target index buffer
  34289. * @param indices defines the data to update
  34290. * @param offset defines the offset in the target index buffer where update should start
  34291. */
  34292. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34293. /**
  34294. * Updates the sample count of a render target texture
  34295. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34296. * @param texture defines the texture to update
  34297. * @param samples defines the sample count to set
  34298. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34299. */
  34300. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34301. /**
  34302. * Updates a depth texture Comparison Mode and Function.
  34303. * If the comparison Function is equal to 0, the mode will be set to none.
  34304. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34305. * @param texture The texture to set the comparison function for
  34306. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34307. */
  34308. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34309. /**
  34310. * Creates a webGL buffer to use with instanciation
  34311. * @param capacity defines the size of the buffer
  34312. * @returns the webGL buffer
  34313. */
  34314. createInstancesBuffer(capacity: number): DataBuffer;
  34315. /**
  34316. * Delete a webGL buffer used with instanciation
  34317. * @param buffer defines the webGL buffer to delete
  34318. */
  34319. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34320. private _clientWaitAsync;
  34321. /** @hidden */
  34322. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34323. /** @hidden */
  34324. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34325. dispose(): void;
  34326. private _disableTouchAction;
  34327. /**
  34328. * Display the loading screen
  34329. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34330. */
  34331. displayLoadingUI(): void;
  34332. /**
  34333. * Hide the loading screen
  34334. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34335. */
  34336. hideLoadingUI(): void;
  34337. /**
  34338. * Gets the current loading screen object
  34339. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34340. */
  34341. get loadingScreen(): ILoadingScreen;
  34342. /**
  34343. * Sets the current loading screen object
  34344. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34345. */
  34346. set loadingScreen(loadingScreen: ILoadingScreen);
  34347. /**
  34348. * Sets the current loading screen text
  34349. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34350. */
  34351. set loadingUIText(text: string);
  34352. /**
  34353. * Sets the current loading screen background color
  34354. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34355. */
  34356. set loadingUIBackgroundColor(color: string);
  34357. /** Pointerlock and fullscreen */
  34358. /**
  34359. * Ask the browser to promote the current element to pointerlock mode
  34360. * @param element defines the DOM element to promote
  34361. */
  34362. static _RequestPointerlock(element: HTMLElement): void;
  34363. /**
  34364. * Asks the browser to exit pointerlock mode
  34365. */
  34366. static _ExitPointerlock(): void;
  34367. /**
  34368. * Ask the browser to promote the current element to fullscreen rendering mode
  34369. * @param element defines the DOM element to promote
  34370. */
  34371. static _RequestFullscreen(element: HTMLElement): void;
  34372. /**
  34373. * Asks the browser to exit fullscreen mode
  34374. */
  34375. static _ExitFullscreen(): void;
  34376. }
  34377. }
  34378. declare module BABYLON {
  34379. /**
  34380. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34381. * during the life time of the application.
  34382. */
  34383. export class EngineStore {
  34384. /** Gets the list of created engines */
  34385. static Instances: Engine[];
  34386. /** @hidden */
  34387. static _LastCreatedScene: Nullable<Scene>;
  34388. /**
  34389. * Gets the latest created engine
  34390. */
  34391. static get LastCreatedEngine(): Nullable<Engine>;
  34392. /**
  34393. * Gets the latest created scene
  34394. */
  34395. static get LastCreatedScene(): Nullable<Scene>;
  34396. /**
  34397. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34398. * @ignorenaming
  34399. */
  34400. static UseFallbackTexture: boolean;
  34401. /**
  34402. * Texture content used if a texture cannot loaded
  34403. * @ignorenaming
  34404. */
  34405. static FallbackTexture: string;
  34406. }
  34407. }
  34408. declare module BABYLON {
  34409. /**
  34410. * Helper class that provides a small promise polyfill
  34411. */
  34412. export class PromisePolyfill {
  34413. /**
  34414. * Static function used to check if the polyfill is required
  34415. * If this is the case then the function will inject the polyfill to window.Promise
  34416. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34417. */
  34418. static Apply(force?: boolean): void;
  34419. }
  34420. }
  34421. declare module BABYLON {
  34422. /**
  34423. * Interface for screenshot methods with describe argument called `size` as object with options
  34424. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34425. */
  34426. export interface IScreenshotSize {
  34427. /**
  34428. * number in pixels for canvas height
  34429. */
  34430. height?: number;
  34431. /**
  34432. * multiplier allowing render at a higher or lower resolution
  34433. * If value is defined then height and width will be ignored and taken from camera
  34434. */
  34435. precision?: number;
  34436. /**
  34437. * number in pixels for canvas width
  34438. */
  34439. width?: number;
  34440. }
  34441. }
  34442. declare module BABYLON {
  34443. interface IColor4Like {
  34444. r: float;
  34445. g: float;
  34446. b: float;
  34447. a: float;
  34448. }
  34449. /**
  34450. * Class containing a set of static utilities functions
  34451. */
  34452. export class Tools {
  34453. /**
  34454. * Gets or sets the base URL to use to load assets
  34455. */
  34456. static get BaseUrl(): string;
  34457. static set BaseUrl(value: string);
  34458. /**
  34459. * Enable/Disable Custom HTTP Request Headers globally.
  34460. * default = false
  34461. * @see CustomRequestHeaders
  34462. */
  34463. static UseCustomRequestHeaders: boolean;
  34464. /**
  34465. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34466. * i.e. when loading files, where the server/service expects an Authorization header
  34467. */
  34468. static CustomRequestHeaders: {
  34469. [key: string]: string;
  34470. };
  34471. /**
  34472. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34473. */
  34474. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34475. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34476. /**
  34477. * Default behaviour for cors in the application.
  34478. * It can be a string if the expected behavior is identical in the entire app.
  34479. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34480. */
  34481. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34482. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34483. /**
  34484. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34485. * @ignorenaming
  34486. */
  34487. static get UseFallbackTexture(): boolean;
  34488. static set UseFallbackTexture(value: boolean);
  34489. /**
  34490. * Use this object to register external classes like custom textures or material
  34491. * to allow the laoders to instantiate them
  34492. */
  34493. static get RegisteredExternalClasses(): {
  34494. [key: string]: Object;
  34495. };
  34496. static set RegisteredExternalClasses(classes: {
  34497. [key: string]: Object;
  34498. });
  34499. /**
  34500. * Texture content used if a texture cannot loaded
  34501. * @ignorenaming
  34502. */
  34503. static get fallbackTexture(): string;
  34504. static set fallbackTexture(value: string);
  34505. /**
  34506. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34507. * @param u defines the coordinate on X axis
  34508. * @param v defines the coordinate on Y axis
  34509. * @param width defines the width of the source data
  34510. * @param height defines the height of the source data
  34511. * @param pixels defines the source byte array
  34512. * @param color defines the output color
  34513. */
  34514. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34515. /**
  34516. * Interpolates between a and b via alpha
  34517. * @param a The lower value (returned when alpha = 0)
  34518. * @param b The upper value (returned when alpha = 1)
  34519. * @param alpha The interpolation-factor
  34520. * @return The mixed value
  34521. */
  34522. static Mix(a: number, b: number, alpha: number): number;
  34523. /**
  34524. * Tries to instantiate a new object from a given class name
  34525. * @param className defines the class name to instantiate
  34526. * @returns the new object or null if the system was not able to do the instantiation
  34527. */
  34528. static Instantiate(className: string): any;
  34529. /**
  34530. * Provides a slice function that will work even on IE
  34531. * @param data defines the array to slice
  34532. * @param start defines the start of the data (optional)
  34533. * @param end defines the end of the data (optional)
  34534. * @returns the new sliced array
  34535. */
  34536. static Slice<T>(data: T, start?: number, end?: number): T;
  34537. /**
  34538. * Polyfill for setImmediate
  34539. * @param action defines the action to execute after the current execution block
  34540. */
  34541. static SetImmediate(action: () => void): void;
  34542. /**
  34543. * Function indicating if a number is an exponent of 2
  34544. * @param value defines the value to test
  34545. * @returns true if the value is an exponent of 2
  34546. */
  34547. static IsExponentOfTwo(value: number): boolean;
  34548. private static _tmpFloatArray;
  34549. /**
  34550. * Returns the nearest 32-bit single precision float representation of a Number
  34551. * @param value A Number. If the parameter is of a different type, it will get converted
  34552. * to a number or to NaN if it cannot be converted
  34553. * @returns number
  34554. */
  34555. static FloatRound(value: number): number;
  34556. /**
  34557. * Extracts the filename from a path
  34558. * @param path defines the path to use
  34559. * @returns the filename
  34560. */
  34561. static GetFilename(path: string): string;
  34562. /**
  34563. * Extracts the "folder" part of a path (everything before the filename).
  34564. * @param uri The URI to extract the info from
  34565. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34566. * @returns The "folder" part of the path
  34567. */
  34568. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34569. /**
  34570. * Extracts text content from a DOM element hierarchy
  34571. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34572. */
  34573. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34574. /**
  34575. * Convert an angle in radians to degrees
  34576. * @param angle defines the angle to convert
  34577. * @returns the angle in degrees
  34578. */
  34579. static ToDegrees(angle: number): number;
  34580. /**
  34581. * Convert an angle in degrees to radians
  34582. * @param angle defines the angle to convert
  34583. * @returns the angle in radians
  34584. */
  34585. static ToRadians(angle: number): number;
  34586. /**
  34587. * Returns an array if obj is not an array
  34588. * @param obj defines the object to evaluate as an array
  34589. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34590. * @returns either obj directly if obj is an array or a new array containing obj
  34591. */
  34592. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34593. /**
  34594. * Gets the pointer prefix to use
  34595. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34596. */
  34597. static GetPointerPrefix(): string;
  34598. /**
  34599. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34600. * @param url define the url we are trying
  34601. * @param element define the dom element where to configure the cors policy
  34602. */
  34603. static SetCorsBehavior(url: string | string[], element: {
  34604. crossOrigin: string | null;
  34605. }): void;
  34606. /**
  34607. * Removes unwanted characters from an url
  34608. * @param url defines the url to clean
  34609. * @returns the cleaned url
  34610. */
  34611. static CleanUrl(url: string): string;
  34612. /**
  34613. * Gets or sets a function used to pre-process url before using them to load assets
  34614. */
  34615. static get PreprocessUrl(): (url: string) => string;
  34616. static set PreprocessUrl(processor: (url: string) => string);
  34617. /**
  34618. * Loads an image as an HTMLImageElement.
  34619. * @param input url string, ArrayBuffer, or Blob to load
  34620. * @param onLoad callback called when the image successfully loads
  34621. * @param onError callback called when the image fails to load
  34622. * @param offlineProvider offline provider for caching
  34623. * @param mimeType optional mime type
  34624. * @returns the HTMLImageElement of the loaded image
  34625. */
  34626. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34627. /**
  34628. * Loads a file from a url
  34629. * @param url url string, ArrayBuffer, or Blob to load
  34630. * @param onSuccess callback called when the file successfully loads
  34631. * @param onProgress callback called while file is loading (if the server supports this mode)
  34632. * @param offlineProvider defines the offline provider for caching
  34633. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34634. * @param onError callback called when the file fails to load
  34635. * @returns a file request object
  34636. */
  34637. 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;
  34638. /**
  34639. * Loads a file from a url
  34640. * @param url the file url to load
  34641. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34642. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34643. */
  34644. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34645. /**
  34646. * Load a script (identified by an url). When the url returns, the
  34647. * content of this file is added into a new script element, attached to the DOM (body element)
  34648. * @param scriptUrl defines the url of the script to laod
  34649. * @param onSuccess defines the callback called when the script is loaded
  34650. * @param onError defines the callback to call if an error occurs
  34651. * @param scriptId defines the id of the script element
  34652. */
  34653. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34654. /**
  34655. * Load an asynchronous script (identified by an url). When the url returns, the
  34656. * content of this file is added into a new script element, attached to the DOM (body element)
  34657. * @param scriptUrl defines the url of the script to laod
  34658. * @param scriptId defines the id of the script element
  34659. * @returns a promise request object
  34660. */
  34661. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34662. /**
  34663. * Loads a file from a blob
  34664. * @param fileToLoad defines the blob to use
  34665. * @param callback defines the callback to call when data is loaded
  34666. * @param progressCallback defines the callback to call during loading process
  34667. * @returns a file request object
  34668. */
  34669. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34670. /**
  34671. * Reads a file from a File object
  34672. * @param file defines the file to load
  34673. * @param onSuccess defines the callback to call when data is loaded
  34674. * @param onProgress defines the callback to call during loading process
  34675. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34676. * @param onError defines the callback to call when an error occurs
  34677. * @returns a file request object
  34678. */
  34679. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34680. /**
  34681. * Creates a data url from a given string content
  34682. * @param content defines the content to convert
  34683. * @returns the new data url link
  34684. */
  34685. static FileAsURL(content: string): string;
  34686. /**
  34687. * Format the given number to a specific decimal format
  34688. * @param value defines the number to format
  34689. * @param decimals defines the number of decimals to use
  34690. * @returns the formatted string
  34691. */
  34692. static Format(value: number, decimals?: number): string;
  34693. /**
  34694. * Tries to copy an object by duplicating every property
  34695. * @param source defines the source object
  34696. * @param destination defines the target object
  34697. * @param doNotCopyList defines a list of properties to avoid
  34698. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34699. */
  34700. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34701. /**
  34702. * Gets a boolean indicating if the given object has no own property
  34703. * @param obj defines the object to test
  34704. * @returns true if object has no own property
  34705. */
  34706. static IsEmpty(obj: any): boolean;
  34707. /**
  34708. * Function used to register events at window level
  34709. * @param windowElement defines the Window object to use
  34710. * @param events defines the events to register
  34711. */
  34712. static RegisterTopRootEvents(windowElement: Window, events: {
  34713. name: string;
  34714. handler: Nullable<(e: FocusEvent) => any>;
  34715. }[]): void;
  34716. /**
  34717. * Function used to unregister events from window level
  34718. * @param windowElement defines the Window object to use
  34719. * @param events defines the events to unregister
  34720. */
  34721. static UnregisterTopRootEvents(windowElement: Window, events: {
  34722. name: string;
  34723. handler: Nullable<(e: FocusEvent) => any>;
  34724. }[]): void;
  34725. /**
  34726. * @ignore
  34727. */
  34728. static _ScreenshotCanvas: HTMLCanvasElement;
  34729. /**
  34730. * Dumps the current bound framebuffer
  34731. * @param width defines the rendering width
  34732. * @param height defines the rendering height
  34733. * @param engine defines the hosting engine
  34734. * @param successCallback defines the callback triggered once the data are available
  34735. * @param mimeType defines the mime type of the result
  34736. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34737. */
  34738. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34739. /**
  34740. * Converts the canvas data to blob.
  34741. * This acts as a polyfill for browsers not supporting the to blob function.
  34742. * @param canvas Defines the canvas to extract the data from
  34743. * @param successCallback Defines the callback triggered once the data are available
  34744. * @param mimeType Defines the mime type of the result
  34745. */
  34746. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34747. /**
  34748. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34749. * @param successCallback defines the callback triggered once the data are available
  34750. * @param mimeType defines the mime type of the result
  34751. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34752. */
  34753. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34754. /**
  34755. * Downloads a blob in the browser
  34756. * @param blob defines the blob to download
  34757. * @param fileName defines the name of the downloaded file
  34758. */
  34759. static Download(blob: Blob, fileName: string): void;
  34760. /**
  34761. * Captures a screenshot of the current rendering
  34762. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34763. * @param engine defines the rendering engine
  34764. * @param camera defines the source camera
  34765. * @param size This parameter can be set to a single number or to an object with the
  34766. * following (optional) properties: precision, width, height. If a single number is passed,
  34767. * it will be used for both width and height. If an object is passed, the screenshot size
  34768. * will be derived from the parameters. The precision property is a multiplier allowing
  34769. * rendering at a higher or lower resolution
  34770. * @param successCallback defines the callback receives a single parameter which contains the
  34771. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34772. * src parameter of an <img> to display it
  34773. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34774. * Check your browser for supported MIME types
  34775. */
  34776. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34777. /**
  34778. * Captures a screenshot of the current rendering
  34779. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34780. * @param engine defines the rendering engine
  34781. * @param camera defines the source camera
  34782. * @param size This parameter can be set to a single number or to an object with the
  34783. * following (optional) properties: precision, width, height. If a single number is passed,
  34784. * it will be used for both width and height. If an object is passed, the screenshot size
  34785. * will be derived from the parameters. The precision property is a multiplier allowing
  34786. * rendering at a higher or lower resolution
  34787. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34788. * Check your browser for supported MIME types
  34789. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34790. * to the src parameter of an <img> to display it
  34791. */
  34792. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34793. /**
  34794. * Generates an image screenshot from the specified camera.
  34795. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34796. * @param engine The engine to use for rendering
  34797. * @param camera The camera to use for rendering
  34798. * @param size This parameter can be set to a single number or to an object with the
  34799. * following (optional) properties: precision, width, height. If a single number is passed,
  34800. * it will be used for both width and height. If an object is passed, the screenshot size
  34801. * will be derived from the parameters. The precision property is a multiplier allowing
  34802. * rendering at a higher or lower resolution
  34803. * @param successCallback The callback receives a single parameter which contains the
  34804. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34805. * src parameter of an <img> to display it
  34806. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34807. * Check your browser for supported MIME types
  34808. * @param samples Texture samples (default: 1)
  34809. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34810. * @param fileName A name for for the downloaded file.
  34811. */
  34812. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34813. /**
  34814. * Generates an image screenshot from the specified camera.
  34815. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34816. * @param engine The engine to use for rendering
  34817. * @param camera The camera to use for rendering
  34818. * @param size This parameter can be set to a single number or to an object with the
  34819. * following (optional) properties: precision, width, height. If a single number is passed,
  34820. * it will be used for both width and height. If an object is passed, the screenshot size
  34821. * will be derived from the parameters. The precision property is a multiplier allowing
  34822. * rendering at a higher or lower resolution
  34823. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34824. * Check your browser for supported MIME types
  34825. * @param samples Texture samples (default: 1)
  34826. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34827. * @param fileName A name for for the downloaded file.
  34828. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34829. * to the src parameter of an <img> to display it
  34830. */
  34831. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34832. /**
  34833. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34834. * Be aware Math.random() could cause collisions, but:
  34835. * "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"
  34836. * @returns a pseudo random id
  34837. */
  34838. static RandomId(): string;
  34839. /**
  34840. * Test if the given uri is a base64 string
  34841. * @param uri The uri to test
  34842. * @return True if the uri is a base64 string or false otherwise
  34843. */
  34844. static IsBase64(uri: string): boolean;
  34845. /**
  34846. * Decode the given base64 uri.
  34847. * @param uri The uri to decode
  34848. * @return The decoded base64 data.
  34849. */
  34850. static DecodeBase64(uri: string): ArrayBuffer;
  34851. /**
  34852. * Gets the absolute url.
  34853. * @param url the input url
  34854. * @return the absolute url
  34855. */
  34856. static GetAbsoluteUrl(url: string): string;
  34857. /**
  34858. * No log
  34859. */
  34860. static readonly NoneLogLevel: number;
  34861. /**
  34862. * Only message logs
  34863. */
  34864. static readonly MessageLogLevel: number;
  34865. /**
  34866. * Only warning logs
  34867. */
  34868. static readonly WarningLogLevel: number;
  34869. /**
  34870. * Only error logs
  34871. */
  34872. static readonly ErrorLogLevel: number;
  34873. /**
  34874. * All logs
  34875. */
  34876. static readonly AllLogLevel: number;
  34877. /**
  34878. * Gets a value indicating the number of loading errors
  34879. * @ignorenaming
  34880. */
  34881. static get errorsCount(): number;
  34882. /**
  34883. * Callback called when a new log is added
  34884. */
  34885. static OnNewCacheEntry: (entry: string) => void;
  34886. /**
  34887. * Log a message to the console
  34888. * @param message defines the message to log
  34889. */
  34890. static Log(message: string): void;
  34891. /**
  34892. * Write a warning message to the console
  34893. * @param message defines the message to log
  34894. */
  34895. static Warn(message: string): void;
  34896. /**
  34897. * Write an error message to the console
  34898. * @param message defines the message to log
  34899. */
  34900. static Error(message: string): void;
  34901. /**
  34902. * Gets current log cache (list of logs)
  34903. */
  34904. static get LogCache(): string;
  34905. /**
  34906. * Clears the log cache
  34907. */
  34908. static ClearLogCache(): void;
  34909. /**
  34910. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34911. */
  34912. static set LogLevels(level: number);
  34913. /**
  34914. * Checks if the window object exists
  34915. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34916. */
  34917. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34918. /**
  34919. * No performance log
  34920. */
  34921. static readonly PerformanceNoneLogLevel: number;
  34922. /**
  34923. * Use user marks to log performance
  34924. */
  34925. static readonly PerformanceUserMarkLogLevel: number;
  34926. /**
  34927. * Log performance to the console
  34928. */
  34929. static readonly PerformanceConsoleLogLevel: number;
  34930. private static _performance;
  34931. /**
  34932. * Sets the current performance log level
  34933. */
  34934. static set PerformanceLogLevel(level: number);
  34935. private static _StartPerformanceCounterDisabled;
  34936. private static _EndPerformanceCounterDisabled;
  34937. private static _StartUserMark;
  34938. private static _EndUserMark;
  34939. private static _StartPerformanceConsole;
  34940. private static _EndPerformanceConsole;
  34941. /**
  34942. * Starts a performance counter
  34943. */
  34944. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34945. /**
  34946. * Ends a specific performance coutner
  34947. */
  34948. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34949. /**
  34950. * Gets either window.performance.now() if supported or Date.now() else
  34951. */
  34952. static get Now(): number;
  34953. /**
  34954. * This method will return the name of the class used to create the instance of the given object.
  34955. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34956. * @param object the object to get the class name from
  34957. * @param isType defines if the object is actually a type
  34958. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34959. */
  34960. static GetClassName(object: any, isType?: boolean): string;
  34961. /**
  34962. * Gets the first element of an array satisfying a given predicate
  34963. * @param array defines the array to browse
  34964. * @param predicate defines the predicate to use
  34965. * @returns null if not found or the element
  34966. */
  34967. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34968. /**
  34969. * This method will return the name of the full name of the class, including its owning module (if any).
  34970. * 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).
  34971. * @param object the object to get the class name from
  34972. * @param isType defines if the object is actually a type
  34973. * @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.
  34974. * @ignorenaming
  34975. */
  34976. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34977. /**
  34978. * Returns a promise that resolves after the given amount of time.
  34979. * @param delay Number of milliseconds to delay
  34980. * @returns Promise that resolves after the given amount of time
  34981. */
  34982. static DelayAsync(delay: number): Promise<void>;
  34983. /**
  34984. * Utility function to detect if the current user agent is Safari
  34985. * @returns whether or not the current user agent is safari
  34986. */
  34987. static IsSafari(): boolean;
  34988. }
  34989. /**
  34990. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34991. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34992. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34993. * @param name The name of the class, case should be preserved
  34994. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34995. */
  34996. export function className(name: string, module?: string): (target: Object) => void;
  34997. /**
  34998. * An implementation of a loop for asynchronous functions.
  34999. */
  35000. export class AsyncLoop {
  35001. /**
  35002. * Defines the number of iterations for the loop
  35003. */
  35004. iterations: number;
  35005. /**
  35006. * Defines the current index of the loop.
  35007. */
  35008. index: number;
  35009. private _done;
  35010. private _fn;
  35011. private _successCallback;
  35012. /**
  35013. * Constructor.
  35014. * @param iterations the number of iterations.
  35015. * @param func the function to run each iteration
  35016. * @param successCallback the callback that will be called upon succesful execution
  35017. * @param offset starting offset.
  35018. */
  35019. constructor(
  35020. /**
  35021. * Defines the number of iterations for the loop
  35022. */
  35023. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35024. /**
  35025. * Execute the next iteration. Must be called after the last iteration was finished.
  35026. */
  35027. executeNext(): void;
  35028. /**
  35029. * Break the loop and run the success callback.
  35030. */
  35031. breakLoop(): void;
  35032. /**
  35033. * Create and run an async loop.
  35034. * @param iterations the number of iterations.
  35035. * @param fn the function to run each iteration
  35036. * @param successCallback the callback that will be called upon succesful execution
  35037. * @param offset starting offset.
  35038. * @returns the created async loop object
  35039. */
  35040. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35041. /**
  35042. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35043. * @param iterations total number of iterations
  35044. * @param syncedIterations number of synchronous iterations in each async iteration.
  35045. * @param fn the function to call each iteration.
  35046. * @param callback a success call back that will be called when iterating stops.
  35047. * @param breakFunction a break condition (optional)
  35048. * @param timeout timeout settings for the setTimeout function. default - 0.
  35049. * @returns the created async loop object
  35050. */
  35051. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35052. }
  35053. }
  35054. declare module BABYLON {
  35055. /**
  35056. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35057. * The underlying implementation relies on an associative array to ensure the best performances.
  35058. * The value can be anything including 'null' but except 'undefined'
  35059. */
  35060. export class StringDictionary<T> {
  35061. /**
  35062. * This will clear this dictionary and copy the content from the 'source' one.
  35063. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35064. * @param source the dictionary to take the content from and copy to this dictionary
  35065. */
  35066. copyFrom(source: StringDictionary<T>): void;
  35067. /**
  35068. * Get a value based from its key
  35069. * @param key the given key to get the matching value from
  35070. * @return the value if found, otherwise undefined is returned
  35071. */
  35072. get(key: string): T | undefined;
  35073. /**
  35074. * Get a value from its key or add it if it doesn't exist.
  35075. * This method will ensure you that a given key/data will be present in the dictionary.
  35076. * @param key the given key to get the matching value from
  35077. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35078. * The factory will only be invoked if there's no data for the given key.
  35079. * @return the value corresponding to the key.
  35080. */
  35081. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35082. /**
  35083. * Get a value from its key if present in the dictionary otherwise add it
  35084. * @param key the key to get the value from
  35085. * @param val if there's no such key/value pair in the dictionary add it with this value
  35086. * @return the value corresponding to the key
  35087. */
  35088. getOrAdd(key: string, val: T): T;
  35089. /**
  35090. * Check if there's a given key in the dictionary
  35091. * @param key the key to check for
  35092. * @return true if the key is present, false otherwise
  35093. */
  35094. contains(key: string): boolean;
  35095. /**
  35096. * Add a new key and its corresponding value
  35097. * @param key the key to add
  35098. * @param value the value corresponding to the key
  35099. * @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
  35100. */
  35101. add(key: string, value: T): boolean;
  35102. /**
  35103. * Update a specific value associated to a key
  35104. * @param key defines the key to use
  35105. * @param value defines the value to store
  35106. * @returns true if the value was updated (or false if the key was not found)
  35107. */
  35108. set(key: string, value: T): boolean;
  35109. /**
  35110. * Get the element of the given key and remove it from the dictionary
  35111. * @param key defines the key to search
  35112. * @returns the value associated with the key or null if not found
  35113. */
  35114. getAndRemove(key: string): Nullable<T>;
  35115. /**
  35116. * Remove a key/value from the dictionary.
  35117. * @param key the key to remove
  35118. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35119. */
  35120. remove(key: string): boolean;
  35121. /**
  35122. * Clear the whole content of the dictionary
  35123. */
  35124. clear(): void;
  35125. /**
  35126. * Gets the current count
  35127. */
  35128. get count(): number;
  35129. /**
  35130. * Execute a callback on each key/val of the dictionary.
  35131. * Note that you can remove any element in this dictionary in the callback implementation
  35132. * @param callback the callback to execute on a given key/value pair
  35133. */
  35134. forEach(callback: (key: string, val: T) => void): void;
  35135. /**
  35136. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35137. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35138. * Note that you can remove any element in this dictionary in the callback implementation
  35139. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35140. * @returns the first item
  35141. */
  35142. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35143. private _count;
  35144. private _data;
  35145. }
  35146. }
  35147. declare module BABYLON {
  35148. /** @hidden */
  35149. export interface ICollisionCoordinator {
  35150. createCollider(): Collider;
  35151. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35152. init(scene: Scene): void;
  35153. }
  35154. /** @hidden */
  35155. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35156. private _scene;
  35157. private _scaledPosition;
  35158. private _scaledVelocity;
  35159. private _finalPosition;
  35160. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35161. createCollider(): Collider;
  35162. init(scene: Scene): void;
  35163. private _collideWithWorld;
  35164. }
  35165. }
  35166. declare module BABYLON {
  35167. /**
  35168. * Class used to manage all inputs for the scene.
  35169. */
  35170. export class InputManager {
  35171. /** The distance in pixel that you have to move to prevent some events */
  35172. static DragMovementThreshold: number;
  35173. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35174. static LongPressDelay: number;
  35175. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35176. static DoubleClickDelay: number;
  35177. /** If you need to check double click without raising a single click at first click, enable this flag */
  35178. static ExclusiveDoubleClickMode: boolean;
  35179. private _wheelEventName;
  35180. private _onPointerMove;
  35181. private _onPointerDown;
  35182. private _onPointerUp;
  35183. private _initClickEvent;
  35184. private _initActionManager;
  35185. private _delayedSimpleClick;
  35186. private _delayedSimpleClickTimeout;
  35187. private _previousDelayedSimpleClickTimeout;
  35188. private _meshPickProceed;
  35189. private _previousButtonPressed;
  35190. private _currentPickResult;
  35191. private _previousPickResult;
  35192. private _totalPointersPressed;
  35193. private _doubleClickOccured;
  35194. private _pointerOverMesh;
  35195. private _pickedDownMesh;
  35196. private _pickedUpMesh;
  35197. private _pointerX;
  35198. private _pointerY;
  35199. private _unTranslatedPointerX;
  35200. private _unTranslatedPointerY;
  35201. private _startingPointerPosition;
  35202. private _previousStartingPointerPosition;
  35203. private _startingPointerTime;
  35204. private _previousStartingPointerTime;
  35205. private _pointerCaptures;
  35206. private _onKeyDown;
  35207. private _onKeyUp;
  35208. private _onCanvasFocusObserver;
  35209. private _onCanvasBlurObserver;
  35210. private _scene;
  35211. /**
  35212. * Creates a new InputManager
  35213. * @param scene defines the hosting scene
  35214. */
  35215. constructor(scene: Scene);
  35216. /**
  35217. * Gets the mesh that is currently under the pointer
  35218. */
  35219. get meshUnderPointer(): Nullable<AbstractMesh>;
  35220. /**
  35221. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35222. */
  35223. get unTranslatedPointer(): Vector2;
  35224. /**
  35225. * Gets or sets the current on-screen X position of the pointer
  35226. */
  35227. get pointerX(): number;
  35228. set pointerX(value: number);
  35229. /**
  35230. * Gets or sets the current on-screen Y position of the pointer
  35231. */
  35232. get pointerY(): number;
  35233. set pointerY(value: number);
  35234. private _updatePointerPosition;
  35235. private _processPointerMove;
  35236. private _setRayOnPointerInfo;
  35237. private _checkPrePointerObservable;
  35238. /**
  35239. * Use this method to simulate a pointer move on a mesh
  35240. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35241. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35242. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35243. */
  35244. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35245. /**
  35246. * Use this method to simulate a pointer down on a mesh
  35247. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35248. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35249. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35250. */
  35251. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35252. private _processPointerDown;
  35253. /** @hidden */
  35254. _isPointerSwiping(): boolean;
  35255. /**
  35256. * Use this method to simulate a pointer up on a mesh
  35257. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35258. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35259. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35260. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35261. */
  35262. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35263. private _processPointerUp;
  35264. /**
  35265. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35266. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35267. * @returns true if the pointer was captured
  35268. */
  35269. isPointerCaptured(pointerId?: number): boolean;
  35270. /**
  35271. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35272. * @param attachUp defines if you want to attach events to pointerup
  35273. * @param attachDown defines if you want to attach events to pointerdown
  35274. * @param attachMove defines if you want to attach events to pointermove
  35275. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35276. */
  35277. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35278. /**
  35279. * Detaches all event handlers
  35280. */
  35281. detachControl(): void;
  35282. /**
  35283. * Force the value of meshUnderPointer
  35284. * @param mesh defines the mesh to use
  35285. */
  35286. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35287. /**
  35288. * Gets the mesh under the pointer
  35289. * @returns a Mesh or null if no mesh is under the pointer
  35290. */
  35291. getPointerOverMesh(): Nullable<AbstractMesh>;
  35292. }
  35293. }
  35294. declare module BABYLON {
  35295. /**
  35296. * Helper class used to generate session unique ID
  35297. */
  35298. export class UniqueIdGenerator {
  35299. private static _UniqueIdCounter;
  35300. /**
  35301. * Gets an unique (relatively to the current scene) Id
  35302. */
  35303. static get UniqueId(): number;
  35304. }
  35305. }
  35306. declare module BABYLON {
  35307. /**
  35308. * This class defines the direct association between an animation and a target
  35309. */
  35310. export class TargetedAnimation {
  35311. /**
  35312. * Animation to perform
  35313. */
  35314. animation: Animation;
  35315. /**
  35316. * Target to animate
  35317. */
  35318. target: any;
  35319. /**
  35320. * Serialize the object
  35321. * @returns the JSON object representing the current entity
  35322. */
  35323. serialize(): any;
  35324. }
  35325. /**
  35326. * Use this class to create coordinated animations on multiple targets
  35327. */
  35328. export class AnimationGroup implements IDisposable {
  35329. /** The name of the animation group */
  35330. name: string;
  35331. private _scene;
  35332. private _targetedAnimations;
  35333. private _animatables;
  35334. private _from;
  35335. private _to;
  35336. private _isStarted;
  35337. private _isPaused;
  35338. private _speedRatio;
  35339. private _loopAnimation;
  35340. private _isAdditive;
  35341. /**
  35342. * Gets or sets the unique id of the node
  35343. */
  35344. uniqueId: number;
  35345. /**
  35346. * This observable will notify when one animation have ended
  35347. */
  35348. onAnimationEndObservable: Observable<TargetedAnimation>;
  35349. /**
  35350. * Observer raised when one animation loops
  35351. */
  35352. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35353. /**
  35354. * Observer raised when all animations have looped
  35355. */
  35356. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35357. /**
  35358. * This observable will notify when all animations have ended.
  35359. */
  35360. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35361. /**
  35362. * This observable will notify when all animations have paused.
  35363. */
  35364. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35365. /**
  35366. * This observable will notify when all animations are playing.
  35367. */
  35368. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35369. /**
  35370. * Gets the first frame
  35371. */
  35372. get from(): number;
  35373. /**
  35374. * Gets the last frame
  35375. */
  35376. get to(): number;
  35377. /**
  35378. * Define if the animations are started
  35379. */
  35380. get isStarted(): boolean;
  35381. /**
  35382. * Gets a value indicating that the current group is playing
  35383. */
  35384. get isPlaying(): boolean;
  35385. /**
  35386. * Gets or sets the speed ratio to use for all animations
  35387. */
  35388. get speedRatio(): number;
  35389. /**
  35390. * Gets or sets the speed ratio to use for all animations
  35391. */
  35392. set speedRatio(value: number);
  35393. /**
  35394. * Gets or sets if all animations should loop or not
  35395. */
  35396. get loopAnimation(): boolean;
  35397. set loopAnimation(value: boolean);
  35398. /**
  35399. * Gets or sets if all animations should be evaluated additively
  35400. */
  35401. get isAdditive(): boolean;
  35402. set isAdditive(value: boolean);
  35403. /**
  35404. * Gets the targeted animations for this animation group
  35405. */
  35406. get targetedAnimations(): Array<TargetedAnimation>;
  35407. /**
  35408. * returning the list of animatables controlled by this animation group.
  35409. */
  35410. get animatables(): Array<Animatable>;
  35411. /**
  35412. * Instantiates a new Animation Group.
  35413. * This helps managing several animations at once.
  35414. * @see http://doc.babylonjs.com/how_to/group
  35415. * @param name Defines the name of the group
  35416. * @param scene Defines the scene the group belongs to
  35417. */
  35418. constructor(
  35419. /** The name of the animation group */
  35420. name: string, scene?: Nullable<Scene>);
  35421. /**
  35422. * Add an animation (with its target) in the group
  35423. * @param animation defines the animation we want to add
  35424. * @param target defines the target of the animation
  35425. * @returns the TargetedAnimation object
  35426. */
  35427. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35428. /**
  35429. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35430. * It can add constant keys at begin or end
  35431. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35432. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35433. * @returns the animation group
  35434. */
  35435. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35436. private _animationLoopCount;
  35437. private _animationLoopFlags;
  35438. private _processLoop;
  35439. /**
  35440. * Start all animations on given targets
  35441. * @param loop defines if animations must loop
  35442. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35443. * @param from defines the from key (optional)
  35444. * @param to defines the to key (optional)
  35445. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35446. * @returns the current animation group
  35447. */
  35448. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35449. /**
  35450. * Pause all animations
  35451. * @returns the animation group
  35452. */
  35453. pause(): AnimationGroup;
  35454. /**
  35455. * Play all animations to initial state
  35456. * This function will start() the animations if they were not started or will restart() them if they were paused
  35457. * @param loop defines if animations must loop
  35458. * @returns the animation group
  35459. */
  35460. play(loop?: boolean): AnimationGroup;
  35461. /**
  35462. * Reset all animations to initial state
  35463. * @returns the animation group
  35464. */
  35465. reset(): AnimationGroup;
  35466. /**
  35467. * Restart animations from key 0
  35468. * @returns the animation group
  35469. */
  35470. restart(): AnimationGroup;
  35471. /**
  35472. * Stop all animations
  35473. * @returns the animation group
  35474. */
  35475. stop(): AnimationGroup;
  35476. /**
  35477. * Set animation weight for all animatables
  35478. * @param weight defines the weight to use
  35479. * @return the animationGroup
  35480. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35481. */
  35482. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35483. /**
  35484. * Synchronize and normalize all animatables with a source animatable
  35485. * @param root defines the root animatable to synchronize with
  35486. * @return the animationGroup
  35487. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35488. */
  35489. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35490. /**
  35491. * Goes to a specific frame in this animation group
  35492. * @param frame the frame number to go to
  35493. * @return the animationGroup
  35494. */
  35495. goToFrame(frame: number): AnimationGroup;
  35496. /**
  35497. * Dispose all associated resources
  35498. */
  35499. dispose(): void;
  35500. private _checkAnimationGroupEnded;
  35501. /**
  35502. * Clone the current animation group and returns a copy
  35503. * @param newName defines the name of the new group
  35504. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35505. * @returns the new aniamtion group
  35506. */
  35507. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35508. /**
  35509. * Serializes the animationGroup to an object
  35510. * @returns Serialized object
  35511. */
  35512. serialize(): any;
  35513. /**
  35514. * Returns a new AnimationGroup object parsed from the source provided.
  35515. * @param parsedAnimationGroup defines the source
  35516. * @param scene defines the scene that will receive the animationGroup
  35517. * @returns a new AnimationGroup
  35518. */
  35519. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35520. /**
  35521. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35522. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35523. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35524. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35525. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35526. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35527. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35528. */
  35529. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35530. /**
  35531. * Returns the string "AnimationGroup"
  35532. * @returns "AnimationGroup"
  35533. */
  35534. getClassName(): string;
  35535. /**
  35536. * Creates a detailled string about the object
  35537. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35538. * @returns a string representing the object
  35539. */
  35540. toString(fullDetails?: boolean): string;
  35541. }
  35542. }
  35543. declare module BABYLON {
  35544. /**
  35545. * Define an interface for all classes that will hold resources
  35546. */
  35547. export interface IDisposable {
  35548. /**
  35549. * Releases all held resources
  35550. */
  35551. dispose(): void;
  35552. }
  35553. /** Interface defining initialization parameters for Scene class */
  35554. export interface SceneOptions {
  35555. /**
  35556. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35557. * It will improve performance when the number of geometries becomes important.
  35558. */
  35559. useGeometryUniqueIdsMap?: boolean;
  35560. /**
  35561. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35562. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35563. */
  35564. useMaterialMeshMap?: boolean;
  35565. /**
  35566. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35567. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35568. */
  35569. useClonedMeshMap?: boolean;
  35570. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35571. virtual?: boolean;
  35572. }
  35573. /**
  35574. * Represents a scene to be rendered by the engine.
  35575. * @see http://doc.babylonjs.com/features/scene
  35576. */
  35577. export class Scene extends AbstractScene implements IAnimatable {
  35578. /** The fog is deactivated */
  35579. static readonly FOGMODE_NONE: number;
  35580. /** The fog density is following an exponential function */
  35581. static readonly FOGMODE_EXP: number;
  35582. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35583. static readonly FOGMODE_EXP2: number;
  35584. /** The fog density is following a linear function. */
  35585. static readonly FOGMODE_LINEAR: number;
  35586. /**
  35587. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35588. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35589. */
  35590. static MinDeltaTime: number;
  35591. /**
  35592. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35593. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35594. */
  35595. static MaxDeltaTime: number;
  35596. /**
  35597. * Factory used to create the default material.
  35598. * @param name The name of the material to create
  35599. * @param scene The scene to create the material for
  35600. * @returns The default material
  35601. */
  35602. static DefaultMaterialFactory(scene: Scene): Material;
  35603. /**
  35604. * Factory used to create the a collision coordinator.
  35605. * @returns The collision coordinator
  35606. */
  35607. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35608. /** @hidden */
  35609. _inputManager: InputManager;
  35610. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35611. cameraToUseForPointers: Nullable<Camera>;
  35612. /** @hidden */
  35613. readonly _isScene: boolean;
  35614. /** @hidden */
  35615. _blockEntityCollection: boolean;
  35616. /**
  35617. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35618. */
  35619. autoClear: boolean;
  35620. /**
  35621. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35622. */
  35623. autoClearDepthAndStencil: boolean;
  35624. /**
  35625. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35626. */
  35627. clearColor: Color4;
  35628. /**
  35629. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35630. */
  35631. ambientColor: Color3;
  35632. /**
  35633. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35634. * It should only be one of the following (if not the default embedded one):
  35635. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35636. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35637. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35638. * The material properties need to be setup according to the type of texture in use.
  35639. */
  35640. environmentBRDFTexture: BaseTexture;
  35641. /** @hidden */
  35642. protected _environmentTexture: Nullable<BaseTexture>;
  35643. /**
  35644. * Texture used in all pbr material as the reflection texture.
  35645. * As in the majority of the scene they are the same (exception for multi room and so on),
  35646. * this is easier to reference from here than from all the materials.
  35647. */
  35648. get environmentTexture(): Nullable<BaseTexture>;
  35649. /**
  35650. * Texture used in all pbr material as the reflection texture.
  35651. * As in the majority of the scene they are the same (exception for multi room and so on),
  35652. * this is easier to set here than in all the materials.
  35653. */
  35654. set environmentTexture(value: Nullable<BaseTexture>);
  35655. /** @hidden */
  35656. protected _environmentIntensity: number;
  35657. /**
  35658. * Intensity of the environment in all pbr material.
  35659. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35660. * As in the majority of the scene they are the same (exception for multi room and so on),
  35661. * this is easier to reference from here than from all the materials.
  35662. */
  35663. get environmentIntensity(): number;
  35664. /**
  35665. * Intensity of the environment in all pbr material.
  35666. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35667. * As in the majority of the scene they are the same (exception for multi room and so on),
  35668. * this is easier to set here than in all the materials.
  35669. */
  35670. set environmentIntensity(value: number);
  35671. /** @hidden */
  35672. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35673. /**
  35674. * Default image processing configuration used either in the rendering
  35675. * Forward main pass or through the imageProcessingPostProcess if present.
  35676. * As in the majority of the scene they are the same (exception for multi camera),
  35677. * this is easier to reference from here than from all the materials and post process.
  35678. *
  35679. * No setter as we it is a shared configuration, you can set the values instead.
  35680. */
  35681. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35682. private _forceWireframe;
  35683. /**
  35684. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35685. */
  35686. set forceWireframe(value: boolean);
  35687. get forceWireframe(): boolean;
  35688. private _skipFrustumClipping;
  35689. /**
  35690. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35691. */
  35692. set skipFrustumClipping(value: boolean);
  35693. get skipFrustumClipping(): boolean;
  35694. private _forcePointsCloud;
  35695. /**
  35696. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35697. */
  35698. set forcePointsCloud(value: boolean);
  35699. get forcePointsCloud(): boolean;
  35700. /**
  35701. * Gets or sets the active clipplane 1
  35702. */
  35703. clipPlane: Nullable<Plane>;
  35704. /**
  35705. * Gets or sets the active clipplane 2
  35706. */
  35707. clipPlane2: Nullable<Plane>;
  35708. /**
  35709. * Gets or sets the active clipplane 3
  35710. */
  35711. clipPlane3: Nullable<Plane>;
  35712. /**
  35713. * Gets or sets the active clipplane 4
  35714. */
  35715. clipPlane4: Nullable<Plane>;
  35716. /**
  35717. * Gets or sets the active clipplane 5
  35718. */
  35719. clipPlane5: Nullable<Plane>;
  35720. /**
  35721. * Gets or sets the active clipplane 6
  35722. */
  35723. clipPlane6: Nullable<Plane>;
  35724. /**
  35725. * Gets or sets a boolean indicating if animations are enabled
  35726. */
  35727. animationsEnabled: boolean;
  35728. private _animationPropertiesOverride;
  35729. /**
  35730. * Gets or sets the animation properties override
  35731. */
  35732. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35733. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35734. /**
  35735. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35736. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35737. */
  35738. useConstantAnimationDeltaTime: boolean;
  35739. /**
  35740. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35741. * Please note that it requires to run a ray cast through the scene on every frame
  35742. */
  35743. constantlyUpdateMeshUnderPointer: boolean;
  35744. /**
  35745. * Defines the HTML cursor to use when hovering over interactive elements
  35746. */
  35747. hoverCursor: string;
  35748. /**
  35749. * Defines the HTML default cursor to use (empty by default)
  35750. */
  35751. defaultCursor: string;
  35752. /**
  35753. * Defines whether cursors are handled by the scene.
  35754. */
  35755. doNotHandleCursors: boolean;
  35756. /**
  35757. * This is used to call preventDefault() on pointer down
  35758. * in order to block unwanted artifacts like system double clicks
  35759. */
  35760. preventDefaultOnPointerDown: boolean;
  35761. /**
  35762. * This is used to call preventDefault() on pointer up
  35763. * in order to block unwanted artifacts like system double clicks
  35764. */
  35765. preventDefaultOnPointerUp: boolean;
  35766. /**
  35767. * Gets or sets user defined metadata
  35768. */
  35769. metadata: any;
  35770. /**
  35771. * For internal use only. Please do not use.
  35772. */
  35773. reservedDataStore: any;
  35774. /**
  35775. * Gets the name of the plugin used to load this scene (null by default)
  35776. */
  35777. loadingPluginName: string;
  35778. /**
  35779. * Use this array to add regular expressions used to disable offline support for specific urls
  35780. */
  35781. disableOfflineSupportExceptionRules: RegExp[];
  35782. /**
  35783. * An event triggered when the scene is disposed.
  35784. */
  35785. onDisposeObservable: Observable<Scene>;
  35786. private _onDisposeObserver;
  35787. /** Sets a function to be executed when this scene is disposed. */
  35788. set onDispose(callback: () => void);
  35789. /**
  35790. * An event triggered before rendering the scene (right after animations and physics)
  35791. */
  35792. onBeforeRenderObservable: Observable<Scene>;
  35793. private _onBeforeRenderObserver;
  35794. /** Sets a function to be executed before rendering this scene */
  35795. set beforeRender(callback: Nullable<() => void>);
  35796. /**
  35797. * An event triggered after rendering the scene
  35798. */
  35799. onAfterRenderObservable: Observable<Scene>;
  35800. /**
  35801. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35802. */
  35803. onAfterRenderCameraObservable: Observable<Camera>;
  35804. private _onAfterRenderObserver;
  35805. /** Sets a function to be executed after rendering this scene */
  35806. set afterRender(callback: Nullable<() => void>);
  35807. /**
  35808. * An event triggered before animating the scene
  35809. */
  35810. onBeforeAnimationsObservable: Observable<Scene>;
  35811. /**
  35812. * An event triggered after animations processing
  35813. */
  35814. onAfterAnimationsObservable: Observable<Scene>;
  35815. /**
  35816. * An event triggered before draw calls are ready to be sent
  35817. */
  35818. onBeforeDrawPhaseObservable: Observable<Scene>;
  35819. /**
  35820. * An event triggered after draw calls have been sent
  35821. */
  35822. onAfterDrawPhaseObservable: Observable<Scene>;
  35823. /**
  35824. * An event triggered when the scene is ready
  35825. */
  35826. onReadyObservable: Observable<Scene>;
  35827. /**
  35828. * An event triggered before rendering a camera
  35829. */
  35830. onBeforeCameraRenderObservable: Observable<Camera>;
  35831. private _onBeforeCameraRenderObserver;
  35832. /** Sets a function to be executed before rendering a camera*/
  35833. set beforeCameraRender(callback: () => void);
  35834. /**
  35835. * An event triggered after rendering a camera
  35836. */
  35837. onAfterCameraRenderObservable: Observable<Camera>;
  35838. private _onAfterCameraRenderObserver;
  35839. /** Sets a function to be executed after rendering a camera*/
  35840. set afterCameraRender(callback: () => void);
  35841. /**
  35842. * An event triggered when active meshes evaluation is about to start
  35843. */
  35844. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35845. /**
  35846. * An event triggered when active meshes evaluation is done
  35847. */
  35848. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35849. /**
  35850. * An event triggered when particles rendering is about to start
  35851. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35852. */
  35853. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35854. /**
  35855. * An event triggered when particles rendering is done
  35856. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35857. */
  35858. onAfterParticlesRenderingObservable: Observable<Scene>;
  35859. /**
  35860. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35861. */
  35862. onDataLoadedObservable: Observable<Scene>;
  35863. /**
  35864. * An event triggered when a camera is created
  35865. */
  35866. onNewCameraAddedObservable: Observable<Camera>;
  35867. /**
  35868. * An event triggered when a camera is removed
  35869. */
  35870. onCameraRemovedObservable: Observable<Camera>;
  35871. /**
  35872. * An event triggered when a light is created
  35873. */
  35874. onNewLightAddedObservable: Observable<Light>;
  35875. /**
  35876. * An event triggered when a light is removed
  35877. */
  35878. onLightRemovedObservable: Observable<Light>;
  35879. /**
  35880. * An event triggered when a geometry is created
  35881. */
  35882. onNewGeometryAddedObservable: Observable<Geometry>;
  35883. /**
  35884. * An event triggered when a geometry is removed
  35885. */
  35886. onGeometryRemovedObservable: Observable<Geometry>;
  35887. /**
  35888. * An event triggered when a transform node is created
  35889. */
  35890. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35891. /**
  35892. * An event triggered when a transform node is removed
  35893. */
  35894. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35895. /**
  35896. * An event triggered when a mesh is created
  35897. */
  35898. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35899. /**
  35900. * An event triggered when a mesh is removed
  35901. */
  35902. onMeshRemovedObservable: Observable<AbstractMesh>;
  35903. /**
  35904. * An event triggered when a skeleton is created
  35905. */
  35906. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35907. /**
  35908. * An event triggered when a skeleton is removed
  35909. */
  35910. onSkeletonRemovedObservable: Observable<Skeleton>;
  35911. /**
  35912. * An event triggered when a material is created
  35913. */
  35914. onNewMaterialAddedObservable: Observable<Material>;
  35915. /**
  35916. * An event triggered when a material is removed
  35917. */
  35918. onMaterialRemovedObservable: Observable<Material>;
  35919. /**
  35920. * An event triggered when a texture is created
  35921. */
  35922. onNewTextureAddedObservable: Observable<BaseTexture>;
  35923. /**
  35924. * An event triggered when a texture is removed
  35925. */
  35926. onTextureRemovedObservable: Observable<BaseTexture>;
  35927. /**
  35928. * An event triggered when render targets are about to be rendered
  35929. * Can happen multiple times per frame.
  35930. */
  35931. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35932. /**
  35933. * An event triggered when render targets were rendered.
  35934. * Can happen multiple times per frame.
  35935. */
  35936. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35937. /**
  35938. * An event triggered before calculating deterministic simulation step
  35939. */
  35940. onBeforeStepObservable: Observable<Scene>;
  35941. /**
  35942. * An event triggered after calculating deterministic simulation step
  35943. */
  35944. onAfterStepObservable: Observable<Scene>;
  35945. /**
  35946. * An event triggered when the activeCamera property is updated
  35947. */
  35948. onActiveCameraChanged: Observable<Scene>;
  35949. /**
  35950. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35951. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35952. * 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)
  35953. */
  35954. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35955. /**
  35956. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35957. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35958. * 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)
  35959. */
  35960. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35961. /**
  35962. * This Observable will when a mesh has been imported into the scene.
  35963. */
  35964. onMeshImportedObservable: Observable<AbstractMesh>;
  35965. /**
  35966. * This Observable will when an animation file has been imported into the scene.
  35967. */
  35968. onAnimationFileImportedObservable: Observable<Scene>;
  35969. /**
  35970. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35971. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35972. */
  35973. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35974. /** @hidden */
  35975. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35976. /**
  35977. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35978. */
  35979. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35980. /**
  35981. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35982. */
  35983. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35984. /**
  35985. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35986. */
  35987. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35988. /** Callback called when a pointer move is detected */
  35989. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35990. /** Callback called when a pointer down is detected */
  35991. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35992. /** Callback called when a pointer up is detected */
  35993. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35994. /** Callback called when a pointer pick is detected */
  35995. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35996. /**
  35997. * 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).
  35998. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35999. */
  36000. onPrePointerObservable: Observable<PointerInfoPre>;
  36001. /**
  36002. * Observable event triggered each time an input event is received from the rendering canvas
  36003. */
  36004. onPointerObservable: Observable<PointerInfo>;
  36005. /**
  36006. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36007. */
  36008. get unTranslatedPointer(): Vector2;
  36009. /**
  36010. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36011. */
  36012. static get DragMovementThreshold(): number;
  36013. static set DragMovementThreshold(value: number);
  36014. /**
  36015. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36016. */
  36017. static get LongPressDelay(): number;
  36018. static set LongPressDelay(value: number);
  36019. /**
  36020. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36021. */
  36022. static get DoubleClickDelay(): number;
  36023. static set DoubleClickDelay(value: number);
  36024. /** If you need to check double click without raising a single click at first click, enable this flag */
  36025. static get ExclusiveDoubleClickMode(): boolean;
  36026. static set ExclusiveDoubleClickMode(value: boolean);
  36027. /** @hidden */
  36028. _mirroredCameraPosition: Nullable<Vector3>;
  36029. /**
  36030. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36031. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36032. */
  36033. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36034. /**
  36035. * Observable event triggered each time an keyboard event is received from the hosting window
  36036. */
  36037. onKeyboardObservable: Observable<KeyboardInfo>;
  36038. private _useRightHandedSystem;
  36039. /**
  36040. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36041. */
  36042. set useRightHandedSystem(value: boolean);
  36043. get useRightHandedSystem(): boolean;
  36044. private _timeAccumulator;
  36045. private _currentStepId;
  36046. private _currentInternalStep;
  36047. /**
  36048. * Sets the step Id used by deterministic lock step
  36049. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36050. * @param newStepId defines the step Id
  36051. */
  36052. setStepId(newStepId: number): void;
  36053. /**
  36054. * Gets the step Id used by deterministic lock step
  36055. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36056. * @returns the step Id
  36057. */
  36058. getStepId(): number;
  36059. /**
  36060. * Gets the internal step used by deterministic lock step
  36061. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36062. * @returns the internal step
  36063. */
  36064. getInternalStep(): number;
  36065. private _fogEnabled;
  36066. /**
  36067. * Gets or sets a boolean indicating if fog is enabled on this scene
  36068. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36069. * (Default is true)
  36070. */
  36071. set fogEnabled(value: boolean);
  36072. get fogEnabled(): boolean;
  36073. private _fogMode;
  36074. /**
  36075. * Gets or sets the fog mode to use
  36076. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36077. * | mode | value |
  36078. * | --- | --- |
  36079. * | FOGMODE_NONE | 0 |
  36080. * | FOGMODE_EXP | 1 |
  36081. * | FOGMODE_EXP2 | 2 |
  36082. * | FOGMODE_LINEAR | 3 |
  36083. */
  36084. set fogMode(value: number);
  36085. get fogMode(): number;
  36086. /**
  36087. * Gets or sets the fog color to use
  36088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36089. * (Default is Color3(0.2, 0.2, 0.3))
  36090. */
  36091. fogColor: Color3;
  36092. /**
  36093. * Gets or sets the fog density to use
  36094. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36095. * (Default is 0.1)
  36096. */
  36097. fogDensity: number;
  36098. /**
  36099. * Gets or sets the fog start distance to use
  36100. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36101. * (Default is 0)
  36102. */
  36103. fogStart: number;
  36104. /**
  36105. * Gets or sets the fog end distance to use
  36106. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36107. * (Default is 1000)
  36108. */
  36109. fogEnd: number;
  36110. private _shadowsEnabled;
  36111. /**
  36112. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36113. */
  36114. set shadowsEnabled(value: boolean);
  36115. get shadowsEnabled(): boolean;
  36116. private _lightsEnabled;
  36117. /**
  36118. * Gets or sets a boolean indicating if lights are enabled on this scene
  36119. */
  36120. set lightsEnabled(value: boolean);
  36121. get lightsEnabled(): boolean;
  36122. /** All of the active cameras added to this scene. */
  36123. activeCameras: Camera[];
  36124. /** @hidden */
  36125. _activeCamera: Nullable<Camera>;
  36126. /** Gets or sets the current active camera */
  36127. get activeCamera(): Nullable<Camera>;
  36128. set activeCamera(value: Nullable<Camera>);
  36129. private _defaultMaterial;
  36130. /** The default material used on meshes when no material is affected */
  36131. get defaultMaterial(): Material;
  36132. /** The default material used on meshes when no material is affected */
  36133. set defaultMaterial(value: Material);
  36134. private _texturesEnabled;
  36135. /**
  36136. * Gets or sets a boolean indicating if textures are enabled on this scene
  36137. */
  36138. set texturesEnabled(value: boolean);
  36139. get texturesEnabled(): boolean;
  36140. /**
  36141. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  36142. */
  36143. physicsEnabled: boolean;
  36144. /**
  36145. * Gets or sets a boolean indicating if particles are enabled on this scene
  36146. */
  36147. particlesEnabled: boolean;
  36148. /**
  36149. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36150. */
  36151. spritesEnabled: boolean;
  36152. private _skeletonsEnabled;
  36153. /**
  36154. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36155. */
  36156. set skeletonsEnabled(value: boolean);
  36157. get skeletonsEnabled(): boolean;
  36158. /**
  36159. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36160. */
  36161. lensFlaresEnabled: boolean;
  36162. /**
  36163. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36164. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36165. */
  36166. collisionsEnabled: boolean;
  36167. private _collisionCoordinator;
  36168. /** @hidden */
  36169. get collisionCoordinator(): ICollisionCoordinator;
  36170. /**
  36171. * Defines the gravity applied to this scene (used only for collisions)
  36172. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36173. */
  36174. gravity: Vector3;
  36175. /**
  36176. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36177. */
  36178. postProcessesEnabled: boolean;
  36179. /**
  36180. * The list of postprocesses added to the scene
  36181. */
  36182. postProcesses: PostProcess[];
  36183. /**
  36184. * Gets the current postprocess manager
  36185. */
  36186. postProcessManager: PostProcessManager;
  36187. /**
  36188. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36189. */
  36190. renderTargetsEnabled: boolean;
  36191. /**
  36192. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36193. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36194. */
  36195. dumpNextRenderTargets: boolean;
  36196. /**
  36197. * The list of user defined render targets added to the scene
  36198. */
  36199. customRenderTargets: RenderTargetTexture[];
  36200. /**
  36201. * Defines if texture loading must be delayed
  36202. * If true, textures will only be loaded when they need to be rendered
  36203. */
  36204. useDelayedTextureLoading: boolean;
  36205. /**
  36206. * Gets the list of meshes imported to the scene through SceneLoader
  36207. */
  36208. importedMeshesFiles: String[];
  36209. /**
  36210. * Gets or sets a boolean indicating if probes are enabled on this scene
  36211. */
  36212. probesEnabled: boolean;
  36213. /**
  36214. * Gets or sets the current offline provider to use to store scene data
  36215. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36216. */
  36217. offlineProvider: IOfflineProvider;
  36218. /**
  36219. * Gets or sets the action manager associated with the scene
  36220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36221. */
  36222. actionManager: AbstractActionManager;
  36223. private _meshesForIntersections;
  36224. /**
  36225. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36226. */
  36227. proceduralTexturesEnabled: boolean;
  36228. private _engine;
  36229. private _totalVertices;
  36230. /** @hidden */
  36231. _activeIndices: PerfCounter;
  36232. /** @hidden */
  36233. _activeParticles: PerfCounter;
  36234. /** @hidden */
  36235. _activeBones: PerfCounter;
  36236. private _animationRatio;
  36237. /** @hidden */
  36238. _animationTimeLast: number;
  36239. /** @hidden */
  36240. _animationTime: number;
  36241. /**
  36242. * Gets or sets a general scale for animation speed
  36243. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36244. */
  36245. animationTimeScale: number;
  36246. /** @hidden */
  36247. _cachedMaterial: Nullable<Material>;
  36248. /** @hidden */
  36249. _cachedEffect: Nullable<Effect>;
  36250. /** @hidden */
  36251. _cachedVisibility: Nullable<number>;
  36252. private _renderId;
  36253. private _frameId;
  36254. private _executeWhenReadyTimeoutId;
  36255. private _intermediateRendering;
  36256. private _viewUpdateFlag;
  36257. private _projectionUpdateFlag;
  36258. /** @hidden */
  36259. _toBeDisposed: Nullable<IDisposable>[];
  36260. private _activeRequests;
  36261. /** @hidden */
  36262. _pendingData: any[];
  36263. private _isDisposed;
  36264. /**
  36265. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36266. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36267. */
  36268. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36269. private _activeMeshes;
  36270. private _processedMaterials;
  36271. private _renderTargets;
  36272. /** @hidden */
  36273. _activeParticleSystems: SmartArray<IParticleSystem>;
  36274. private _activeSkeletons;
  36275. private _softwareSkinnedMeshes;
  36276. private _renderingManager;
  36277. /** @hidden */
  36278. _activeAnimatables: Animatable[];
  36279. private _transformMatrix;
  36280. private _sceneUbo;
  36281. /** @hidden */
  36282. _viewMatrix: Matrix;
  36283. private _projectionMatrix;
  36284. /** @hidden */
  36285. _forcedViewPosition: Nullable<Vector3>;
  36286. /** @hidden */
  36287. _frustumPlanes: Plane[];
  36288. /**
  36289. * Gets the list of frustum planes (built from the active camera)
  36290. */
  36291. get frustumPlanes(): Plane[];
  36292. /**
  36293. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36294. * This is useful if there are more lights that the maximum simulteanous authorized
  36295. */
  36296. requireLightSorting: boolean;
  36297. /** @hidden */
  36298. readonly useMaterialMeshMap: boolean;
  36299. /** @hidden */
  36300. readonly useClonedMeshMap: boolean;
  36301. private _externalData;
  36302. private _uid;
  36303. /**
  36304. * @hidden
  36305. * Backing store of defined scene components.
  36306. */
  36307. _components: ISceneComponent[];
  36308. /**
  36309. * @hidden
  36310. * Backing store of defined scene components.
  36311. */
  36312. _serializableComponents: ISceneSerializableComponent[];
  36313. /**
  36314. * List of components to register on the next registration step.
  36315. */
  36316. private _transientComponents;
  36317. /**
  36318. * Registers the transient components if needed.
  36319. */
  36320. private _registerTransientComponents;
  36321. /**
  36322. * @hidden
  36323. * Add a component to the scene.
  36324. * Note that the ccomponent could be registered on th next frame if this is called after
  36325. * the register component stage.
  36326. * @param component Defines the component to add to the scene
  36327. */
  36328. _addComponent(component: ISceneComponent): void;
  36329. /**
  36330. * @hidden
  36331. * Gets a component from the scene.
  36332. * @param name defines the name of the component to retrieve
  36333. * @returns the component or null if not present
  36334. */
  36335. _getComponent(name: string): Nullable<ISceneComponent>;
  36336. /**
  36337. * @hidden
  36338. * Defines the actions happening before camera updates.
  36339. */
  36340. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36341. /**
  36342. * @hidden
  36343. * Defines the actions happening before clear the canvas.
  36344. */
  36345. _beforeClearStage: Stage<SimpleStageAction>;
  36346. /**
  36347. * @hidden
  36348. * Defines the actions when collecting render targets for the frame.
  36349. */
  36350. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36351. /**
  36352. * @hidden
  36353. * Defines the actions happening for one camera in the frame.
  36354. */
  36355. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36356. /**
  36357. * @hidden
  36358. * Defines the actions happening during the per mesh ready checks.
  36359. */
  36360. _isReadyForMeshStage: Stage<MeshStageAction>;
  36361. /**
  36362. * @hidden
  36363. * Defines the actions happening before evaluate active mesh checks.
  36364. */
  36365. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36366. /**
  36367. * @hidden
  36368. * Defines the actions happening during the evaluate sub mesh checks.
  36369. */
  36370. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36371. /**
  36372. * @hidden
  36373. * Defines the actions happening during the active mesh stage.
  36374. */
  36375. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36376. /**
  36377. * @hidden
  36378. * Defines the actions happening during the per camera render target step.
  36379. */
  36380. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36381. /**
  36382. * @hidden
  36383. * Defines the actions happening just before the active camera is drawing.
  36384. */
  36385. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36386. /**
  36387. * @hidden
  36388. * Defines the actions happening just before a render target is drawing.
  36389. */
  36390. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36391. /**
  36392. * @hidden
  36393. * Defines the actions happening just before a rendering group is drawing.
  36394. */
  36395. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36396. /**
  36397. * @hidden
  36398. * Defines the actions happening just before a mesh is drawing.
  36399. */
  36400. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36401. /**
  36402. * @hidden
  36403. * Defines the actions happening just after a mesh has been drawn.
  36404. */
  36405. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36406. /**
  36407. * @hidden
  36408. * Defines the actions happening just after a rendering group has been drawn.
  36409. */
  36410. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36411. /**
  36412. * @hidden
  36413. * Defines the actions happening just after the active camera has been drawn.
  36414. */
  36415. _afterCameraDrawStage: Stage<CameraStageAction>;
  36416. /**
  36417. * @hidden
  36418. * Defines the actions happening just after a render target has been drawn.
  36419. */
  36420. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36421. /**
  36422. * @hidden
  36423. * Defines the actions happening just after rendering all cameras and computing intersections.
  36424. */
  36425. _afterRenderStage: Stage<SimpleStageAction>;
  36426. /**
  36427. * @hidden
  36428. * Defines the actions happening when a pointer move event happens.
  36429. */
  36430. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36431. /**
  36432. * @hidden
  36433. * Defines the actions happening when a pointer down event happens.
  36434. */
  36435. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36436. /**
  36437. * @hidden
  36438. * Defines the actions happening when a pointer up event happens.
  36439. */
  36440. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36441. /**
  36442. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36443. */
  36444. private geometriesByUniqueId;
  36445. /**
  36446. * Creates a new Scene
  36447. * @param engine defines the engine to use to render this scene
  36448. * @param options defines the scene options
  36449. */
  36450. constructor(engine: Engine, options?: SceneOptions);
  36451. /**
  36452. * Gets a string idenfifying the name of the class
  36453. * @returns "Scene" string
  36454. */
  36455. getClassName(): string;
  36456. private _defaultMeshCandidates;
  36457. /**
  36458. * @hidden
  36459. */
  36460. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36461. private _defaultSubMeshCandidates;
  36462. /**
  36463. * @hidden
  36464. */
  36465. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36466. /**
  36467. * Sets the default candidate providers for the scene.
  36468. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36469. * and getCollidingSubMeshCandidates to their default function
  36470. */
  36471. setDefaultCandidateProviders(): void;
  36472. /**
  36473. * Gets the mesh that is currently under the pointer
  36474. */
  36475. get meshUnderPointer(): Nullable<AbstractMesh>;
  36476. /**
  36477. * Gets or sets the current on-screen X position of the pointer
  36478. */
  36479. get pointerX(): number;
  36480. set pointerX(value: number);
  36481. /**
  36482. * Gets or sets the current on-screen Y position of the pointer
  36483. */
  36484. get pointerY(): number;
  36485. set pointerY(value: number);
  36486. /**
  36487. * Gets the cached material (ie. the latest rendered one)
  36488. * @returns the cached material
  36489. */
  36490. getCachedMaterial(): Nullable<Material>;
  36491. /**
  36492. * Gets the cached effect (ie. the latest rendered one)
  36493. * @returns the cached effect
  36494. */
  36495. getCachedEffect(): Nullable<Effect>;
  36496. /**
  36497. * Gets the cached visibility state (ie. the latest rendered one)
  36498. * @returns the cached visibility state
  36499. */
  36500. getCachedVisibility(): Nullable<number>;
  36501. /**
  36502. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36503. * @param material defines the current material
  36504. * @param effect defines the current effect
  36505. * @param visibility defines the current visibility state
  36506. * @returns true if one parameter is not cached
  36507. */
  36508. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36509. /**
  36510. * Gets the engine associated with the scene
  36511. * @returns an Engine
  36512. */
  36513. getEngine(): Engine;
  36514. /**
  36515. * Gets the total number of vertices rendered per frame
  36516. * @returns the total number of vertices rendered per frame
  36517. */
  36518. getTotalVertices(): number;
  36519. /**
  36520. * Gets the performance counter for total vertices
  36521. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36522. */
  36523. get totalVerticesPerfCounter(): PerfCounter;
  36524. /**
  36525. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36526. * @returns the total number of active indices rendered per frame
  36527. */
  36528. getActiveIndices(): number;
  36529. /**
  36530. * Gets the performance counter for active indices
  36531. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36532. */
  36533. get totalActiveIndicesPerfCounter(): PerfCounter;
  36534. /**
  36535. * Gets the total number of active particles rendered per frame
  36536. * @returns the total number of active particles rendered per frame
  36537. */
  36538. getActiveParticles(): number;
  36539. /**
  36540. * Gets the performance counter for active particles
  36541. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36542. */
  36543. get activeParticlesPerfCounter(): PerfCounter;
  36544. /**
  36545. * Gets the total number of active bones rendered per frame
  36546. * @returns the total number of active bones rendered per frame
  36547. */
  36548. getActiveBones(): number;
  36549. /**
  36550. * Gets the performance counter for active bones
  36551. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36552. */
  36553. get activeBonesPerfCounter(): PerfCounter;
  36554. /**
  36555. * Gets the array of active meshes
  36556. * @returns an array of AbstractMesh
  36557. */
  36558. getActiveMeshes(): SmartArray<AbstractMesh>;
  36559. /**
  36560. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36561. * @returns a number
  36562. */
  36563. getAnimationRatio(): number;
  36564. /**
  36565. * Gets an unique Id for the current render phase
  36566. * @returns a number
  36567. */
  36568. getRenderId(): number;
  36569. /**
  36570. * Gets an unique Id for the current frame
  36571. * @returns a number
  36572. */
  36573. getFrameId(): number;
  36574. /** Call this function if you want to manually increment the render Id*/
  36575. incrementRenderId(): void;
  36576. private _createUbo;
  36577. /**
  36578. * Use this method to simulate a pointer move on a mesh
  36579. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36580. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36581. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36582. * @returns the current scene
  36583. */
  36584. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36585. /**
  36586. * Use this method to simulate a pointer down on a mesh
  36587. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36588. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36589. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36590. * @returns the current scene
  36591. */
  36592. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36593. /**
  36594. * Use this method to simulate a pointer up on a mesh
  36595. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36596. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36597. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36598. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36599. * @returns the current scene
  36600. */
  36601. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36602. /**
  36603. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36604. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36605. * @returns true if the pointer was captured
  36606. */
  36607. isPointerCaptured(pointerId?: number): boolean;
  36608. /**
  36609. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36610. * @param attachUp defines if you want to attach events to pointerup
  36611. * @param attachDown defines if you want to attach events to pointerdown
  36612. * @param attachMove defines if you want to attach events to pointermove
  36613. */
  36614. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36615. /** Detaches all event handlers*/
  36616. detachControl(): void;
  36617. /**
  36618. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36619. * Delay loaded resources are not taking in account
  36620. * @return true if all required resources are ready
  36621. */
  36622. isReady(): boolean;
  36623. /** Resets all cached information relative to material (including effect and visibility) */
  36624. resetCachedMaterial(): void;
  36625. /**
  36626. * Registers a function to be called before every frame render
  36627. * @param func defines the function to register
  36628. */
  36629. registerBeforeRender(func: () => void): void;
  36630. /**
  36631. * Unregisters a function called before every frame render
  36632. * @param func defines the function to unregister
  36633. */
  36634. unregisterBeforeRender(func: () => void): void;
  36635. /**
  36636. * Registers a function to be called after every frame render
  36637. * @param func defines the function to register
  36638. */
  36639. registerAfterRender(func: () => void): void;
  36640. /**
  36641. * Unregisters a function called after every frame render
  36642. * @param func defines the function to unregister
  36643. */
  36644. unregisterAfterRender(func: () => void): void;
  36645. private _executeOnceBeforeRender;
  36646. /**
  36647. * The provided function will run before render once and will be disposed afterwards.
  36648. * A timeout delay can be provided so that the function will be executed in N ms.
  36649. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36650. * @param func The function to be executed.
  36651. * @param timeout optional delay in ms
  36652. */
  36653. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36654. /** @hidden */
  36655. _addPendingData(data: any): void;
  36656. /** @hidden */
  36657. _removePendingData(data: any): void;
  36658. /**
  36659. * Returns the number of items waiting to be loaded
  36660. * @returns the number of items waiting to be loaded
  36661. */
  36662. getWaitingItemsCount(): number;
  36663. /**
  36664. * Returns a boolean indicating if the scene is still loading data
  36665. */
  36666. get isLoading(): boolean;
  36667. /**
  36668. * Registers a function to be executed when the scene is ready
  36669. * @param {Function} func - the function to be executed
  36670. */
  36671. executeWhenReady(func: () => void): void;
  36672. /**
  36673. * Returns a promise that resolves when the scene is ready
  36674. * @returns A promise that resolves when the scene is ready
  36675. */
  36676. whenReadyAsync(): Promise<void>;
  36677. /** @hidden */
  36678. _checkIsReady(): void;
  36679. /**
  36680. * Gets all animatable attached to the scene
  36681. */
  36682. get animatables(): Animatable[];
  36683. /**
  36684. * Resets the last animation time frame.
  36685. * Useful to override when animations start running when loading a scene for the first time.
  36686. */
  36687. resetLastAnimationTimeFrame(): void;
  36688. /**
  36689. * Gets the current view matrix
  36690. * @returns a Matrix
  36691. */
  36692. getViewMatrix(): Matrix;
  36693. /**
  36694. * Gets the current projection matrix
  36695. * @returns a Matrix
  36696. */
  36697. getProjectionMatrix(): Matrix;
  36698. /**
  36699. * Gets the current transform matrix
  36700. * @returns a Matrix made of View * Projection
  36701. */
  36702. getTransformMatrix(): Matrix;
  36703. /**
  36704. * Sets the current transform matrix
  36705. * @param viewL defines the View matrix to use
  36706. * @param projectionL defines the Projection matrix to use
  36707. * @param viewR defines the right View matrix to use (if provided)
  36708. * @param projectionR defines the right Projection matrix to use (if provided)
  36709. */
  36710. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36711. /**
  36712. * Gets the uniform buffer used to store scene data
  36713. * @returns a UniformBuffer
  36714. */
  36715. getSceneUniformBuffer(): UniformBuffer;
  36716. /**
  36717. * Gets an unique (relatively to the current scene) Id
  36718. * @returns an unique number for the scene
  36719. */
  36720. getUniqueId(): number;
  36721. /**
  36722. * Add a mesh to the list of scene's meshes
  36723. * @param newMesh defines the mesh to add
  36724. * @param recursive if all child meshes should also be added to the scene
  36725. */
  36726. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36727. /**
  36728. * Remove a mesh for the list of scene's meshes
  36729. * @param toRemove defines the mesh to remove
  36730. * @param recursive if all child meshes should also be removed from the scene
  36731. * @returns the index where the mesh was in the mesh list
  36732. */
  36733. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36734. /**
  36735. * Add a transform node to the list of scene's transform nodes
  36736. * @param newTransformNode defines the transform node to add
  36737. */
  36738. addTransformNode(newTransformNode: TransformNode): void;
  36739. /**
  36740. * Remove a transform node for the list of scene's transform nodes
  36741. * @param toRemove defines the transform node to remove
  36742. * @returns the index where the transform node was in the transform node list
  36743. */
  36744. removeTransformNode(toRemove: TransformNode): number;
  36745. /**
  36746. * Remove a skeleton for the list of scene's skeletons
  36747. * @param toRemove defines the skeleton to remove
  36748. * @returns the index where the skeleton was in the skeleton list
  36749. */
  36750. removeSkeleton(toRemove: Skeleton): number;
  36751. /**
  36752. * Remove a morph target for the list of scene's morph targets
  36753. * @param toRemove defines the morph target to remove
  36754. * @returns the index where the morph target was in the morph target list
  36755. */
  36756. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36757. /**
  36758. * Remove a light for the list of scene's lights
  36759. * @param toRemove defines the light to remove
  36760. * @returns the index where the light was in the light list
  36761. */
  36762. removeLight(toRemove: Light): number;
  36763. /**
  36764. * Remove a camera for the list of scene's cameras
  36765. * @param toRemove defines the camera to remove
  36766. * @returns the index where the camera was in the camera list
  36767. */
  36768. removeCamera(toRemove: Camera): number;
  36769. /**
  36770. * Remove a particle system for the list of scene's particle systems
  36771. * @param toRemove defines the particle system to remove
  36772. * @returns the index where the particle system was in the particle system list
  36773. */
  36774. removeParticleSystem(toRemove: IParticleSystem): number;
  36775. /**
  36776. * Remove a animation for the list of scene's animations
  36777. * @param toRemove defines the animation to remove
  36778. * @returns the index where the animation was in the animation list
  36779. */
  36780. removeAnimation(toRemove: Animation): number;
  36781. /**
  36782. * Will stop the animation of the given target
  36783. * @param target - the target
  36784. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36785. * @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)
  36786. */
  36787. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36788. /**
  36789. * Removes the given animation group from this scene.
  36790. * @param toRemove The animation group to remove
  36791. * @returns The index of the removed animation group
  36792. */
  36793. removeAnimationGroup(toRemove: AnimationGroup): number;
  36794. /**
  36795. * Removes the given multi-material from this scene.
  36796. * @param toRemove The multi-material to remove
  36797. * @returns The index of the removed multi-material
  36798. */
  36799. removeMultiMaterial(toRemove: MultiMaterial): number;
  36800. /**
  36801. * Removes the given material from this scene.
  36802. * @param toRemove The material to remove
  36803. * @returns The index of the removed material
  36804. */
  36805. removeMaterial(toRemove: Material): number;
  36806. /**
  36807. * Removes the given action manager from this scene.
  36808. * @param toRemove The action manager to remove
  36809. * @returns The index of the removed action manager
  36810. */
  36811. removeActionManager(toRemove: AbstractActionManager): number;
  36812. /**
  36813. * Removes the given texture from this scene.
  36814. * @param toRemove The texture to remove
  36815. * @returns The index of the removed texture
  36816. */
  36817. removeTexture(toRemove: BaseTexture): number;
  36818. /**
  36819. * Adds the given light to this scene
  36820. * @param newLight The light to add
  36821. */
  36822. addLight(newLight: Light): void;
  36823. /**
  36824. * Sorts the list list based on light priorities
  36825. */
  36826. sortLightsByPriority(): void;
  36827. /**
  36828. * Adds the given camera to this scene
  36829. * @param newCamera The camera to add
  36830. */
  36831. addCamera(newCamera: Camera): void;
  36832. /**
  36833. * Adds the given skeleton to this scene
  36834. * @param newSkeleton The skeleton to add
  36835. */
  36836. addSkeleton(newSkeleton: Skeleton): void;
  36837. /**
  36838. * Adds the given particle system to this scene
  36839. * @param newParticleSystem The particle system to add
  36840. */
  36841. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36842. /**
  36843. * Adds the given animation to this scene
  36844. * @param newAnimation The animation to add
  36845. */
  36846. addAnimation(newAnimation: Animation): void;
  36847. /**
  36848. * Adds the given animation group to this scene.
  36849. * @param newAnimationGroup The animation group to add
  36850. */
  36851. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36852. /**
  36853. * Adds the given multi-material to this scene
  36854. * @param newMultiMaterial The multi-material to add
  36855. */
  36856. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36857. /**
  36858. * Adds the given material to this scene
  36859. * @param newMaterial The material to add
  36860. */
  36861. addMaterial(newMaterial: Material): void;
  36862. /**
  36863. * Adds the given morph target to this scene
  36864. * @param newMorphTargetManager The morph target to add
  36865. */
  36866. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36867. /**
  36868. * Adds the given geometry to this scene
  36869. * @param newGeometry The geometry to add
  36870. */
  36871. addGeometry(newGeometry: Geometry): void;
  36872. /**
  36873. * Adds the given action manager to this scene
  36874. * @param newActionManager The action manager to add
  36875. */
  36876. addActionManager(newActionManager: AbstractActionManager): void;
  36877. /**
  36878. * Adds the given texture to this scene.
  36879. * @param newTexture The texture to add
  36880. */
  36881. addTexture(newTexture: BaseTexture): void;
  36882. /**
  36883. * Switch active camera
  36884. * @param newCamera defines the new active camera
  36885. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36886. */
  36887. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36888. /**
  36889. * sets the active camera of the scene using its ID
  36890. * @param id defines the camera's ID
  36891. * @return the new active camera or null if none found.
  36892. */
  36893. setActiveCameraByID(id: string): Nullable<Camera>;
  36894. /**
  36895. * sets the active camera of the scene using its name
  36896. * @param name defines the camera's name
  36897. * @returns the new active camera or null if none found.
  36898. */
  36899. setActiveCameraByName(name: string): Nullable<Camera>;
  36900. /**
  36901. * get an animation group using its name
  36902. * @param name defines the material's name
  36903. * @return the animation group or null if none found.
  36904. */
  36905. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36906. /**
  36907. * Get a material using its unique id
  36908. * @param uniqueId defines the material's unique id
  36909. * @return the material or null if none found.
  36910. */
  36911. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36912. /**
  36913. * get a material using its id
  36914. * @param id defines the material's ID
  36915. * @return the material or null if none found.
  36916. */
  36917. getMaterialByID(id: string): Nullable<Material>;
  36918. /**
  36919. * Gets a the last added material using a given id
  36920. * @param id defines the material's ID
  36921. * @return the last material with the given id or null if none found.
  36922. */
  36923. getLastMaterialByID(id: string): Nullable<Material>;
  36924. /**
  36925. * Gets a material using its name
  36926. * @param name defines the material's name
  36927. * @return the material or null if none found.
  36928. */
  36929. getMaterialByName(name: string): Nullable<Material>;
  36930. /**
  36931. * Get a texture using its unique id
  36932. * @param uniqueId defines the texture's unique id
  36933. * @return the texture or null if none found.
  36934. */
  36935. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36936. /**
  36937. * Gets a camera using its id
  36938. * @param id defines the id to look for
  36939. * @returns the camera or null if not found
  36940. */
  36941. getCameraByID(id: string): Nullable<Camera>;
  36942. /**
  36943. * Gets a camera using its unique id
  36944. * @param uniqueId defines the unique id to look for
  36945. * @returns the camera or null if not found
  36946. */
  36947. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36948. /**
  36949. * Gets a camera using its name
  36950. * @param name defines the camera's name
  36951. * @return the camera or null if none found.
  36952. */
  36953. getCameraByName(name: string): Nullable<Camera>;
  36954. /**
  36955. * Gets a bone using its id
  36956. * @param id defines the bone's id
  36957. * @return the bone or null if not found
  36958. */
  36959. getBoneByID(id: string): Nullable<Bone>;
  36960. /**
  36961. * Gets a bone using its id
  36962. * @param name defines the bone's name
  36963. * @return the bone or null if not found
  36964. */
  36965. getBoneByName(name: string): Nullable<Bone>;
  36966. /**
  36967. * Gets a light node using its name
  36968. * @param name defines the the light's name
  36969. * @return the light or null if none found.
  36970. */
  36971. getLightByName(name: string): Nullable<Light>;
  36972. /**
  36973. * Gets a light node using its id
  36974. * @param id defines the light's id
  36975. * @return the light or null if none found.
  36976. */
  36977. getLightByID(id: string): Nullable<Light>;
  36978. /**
  36979. * Gets a light node using its scene-generated unique ID
  36980. * @param uniqueId defines the light's unique id
  36981. * @return the light or null if none found.
  36982. */
  36983. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36984. /**
  36985. * Gets a particle system by id
  36986. * @param id defines the particle system id
  36987. * @return the corresponding system or null if none found
  36988. */
  36989. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36990. /**
  36991. * Gets a geometry using its ID
  36992. * @param id defines the geometry's id
  36993. * @return the geometry or null if none found.
  36994. */
  36995. getGeometryByID(id: string): Nullable<Geometry>;
  36996. private _getGeometryByUniqueID;
  36997. /**
  36998. * Add a new geometry to this scene
  36999. * @param geometry defines the geometry to be added to the scene.
  37000. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37001. * @return a boolean defining if the geometry was added or not
  37002. */
  37003. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37004. /**
  37005. * Removes an existing geometry
  37006. * @param geometry defines the geometry to be removed from the scene
  37007. * @return a boolean defining if the geometry was removed or not
  37008. */
  37009. removeGeometry(geometry: Geometry): boolean;
  37010. /**
  37011. * Gets the list of geometries attached to the scene
  37012. * @returns an array of Geometry
  37013. */
  37014. getGeometries(): Geometry[];
  37015. /**
  37016. * Gets the first added mesh found of a given ID
  37017. * @param id defines the id to search for
  37018. * @return the mesh found or null if not found at all
  37019. */
  37020. getMeshByID(id: string): Nullable<AbstractMesh>;
  37021. /**
  37022. * Gets a list of meshes using their id
  37023. * @param id defines the id to search for
  37024. * @returns a list of meshes
  37025. */
  37026. getMeshesByID(id: string): Array<AbstractMesh>;
  37027. /**
  37028. * Gets the first added transform node found of a given ID
  37029. * @param id defines the id to search for
  37030. * @return the found transform node or null if not found at all.
  37031. */
  37032. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37033. /**
  37034. * Gets a transform node with its auto-generated unique id
  37035. * @param uniqueId efines the unique id to search for
  37036. * @return the found transform node or null if not found at all.
  37037. */
  37038. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37039. /**
  37040. * Gets a list of transform nodes using their id
  37041. * @param id defines the id to search for
  37042. * @returns a list of transform nodes
  37043. */
  37044. getTransformNodesByID(id: string): Array<TransformNode>;
  37045. /**
  37046. * Gets a mesh with its auto-generated unique id
  37047. * @param uniqueId defines the unique id to search for
  37048. * @return the found mesh or null if not found at all.
  37049. */
  37050. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37051. /**
  37052. * Gets a the last added mesh using a given id
  37053. * @param id defines the id to search for
  37054. * @return the found mesh or null if not found at all.
  37055. */
  37056. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37057. /**
  37058. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37059. * @param id defines the id to search for
  37060. * @return the found node or null if not found at all
  37061. */
  37062. getLastEntryByID(id: string): Nullable<Node>;
  37063. /**
  37064. * Gets a node (Mesh, Camera, Light) using a given id
  37065. * @param id defines the id to search for
  37066. * @return the found node or null if not found at all
  37067. */
  37068. getNodeByID(id: string): Nullable<Node>;
  37069. /**
  37070. * Gets a node (Mesh, Camera, Light) using a given name
  37071. * @param name defines the name to search for
  37072. * @return the found node or null if not found at all.
  37073. */
  37074. getNodeByName(name: string): Nullable<Node>;
  37075. /**
  37076. * Gets a mesh using a given name
  37077. * @param name defines the name to search for
  37078. * @return the found mesh or null if not found at all.
  37079. */
  37080. getMeshByName(name: string): Nullable<AbstractMesh>;
  37081. /**
  37082. * Gets a transform node using a given name
  37083. * @param name defines the name to search for
  37084. * @return the found transform node or null if not found at all.
  37085. */
  37086. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37087. /**
  37088. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37089. * @param id defines the id to search for
  37090. * @return the found skeleton or null if not found at all.
  37091. */
  37092. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37093. /**
  37094. * Gets a skeleton using a given auto generated unique id
  37095. * @param uniqueId defines the unique id to search for
  37096. * @return the found skeleton or null if not found at all.
  37097. */
  37098. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37099. /**
  37100. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37101. * @param id defines the id to search for
  37102. * @return the found skeleton or null if not found at all.
  37103. */
  37104. getSkeletonById(id: string): Nullable<Skeleton>;
  37105. /**
  37106. * Gets a skeleton using a given name
  37107. * @param name defines the name to search for
  37108. * @return the found skeleton or null if not found at all.
  37109. */
  37110. getSkeletonByName(name: string): Nullable<Skeleton>;
  37111. /**
  37112. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37113. * @param id defines the id to search for
  37114. * @return the found morph target manager or null if not found at all.
  37115. */
  37116. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37117. /**
  37118. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37119. * @param id defines the id to search for
  37120. * @return the found morph target or null if not found at all.
  37121. */
  37122. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37123. /**
  37124. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37125. * @param name defines the name to search for
  37126. * @return the found morph target or null if not found at all.
  37127. */
  37128. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37129. /**
  37130. * Gets a boolean indicating if the given mesh is active
  37131. * @param mesh defines the mesh to look for
  37132. * @returns true if the mesh is in the active list
  37133. */
  37134. isActiveMesh(mesh: AbstractMesh): boolean;
  37135. /**
  37136. * Return a unique id as a string which can serve as an identifier for the scene
  37137. */
  37138. get uid(): string;
  37139. /**
  37140. * Add an externaly attached data from its key.
  37141. * This method call will fail and return false, if such key already exists.
  37142. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37143. * @param key the unique key that identifies the data
  37144. * @param data the data object to associate to the key for this Engine instance
  37145. * @return true if no such key were already present and the data was added successfully, false otherwise
  37146. */
  37147. addExternalData<T>(key: string, data: T): boolean;
  37148. /**
  37149. * Get an externaly attached data from its key
  37150. * @param key the unique key that identifies the data
  37151. * @return the associated data, if present (can be null), or undefined if not present
  37152. */
  37153. getExternalData<T>(key: string): Nullable<T>;
  37154. /**
  37155. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37156. * @param key the unique key that identifies the data
  37157. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37158. * @return the associated data, can be null if the factory returned null.
  37159. */
  37160. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37161. /**
  37162. * Remove an externaly attached data from the Engine instance
  37163. * @param key the unique key that identifies the data
  37164. * @return true if the data was successfully removed, false if it doesn't exist
  37165. */
  37166. removeExternalData(key: string): boolean;
  37167. private _evaluateSubMesh;
  37168. /**
  37169. * Clear the processed materials smart array preventing retention point in material dispose.
  37170. */
  37171. freeProcessedMaterials(): void;
  37172. private _preventFreeActiveMeshesAndRenderingGroups;
  37173. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37174. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37175. * when disposing several meshes in a row or a hierarchy of meshes.
  37176. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37177. */
  37178. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37179. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37180. /**
  37181. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37182. */
  37183. freeActiveMeshes(): void;
  37184. /**
  37185. * Clear the info related to rendering groups preventing retention points during dispose.
  37186. */
  37187. freeRenderingGroups(): void;
  37188. /** @hidden */
  37189. _isInIntermediateRendering(): boolean;
  37190. /**
  37191. * Lambda returning the list of potentially active meshes.
  37192. */
  37193. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37194. /**
  37195. * Lambda returning the list of potentially active sub meshes.
  37196. */
  37197. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37198. /**
  37199. * Lambda returning the list of potentially intersecting sub meshes.
  37200. */
  37201. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37202. /**
  37203. * Lambda returning the list of potentially colliding sub meshes.
  37204. */
  37205. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37206. private _activeMeshesFrozen;
  37207. private _skipEvaluateActiveMeshesCompletely;
  37208. /**
  37209. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37210. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37211. * @returns the current scene
  37212. */
  37213. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37214. /**
  37215. * Use this function to restart evaluating active meshes on every frame
  37216. * @returns the current scene
  37217. */
  37218. unfreezeActiveMeshes(): Scene;
  37219. private _evaluateActiveMeshes;
  37220. private _activeMesh;
  37221. /**
  37222. * Update the transform matrix to update from the current active camera
  37223. * @param force defines a boolean used to force the update even if cache is up to date
  37224. */
  37225. updateTransformMatrix(force?: boolean): void;
  37226. private _bindFrameBuffer;
  37227. /** @hidden */
  37228. _allowPostProcessClearColor: boolean;
  37229. /** @hidden */
  37230. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37231. private _processSubCameras;
  37232. private _checkIntersections;
  37233. /** @hidden */
  37234. _advancePhysicsEngineStep(step: number): void;
  37235. /**
  37236. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37237. */
  37238. getDeterministicFrameTime: () => number;
  37239. /** @hidden */
  37240. _animate(): void;
  37241. /** Execute all animations (for a frame) */
  37242. animate(): void;
  37243. /**
  37244. * Render the scene
  37245. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37246. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37247. */
  37248. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37249. /**
  37250. * Freeze all materials
  37251. * A frozen material will not be updatable but should be faster to render
  37252. */
  37253. freezeMaterials(): void;
  37254. /**
  37255. * Unfreeze all materials
  37256. * A frozen material will not be updatable but should be faster to render
  37257. */
  37258. unfreezeMaterials(): void;
  37259. /**
  37260. * Releases all held ressources
  37261. */
  37262. dispose(): void;
  37263. /**
  37264. * Gets if the scene is already disposed
  37265. */
  37266. get isDisposed(): boolean;
  37267. /**
  37268. * Call this function to reduce memory footprint of the scene.
  37269. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37270. */
  37271. clearCachedVertexData(): void;
  37272. /**
  37273. * This function will remove the local cached buffer data from texture.
  37274. * It will save memory but will prevent the texture from being rebuilt
  37275. */
  37276. cleanCachedTextureBuffer(): void;
  37277. /**
  37278. * Get the world extend vectors with an optional filter
  37279. *
  37280. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37281. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37282. */
  37283. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37284. min: Vector3;
  37285. max: Vector3;
  37286. };
  37287. /**
  37288. * Creates a ray that can be used to pick in the scene
  37289. * @param x defines the x coordinate of the origin (on-screen)
  37290. * @param y defines the y coordinate of the origin (on-screen)
  37291. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37292. * @param camera defines the camera to use for the picking
  37293. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37294. * @returns a Ray
  37295. */
  37296. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37297. /**
  37298. * Creates a ray that can be used to pick in the scene
  37299. * @param x defines the x coordinate of the origin (on-screen)
  37300. * @param y defines the y coordinate of the origin (on-screen)
  37301. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37302. * @param result defines the ray where to store the picking ray
  37303. * @param camera defines the camera to use for the picking
  37304. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37305. * @returns the current scene
  37306. */
  37307. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37308. /**
  37309. * Creates a ray that can be used to pick in the scene
  37310. * @param x defines the x coordinate of the origin (on-screen)
  37311. * @param y defines the y coordinate of the origin (on-screen)
  37312. * @param camera defines the camera to use for the picking
  37313. * @returns a Ray
  37314. */
  37315. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37316. /**
  37317. * Creates a ray that can be used to pick in the scene
  37318. * @param x defines the x coordinate of the origin (on-screen)
  37319. * @param y defines the y coordinate of the origin (on-screen)
  37320. * @param result defines the ray where to store the picking ray
  37321. * @param camera defines the camera to use for the picking
  37322. * @returns the current scene
  37323. */
  37324. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37325. /** Launch a ray to try to pick a mesh in the scene
  37326. * @param x position on screen
  37327. * @param y position on screen
  37328. * @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
  37329. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37330. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37331. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37332. * @returns a PickingInfo
  37333. */
  37334. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37335. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  37336. * @param x position on screen
  37337. * @param y position on screen
  37338. * @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
  37339. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37340. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37341. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  37342. */
  37343. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  37344. /** Use the given ray to pick a mesh in the scene
  37345. * @param ray The ray to use to pick meshes
  37346. * @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
  37347. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37348. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37349. * @returns a PickingInfo
  37350. */
  37351. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37352. /**
  37353. * Launch a ray to try to pick a mesh in the scene
  37354. * @param x X position on screen
  37355. * @param y Y position on screen
  37356. * @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
  37357. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37358. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37359. * @returns an array of PickingInfo
  37360. */
  37361. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37362. /**
  37363. * Launch a ray to try to pick a mesh in the scene
  37364. * @param ray Ray to use
  37365. * @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
  37366. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37367. * @returns an array of PickingInfo
  37368. */
  37369. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37370. /**
  37371. * Force the value of meshUnderPointer
  37372. * @param mesh defines the mesh to use
  37373. */
  37374. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37375. /**
  37376. * Gets the mesh under the pointer
  37377. * @returns a Mesh or null if no mesh is under the pointer
  37378. */
  37379. getPointerOverMesh(): Nullable<AbstractMesh>;
  37380. /** @hidden */
  37381. _rebuildGeometries(): void;
  37382. /** @hidden */
  37383. _rebuildTextures(): void;
  37384. private _getByTags;
  37385. /**
  37386. * Get a list of meshes by tags
  37387. * @param tagsQuery defines the tags query to use
  37388. * @param forEach defines a predicate used to filter results
  37389. * @returns an array of Mesh
  37390. */
  37391. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37392. /**
  37393. * Get a list of cameras by tags
  37394. * @param tagsQuery defines the tags query to use
  37395. * @param forEach defines a predicate used to filter results
  37396. * @returns an array of Camera
  37397. */
  37398. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37399. /**
  37400. * Get a list of lights by tags
  37401. * @param tagsQuery defines the tags query to use
  37402. * @param forEach defines a predicate used to filter results
  37403. * @returns an array of Light
  37404. */
  37405. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37406. /**
  37407. * Get a list of materials by tags
  37408. * @param tagsQuery defines the tags query to use
  37409. * @param forEach defines a predicate used to filter results
  37410. * @returns an array of Material
  37411. */
  37412. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37413. /**
  37414. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37415. * This allowed control for front to back rendering or reversly depending of the special needs.
  37416. *
  37417. * @param renderingGroupId The rendering group id corresponding to its index
  37418. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37419. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37420. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37421. */
  37422. 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;
  37423. /**
  37424. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37425. *
  37426. * @param renderingGroupId The rendering group id corresponding to its index
  37427. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37428. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37429. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37430. */
  37431. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37432. /**
  37433. * Gets the current auto clear configuration for one rendering group of the rendering
  37434. * manager.
  37435. * @param index the rendering group index to get the information for
  37436. * @returns The auto clear setup for the requested rendering group
  37437. */
  37438. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37439. private _blockMaterialDirtyMechanism;
  37440. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37441. get blockMaterialDirtyMechanism(): boolean;
  37442. set blockMaterialDirtyMechanism(value: boolean);
  37443. /**
  37444. * Will flag all materials as dirty to trigger new shader compilation
  37445. * @param flag defines the flag used to specify which material part must be marked as dirty
  37446. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37447. */
  37448. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37449. /** @hidden */
  37450. _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;
  37451. /** @hidden */
  37452. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37453. /** @hidden */
  37454. _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;
  37455. /** @hidden */
  37456. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37457. /** @hidden */
  37458. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37459. /** @hidden */
  37460. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37461. }
  37462. }
  37463. declare module BABYLON {
  37464. /**
  37465. * Set of assets to keep when moving a scene into an asset container.
  37466. */
  37467. export class KeepAssets extends AbstractScene {
  37468. }
  37469. /**
  37470. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37471. */
  37472. export class InstantiatedEntries {
  37473. /**
  37474. * List of new root nodes (eg. nodes with no parent)
  37475. */
  37476. rootNodes: TransformNode[];
  37477. /**
  37478. * List of new skeletons
  37479. */
  37480. skeletons: Skeleton[];
  37481. /**
  37482. * List of new animation groups
  37483. */
  37484. animationGroups: AnimationGroup[];
  37485. }
  37486. /**
  37487. * Container with a set of assets that can be added or removed from a scene.
  37488. */
  37489. export class AssetContainer extends AbstractScene {
  37490. private _wasAddedToScene;
  37491. /**
  37492. * The scene the AssetContainer belongs to.
  37493. */
  37494. scene: Scene;
  37495. /**
  37496. * Instantiates an AssetContainer.
  37497. * @param scene The scene the AssetContainer belongs to.
  37498. */
  37499. constructor(scene: Scene);
  37500. /**
  37501. * Instantiate or clone all meshes and add the new ones to the scene.
  37502. * Skeletons and animation groups will all be cloned
  37503. * @param nameFunction defines an optional function used to get new names for clones
  37504. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37505. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37506. */
  37507. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37508. /**
  37509. * Adds all the assets from the container to the scene.
  37510. */
  37511. addAllToScene(): void;
  37512. /**
  37513. * Removes all the assets in the container from the scene
  37514. */
  37515. removeAllFromScene(): void;
  37516. /**
  37517. * Disposes all the assets in the container
  37518. */
  37519. dispose(): void;
  37520. private _moveAssets;
  37521. /**
  37522. * Removes all the assets contained in the scene and adds them to the container.
  37523. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37524. */
  37525. moveAllFromScene(keepAssets?: KeepAssets): void;
  37526. /**
  37527. * 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.
  37528. * @returns the root mesh
  37529. */
  37530. createRootMesh(): Mesh;
  37531. /**
  37532. * Merge animations (direct and animation groups) from this asset container into a scene
  37533. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37534. * @param animatables set of animatables to retarget to a node from the scene
  37535. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37536. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  37537. */
  37538. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  37539. }
  37540. }
  37541. declare module BABYLON {
  37542. /**
  37543. * Defines how the parser contract is defined.
  37544. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37545. */
  37546. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37547. /**
  37548. * Defines how the individual parser contract is defined.
  37549. * These parser can parse an individual asset
  37550. */
  37551. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37552. /**
  37553. * Base class of the scene acting as a container for the different elements composing a scene.
  37554. * This class is dynamically extended by the different components of the scene increasing
  37555. * flexibility and reducing coupling
  37556. */
  37557. export abstract class AbstractScene {
  37558. /**
  37559. * Stores the list of available parsers in the application.
  37560. */
  37561. private static _BabylonFileParsers;
  37562. /**
  37563. * Stores the list of available individual parsers in the application.
  37564. */
  37565. private static _IndividualBabylonFileParsers;
  37566. /**
  37567. * Adds a parser in the list of available ones
  37568. * @param name Defines the name of the parser
  37569. * @param parser Defines the parser to add
  37570. */
  37571. static AddParser(name: string, parser: BabylonFileParser): void;
  37572. /**
  37573. * Gets a general parser from the list of avaialble ones
  37574. * @param name Defines the name of the parser
  37575. * @returns the requested parser or null
  37576. */
  37577. static GetParser(name: string): Nullable<BabylonFileParser>;
  37578. /**
  37579. * Adds n individual parser in the list of available ones
  37580. * @param name Defines the name of the parser
  37581. * @param parser Defines the parser to add
  37582. */
  37583. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37584. /**
  37585. * Gets an individual parser from the list of avaialble ones
  37586. * @param name Defines the name of the parser
  37587. * @returns the requested parser or null
  37588. */
  37589. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37590. /**
  37591. * Parser json data and populate both a scene and its associated container object
  37592. * @param jsonData Defines the data to parse
  37593. * @param scene Defines the scene to parse the data for
  37594. * @param container Defines the container attached to the parsing sequence
  37595. * @param rootUrl Defines the root url of the data
  37596. */
  37597. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37598. /**
  37599. * Gets the list of root nodes (ie. nodes with no parent)
  37600. */
  37601. rootNodes: Node[];
  37602. /** All of the cameras added to this scene
  37603. * @see http://doc.babylonjs.com/babylon101/cameras
  37604. */
  37605. cameras: Camera[];
  37606. /**
  37607. * All of the lights added to this scene
  37608. * @see http://doc.babylonjs.com/babylon101/lights
  37609. */
  37610. lights: Light[];
  37611. /**
  37612. * All of the (abstract) meshes added to this scene
  37613. */
  37614. meshes: AbstractMesh[];
  37615. /**
  37616. * The list of skeletons added to the scene
  37617. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37618. */
  37619. skeletons: Skeleton[];
  37620. /**
  37621. * All of the particle systems added to this scene
  37622. * @see http://doc.babylonjs.com/babylon101/particles
  37623. */
  37624. particleSystems: IParticleSystem[];
  37625. /**
  37626. * Gets a list of Animations associated with the scene
  37627. */
  37628. animations: Animation[];
  37629. /**
  37630. * All of the animation groups added to this scene
  37631. * @see http://doc.babylonjs.com/how_to/group
  37632. */
  37633. animationGroups: AnimationGroup[];
  37634. /**
  37635. * All of the multi-materials added to this scene
  37636. * @see http://doc.babylonjs.com/how_to/multi_materials
  37637. */
  37638. multiMaterials: MultiMaterial[];
  37639. /**
  37640. * All of the materials added to this scene
  37641. * In the context of a Scene, it is not supposed to be modified manually.
  37642. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37643. * Note also that the order of the Material within the array is not significant and might change.
  37644. * @see http://doc.babylonjs.com/babylon101/materials
  37645. */
  37646. materials: Material[];
  37647. /**
  37648. * The list of morph target managers added to the scene
  37649. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37650. */
  37651. morphTargetManagers: MorphTargetManager[];
  37652. /**
  37653. * The list of geometries used in the scene.
  37654. */
  37655. geometries: Geometry[];
  37656. /**
  37657. * All of the tranform nodes added to this scene
  37658. * In the context of a Scene, it is not supposed to be modified manually.
  37659. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37660. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37661. * @see http://doc.babylonjs.com/how_to/transformnode
  37662. */
  37663. transformNodes: TransformNode[];
  37664. /**
  37665. * ActionManagers available on the scene.
  37666. */
  37667. actionManagers: AbstractActionManager[];
  37668. /**
  37669. * Textures to keep.
  37670. */
  37671. textures: BaseTexture[];
  37672. /**
  37673. * Environment texture for the scene
  37674. */
  37675. environmentTexture: Nullable<BaseTexture>;
  37676. /**
  37677. * @returns all meshes, lights, cameras, transformNodes and bones
  37678. */
  37679. getNodes(): Array<Node>;
  37680. }
  37681. }
  37682. declare module BABYLON {
  37683. /**
  37684. * Interface used to define options for Sound class
  37685. */
  37686. export interface ISoundOptions {
  37687. /**
  37688. * Does the sound autoplay once loaded.
  37689. */
  37690. autoplay?: boolean;
  37691. /**
  37692. * Does the sound loop after it finishes playing once.
  37693. */
  37694. loop?: boolean;
  37695. /**
  37696. * Sound's volume
  37697. */
  37698. volume?: number;
  37699. /**
  37700. * Is it a spatial sound?
  37701. */
  37702. spatialSound?: boolean;
  37703. /**
  37704. * Maximum distance to hear that sound
  37705. */
  37706. maxDistance?: number;
  37707. /**
  37708. * Uses user defined attenuation function
  37709. */
  37710. useCustomAttenuation?: boolean;
  37711. /**
  37712. * Define the roll off factor of spatial sounds.
  37713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37714. */
  37715. rolloffFactor?: number;
  37716. /**
  37717. * Define the reference distance the sound should be heard perfectly.
  37718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37719. */
  37720. refDistance?: number;
  37721. /**
  37722. * Define the distance attenuation model the sound will follow.
  37723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37724. */
  37725. distanceModel?: string;
  37726. /**
  37727. * Defines the playback speed (1 by default)
  37728. */
  37729. playbackRate?: number;
  37730. /**
  37731. * Defines if the sound is from a streaming source
  37732. */
  37733. streaming?: boolean;
  37734. /**
  37735. * Defines an optional length (in seconds) inside the sound file
  37736. */
  37737. length?: number;
  37738. /**
  37739. * Defines an optional offset (in seconds) inside the sound file
  37740. */
  37741. offset?: number;
  37742. /**
  37743. * If true, URLs will not be required to state the audio file codec to use.
  37744. */
  37745. skipCodecCheck?: boolean;
  37746. }
  37747. /**
  37748. * Defines a sound that can be played in the application.
  37749. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37751. */
  37752. export class Sound {
  37753. /**
  37754. * The name of the sound in the scene.
  37755. */
  37756. name: string;
  37757. /**
  37758. * Does the sound autoplay once loaded.
  37759. */
  37760. autoplay: boolean;
  37761. /**
  37762. * Does the sound loop after it finishes playing once.
  37763. */
  37764. loop: boolean;
  37765. /**
  37766. * Does the sound use a custom attenuation curve to simulate the falloff
  37767. * happening when the source gets further away from the camera.
  37768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37769. */
  37770. useCustomAttenuation: boolean;
  37771. /**
  37772. * The sound track id this sound belongs to.
  37773. */
  37774. soundTrackId: number;
  37775. /**
  37776. * Is this sound currently played.
  37777. */
  37778. isPlaying: boolean;
  37779. /**
  37780. * Is this sound currently paused.
  37781. */
  37782. isPaused: boolean;
  37783. /**
  37784. * Does this sound enables spatial sound.
  37785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37786. */
  37787. spatialSound: boolean;
  37788. /**
  37789. * Define the reference distance the sound should be heard perfectly.
  37790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37791. */
  37792. refDistance: number;
  37793. /**
  37794. * Define the roll off factor of spatial sounds.
  37795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37796. */
  37797. rolloffFactor: number;
  37798. /**
  37799. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37801. */
  37802. maxDistance: number;
  37803. /**
  37804. * Define the distance attenuation model the sound will follow.
  37805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37806. */
  37807. distanceModel: string;
  37808. /**
  37809. * @hidden
  37810. * Back Compat
  37811. **/
  37812. onended: () => any;
  37813. /**
  37814. * Observable event when the current playing sound finishes.
  37815. */
  37816. onEndedObservable: Observable<Sound>;
  37817. private _panningModel;
  37818. private _playbackRate;
  37819. private _streaming;
  37820. private _startTime;
  37821. private _startOffset;
  37822. private _position;
  37823. /** @hidden */
  37824. _positionInEmitterSpace: boolean;
  37825. private _localDirection;
  37826. private _volume;
  37827. private _isReadyToPlay;
  37828. private _isDirectional;
  37829. private _readyToPlayCallback;
  37830. private _audioBuffer;
  37831. private _soundSource;
  37832. private _streamingSource;
  37833. private _soundPanner;
  37834. private _soundGain;
  37835. private _inputAudioNode;
  37836. private _outputAudioNode;
  37837. private _coneInnerAngle;
  37838. private _coneOuterAngle;
  37839. private _coneOuterGain;
  37840. private _scene;
  37841. private _connectedTransformNode;
  37842. private _customAttenuationFunction;
  37843. private _registerFunc;
  37844. private _isOutputConnected;
  37845. private _htmlAudioElement;
  37846. private _urlType;
  37847. private _length?;
  37848. private _offset?;
  37849. /** @hidden */
  37850. static _SceneComponentInitialization: (scene: Scene) => void;
  37851. /**
  37852. * Create a sound and attach it to a scene
  37853. * @param name Name of your sound
  37854. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37855. * @param scene defines the scene the sound belongs to
  37856. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37857. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37858. */
  37859. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37860. /**
  37861. * Release the sound and its associated resources
  37862. */
  37863. dispose(): void;
  37864. /**
  37865. * Gets if the sounds is ready to be played or not.
  37866. * @returns true if ready, otherwise false
  37867. */
  37868. isReady(): boolean;
  37869. private _soundLoaded;
  37870. /**
  37871. * Sets the data of the sound from an audiobuffer
  37872. * @param audioBuffer The audioBuffer containing the data
  37873. */
  37874. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37875. /**
  37876. * Updates the current sounds options such as maxdistance, loop...
  37877. * @param options A JSON object containing values named as the object properties
  37878. */
  37879. updateOptions(options: ISoundOptions): void;
  37880. private _createSpatialParameters;
  37881. private _updateSpatialParameters;
  37882. /**
  37883. * Switch the panning model to HRTF:
  37884. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37885. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37886. */
  37887. switchPanningModelToHRTF(): void;
  37888. /**
  37889. * Switch the panning model to Equal Power:
  37890. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37892. */
  37893. switchPanningModelToEqualPower(): void;
  37894. private _switchPanningModel;
  37895. /**
  37896. * Connect this sound to a sound track audio node like gain...
  37897. * @param soundTrackAudioNode the sound track audio node to connect to
  37898. */
  37899. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37900. /**
  37901. * Transform this sound into a directional source
  37902. * @param coneInnerAngle Size of the inner cone in degree
  37903. * @param coneOuterAngle Size of the outer cone in degree
  37904. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37905. */
  37906. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37907. /**
  37908. * Gets or sets the inner angle for the directional cone.
  37909. */
  37910. get directionalConeInnerAngle(): number;
  37911. /**
  37912. * Gets or sets the inner angle for the directional cone.
  37913. */
  37914. set directionalConeInnerAngle(value: number);
  37915. /**
  37916. * Gets or sets the outer angle for the directional cone.
  37917. */
  37918. get directionalConeOuterAngle(): number;
  37919. /**
  37920. * Gets or sets the outer angle for the directional cone.
  37921. */
  37922. set directionalConeOuterAngle(value: number);
  37923. /**
  37924. * Sets the position of the emitter if spatial sound is enabled
  37925. * @param newPosition Defines the new posisiton
  37926. */
  37927. setPosition(newPosition: Vector3): void;
  37928. /**
  37929. * Sets the local direction of the emitter if spatial sound is enabled
  37930. * @param newLocalDirection Defines the new local direction
  37931. */
  37932. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37933. private _updateDirection;
  37934. /** @hidden */
  37935. updateDistanceFromListener(): void;
  37936. /**
  37937. * Sets a new custom attenuation function for the sound.
  37938. * @param callback Defines the function used for the attenuation
  37939. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37940. */
  37941. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37942. /**
  37943. * Play the sound
  37944. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37945. * @param offset (optional) Start the sound at a specific time in seconds
  37946. * @param length (optional) Sound duration (in seconds)
  37947. */
  37948. play(time?: number, offset?: number, length?: number): void;
  37949. private _onended;
  37950. /**
  37951. * Stop the sound
  37952. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37953. */
  37954. stop(time?: number): void;
  37955. /**
  37956. * Put the sound in pause
  37957. */
  37958. pause(): void;
  37959. /**
  37960. * Sets a dedicated volume for this sounds
  37961. * @param newVolume Define the new volume of the sound
  37962. * @param time Define time for gradual change to new volume
  37963. */
  37964. setVolume(newVolume: number, time?: number): void;
  37965. /**
  37966. * Set the sound play back rate
  37967. * @param newPlaybackRate Define the playback rate the sound should be played at
  37968. */
  37969. setPlaybackRate(newPlaybackRate: number): void;
  37970. /**
  37971. * Gets the volume of the sound.
  37972. * @returns the volume of the sound
  37973. */
  37974. getVolume(): number;
  37975. /**
  37976. * Attach the sound to a dedicated mesh
  37977. * @param transformNode The transform node to connect the sound with
  37978. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37979. */
  37980. attachToMesh(transformNode: TransformNode): void;
  37981. /**
  37982. * Detach the sound from the previously attached mesh
  37983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37984. */
  37985. detachFromMesh(): void;
  37986. private _onRegisterAfterWorldMatrixUpdate;
  37987. /**
  37988. * Clone the current sound in the scene.
  37989. * @returns the new sound clone
  37990. */
  37991. clone(): Nullable<Sound>;
  37992. /**
  37993. * Gets the current underlying audio buffer containing the data
  37994. * @returns the audio buffer
  37995. */
  37996. getAudioBuffer(): Nullable<AudioBuffer>;
  37997. /**
  37998. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37999. * @returns the source node
  38000. */
  38001. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38002. /**
  38003. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38004. * @returns the gain node
  38005. */
  38006. getSoundGain(): Nullable<GainNode>;
  38007. /**
  38008. * Serializes the Sound in a JSON representation
  38009. * @returns the JSON representation of the sound
  38010. */
  38011. serialize(): any;
  38012. /**
  38013. * Parse a JSON representation of a sound to innstantiate in a given scene
  38014. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38015. * @param scene Define the scene the new parsed sound should be created in
  38016. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38017. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38018. * @returns the newly parsed sound
  38019. */
  38020. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38021. }
  38022. }
  38023. declare module BABYLON {
  38024. /**
  38025. * This defines an action helpful to play a defined sound on a triggered action.
  38026. */
  38027. export class PlaySoundAction extends Action {
  38028. private _sound;
  38029. /**
  38030. * Instantiate the action
  38031. * @param triggerOptions defines the trigger options
  38032. * @param sound defines the sound to play
  38033. * @param condition defines the trigger related conditions
  38034. */
  38035. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38036. /** @hidden */
  38037. _prepare(): void;
  38038. /**
  38039. * Execute the action and play the sound.
  38040. */
  38041. execute(): void;
  38042. /**
  38043. * Serializes the actions and its related information.
  38044. * @param parent defines the object to serialize in
  38045. * @returns the serialized object
  38046. */
  38047. serialize(parent: any): any;
  38048. }
  38049. /**
  38050. * This defines an action helpful to stop a defined sound on a triggered action.
  38051. */
  38052. export class StopSoundAction extends Action {
  38053. private _sound;
  38054. /**
  38055. * Instantiate the action
  38056. * @param triggerOptions defines the trigger options
  38057. * @param sound defines the sound to stop
  38058. * @param condition defines the trigger related conditions
  38059. */
  38060. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38061. /** @hidden */
  38062. _prepare(): void;
  38063. /**
  38064. * Execute the action and stop the sound.
  38065. */
  38066. execute(): void;
  38067. /**
  38068. * Serializes the actions and its related information.
  38069. * @param parent defines the object to serialize in
  38070. * @returns the serialized object
  38071. */
  38072. serialize(parent: any): any;
  38073. }
  38074. }
  38075. declare module BABYLON {
  38076. /**
  38077. * This defines an action responsible to change the value of a property
  38078. * by interpolating between its current value and the newly set one once triggered.
  38079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38080. */
  38081. export class InterpolateValueAction extends Action {
  38082. /**
  38083. * Defines the path of the property where the value should be interpolated
  38084. */
  38085. propertyPath: string;
  38086. /**
  38087. * Defines the target value at the end of the interpolation.
  38088. */
  38089. value: any;
  38090. /**
  38091. * Defines the time it will take for the property to interpolate to the value.
  38092. */
  38093. duration: number;
  38094. /**
  38095. * Defines if the other scene animations should be stopped when the action has been triggered
  38096. */
  38097. stopOtherAnimations?: boolean;
  38098. /**
  38099. * Defines a callback raised once the interpolation animation has been done.
  38100. */
  38101. onInterpolationDone?: () => void;
  38102. /**
  38103. * Observable triggered once the interpolation animation has been done.
  38104. */
  38105. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38106. private _target;
  38107. private _effectiveTarget;
  38108. private _property;
  38109. /**
  38110. * Instantiate the action
  38111. * @param triggerOptions defines the trigger options
  38112. * @param target defines the object containing the value to interpolate
  38113. * @param propertyPath defines the path to the property in the target object
  38114. * @param value defines the target value at the end of the interpolation
  38115. * @param duration deines the time it will take for the property to interpolate to the value.
  38116. * @param condition defines the trigger related conditions
  38117. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38118. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38119. */
  38120. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38121. /** @hidden */
  38122. _prepare(): void;
  38123. /**
  38124. * Execute the action starts the value interpolation.
  38125. */
  38126. execute(): void;
  38127. /**
  38128. * Serializes the actions and its related information.
  38129. * @param parent defines the object to serialize in
  38130. * @returns the serialized object
  38131. */
  38132. serialize(parent: any): any;
  38133. }
  38134. }
  38135. declare module BABYLON {
  38136. /**
  38137. * Options allowed during the creation of a sound track.
  38138. */
  38139. export interface ISoundTrackOptions {
  38140. /**
  38141. * The volume the sound track should take during creation
  38142. */
  38143. volume?: number;
  38144. /**
  38145. * Define if the sound track is the main sound track of the scene
  38146. */
  38147. mainTrack?: boolean;
  38148. }
  38149. /**
  38150. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38151. * It will be also used in a future release to apply effects on a specific track.
  38152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38153. */
  38154. export class SoundTrack {
  38155. /**
  38156. * The unique identifier of the sound track in the scene.
  38157. */
  38158. id: number;
  38159. /**
  38160. * The list of sounds included in the sound track.
  38161. */
  38162. soundCollection: Array<Sound>;
  38163. private _outputAudioNode;
  38164. private _scene;
  38165. private _connectedAnalyser;
  38166. private _options;
  38167. private _isInitialized;
  38168. /**
  38169. * Creates a new sound track.
  38170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38171. * @param scene Define the scene the sound track belongs to
  38172. * @param options
  38173. */
  38174. constructor(scene: Scene, options?: ISoundTrackOptions);
  38175. private _initializeSoundTrackAudioGraph;
  38176. /**
  38177. * Release the sound track and its associated resources
  38178. */
  38179. dispose(): void;
  38180. /**
  38181. * Adds a sound to this sound track
  38182. * @param sound define the cound to add
  38183. * @ignoreNaming
  38184. */
  38185. AddSound(sound: Sound): void;
  38186. /**
  38187. * Removes a sound to this sound track
  38188. * @param sound define the cound to remove
  38189. * @ignoreNaming
  38190. */
  38191. RemoveSound(sound: Sound): void;
  38192. /**
  38193. * Set a global volume for the full sound track.
  38194. * @param newVolume Define the new volume of the sound track
  38195. */
  38196. setVolume(newVolume: number): void;
  38197. /**
  38198. * Switch the panning model to HRTF:
  38199. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38201. */
  38202. switchPanningModelToHRTF(): void;
  38203. /**
  38204. * Switch the panning model to Equal Power:
  38205. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38207. */
  38208. switchPanningModelToEqualPower(): void;
  38209. /**
  38210. * Connect the sound track to an audio analyser allowing some amazing
  38211. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38213. * @param analyser The analyser to connect to the engine
  38214. */
  38215. connectToAnalyser(analyser: Analyser): void;
  38216. }
  38217. }
  38218. declare module BABYLON {
  38219. interface AbstractScene {
  38220. /**
  38221. * The list of sounds used in the scene.
  38222. */
  38223. sounds: Nullable<Array<Sound>>;
  38224. }
  38225. interface Scene {
  38226. /**
  38227. * @hidden
  38228. * Backing field
  38229. */
  38230. _mainSoundTrack: SoundTrack;
  38231. /**
  38232. * The main sound track played by the scene.
  38233. * It cotains your primary collection of sounds.
  38234. */
  38235. mainSoundTrack: SoundTrack;
  38236. /**
  38237. * The list of sound tracks added to the scene
  38238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38239. */
  38240. soundTracks: Nullable<Array<SoundTrack>>;
  38241. /**
  38242. * Gets a sound using a given name
  38243. * @param name defines the name to search for
  38244. * @return the found sound or null if not found at all.
  38245. */
  38246. getSoundByName(name: string): Nullable<Sound>;
  38247. /**
  38248. * Gets or sets if audio support is enabled
  38249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38250. */
  38251. audioEnabled: boolean;
  38252. /**
  38253. * Gets or sets if audio will be output to headphones
  38254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38255. */
  38256. headphone: boolean;
  38257. /**
  38258. * Gets or sets custom audio listener position provider
  38259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38260. */
  38261. audioListenerPositionProvider: Nullable<() => Vector3>;
  38262. /**
  38263. * Gets or sets a refresh rate when using 3D audio positioning
  38264. */
  38265. audioPositioningRefreshRate: number;
  38266. }
  38267. /**
  38268. * Defines the sound scene component responsible to manage any sounds
  38269. * in a given scene.
  38270. */
  38271. export class AudioSceneComponent implements ISceneSerializableComponent {
  38272. /**
  38273. * The component name helpfull to identify the component in the list of scene components.
  38274. */
  38275. readonly name: string;
  38276. /**
  38277. * The scene the component belongs to.
  38278. */
  38279. scene: Scene;
  38280. private _audioEnabled;
  38281. /**
  38282. * Gets whether audio is enabled or not.
  38283. * Please use related enable/disable method to switch state.
  38284. */
  38285. get audioEnabled(): boolean;
  38286. private _headphone;
  38287. /**
  38288. * Gets whether audio is outputing to headphone or not.
  38289. * Please use the according Switch methods to change output.
  38290. */
  38291. get headphone(): boolean;
  38292. /**
  38293. * Gets or sets a refresh rate when using 3D audio positioning
  38294. */
  38295. audioPositioningRefreshRate: number;
  38296. private _audioListenerPositionProvider;
  38297. /**
  38298. * Gets the current audio listener position provider
  38299. */
  38300. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38301. /**
  38302. * Sets a custom listener position for all sounds in the scene
  38303. * By default, this is the position of the first active camera
  38304. */
  38305. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38306. /**
  38307. * Creates a new instance of the component for the given scene
  38308. * @param scene Defines the scene to register the component in
  38309. */
  38310. constructor(scene: Scene);
  38311. /**
  38312. * Registers the component in a given scene
  38313. */
  38314. register(): void;
  38315. /**
  38316. * Rebuilds the elements related to this component in case of
  38317. * context lost for instance.
  38318. */
  38319. rebuild(): void;
  38320. /**
  38321. * Serializes the component data to the specified json object
  38322. * @param serializationObject The object to serialize to
  38323. */
  38324. serialize(serializationObject: any): void;
  38325. /**
  38326. * Adds all the elements from the container to the scene
  38327. * @param container the container holding the elements
  38328. */
  38329. addFromContainer(container: AbstractScene): void;
  38330. /**
  38331. * Removes all the elements in the container from the scene
  38332. * @param container contains the elements to remove
  38333. * @param dispose if the removed element should be disposed (default: false)
  38334. */
  38335. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38336. /**
  38337. * Disposes the component and the associated ressources.
  38338. */
  38339. dispose(): void;
  38340. /**
  38341. * Disables audio in the associated scene.
  38342. */
  38343. disableAudio(): void;
  38344. /**
  38345. * Enables audio in the associated scene.
  38346. */
  38347. enableAudio(): void;
  38348. /**
  38349. * Switch audio to headphone output.
  38350. */
  38351. switchAudioModeForHeadphones(): void;
  38352. /**
  38353. * Switch audio to normal speakers.
  38354. */
  38355. switchAudioModeForNormalSpeakers(): void;
  38356. private _cachedCameraDirection;
  38357. private _cachedCameraPosition;
  38358. private _lastCheck;
  38359. private _afterRender;
  38360. }
  38361. }
  38362. declare module BABYLON {
  38363. /**
  38364. * Wraps one or more Sound objects and selects one with random weight for playback.
  38365. */
  38366. export class WeightedSound {
  38367. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38368. loop: boolean;
  38369. private _coneInnerAngle;
  38370. private _coneOuterAngle;
  38371. private _volume;
  38372. /** A Sound is currently playing. */
  38373. isPlaying: boolean;
  38374. /** A Sound is currently paused. */
  38375. isPaused: boolean;
  38376. private _sounds;
  38377. private _weights;
  38378. private _currentIndex?;
  38379. /**
  38380. * Creates a new WeightedSound from the list of sounds given.
  38381. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38382. * @param sounds Array of Sounds that will be selected from.
  38383. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38384. */
  38385. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38386. /**
  38387. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38388. */
  38389. get directionalConeInnerAngle(): number;
  38390. /**
  38391. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38392. */
  38393. set directionalConeInnerAngle(value: number);
  38394. /**
  38395. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38396. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38397. */
  38398. get directionalConeOuterAngle(): number;
  38399. /**
  38400. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38401. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38402. */
  38403. set directionalConeOuterAngle(value: number);
  38404. /**
  38405. * Playback volume.
  38406. */
  38407. get volume(): number;
  38408. /**
  38409. * Playback volume.
  38410. */
  38411. set volume(value: number);
  38412. private _onended;
  38413. /**
  38414. * Suspend playback
  38415. */
  38416. pause(): void;
  38417. /**
  38418. * Stop playback
  38419. */
  38420. stop(): void;
  38421. /**
  38422. * Start playback.
  38423. * @param startOffset Position the clip head at a specific time in seconds.
  38424. */
  38425. play(startOffset?: number): void;
  38426. }
  38427. }
  38428. declare module BABYLON {
  38429. /**
  38430. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38431. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38432. */
  38433. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38434. /**
  38435. * Gets the name of the behavior.
  38436. */
  38437. get name(): string;
  38438. /**
  38439. * The easing function used by animations
  38440. */
  38441. static EasingFunction: BackEase;
  38442. /**
  38443. * The easing mode used by animations
  38444. */
  38445. static EasingMode: number;
  38446. /**
  38447. * The duration of the animation, in milliseconds
  38448. */
  38449. transitionDuration: number;
  38450. /**
  38451. * Length of the distance animated by the transition when lower radius is reached
  38452. */
  38453. lowerRadiusTransitionRange: number;
  38454. /**
  38455. * Length of the distance animated by the transition when upper radius is reached
  38456. */
  38457. upperRadiusTransitionRange: number;
  38458. private _autoTransitionRange;
  38459. /**
  38460. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38461. */
  38462. get autoTransitionRange(): boolean;
  38463. /**
  38464. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38465. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38466. */
  38467. set autoTransitionRange(value: boolean);
  38468. private _attachedCamera;
  38469. private _onAfterCheckInputsObserver;
  38470. private _onMeshTargetChangedObserver;
  38471. /**
  38472. * Initializes the behavior.
  38473. */
  38474. init(): void;
  38475. /**
  38476. * Attaches the behavior to its arc rotate camera.
  38477. * @param camera Defines the camera to attach the behavior to
  38478. */
  38479. attach(camera: ArcRotateCamera): void;
  38480. /**
  38481. * Detaches the behavior from its current arc rotate camera.
  38482. */
  38483. detach(): void;
  38484. private _radiusIsAnimating;
  38485. private _radiusBounceTransition;
  38486. private _animatables;
  38487. private _cachedWheelPrecision;
  38488. /**
  38489. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38490. * @param radiusLimit The limit to check against.
  38491. * @return Bool to indicate if at limit.
  38492. */
  38493. private _isRadiusAtLimit;
  38494. /**
  38495. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38496. * @param radiusDelta The delta by which to animate to. Can be negative.
  38497. */
  38498. private _applyBoundRadiusAnimation;
  38499. /**
  38500. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38501. */
  38502. protected _clearAnimationLocks(): void;
  38503. /**
  38504. * Stops and removes all animations that have been applied to the camera
  38505. */
  38506. stopAllAnimations(): void;
  38507. }
  38508. }
  38509. declare module BABYLON {
  38510. /**
  38511. * 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.
  38512. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38513. */
  38514. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38515. /**
  38516. * Gets the name of the behavior.
  38517. */
  38518. get name(): string;
  38519. private _mode;
  38520. private _radiusScale;
  38521. private _positionScale;
  38522. private _defaultElevation;
  38523. private _elevationReturnTime;
  38524. private _elevationReturnWaitTime;
  38525. private _zoomStopsAnimation;
  38526. private _framingTime;
  38527. /**
  38528. * The easing function used by animations
  38529. */
  38530. static EasingFunction: ExponentialEase;
  38531. /**
  38532. * The easing mode used by animations
  38533. */
  38534. static EasingMode: number;
  38535. /**
  38536. * Sets the current mode used by the behavior
  38537. */
  38538. set mode(mode: number);
  38539. /**
  38540. * Gets current mode used by the behavior.
  38541. */
  38542. get mode(): number;
  38543. /**
  38544. * Sets the scale applied to the radius (1 by default)
  38545. */
  38546. set radiusScale(radius: number);
  38547. /**
  38548. * Gets the scale applied to the radius
  38549. */
  38550. get radiusScale(): number;
  38551. /**
  38552. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38553. */
  38554. set positionScale(scale: number);
  38555. /**
  38556. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38557. */
  38558. get positionScale(): number;
  38559. /**
  38560. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38561. * behaviour is triggered, in radians.
  38562. */
  38563. set defaultElevation(elevation: number);
  38564. /**
  38565. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38566. * behaviour is triggered, in radians.
  38567. */
  38568. get defaultElevation(): number;
  38569. /**
  38570. * Sets the time (in milliseconds) taken to return to the default beta position.
  38571. * Negative value indicates camera should not return to default.
  38572. */
  38573. set elevationReturnTime(speed: number);
  38574. /**
  38575. * Gets the time (in milliseconds) taken to return to the default beta position.
  38576. * Negative value indicates camera should not return to default.
  38577. */
  38578. get elevationReturnTime(): number;
  38579. /**
  38580. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38581. */
  38582. set elevationReturnWaitTime(time: number);
  38583. /**
  38584. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38585. */
  38586. get elevationReturnWaitTime(): number;
  38587. /**
  38588. * Sets the flag that indicates if user zooming should stop animation.
  38589. */
  38590. set zoomStopsAnimation(flag: boolean);
  38591. /**
  38592. * Gets the flag that indicates if user zooming should stop animation.
  38593. */
  38594. get zoomStopsAnimation(): boolean;
  38595. /**
  38596. * Sets the transition time when framing the mesh, in milliseconds
  38597. */
  38598. set framingTime(time: number);
  38599. /**
  38600. * Gets the transition time when framing the mesh, in milliseconds
  38601. */
  38602. get framingTime(): number;
  38603. /**
  38604. * Define if the behavior should automatically change the configured
  38605. * camera limits and sensibilities.
  38606. */
  38607. autoCorrectCameraLimitsAndSensibility: boolean;
  38608. private _onPrePointerObservableObserver;
  38609. private _onAfterCheckInputsObserver;
  38610. private _onMeshTargetChangedObserver;
  38611. private _attachedCamera;
  38612. private _isPointerDown;
  38613. private _lastInteractionTime;
  38614. /**
  38615. * Initializes the behavior.
  38616. */
  38617. init(): void;
  38618. /**
  38619. * Attaches the behavior to its arc rotate camera.
  38620. * @param camera Defines the camera to attach the behavior to
  38621. */
  38622. attach(camera: ArcRotateCamera): void;
  38623. /**
  38624. * Detaches the behavior from its current arc rotate camera.
  38625. */
  38626. detach(): void;
  38627. private _animatables;
  38628. private _betaIsAnimating;
  38629. private _betaTransition;
  38630. private _radiusTransition;
  38631. private _vectorTransition;
  38632. /**
  38633. * Targets the given mesh and updates zoom level accordingly.
  38634. * @param mesh The mesh to target.
  38635. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38636. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38637. */
  38638. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38639. /**
  38640. * Targets the given mesh with its children and updates zoom level accordingly.
  38641. * @param mesh The mesh to target.
  38642. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38643. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38644. */
  38645. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38646. /**
  38647. * Targets the given meshes with their children and updates zoom level accordingly.
  38648. * @param meshes The mesh to target.
  38649. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38650. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38651. */
  38652. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38653. /**
  38654. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38655. * @param minimumWorld Determines the smaller position of the bounding box extend
  38656. * @param maximumWorld Determines the bigger position of the bounding box extend
  38657. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38658. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38659. */
  38660. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38661. /**
  38662. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38663. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38664. * frustum width.
  38665. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38666. * to fully enclose the mesh in the viewing frustum.
  38667. */
  38668. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38669. /**
  38670. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38671. * is automatically returned to its default position (expected to be above ground plane).
  38672. */
  38673. private _maintainCameraAboveGround;
  38674. /**
  38675. * Returns the frustum slope based on the canvas ratio and camera FOV
  38676. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38677. */
  38678. private _getFrustumSlope;
  38679. /**
  38680. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38681. */
  38682. private _clearAnimationLocks;
  38683. /**
  38684. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38685. */
  38686. private _applyUserInteraction;
  38687. /**
  38688. * Stops and removes all animations that have been applied to the camera
  38689. */
  38690. stopAllAnimations(): void;
  38691. /**
  38692. * Gets a value indicating if the user is moving the camera
  38693. */
  38694. get isUserIsMoving(): boolean;
  38695. /**
  38696. * The camera can move all the way towards the mesh.
  38697. */
  38698. static IgnoreBoundsSizeMode: number;
  38699. /**
  38700. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38701. */
  38702. static FitFrustumSidesMode: number;
  38703. }
  38704. }
  38705. declare module BABYLON {
  38706. /**
  38707. * Base class for Camera Pointer Inputs.
  38708. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38709. * for example usage.
  38710. */
  38711. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38712. /**
  38713. * Defines the camera the input is attached to.
  38714. */
  38715. abstract camera: Camera;
  38716. /**
  38717. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38718. */
  38719. protected _altKey: boolean;
  38720. protected _ctrlKey: boolean;
  38721. protected _metaKey: boolean;
  38722. protected _shiftKey: boolean;
  38723. /**
  38724. * Which mouse buttons were pressed at time of last mouse event.
  38725. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38726. */
  38727. protected _buttonsPressed: number;
  38728. /**
  38729. * Defines the buttons associated with the input to handle camera move.
  38730. */
  38731. buttons: number[];
  38732. /**
  38733. * Attach the input controls to a specific dom element to get the input from.
  38734. * @param element Defines the element the controls should be listened from
  38735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38736. */
  38737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38738. /**
  38739. * Detach the current controls from the specified dom element.
  38740. * @param element Defines the element to stop listening the inputs from
  38741. */
  38742. detachControl(element: Nullable<HTMLElement>): void;
  38743. /**
  38744. * Gets the class name of the current input.
  38745. * @returns the class name
  38746. */
  38747. getClassName(): string;
  38748. /**
  38749. * Get the friendly name associated with the input class.
  38750. * @returns the input friendly name
  38751. */
  38752. getSimpleName(): string;
  38753. /**
  38754. * Called on pointer POINTERDOUBLETAP event.
  38755. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38756. */
  38757. protected onDoubleTap(type: string): void;
  38758. /**
  38759. * Called on pointer POINTERMOVE event if only a single touch is active.
  38760. * Override this method to provide functionality.
  38761. */
  38762. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38763. /**
  38764. * Called on pointer POINTERMOVE event if multiple touches are active.
  38765. * Override this method to provide functionality.
  38766. */
  38767. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38768. /**
  38769. * Called on JS contextmenu event.
  38770. * Override this method to provide functionality.
  38771. */
  38772. protected onContextMenu(evt: PointerEvent): void;
  38773. /**
  38774. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38775. * press.
  38776. * Override this method to provide functionality.
  38777. */
  38778. protected onButtonDown(evt: PointerEvent): void;
  38779. /**
  38780. * Called each time a new POINTERUP event occurs. Ie, for each button
  38781. * release.
  38782. * Override this method to provide functionality.
  38783. */
  38784. protected onButtonUp(evt: PointerEvent): void;
  38785. /**
  38786. * Called when window becomes inactive.
  38787. * Override this method to provide functionality.
  38788. */
  38789. protected onLostFocus(): void;
  38790. private _pointerInput;
  38791. private _observer;
  38792. private _onLostFocus;
  38793. private pointA;
  38794. private pointB;
  38795. }
  38796. }
  38797. declare module BABYLON {
  38798. /**
  38799. * Manage the pointers inputs to control an arc rotate camera.
  38800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38801. */
  38802. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38803. /**
  38804. * Defines the camera the input is attached to.
  38805. */
  38806. camera: ArcRotateCamera;
  38807. /**
  38808. * Gets the class name of the current input.
  38809. * @returns the class name
  38810. */
  38811. getClassName(): string;
  38812. /**
  38813. * Defines the buttons associated with the input to handle camera move.
  38814. */
  38815. buttons: number[];
  38816. /**
  38817. * Defines the pointer angular sensibility along the X axis or how fast is
  38818. * the camera rotating.
  38819. */
  38820. angularSensibilityX: number;
  38821. /**
  38822. * Defines the pointer angular sensibility along the Y axis or how fast is
  38823. * the camera rotating.
  38824. */
  38825. angularSensibilityY: number;
  38826. /**
  38827. * Defines the pointer pinch precision or how fast is the camera zooming.
  38828. */
  38829. pinchPrecision: number;
  38830. /**
  38831. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38832. * from 0.
  38833. * It defines the percentage of current camera.radius to use as delta when
  38834. * pinch zoom is used.
  38835. */
  38836. pinchDeltaPercentage: number;
  38837. /**
  38838. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38839. * that any object in the plane at the camera's target point will scale
  38840. * perfectly with finger motion.
  38841. * Overrides pinchDeltaPercentage and pinchPrecision.
  38842. */
  38843. useNaturalPinchZoom: boolean;
  38844. /**
  38845. * Defines the pointer panning sensibility or how fast is the camera moving.
  38846. */
  38847. panningSensibility: number;
  38848. /**
  38849. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38850. */
  38851. multiTouchPanning: boolean;
  38852. /**
  38853. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38854. * zoom (pinch) through multitouch.
  38855. */
  38856. multiTouchPanAndZoom: boolean;
  38857. /**
  38858. * Revers pinch action direction.
  38859. */
  38860. pinchInwards: boolean;
  38861. private _isPanClick;
  38862. private _twoFingerActivityCount;
  38863. private _isPinching;
  38864. /**
  38865. * Called on pointer POINTERMOVE event if only a single touch is active.
  38866. */
  38867. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38868. /**
  38869. * Called on pointer POINTERDOUBLETAP event.
  38870. */
  38871. protected onDoubleTap(type: string): void;
  38872. /**
  38873. * Called on pointer POINTERMOVE event if multiple touches are active.
  38874. */
  38875. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38876. /**
  38877. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38878. * press.
  38879. */
  38880. protected onButtonDown(evt: PointerEvent): void;
  38881. /**
  38882. * Called each time a new POINTERUP event occurs. Ie, for each button
  38883. * release.
  38884. */
  38885. protected onButtonUp(evt: PointerEvent): void;
  38886. /**
  38887. * Called when window becomes inactive.
  38888. */
  38889. protected onLostFocus(): void;
  38890. }
  38891. }
  38892. declare module BABYLON {
  38893. /**
  38894. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38896. */
  38897. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38898. /**
  38899. * Defines the camera the input is attached to.
  38900. */
  38901. camera: ArcRotateCamera;
  38902. /**
  38903. * Defines the list of key codes associated with the up action (increase alpha)
  38904. */
  38905. keysUp: number[];
  38906. /**
  38907. * Defines the list of key codes associated with the down action (decrease alpha)
  38908. */
  38909. keysDown: number[];
  38910. /**
  38911. * Defines the list of key codes associated with the left action (increase beta)
  38912. */
  38913. keysLeft: number[];
  38914. /**
  38915. * Defines the list of key codes associated with the right action (decrease beta)
  38916. */
  38917. keysRight: number[];
  38918. /**
  38919. * Defines the list of key codes associated with the reset action.
  38920. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38921. */
  38922. keysReset: number[];
  38923. /**
  38924. * Defines the panning sensibility of the inputs.
  38925. * (How fast is the camera panning)
  38926. */
  38927. panningSensibility: number;
  38928. /**
  38929. * Defines the zooming sensibility of the inputs.
  38930. * (How fast is the camera zooming)
  38931. */
  38932. zoomingSensibility: number;
  38933. /**
  38934. * Defines whether maintaining the alt key down switch the movement mode from
  38935. * orientation to zoom.
  38936. */
  38937. useAltToZoom: boolean;
  38938. /**
  38939. * Rotation speed of the camera
  38940. */
  38941. angularSpeed: number;
  38942. private _keys;
  38943. private _ctrlPressed;
  38944. private _altPressed;
  38945. private _onCanvasBlurObserver;
  38946. private _onKeyboardObserver;
  38947. private _engine;
  38948. private _scene;
  38949. /**
  38950. * Attach the input controls to a specific dom element to get the input from.
  38951. * @param element Defines the element the controls should be listened from
  38952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38953. */
  38954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38955. /**
  38956. * Detach the current controls from the specified dom element.
  38957. * @param element Defines the element to stop listening the inputs from
  38958. */
  38959. detachControl(element: Nullable<HTMLElement>): void;
  38960. /**
  38961. * Update the current camera state depending on the inputs that have been used this frame.
  38962. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38963. */
  38964. checkInputs(): void;
  38965. /**
  38966. * Gets the class name of the current intput.
  38967. * @returns the class name
  38968. */
  38969. getClassName(): string;
  38970. /**
  38971. * Get the friendly name associated with the input class.
  38972. * @returns the input friendly name
  38973. */
  38974. getSimpleName(): string;
  38975. }
  38976. }
  38977. declare module BABYLON {
  38978. /**
  38979. * Manage the mouse wheel inputs to control an arc rotate camera.
  38980. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38981. */
  38982. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38983. /**
  38984. * Defines the camera the input is attached to.
  38985. */
  38986. camera: ArcRotateCamera;
  38987. /**
  38988. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38989. */
  38990. wheelPrecision: number;
  38991. /**
  38992. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38993. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38994. */
  38995. wheelDeltaPercentage: number;
  38996. private _wheel;
  38997. private _observer;
  38998. private computeDeltaFromMouseWheelLegacyEvent;
  38999. /**
  39000. * Attach the input controls to a specific dom element to get the input from.
  39001. * @param element Defines the element the controls should be listened from
  39002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39003. */
  39004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39005. /**
  39006. * Detach the current controls from the specified dom element.
  39007. * @param element Defines the element to stop listening the inputs from
  39008. */
  39009. detachControl(element: Nullable<HTMLElement>): void;
  39010. /**
  39011. * Gets the class name of the current intput.
  39012. * @returns the class name
  39013. */
  39014. getClassName(): string;
  39015. /**
  39016. * Get the friendly name associated with the input class.
  39017. * @returns the input friendly name
  39018. */
  39019. getSimpleName(): string;
  39020. }
  39021. }
  39022. declare module BABYLON {
  39023. /**
  39024. * Default Inputs manager for the ArcRotateCamera.
  39025. * It groups all the default supported inputs for ease of use.
  39026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39027. */
  39028. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39029. /**
  39030. * Instantiates a new ArcRotateCameraInputsManager.
  39031. * @param camera Defines the camera the inputs belong to
  39032. */
  39033. constructor(camera: ArcRotateCamera);
  39034. /**
  39035. * Add mouse wheel input support to the input manager.
  39036. * @returns the current input manager
  39037. */
  39038. addMouseWheel(): ArcRotateCameraInputsManager;
  39039. /**
  39040. * Add pointers input support to the input manager.
  39041. * @returns the current input manager
  39042. */
  39043. addPointers(): ArcRotateCameraInputsManager;
  39044. /**
  39045. * Add keyboard input support to the input manager.
  39046. * @returns the current input manager
  39047. */
  39048. addKeyboard(): ArcRotateCameraInputsManager;
  39049. }
  39050. }
  39051. declare module BABYLON {
  39052. /**
  39053. * This represents an orbital type of camera.
  39054. *
  39055. * 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.
  39056. * 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.
  39057. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39058. */
  39059. export class ArcRotateCamera extends TargetCamera {
  39060. /**
  39061. * Defines the rotation angle of the camera along the longitudinal axis.
  39062. */
  39063. alpha: number;
  39064. /**
  39065. * Defines the rotation angle of the camera along the latitudinal axis.
  39066. */
  39067. beta: number;
  39068. /**
  39069. * Defines the radius of the camera from it s target point.
  39070. */
  39071. radius: number;
  39072. protected _target: Vector3;
  39073. protected _targetHost: Nullable<AbstractMesh>;
  39074. /**
  39075. * Defines the target point of the camera.
  39076. * The camera looks towards it form the radius distance.
  39077. */
  39078. get target(): Vector3;
  39079. set target(value: Vector3);
  39080. /**
  39081. * Define the current local position of the camera in the scene
  39082. */
  39083. get position(): Vector3;
  39084. set position(newPosition: Vector3);
  39085. protected _upVector: Vector3;
  39086. protected _upToYMatrix: Matrix;
  39087. protected _YToUpMatrix: Matrix;
  39088. /**
  39089. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39090. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39091. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39092. */
  39093. set upVector(vec: Vector3);
  39094. get upVector(): Vector3;
  39095. /**
  39096. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39097. */
  39098. setMatUp(): void;
  39099. /**
  39100. * Current inertia value on the longitudinal axis.
  39101. * The bigger this number the longer it will take for the camera to stop.
  39102. */
  39103. inertialAlphaOffset: number;
  39104. /**
  39105. * Current inertia value on the latitudinal axis.
  39106. * The bigger this number the longer it will take for the camera to stop.
  39107. */
  39108. inertialBetaOffset: number;
  39109. /**
  39110. * Current inertia value on the radius axis.
  39111. * The bigger this number the longer it will take for the camera to stop.
  39112. */
  39113. inertialRadiusOffset: number;
  39114. /**
  39115. * Minimum allowed angle on the longitudinal axis.
  39116. * This can help limiting how the Camera is able to move in the scene.
  39117. */
  39118. lowerAlphaLimit: Nullable<number>;
  39119. /**
  39120. * Maximum allowed angle on the longitudinal axis.
  39121. * This can help limiting how the Camera is able to move in the scene.
  39122. */
  39123. upperAlphaLimit: Nullable<number>;
  39124. /**
  39125. * Minimum allowed angle on the latitudinal axis.
  39126. * This can help limiting how the Camera is able to move in the scene.
  39127. */
  39128. lowerBetaLimit: number;
  39129. /**
  39130. * Maximum allowed angle on the latitudinal axis.
  39131. * This can help limiting how the Camera is able to move in the scene.
  39132. */
  39133. upperBetaLimit: number;
  39134. /**
  39135. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39136. * This can help limiting how the Camera is able to move in the scene.
  39137. */
  39138. lowerRadiusLimit: Nullable<number>;
  39139. /**
  39140. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39141. * This can help limiting how the Camera is able to move in the scene.
  39142. */
  39143. upperRadiusLimit: Nullable<number>;
  39144. /**
  39145. * Defines the current inertia value used during panning of the camera along the X axis.
  39146. */
  39147. inertialPanningX: number;
  39148. /**
  39149. * Defines the current inertia value used during panning of the camera along the Y axis.
  39150. */
  39151. inertialPanningY: number;
  39152. /**
  39153. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39154. * Basically if your fingers moves away from more than this distance you will be considered
  39155. * in pinch mode.
  39156. */
  39157. pinchToPanMaxDistance: number;
  39158. /**
  39159. * Defines the maximum distance the camera can pan.
  39160. * This could help keeping the cammera always in your scene.
  39161. */
  39162. panningDistanceLimit: Nullable<number>;
  39163. /**
  39164. * Defines the target of the camera before paning.
  39165. */
  39166. panningOriginTarget: Vector3;
  39167. /**
  39168. * Defines the value of the inertia used during panning.
  39169. * 0 would mean stop inertia and one would mean no decelleration at all.
  39170. */
  39171. panningInertia: number;
  39172. /**
  39173. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39174. */
  39175. get angularSensibilityX(): number;
  39176. set angularSensibilityX(value: number);
  39177. /**
  39178. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39179. */
  39180. get angularSensibilityY(): number;
  39181. set angularSensibilityY(value: number);
  39182. /**
  39183. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39184. */
  39185. get pinchPrecision(): number;
  39186. set pinchPrecision(value: number);
  39187. /**
  39188. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39189. * It will be used instead of pinchDeltaPrecision if different from 0.
  39190. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39191. */
  39192. get pinchDeltaPercentage(): number;
  39193. set pinchDeltaPercentage(value: number);
  39194. /**
  39195. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39196. * and pinch delta percentage.
  39197. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39198. * that any object in the plane at the camera's target point will scale
  39199. * perfectly with finger motion.
  39200. */
  39201. get useNaturalPinchZoom(): boolean;
  39202. set useNaturalPinchZoom(value: boolean);
  39203. /**
  39204. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39205. */
  39206. get panningSensibility(): number;
  39207. set panningSensibility(value: number);
  39208. /**
  39209. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39210. */
  39211. get keysUp(): number[];
  39212. set keysUp(value: number[]);
  39213. /**
  39214. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39215. */
  39216. get keysDown(): number[];
  39217. set keysDown(value: number[]);
  39218. /**
  39219. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39220. */
  39221. get keysLeft(): number[];
  39222. set keysLeft(value: number[]);
  39223. /**
  39224. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39225. */
  39226. get keysRight(): number[];
  39227. set keysRight(value: number[]);
  39228. /**
  39229. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39230. */
  39231. get wheelPrecision(): number;
  39232. set wheelPrecision(value: number);
  39233. /**
  39234. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39235. * It will be used instead of pinchDeltaPrecision if different from 0.
  39236. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39237. */
  39238. get wheelDeltaPercentage(): number;
  39239. set wheelDeltaPercentage(value: number);
  39240. /**
  39241. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39242. */
  39243. zoomOnFactor: number;
  39244. /**
  39245. * Defines a screen offset for the camera position.
  39246. */
  39247. targetScreenOffset: Vector2;
  39248. /**
  39249. * Allows the camera to be completely reversed.
  39250. * If false the camera can not arrive upside down.
  39251. */
  39252. allowUpsideDown: boolean;
  39253. /**
  39254. * Define if double tap/click is used to restore the previously saved state of the camera.
  39255. */
  39256. useInputToRestoreState: boolean;
  39257. /** @hidden */
  39258. _viewMatrix: Matrix;
  39259. /** @hidden */
  39260. _useCtrlForPanning: boolean;
  39261. /** @hidden */
  39262. _panningMouseButton: number;
  39263. /**
  39264. * Defines the input associated to the camera.
  39265. */
  39266. inputs: ArcRotateCameraInputsManager;
  39267. /** @hidden */
  39268. _reset: () => void;
  39269. /**
  39270. * Defines the allowed panning axis.
  39271. */
  39272. panningAxis: Vector3;
  39273. protected _localDirection: Vector3;
  39274. protected _transformedDirection: Vector3;
  39275. private _bouncingBehavior;
  39276. /**
  39277. * Gets the bouncing behavior of the camera if it has been enabled.
  39278. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39279. */
  39280. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39281. /**
  39282. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39283. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39284. */
  39285. get useBouncingBehavior(): boolean;
  39286. set useBouncingBehavior(value: boolean);
  39287. private _framingBehavior;
  39288. /**
  39289. * Gets the framing behavior of the camera if it has been enabled.
  39290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39291. */
  39292. get framingBehavior(): Nullable<FramingBehavior>;
  39293. /**
  39294. * Defines if the framing behavior of the camera is enabled on the camera.
  39295. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39296. */
  39297. get useFramingBehavior(): boolean;
  39298. set useFramingBehavior(value: boolean);
  39299. private _autoRotationBehavior;
  39300. /**
  39301. * Gets the auto rotation behavior of the camera if it has been enabled.
  39302. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39303. */
  39304. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39305. /**
  39306. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39307. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39308. */
  39309. get useAutoRotationBehavior(): boolean;
  39310. set useAutoRotationBehavior(value: boolean);
  39311. /**
  39312. * Observable triggered when the mesh target has been changed on the camera.
  39313. */
  39314. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39315. /**
  39316. * Event raised when the camera is colliding with a mesh.
  39317. */
  39318. onCollide: (collidedMesh: AbstractMesh) => void;
  39319. /**
  39320. * Defines whether the camera should check collision with the objects oh the scene.
  39321. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39322. */
  39323. checkCollisions: boolean;
  39324. /**
  39325. * Defines the collision radius of the camera.
  39326. * This simulates a sphere around the camera.
  39327. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39328. */
  39329. collisionRadius: Vector3;
  39330. protected _collider: Collider;
  39331. protected _previousPosition: Vector3;
  39332. protected _collisionVelocity: Vector3;
  39333. protected _newPosition: Vector3;
  39334. protected _previousAlpha: number;
  39335. protected _previousBeta: number;
  39336. protected _previousRadius: number;
  39337. protected _collisionTriggered: boolean;
  39338. protected _targetBoundingCenter: Nullable<Vector3>;
  39339. private _computationVector;
  39340. /**
  39341. * Instantiates a new ArcRotateCamera in a given scene
  39342. * @param name Defines the name of the camera
  39343. * @param alpha Defines the camera rotation along the logitudinal axis
  39344. * @param beta Defines the camera rotation along the latitudinal axis
  39345. * @param radius Defines the camera distance from its target
  39346. * @param target Defines the camera target
  39347. * @param scene Defines the scene the camera belongs to
  39348. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39349. */
  39350. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39351. /** @hidden */
  39352. _initCache(): void;
  39353. /** @hidden */
  39354. _updateCache(ignoreParentClass?: boolean): void;
  39355. protected _getTargetPosition(): Vector3;
  39356. private _storedAlpha;
  39357. private _storedBeta;
  39358. private _storedRadius;
  39359. private _storedTarget;
  39360. private _storedTargetScreenOffset;
  39361. /**
  39362. * Stores the current state of the camera (alpha, beta, radius and target)
  39363. * @returns the camera itself
  39364. */
  39365. storeState(): Camera;
  39366. /**
  39367. * @hidden
  39368. * Restored camera state. You must call storeState() first
  39369. */
  39370. _restoreStateValues(): boolean;
  39371. /** @hidden */
  39372. _isSynchronizedViewMatrix(): boolean;
  39373. /**
  39374. * Attached controls to the current camera.
  39375. * @param element Defines the element the controls should be listened from
  39376. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39377. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39378. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39379. */
  39380. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39381. /**
  39382. * Detach the current controls from the camera.
  39383. * The camera will stop reacting to inputs.
  39384. * @param element Defines the element to stop listening the inputs from
  39385. */
  39386. detachControl(element: HTMLElement): void;
  39387. /** @hidden */
  39388. _checkInputs(): void;
  39389. protected _checkLimits(): void;
  39390. /**
  39391. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39392. */
  39393. rebuildAnglesAndRadius(): void;
  39394. /**
  39395. * Use a position to define the current camera related information like alpha, beta and radius
  39396. * @param position Defines the position to set the camera at
  39397. */
  39398. setPosition(position: Vector3): void;
  39399. /**
  39400. * Defines the target the camera should look at.
  39401. * This will automatically adapt alpha beta and radius to fit within the new target.
  39402. * @param target Defines the new target as a Vector or a mesh
  39403. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39404. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39405. */
  39406. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39407. /** @hidden */
  39408. _getViewMatrix(): Matrix;
  39409. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39410. /**
  39411. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39412. * @param meshes Defines the mesh to zoom on
  39413. * @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)
  39414. */
  39415. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39416. /**
  39417. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39418. * The target will be changed but the radius
  39419. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39420. * @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)
  39421. */
  39422. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39423. min: Vector3;
  39424. max: Vector3;
  39425. distance: number;
  39426. }, doNotUpdateMaxZ?: boolean): void;
  39427. /**
  39428. * @override
  39429. * Override Camera.createRigCamera
  39430. */
  39431. createRigCamera(name: string, cameraIndex: number): Camera;
  39432. /**
  39433. * @hidden
  39434. * @override
  39435. * Override Camera._updateRigCameras
  39436. */
  39437. _updateRigCameras(): void;
  39438. /**
  39439. * Destroy the camera and release the current resources hold by it.
  39440. */
  39441. dispose(): void;
  39442. /**
  39443. * Gets the current object class name.
  39444. * @return the class name
  39445. */
  39446. getClassName(): string;
  39447. }
  39448. }
  39449. declare module BABYLON {
  39450. /**
  39451. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39452. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39453. */
  39454. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39455. /**
  39456. * Gets the name of the behavior.
  39457. */
  39458. get name(): string;
  39459. private _zoomStopsAnimation;
  39460. private _idleRotationSpeed;
  39461. private _idleRotationWaitTime;
  39462. private _idleRotationSpinupTime;
  39463. /**
  39464. * Sets the flag that indicates if user zooming should stop animation.
  39465. */
  39466. set zoomStopsAnimation(flag: boolean);
  39467. /**
  39468. * Gets the flag that indicates if user zooming should stop animation.
  39469. */
  39470. get zoomStopsAnimation(): boolean;
  39471. /**
  39472. * Sets the default speed at which the camera rotates around the model.
  39473. */
  39474. set idleRotationSpeed(speed: number);
  39475. /**
  39476. * Gets the default speed at which the camera rotates around the model.
  39477. */
  39478. get idleRotationSpeed(): number;
  39479. /**
  39480. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39481. */
  39482. set idleRotationWaitTime(time: number);
  39483. /**
  39484. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39485. */
  39486. get idleRotationWaitTime(): number;
  39487. /**
  39488. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39489. */
  39490. set idleRotationSpinupTime(time: number);
  39491. /**
  39492. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39493. */
  39494. get idleRotationSpinupTime(): number;
  39495. /**
  39496. * Gets a value indicating if the camera is currently rotating because of this behavior
  39497. */
  39498. get rotationInProgress(): boolean;
  39499. private _onPrePointerObservableObserver;
  39500. private _onAfterCheckInputsObserver;
  39501. private _attachedCamera;
  39502. private _isPointerDown;
  39503. private _lastFrameTime;
  39504. private _lastInteractionTime;
  39505. private _cameraRotationSpeed;
  39506. /**
  39507. * Initializes the behavior.
  39508. */
  39509. init(): void;
  39510. /**
  39511. * Attaches the behavior to its arc rotate camera.
  39512. * @param camera Defines the camera to attach the behavior to
  39513. */
  39514. attach(camera: ArcRotateCamera): void;
  39515. /**
  39516. * Detaches the behavior from its current arc rotate camera.
  39517. */
  39518. detach(): void;
  39519. /**
  39520. * Returns true if user is scrolling.
  39521. * @return true if user is scrolling.
  39522. */
  39523. private _userIsZooming;
  39524. private _lastFrameRadius;
  39525. private _shouldAnimationStopForInteraction;
  39526. /**
  39527. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39528. */
  39529. private _applyUserInteraction;
  39530. private _userIsMoving;
  39531. }
  39532. }
  39533. declare module BABYLON {
  39534. /**
  39535. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39536. */
  39537. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39538. private ui;
  39539. /**
  39540. * The name of the behavior
  39541. */
  39542. name: string;
  39543. /**
  39544. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39545. */
  39546. distanceAwayFromFace: number;
  39547. /**
  39548. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39549. */
  39550. distanceAwayFromBottomOfFace: number;
  39551. private _faceVectors;
  39552. private _target;
  39553. private _scene;
  39554. private _onRenderObserver;
  39555. private _tmpMatrix;
  39556. private _tmpVector;
  39557. /**
  39558. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39559. * @param ui The transform node that should be attched to the mesh
  39560. */
  39561. constructor(ui: TransformNode);
  39562. /**
  39563. * Initializes the behavior
  39564. */
  39565. init(): void;
  39566. private _closestFace;
  39567. private _zeroVector;
  39568. private _lookAtTmpMatrix;
  39569. private _lookAtToRef;
  39570. /**
  39571. * Attaches the AttachToBoxBehavior to the passed in mesh
  39572. * @param target The mesh that the specified node will be attached to
  39573. */
  39574. attach(target: Mesh): void;
  39575. /**
  39576. * Detaches the behavior from the mesh
  39577. */
  39578. detach(): void;
  39579. }
  39580. }
  39581. declare module BABYLON {
  39582. /**
  39583. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39584. */
  39585. export class FadeInOutBehavior implements Behavior<Mesh> {
  39586. /**
  39587. * Time in milliseconds to delay before fading in (Default: 0)
  39588. */
  39589. delay: number;
  39590. /**
  39591. * Time in milliseconds for the mesh to fade in (Default: 300)
  39592. */
  39593. fadeInTime: number;
  39594. private _millisecondsPerFrame;
  39595. private _hovered;
  39596. private _hoverValue;
  39597. private _ownerNode;
  39598. /**
  39599. * Instatiates the FadeInOutBehavior
  39600. */
  39601. constructor();
  39602. /**
  39603. * The name of the behavior
  39604. */
  39605. get name(): string;
  39606. /**
  39607. * Initializes the behavior
  39608. */
  39609. init(): void;
  39610. /**
  39611. * Attaches the fade behavior on the passed in mesh
  39612. * @param ownerNode The mesh that will be faded in/out once attached
  39613. */
  39614. attach(ownerNode: Mesh): void;
  39615. /**
  39616. * Detaches the behavior from the mesh
  39617. */
  39618. detach(): void;
  39619. /**
  39620. * Triggers the mesh to begin fading in or out
  39621. * @param value if the object should fade in or out (true to fade in)
  39622. */
  39623. fadeIn(value: boolean): void;
  39624. private _update;
  39625. private _setAllVisibility;
  39626. }
  39627. }
  39628. declare module BABYLON {
  39629. /**
  39630. * Class containing a set of static utilities functions for managing Pivots
  39631. * @hidden
  39632. */
  39633. export class PivotTools {
  39634. private static _PivotCached;
  39635. private static _OldPivotPoint;
  39636. private static _PivotTranslation;
  39637. private static _PivotTmpVector;
  39638. /** @hidden */
  39639. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39640. /** @hidden */
  39641. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39642. }
  39643. }
  39644. declare module BABYLON {
  39645. /**
  39646. * Class containing static functions to help procedurally build meshes
  39647. */
  39648. export class PlaneBuilder {
  39649. /**
  39650. * Creates a plane mesh
  39651. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39652. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39653. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39655. * * 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
  39656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39657. * @param name defines the name of the mesh
  39658. * @param options defines the options used to create the mesh
  39659. * @param scene defines the hosting scene
  39660. * @returns the plane mesh
  39661. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39662. */
  39663. static CreatePlane(name: string, options: {
  39664. size?: number;
  39665. width?: number;
  39666. height?: number;
  39667. sideOrientation?: number;
  39668. frontUVs?: Vector4;
  39669. backUVs?: Vector4;
  39670. updatable?: boolean;
  39671. sourcePlane?: Plane;
  39672. }, scene?: Nullable<Scene>): Mesh;
  39673. }
  39674. }
  39675. declare module BABYLON {
  39676. /**
  39677. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39678. */
  39679. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39680. private static _AnyMouseID;
  39681. /**
  39682. * Abstract mesh the behavior is set on
  39683. */
  39684. attachedNode: AbstractMesh;
  39685. private _dragPlane;
  39686. private _scene;
  39687. private _pointerObserver;
  39688. private _beforeRenderObserver;
  39689. private static _planeScene;
  39690. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39691. /**
  39692. * 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)
  39693. */
  39694. maxDragAngle: number;
  39695. /**
  39696. * @hidden
  39697. */
  39698. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39699. /**
  39700. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39701. */
  39702. currentDraggingPointerID: number;
  39703. /**
  39704. * The last position where the pointer hit the drag plane in world space
  39705. */
  39706. lastDragPosition: Vector3;
  39707. /**
  39708. * If the behavior is currently in a dragging state
  39709. */
  39710. dragging: boolean;
  39711. /**
  39712. * 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)
  39713. */
  39714. dragDeltaRatio: number;
  39715. /**
  39716. * If the drag plane orientation should be updated during the dragging (Default: true)
  39717. */
  39718. updateDragPlane: boolean;
  39719. private _debugMode;
  39720. private _moving;
  39721. /**
  39722. * Fires each time the attached mesh is dragged with the pointer
  39723. * * delta between last drag position and current drag position in world space
  39724. * * dragDistance along the drag axis
  39725. * * dragPlaneNormal normal of the current drag plane used during the drag
  39726. * * dragPlanePoint in world space where the drag intersects the drag plane
  39727. */
  39728. onDragObservable: Observable<{
  39729. delta: Vector3;
  39730. dragPlanePoint: Vector3;
  39731. dragPlaneNormal: Vector3;
  39732. dragDistance: number;
  39733. pointerId: number;
  39734. }>;
  39735. /**
  39736. * Fires each time a drag begins (eg. mouse down on mesh)
  39737. */
  39738. onDragStartObservable: Observable<{
  39739. dragPlanePoint: Vector3;
  39740. pointerId: number;
  39741. }>;
  39742. /**
  39743. * Fires each time a drag ends (eg. mouse release after drag)
  39744. */
  39745. onDragEndObservable: Observable<{
  39746. dragPlanePoint: Vector3;
  39747. pointerId: number;
  39748. }>;
  39749. /**
  39750. * If the attached mesh should be moved when dragged
  39751. */
  39752. moveAttached: boolean;
  39753. /**
  39754. * If the drag behavior will react to drag events (Default: true)
  39755. */
  39756. enabled: boolean;
  39757. /**
  39758. * If pointer events should start and release the drag (Default: true)
  39759. */
  39760. startAndReleaseDragOnPointerEvents: boolean;
  39761. /**
  39762. * If camera controls should be detached during the drag
  39763. */
  39764. detachCameraControls: boolean;
  39765. /**
  39766. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39767. */
  39768. useObjectOrientationForDragging: boolean;
  39769. private _options;
  39770. /**
  39771. * Gets the options used by the behavior
  39772. */
  39773. get options(): {
  39774. dragAxis?: Vector3;
  39775. dragPlaneNormal?: Vector3;
  39776. };
  39777. /**
  39778. * Sets the options used by the behavior
  39779. */
  39780. set options(options: {
  39781. dragAxis?: Vector3;
  39782. dragPlaneNormal?: Vector3;
  39783. });
  39784. /**
  39785. * Creates a pointer drag behavior that can be attached to a mesh
  39786. * @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)
  39787. */
  39788. constructor(options?: {
  39789. dragAxis?: Vector3;
  39790. dragPlaneNormal?: Vector3;
  39791. });
  39792. /**
  39793. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39794. */
  39795. validateDrag: (targetPosition: Vector3) => boolean;
  39796. /**
  39797. * The name of the behavior
  39798. */
  39799. get name(): string;
  39800. /**
  39801. * Initializes the behavior
  39802. */
  39803. init(): void;
  39804. private _tmpVector;
  39805. private _alternatePickedPoint;
  39806. private _worldDragAxis;
  39807. private _targetPosition;
  39808. private _attachedElement;
  39809. /**
  39810. * Attaches the drag behavior the passed in mesh
  39811. * @param ownerNode The mesh that will be dragged around once attached
  39812. * @param predicate Predicate to use for pick filtering
  39813. */
  39814. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39815. /**
  39816. * Force relase the drag action by code.
  39817. */
  39818. releaseDrag(): void;
  39819. private _startDragRay;
  39820. private _lastPointerRay;
  39821. /**
  39822. * Simulates the start of a pointer drag event on the behavior
  39823. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39824. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39825. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39826. */
  39827. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39828. private _startDrag;
  39829. private _dragDelta;
  39830. private _moveDrag;
  39831. private _pickWithRayOnDragPlane;
  39832. private _pointA;
  39833. private _pointB;
  39834. private _pointC;
  39835. private _lineA;
  39836. private _lineB;
  39837. private _localAxis;
  39838. private _lookAt;
  39839. private _updateDragPlanePosition;
  39840. /**
  39841. * Detaches the behavior from the mesh
  39842. */
  39843. detach(): void;
  39844. }
  39845. }
  39846. declare module BABYLON {
  39847. /**
  39848. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39849. */
  39850. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39851. private _dragBehaviorA;
  39852. private _dragBehaviorB;
  39853. private _startDistance;
  39854. private _initialScale;
  39855. private _targetScale;
  39856. private _ownerNode;
  39857. private _sceneRenderObserver;
  39858. /**
  39859. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39860. */
  39861. constructor();
  39862. /**
  39863. * The name of the behavior
  39864. */
  39865. get name(): string;
  39866. /**
  39867. * Initializes the behavior
  39868. */
  39869. init(): void;
  39870. private _getCurrentDistance;
  39871. /**
  39872. * Attaches the scale behavior the passed in mesh
  39873. * @param ownerNode The mesh that will be scaled around once attached
  39874. */
  39875. attach(ownerNode: Mesh): void;
  39876. /**
  39877. * Detaches the behavior from the mesh
  39878. */
  39879. detach(): void;
  39880. }
  39881. }
  39882. declare module BABYLON {
  39883. /**
  39884. * 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
  39885. */
  39886. export class SixDofDragBehavior implements Behavior<Mesh> {
  39887. private static _virtualScene;
  39888. private _ownerNode;
  39889. private _sceneRenderObserver;
  39890. private _scene;
  39891. private _targetPosition;
  39892. private _virtualOriginMesh;
  39893. private _virtualDragMesh;
  39894. private _pointerObserver;
  39895. private _moving;
  39896. private _startingOrientation;
  39897. private _attachedElement;
  39898. /**
  39899. * 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)
  39900. */
  39901. private zDragFactor;
  39902. /**
  39903. * If the object should rotate to face the drag origin
  39904. */
  39905. rotateDraggedObject: boolean;
  39906. /**
  39907. * If the behavior is currently in a dragging state
  39908. */
  39909. dragging: boolean;
  39910. /**
  39911. * 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)
  39912. */
  39913. dragDeltaRatio: number;
  39914. /**
  39915. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39916. */
  39917. currentDraggingPointerID: number;
  39918. /**
  39919. * If camera controls should be detached during the drag
  39920. */
  39921. detachCameraControls: boolean;
  39922. /**
  39923. * Fires each time a drag starts
  39924. */
  39925. onDragStartObservable: Observable<{}>;
  39926. /**
  39927. * Fires each time a drag ends (eg. mouse release after drag)
  39928. */
  39929. onDragEndObservable: Observable<{}>;
  39930. /**
  39931. * 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
  39932. */
  39933. constructor();
  39934. /**
  39935. * The name of the behavior
  39936. */
  39937. get name(): string;
  39938. /**
  39939. * Initializes the behavior
  39940. */
  39941. init(): void;
  39942. /**
  39943. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39944. */
  39945. private get _pointerCamera();
  39946. /**
  39947. * Attaches the scale behavior the passed in mesh
  39948. * @param ownerNode The mesh that will be scaled around once attached
  39949. */
  39950. attach(ownerNode: Mesh): void;
  39951. /**
  39952. * Detaches the behavior from the mesh
  39953. */
  39954. detach(): void;
  39955. }
  39956. }
  39957. declare module BABYLON {
  39958. /**
  39959. * Class used to apply inverse kinematics to bones
  39960. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39961. */
  39962. export class BoneIKController {
  39963. private static _tmpVecs;
  39964. private static _tmpQuat;
  39965. private static _tmpMats;
  39966. /**
  39967. * Gets or sets the target mesh
  39968. */
  39969. targetMesh: AbstractMesh;
  39970. /** Gets or sets the mesh used as pole */
  39971. poleTargetMesh: AbstractMesh;
  39972. /**
  39973. * Gets or sets the bone used as pole
  39974. */
  39975. poleTargetBone: Nullable<Bone>;
  39976. /**
  39977. * Gets or sets the target position
  39978. */
  39979. targetPosition: Vector3;
  39980. /**
  39981. * Gets or sets the pole target position
  39982. */
  39983. poleTargetPosition: Vector3;
  39984. /**
  39985. * Gets or sets the pole target local offset
  39986. */
  39987. poleTargetLocalOffset: Vector3;
  39988. /**
  39989. * Gets or sets the pole angle
  39990. */
  39991. poleAngle: number;
  39992. /**
  39993. * Gets or sets the mesh associated with the controller
  39994. */
  39995. mesh: AbstractMesh;
  39996. /**
  39997. * 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)
  39998. */
  39999. slerpAmount: number;
  40000. private _bone1Quat;
  40001. private _bone1Mat;
  40002. private _bone2Ang;
  40003. private _bone1;
  40004. private _bone2;
  40005. private _bone1Length;
  40006. private _bone2Length;
  40007. private _maxAngle;
  40008. private _maxReach;
  40009. private _rightHandedSystem;
  40010. private _bendAxis;
  40011. private _slerping;
  40012. private _adjustRoll;
  40013. /**
  40014. * Gets or sets maximum allowed angle
  40015. */
  40016. get maxAngle(): number;
  40017. set maxAngle(value: number);
  40018. /**
  40019. * Creates a new BoneIKController
  40020. * @param mesh defines the mesh to control
  40021. * @param bone defines the bone to control
  40022. * @param options defines options to set up the controller
  40023. */
  40024. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40025. targetMesh?: AbstractMesh;
  40026. poleTargetMesh?: AbstractMesh;
  40027. poleTargetBone?: Bone;
  40028. poleTargetLocalOffset?: Vector3;
  40029. poleAngle?: number;
  40030. bendAxis?: Vector3;
  40031. maxAngle?: number;
  40032. slerpAmount?: number;
  40033. });
  40034. private _setMaxAngle;
  40035. /**
  40036. * Force the controller to update the bones
  40037. */
  40038. update(): void;
  40039. }
  40040. }
  40041. declare module BABYLON {
  40042. /**
  40043. * Class used to make a bone look toward a point in space
  40044. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40045. */
  40046. export class BoneLookController {
  40047. private static _tmpVecs;
  40048. private static _tmpQuat;
  40049. private static _tmpMats;
  40050. /**
  40051. * The target Vector3 that the bone will look at
  40052. */
  40053. target: Vector3;
  40054. /**
  40055. * The mesh that the bone is attached to
  40056. */
  40057. mesh: AbstractMesh;
  40058. /**
  40059. * The bone that will be looking to the target
  40060. */
  40061. bone: Bone;
  40062. /**
  40063. * The up axis of the coordinate system that is used when the bone is rotated
  40064. */
  40065. upAxis: Vector3;
  40066. /**
  40067. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40068. */
  40069. upAxisSpace: Space;
  40070. /**
  40071. * Used to make an adjustment to the yaw of the bone
  40072. */
  40073. adjustYaw: number;
  40074. /**
  40075. * Used to make an adjustment to the pitch of the bone
  40076. */
  40077. adjustPitch: number;
  40078. /**
  40079. * Used to make an adjustment to the roll of the bone
  40080. */
  40081. adjustRoll: number;
  40082. /**
  40083. * 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)
  40084. */
  40085. slerpAmount: number;
  40086. private _minYaw;
  40087. private _maxYaw;
  40088. private _minPitch;
  40089. private _maxPitch;
  40090. private _minYawSin;
  40091. private _minYawCos;
  40092. private _maxYawSin;
  40093. private _maxYawCos;
  40094. private _midYawConstraint;
  40095. private _minPitchTan;
  40096. private _maxPitchTan;
  40097. private _boneQuat;
  40098. private _slerping;
  40099. private _transformYawPitch;
  40100. private _transformYawPitchInv;
  40101. private _firstFrameSkipped;
  40102. private _yawRange;
  40103. private _fowardAxis;
  40104. /**
  40105. * Gets or sets the minimum yaw angle that the bone can look to
  40106. */
  40107. get minYaw(): number;
  40108. set minYaw(value: number);
  40109. /**
  40110. * Gets or sets the maximum yaw angle that the bone can look to
  40111. */
  40112. get maxYaw(): number;
  40113. set maxYaw(value: number);
  40114. /**
  40115. * Gets or sets the minimum pitch angle that the bone can look to
  40116. */
  40117. get minPitch(): number;
  40118. set minPitch(value: number);
  40119. /**
  40120. * Gets or sets the maximum pitch angle that the bone can look to
  40121. */
  40122. get maxPitch(): number;
  40123. set maxPitch(value: number);
  40124. /**
  40125. * Create a BoneLookController
  40126. * @param mesh the mesh that the bone belongs to
  40127. * @param bone the bone that will be looking to the target
  40128. * @param target the target Vector3 to look at
  40129. * @param options optional settings:
  40130. * * maxYaw: the maximum angle the bone will yaw to
  40131. * * minYaw: the minimum angle the bone will yaw to
  40132. * * maxPitch: the maximum angle the bone will pitch to
  40133. * * minPitch: the minimum angle the bone will yaw to
  40134. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40135. * * upAxis: the up axis of the coordinate system
  40136. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40137. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40138. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40139. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40140. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40141. * * adjustRoll: used to make an adjustment to the roll of the bone
  40142. **/
  40143. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40144. maxYaw?: number;
  40145. minYaw?: number;
  40146. maxPitch?: number;
  40147. minPitch?: number;
  40148. slerpAmount?: number;
  40149. upAxis?: Vector3;
  40150. upAxisSpace?: Space;
  40151. yawAxis?: Vector3;
  40152. pitchAxis?: Vector3;
  40153. adjustYaw?: number;
  40154. adjustPitch?: number;
  40155. adjustRoll?: number;
  40156. });
  40157. /**
  40158. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40159. */
  40160. update(): void;
  40161. private _getAngleDiff;
  40162. private _getAngleBetween;
  40163. private _isAngleBetween;
  40164. }
  40165. }
  40166. declare module BABYLON {
  40167. /**
  40168. * Manage the gamepad inputs to control an arc rotate camera.
  40169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40170. */
  40171. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40172. /**
  40173. * Defines the camera the input is attached to.
  40174. */
  40175. camera: ArcRotateCamera;
  40176. /**
  40177. * Defines the gamepad the input is gathering event from.
  40178. */
  40179. gamepad: Nullable<Gamepad>;
  40180. /**
  40181. * Defines the gamepad rotation sensiblity.
  40182. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40183. */
  40184. gamepadRotationSensibility: number;
  40185. /**
  40186. * Defines the gamepad move sensiblity.
  40187. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40188. */
  40189. gamepadMoveSensibility: number;
  40190. private _yAxisScale;
  40191. /**
  40192. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40193. */
  40194. get invertYAxis(): boolean;
  40195. set invertYAxis(value: boolean);
  40196. private _onGamepadConnectedObserver;
  40197. private _onGamepadDisconnectedObserver;
  40198. /**
  40199. * Attach the input controls to a specific dom element to get the input from.
  40200. * @param element Defines the element the controls should be listened from
  40201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40202. */
  40203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40204. /**
  40205. * Detach the current controls from the specified dom element.
  40206. * @param element Defines the element to stop listening the inputs from
  40207. */
  40208. detachControl(element: Nullable<HTMLElement>): void;
  40209. /**
  40210. * Update the current camera state depending on the inputs that have been used this frame.
  40211. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40212. */
  40213. checkInputs(): void;
  40214. /**
  40215. * Gets the class name of the current intput.
  40216. * @returns the class name
  40217. */
  40218. getClassName(): string;
  40219. /**
  40220. * Get the friendly name associated with the input class.
  40221. * @returns the input friendly name
  40222. */
  40223. getSimpleName(): string;
  40224. }
  40225. }
  40226. declare module BABYLON {
  40227. interface ArcRotateCameraInputsManager {
  40228. /**
  40229. * Add orientation input support to the input manager.
  40230. * @returns the current input manager
  40231. */
  40232. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40233. }
  40234. /**
  40235. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40236. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40237. */
  40238. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40239. /**
  40240. * Defines the camera the input is attached to.
  40241. */
  40242. camera: ArcRotateCamera;
  40243. /**
  40244. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40245. */
  40246. alphaCorrection: number;
  40247. /**
  40248. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40249. */
  40250. gammaCorrection: number;
  40251. private _alpha;
  40252. private _gamma;
  40253. private _dirty;
  40254. private _deviceOrientationHandler;
  40255. /**
  40256. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40257. */
  40258. constructor();
  40259. /**
  40260. * Attach the input controls to a specific dom element to get the input from.
  40261. * @param element Defines the element the controls should be listened from
  40262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40263. */
  40264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40265. /** @hidden */
  40266. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40267. /**
  40268. * Update the current camera state depending on the inputs that have been used this frame.
  40269. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40270. */
  40271. checkInputs(): void;
  40272. /**
  40273. * Detach the current controls from the specified dom element.
  40274. * @param element Defines the element to stop listening the inputs from
  40275. */
  40276. detachControl(element: Nullable<HTMLElement>): void;
  40277. /**
  40278. * Gets the class name of the current intput.
  40279. * @returns the class name
  40280. */
  40281. getClassName(): string;
  40282. /**
  40283. * Get the friendly name associated with the input class.
  40284. * @returns the input friendly name
  40285. */
  40286. getSimpleName(): string;
  40287. }
  40288. }
  40289. declare module BABYLON {
  40290. /**
  40291. * Listen to mouse events to control the camera.
  40292. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40293. */
  40294. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40295. /**
  40296. * Defines the camera the input is attached to.
  40297. */
  40298. camera: FlyCamera;
  40299. /**
  40300. * Defines if touch is enabled. (Default is true.)
  40301. */
  40302. touchEnabled: boolean;
  40303. /**
  40304. * Defines the buttons associated with the input to handle camera rotation.
  40305. */
  40306. buttons: number[];
  40307. /**
  40308. * Assign buttons for Yaw control.
  40309. */
  40310. buttonsYaw: number[];
  40311. /**
  40312. * Assign buttons for Pitch control.
  40313. */
  40314. buttonsPitch: number[];
  40315. /**
  40316. * Assign buttons for Roll control.
  40317. */
  40318. buttonsRoll: number[];
  40319. /**
  40320. * Detect if any button is being pressed while mouse is moved.
  40321. * -1 = Mouse locked.
  40322. * 0 = Left button.
  40323. * 1 = Middle Button.
  40324. * 2 = Right Button.
  40325. */
  40326. activeButton: number;
  40327. /**
  40328. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40329. * Higher values reduce its sensitivity.
  40330. */
  40331. angularSensibility: number;
  40332. private _mousemoveCallback;
  40333. private _observer;
  40334. private _rollObserver;
  40335. private previousPosition;
  40336. private noPreventDefault;
  40337. private element;
  40338. /**
  40339. * Listen to mouse events to control the camera.
  40340. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40342. */
  40343. constructor(touchEnabled?: boolean);
  40344. /**
  40345. * Attach the mouse control to the HTML DOM element.
  40346. * @param element Defines the element that listens to the input events.
  40347. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40348. */
  40349. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40350. /**
  40351. * Detach the current controls from the specified dom element.
  40352. * @param element Defines the element to stop listening the inputs from
  40353. */
  40354. detachControl(element: Nullable<HTMLElement>): void;
  40355. /**
  40356. * Gets the class name of the current input.
  40357. * @returns the class name.
  40358. */
  40359. getClassName(): string;
  40360. /**
  40361. * Get the friendly name associated with the input class.
  40362. * @returns the input's friendly name.
  40363. */
  40364. getSimpleName(): string;
  40365. private _pointerInput;
  40366. private _onMouseMove;
  40367. /**
  40368. * Rotate camera by mouse offset.
  40369. */
  40370. private rotateCamera;
  40371. }
  40372. }
  40373. declare module BABYLON {
  40374. /**
  40375. * Default Inputs manager for the FlyCamera.
  40376. * It groups all the default supported inputs for ease of use.
  40377. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40378. */
  40379. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40380. /**
  40381. * Instantiates a new FlyCameraInputsManager.
  40382. * @param camera Defines the camera the inputs belong to.
  40383. */
  40384. constructor(camera: FlyCamera);
  40385. /**
  40386. * Add keyboard input support to the input manager.
  40387. * @returns the new FlyCameraKeyboardMoveInput().
  40388. */
  40389. addKeyboard(): FlyCameraInputsManager;
  40390. /**
  40391. * Add mouse input support to the input manager.
  40392. * @param touchEnabled Enable touch screen support.
  40393. * @returns the new FlyCameraMouseInput().
  40394. */
  40395. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40396. }
  40397. }
  40398. declare module BABYLON {
  40399. /**
  40400. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40401. * such as in a 3D Space Shooter or a Flight Simulator.
  40402. */
  40403. export class FlyCamera extends TargetCamera {
  40404. /**
  40405. * Define the collision ellipsoid of the camera.
  40406. * This is helpful for simulating a camera body, like a player's body.
  40407. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40408. */
  40409. ellipsoid: Vector3;
  40410. /**
  40411. * Define an offset for the position of the ellipsoid around the camera.
  40412. * This can be helpful if the camera is attached away from the player's body center,
  40413. * such as at its head.
  40414. */
  40415. ellipsoidOffset: Vector3;
  40416. /**
  40417. * Enable or disable collisions of the camera with the rest of the scene objects.
  40418. */
  40419. checkCollisions: boolean;
  40420. /**
  40421. * Enable or disable gravity on the camera.
  40422. */
  40423. applyGravity: boolean;
  40424. /**
  40425. * Define the current direction the camera is moving to.
  40426. */
  40427. cameraDirection: Vector3;
  40428. /**
  40429. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40430. * This overrides and empties cameraRotation.
  40431. */
  40432. rotationQuaternion: Quaternion;
  40433. /**
  40434. * Track Roll to maintain the wanted Rolling when looking around.
  40435. */
  40436. _trackRoll: number;
  40437. /**
  40438. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40439. */
  40440. rollCorrect: number;
  40441. /**
  40442. * Mimic a banked turn, Rolling the camera when Yawing.
  40443. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40444. */
  40445. bankedTurn: boolean;
  40446. /**
  40447. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40448. */
  40449. bankedTurnLimit: number;
  40450. /**
  40451. * Value of 0 disables the banked Roll.
  40452. * Value of 1 is equal to the Yaw angle in radians.
  40453. */
  40454. bankedTurnMultiplier: number;
  40455. /**
  40456. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40457. */
  40458. inputs: FlyCameraInputsManager;
  40459. /**
  40460. * Gets the input sensibility for mouse input.
  40461. * Higher values reduce sensitivity.
  40462. */
  40463. get angularSensibility(): number;
  40464. /**
  40465. * Sets the input sensibility for a mouse input.
  40466. * Higher values reduce sensitivity.
  40467. */
  40468. set angularSensibility(value: number);
  40469. /**
  40470. * Get the keys for camera movement forward.
  40471. */
  40472. get keysForward(): number[];
  40473. /**
  40474. * Set the keys for camera movement forward.
  40475. */
  40476. set keysForward(value: number[]);
  40477. /**
  40478. * Get the keys for camera movement backward.
  40479. */
  40480. get keysBackward(): number[];
  40481. set keysBackward(value: number[]);
  40482. /**
  40483. * Get the keys for camera movement up.
  40484. */
  40485. get keysUp(): number[];
  40486. /**
  40487. * Set the keys for camera movement up.
  40488. */
  40489. set keysUp(value: number[]);
  40490. /**
  40491. * Get the keys for camera movement down.
  40492. */
  40493. get keysDown(): number[];
  40494. /**
  40495. * Set the keys for camera movement down.
  40496. */
  40497. set keysDown(value: number[]);
  40498. /**
  40499. * Get the keys for camera movement left.
  40500. */
  40501. get keysLeft(): number[];
  40502. /**
  40503. * Set the keys for camera movement left.
  40504. */
  40505. set keysLeft(value: number[]);
  40506. /**
  40507. * Set the keys for camera movement right.
  40508. */
  40509. get keysRight(): number[];
  40510. /**
  40511. * Set the keys for camera movement right.
  40512. */
  40513. set keysRight(value: number[]);
  40514. /**
  40515. * Event raised when the camera collides with a mesh in the scene.
  40516. */
  40517. onCollide: (collidedMesh: AbstractMesh) => void;
  40518. private _collider;
  40519. private _needMoveForGravity;
  40520. private _oldPosition;
  40521. private _diffPosition;
  40522. private _newPosition;
  40523. /** @hidden */
  40524. _localDirection: Vector3;
  40525. /** @hidden */
  40526. _transformedDirection: Vector3;
  40527. /**
  40528. * Instantiates a FlyCamera.
  40529. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40530. * such as in a 3D Space Shooter or a Flight Simulator.
  40531. * @param name Define the name of the camera in the scene.
  40532. * @param position Define the starting position of the camera in the scene.
  40533. * @param scene Define the scene the camera belongs to.
  40534. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40535. */
  40536. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40537. /**
  40538. * Attach a control to the HTML DOM element.
  40539. * @param element Defines the element that listens to the input events.
  40540. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40541. */
  40542. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40543. /**
  40544. * Detach a control from the HTML DOM element.
  40545. * The camera will stop reacting to that input.
  40546. * @param element Defines the element that listens to the input events.
  40547. */
  40548. detachControl(element: HTMLElement): void;
  40549. private _collisionMask;
  40550. /**
  40551. * Get the mask that the camera ignores in collision events.
  40552. */
  40553. get collisionMask(): number;
  40554. /**
  40555. * Set the mask that the camera ignores in collision events.
  40556. */
  40557. set collisionMask(mask: number);
  40558. /** @hidden */
  40559. _collideWithWorld(displacement: Vector3): void;
  40560. /** @hidden */
  40561. private _onCollisionPositionChange;
  40562. /** @hidden */
  40563. _checkInputs(): void;
  40564. /** @hidden */
  40565. _decideIfNeedsToMove(): boolean;
  40566. /** @hidden */
  40567. _updatePosition(): void;
  40568. /**
  40569. * Restore the Roll to its target value at the rate specified.
  40570. * @param rate - Higher means slower restoring.
  40571. * @hidden
  40572. */
  40573. restoreRoll(rate: number): void;
  40574. /**
  40575. * Destroy the camera and release the current resources held by it.
  40576. */
  40577. dispose(): void;
  40578. /**
  40579. * Get the current object class name.
  40580. * @returns the class name.
  40581. */
  40582. getClassName(): string;
  40583. }
  40584. }
  40585. declare module BABYLON {
  40586. /**
  40587. * Listen to keyboard events to control the camera.
  40588. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40589. */
  40590. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40591. /**
  40592. * Defines the camera the input is attached to.
  40593. */
  40594. camera: FlyCamera;
  40595. /**
  40596. * The list of keyboard keys used to control the forward move of the camera.
  40597. */
  40598. keysForward: number[];
  40599. /**
  40600. * The list of keyboard keys used to control the backward move of the camera.
  40601. */
  40602. keysBackward: number[];
  40603. /**
  40604. * The list of keyboard keys used to control the forward move of the camera.
  40605. */
  40606. keysUp: number[];
  40607. /**
  40608. * The list of keyboard keys used to control the backward move of the camera.
  40609. */
  40610. keysDown: number[];
  40611. /**
  40612. * The list of keyboard keys used to control the right strafe move of the camera.
  40613. */
  40614. keysRight: number[];
  40615. /**
  40616. * The list of keyboard keys used to control the left strafe move of the camera.
  40617. */
  40618. keysLeft: number[];
  40619. private _keys;
  40620. private _onCanvasBlurObserver;
  40621. private _onKeyboardObserver;
  40622. private _engine;
  40623. private _scene;
  40624. /**
  40625. * Attach the input controls to a specific dom element to get the input from.
  40626. * @param element Defines the element the controls should be listened from
  40627. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40628. */
  40629. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40630. /**
  40631. * Detach the current controls from the specified dom element.
  40632. * @param element Defines the element to stop listening the inputs from
  40633. */
  40634. detachControl(element: Nullable<HTMLElement>): void;
  40635. /**
  40636. * Gets the class name of the current intput.
  40637. * @returns the class name
  40638. */
  40639. getClassName(): string;
  40640. /** @hidden */
  40641. _onLostFocus(e: FocusEvent): void;
  40642. /**
  40643. * Get the friendly name associated with the input class.
  40644. * @returns the input friendly name
  40645. */
  40646. getSimpleName(): string;
  40647. /**
  40648. * Update the current camera state depending on the inputs that have been used this frame.
  40649. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40650. */
  40651. checkInputs(): void;
  40652. }
  40653. }
  40654. declare module BABYLON {
  40655. /**
  40656. * Manage the mouse wheel inputs to control a follow camera.
  40657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40658. */
  40659. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40660. /**
  40661. * Defines the camera the input is attached to.
  40662. */
  40663. camera: FollowCamera;
  40664. /**
  40665. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40666. */
  40667. axisControlRadius: boolean;
  40668. /**
  40669. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40670. */
  40671. axisControlHeight: boolean;
  40672. /**
  40673. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40674. */
  40675. axisControlRotation: boolean;
  40676. /**
  40677. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40678. * relation to mouseWheel events.
  40679. */
  40680. wheelPrecision: number;
  40681. /**
  40682. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40683. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40684. */
  40685. wheelDeltaPercentage: number;
  40686. private _wheel;
  40687. private _observer;
  40688. /**
  40689. * Attach the input controls to a specific dom element to get the input from.
  40690. * @param element Defines the element the controls should be listened from
  40691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40692. */
  40693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40694. /**
  40695. * Detach the current controls from the specified dom element.
  40696. * @param element Defines the element to stop listening the inputs from
  40697. */
  40698. detachControl(element: Nullable<HTMLElement>): void;
  40699. /**
  40700. * Gets the class name of the current intput.
  40701. * @returns the class name
  40702. */
  40703. getClassName(): string;
  40704. /**
  40705. * Get the friendly name associated with the input class.
  40706. * @returns the input friendly name
  40707. */
  40708. getSimpleName(): string;
  40709. }
  40710. }
  40711. declare module BABYLON {
  40712. /**
  40713. * Manage the pointers inputs to control an follow camera.
  40714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40715. */
  40716. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40717. /**
  40718. * Defines the camera the input is attached to.
  40719. */
  40720. camera: FollowCamera;
  40721. /**
  40722. * Gets the class name of the current input.
  40723. * @returns the class name
  40724. */
  40725. getClassName(): string;
  40726. /**
  40727. * Defines the pointer angular sensibility along the X axis or how fast is
  40728. * the camera rotating.
  40729. * A negative number will reverse the axis direction.
  40730. */
  40731. angularSensibilityX: number;
  40732. /**
  40733. * Defines the pointer angular sensibility along the Y axis or how fast is
  40734. * the camera rotating.
  40735. * A negative number will reverse the axis direction.
  40736. */
  40737. angularSensibilityY: number;
  40738. /**
  40739. * Defines the pointer pinch precision or how fast is the camera zooming.
  40740. * A negative number will reverse the axis direction.
  40741. */
  40742. pinchPrecision: number;
  40743. /**
  40744. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40745. * from 0.
  40746. * It defines the percentage of current camera.radius to use as delta when
  40747. * pinch zoom is used.
  40748. */
  40749. pinchDeltaPercentage: number;
  40750. /**
  40751. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40752. */
  40753. axisXControlRadius: boolean;
  40754. /**
  40755. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40756. */
  40757. axisXControlHeight: boolean;
  40758. /**
  40759. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40760. */
  40761. axisXControlRotation: boolean;
  40762. /**
  40763. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40764. */
  40765. axisYControlRadius: boolean;
  40766. /**
  40767. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40768. */
  40769. axisYControlHeight: boolean;
  40770. /**
  40771. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40772. */
  40773. axisYControlRotation: boolean;
  40774. /**
  40775. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40776. */
  40777. axisPinchControlRadius: boolean;
  40778. /**
  40779. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40780. */
  40781. axisPinchControlHeight: boolean;
  40782. /**
  40783. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40784. */
  40785. axisPinchControlRotation: boolean;
  40786. /**
  40787. * Log error messages if basic misconfiguration has occurred.
  40788. */
  40789. warningEnable: boolean;
  40790. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40791. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40792. private _warningCounter;
  40793. private _warning;
  40794. }
  40795. }
  40796. declare module BABYLON {
  40797. /**
  40798. * Default Inputs manager for the FollowCamera.
  40799. * It groups all the default supported inputs for ease of use.
  40800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40801. */
  40802. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40803. /**
  40804. * Instantiates a new FollowCameraInputsManager.
  40805. * @param camera Defines the camera the inputs belong to
  40806. */
  40807. constructor(camera: FollowCamera);
  40808. /**
  40809. * Add keyboard input support to the input manager.
  40810. * @returns the current input manager
  40811. */
  40812. addKeyboard(): FollowCameraInputsManager;
  40813. /**
  40814. * Add mouse wheel input support to the input manager.
  40815. * @returns the current input manager
  40816. */
  40817. addMouseWheel(): FollowCameraInputsManager;
  40818. /**
  40819. * Add pointers input support to the input manager.
  40820. * @returns the current input manager
  40821. */
  40822. addPointers(): FollowCameraInputsManager;
  40823. /**
  40824. * Add orientation input support to the input manager.
  40825. * @returns the current input manager
  40826. */
  40827. addVRDeviceOrientation(): FollowCameraInputsManager;
  40828. }
  40829. }
  40830. declare module BABYLON {
  40831. /**
  40832. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40833. * an arc rotate version arcFollowCamera are available.
  40834. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40835. */
  40836. export class FollowCamera extends TargetCamera {
  40837. /**
  40838. * Distance the follow camera should follow an object at
  40839. */
  40840. radius: number;
  40841. /**
  40842. * Minimum allowed distance of the camera to the axis of rotation
  40843. * (The camera can not get closer).
  40844. * This can help limiting how the Camera is able to move in the scene.
  40845. */
  40846. lowerRadiusLimit: Nullable<number>;
  40847. /**
  40848. * Maximum allowed distance of the camera to the axis of rotation
  40849. * (The camera can not get further).
  40850. * This can help limiting how the Camera is able to move in the scene.
  40851. */
  40852. upperRadiusLimit: Nullable<number>;
  40853. /**
  40854. * Define a rotation offset between the camera and the object it follows
  40855. */
  40856. rotationOffset: number;
  40857. /**
  40858. * Minimum allowed angle to camera position relative to target object.
  40859. * This can help limiting how the Camera is able to move in the scene.
  40860. */
  40861. lowerRotationOffsetLimit: Nullable<number>;
  40862. /**
  40863. * Maximum allowed angle to camera position relative to target object.
  40864. * This can help limiting how the Camera is able to move in the scene.
  40865. */
  40866. upperRotationOffsetLimit: Nullable<number>;
  40867. /**
  40868. * Define a height offset between the camera and the object it follows.
  40869. * It can help following an object from the top (like a car chaing a plane)
  40870. */
  40871. heightOffset: number;
  40872. /**
  40873. * Minimum allowed height of camera position relative to target object.
  40874. * This can help limiting how the Camera is able to move in the scene.
  40875. */
  40876. lowerHeightOffsetLimit: Nullable<number>;
  40877. /**
  40878. * Maximum allowed height of camera position relative to target object.
  40879. * This can help limiting how the Camera is able to move in the scene.
  40880. */
  40881. upperHeightOffsetLimit: Nullable<number>;
  40882. /**
  40883. * Define how fast the camera can accelerate to follow it s target.
  40884. */
  40885. cameraAcceleration: number;
  40886. /**
  40887. * Define the speed limit of the camera following an object.
  40888. */
  40889. maxCameraSpeed: number;
  40890. /**
  40891. * Define the target of the camera.
  40892. */
  40893. lockedTarget: Nullable<AbstractMesh>;
  40894. /**
  40895. * Defines the input associated with the camera.
  40896. */
  40897. inputs: FollowCameraInputsManager;
  40898. /**
  40899. * Instantiates the follow camera.
  40900. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40901. * @param name Define the name of the camera in the scene
  40902. * @param position Define the position of the camera
  40903. * @param scene Define the scene the camera belong to
  40904. * @param lockedTarget Define the target of the camera
  40905. */
  40906. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40907. private _follow;
  40908. /**
  40909. * Attached controls to the current camera.
  40910. * @param element Defines the element the controls should be listened from
  40911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40912. */
  40913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40914. /**
  40915. * Detach the current controls from the camera.
  40916. * The camera will stop reacting to inputs.
  40917. * @param element Defines the element to stop listening the inputs from
  40918. */
  40919. detachControl(element: HTMLElement): void;
  40920. /** @hidden */
  40921. _checkInputs(): void;
  40922. private _checkLimits;
  40923. /**
  40924. * Gets the camera class name.
  40925. * @returns the class name
  40926. */
  40927. getClassName(): string;
  40928. }
  40929. /**
  40930. * Arc Rotate version of the follow camera.
  40931. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40932. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40933. */
  40934. export class ArcFollowCamera extends TargetCamera {
  40935. /** The longitudinal angle of the camera */
  40936. alpha: number;
  40937. /** The latitudinal angle of the camera */
  40938. beta: number;
  40939. /** The radius of the camera from its target */
  40940. radius: number;
  40941. /** Define the camera target (the messh it should follow) */
  40942. target: Nullable<AbstractMesh>;
  40943. private _cartesianCoordinates;
  40944. /**
  40945. * Instantiates a new ArcFollowCamera
  40946. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40947. * @param name Define the name of the camera
  40948. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40949. * @param beta Define the rotation angle of the camera around the elevation axis
  40950. * @param radius Define the radius of the camera from its target point
  40951. * @param target Define the target of the camera
  40952. * @param scene Define the scene the camera belongs to
  40953. */
  40954. constructor(name: string,
  40955. /** The longitudinal angle of the camera */
  40956. alpha: number,
  40957. /** The latitudinal angle of the camera */
  40958. beta: number,
  40959. /** The radius of the camera from its target */
  40960. radius: number,
  40961. /** Define the camera target (the messh it should follow) */
  40962. target: Nullable<AbstractMesh>, scene: Scene);
  40963. private _follow;
  40964. /** @hidden */
  40965. _checkInputs(): void;
  40966. /**
  40967. * Returns the class name of the object.
  40968. * It is mostly used internally for serialization purposes.
  40969. */
  40970. getClassName(): string;
  40971. }
  40972. }
  40973. declare module BABYLON {
  40974. /**
  40975. * Manage the keyboard inputs to control the movement of a follow camera.
  40976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40977. */
  40978. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40979. /**
  40980. * Defines the camera the input is attached to.
  40981. */
  40982. camera: FollowCamera;
  40983. /**
  40984. * Defines the list of key codes associated with the up action (increase heightOffset)
  40985. */
  40986. keysHeightOffsetIncr: number[];
  40987. /**
  40988. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40989. */
  40990. keysHeightOffsetDecr: number[];
  40991. /**
  40992. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40993. */
  40994. keysHeightOffsetModifierAlt: boolean;
  40995. /**
  40996. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40997. */
  40998. keysHeightOffsetModifierCtrl: boolean;
  40999. /**
  41000. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41001. */
  41002. keysHeightOffsetModifierShift: boolean;
  41003. /**
  41004. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41005. */
  41006. keysRotationOffsetIncr: number[];
  41007. /**
  41008. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41009. */
  41010. keysRotationOffsetDecr: number[];
  41011. /**
  41012. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41013. */
  41014. keysRotationOffsetModifierAlt: boolean;
  41015. /**
  41016. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41017. */
  41018. keysRotationOffsetModifierCtrl: boolean;
  41019. /**
  41020. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41021. */
  41022. keysRotationOffsetModifierShift: boolean;
  41023. /**
  41024. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41025. */
  41026. keysRadiusIncr: number[];
  41027. /**
  41028. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41029. */
  41030. keysRadiusDecr: number[];
  41031. /**
  41032. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41033. */
  41034. keysRadiusModifierAlt: boolean;
  41035. /**
  41036. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41037. */
  41038. keysRadiusModifierCtrl: boolean;
  41039. /**
  41040. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41041. */
  41042. keysRadiusModifierShift: boolean;
  41043. /**
  41044. * Defines the rate of change of heightOffset.
  41045. */
  41046. heightSensibility: number;
  41047. /**
  41048. * Defines the rate of change of rotationOffset.
  41049. */
  41050. rotationSensibility: number;
  41051. /**
  41052. * Defines the rate of change of radius.
  41053. */
  41054. radiusSensibility: number;
  41055. private _keys;
  41056. private _ctrlPressed;
  41057. private _altPressed;
  41058. private _shiftPressed;
  41059. private _onCanvasBlurObserver;
  41060. private _onKeyboardObserver;
  41061. private _engine;
  41062. private _scene;
  41063. /**
  41064. * Attach the input controls to a specific dom element to get the input from.
  41065. * @param element Defines the element the controls should be listened from
  41066. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41067. */
  41068. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41069. /**
  41070. * Detach the current controls from the specified dom element.
  41071. * @param element Defines the element to stop listening the inputs from
  41072. */
  41073. detachControl(element: Nullable<HTMLElement>): void;
  41074. /**
  41075. * Update the current camera state depending on the inputs that have been used this frame.
  41076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41077. */
  41078. checkInputs(): void;
  41079. /**
  41080. * Gets the class name of the current input.
  41081. * @returns the class name
  41082. */
  41083. getClassName(): string;
  41084. /**
  41085. * Get the friendly name associated with the input class.
  41086. * @returns the input friendly name
  41087. */
  41088. getSimpleName(): string;
  41089. /**
  41090. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41091. * allow modification of the heightOffset value.
  41092. */
  41093. private _modifierHeightOffset;
  41094. /**
  41095. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41096. * allow modification of the rotationOffset value.
  41097. */
  41098. private _modifierRotationOffset;
  41099. /**
  41100. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41101. * allow modification of the radius value.
  41102. */
  41103. private _modifierRadius;
  41104. }
  41105. }
  41106. declare module BABYLON {
  41107. interface FreeCameraInputsManager {
  41108. /**
  41109. * @hidden
  41110. */
  41111. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41112. /**
  41113. * Add orientation input support to the input manager.
  41114. * @returns the current input manager
  41115. */
  41116. addDeviceOrientation(): FreeCameraInputsManager;
  41117. }
  41118. /**
  41119. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41120. * Screen rotation is taken into account.
  41121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41122. */
  41123. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41124. private _camera;
  41125. private _screenOrientationAngle;
  41126. private _constantTranform;
  41127. private _screenQuaternion;
  41128. private _alpha;
  41129. private _beta;
  41130. private _gamma;
  41131. /**
  41132. * Can be used to detect if a device orientation sensor is available on a device
  41133. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41134. * @returns a promise that will resolve on orientation change
  41135. */
  41136. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41137. /**
  41138. * @hidden
  41139. */
  41140. _onDeviceOrientationChangedObservable: Observable<void>;
  41141. /**
  41142. * Instantiates a new input
  41143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41144. */
  41145. constructor();
  41146. /**
  41147. * Define the camera controlled by the input.
  41148. */
  41149. get camera(): FreeCamera;
  41150. set camera(camera: FreeCamera);
  41151. /**
  41152. * Attach the input controls to a specific dom element to get the input from.
  41153. * @param element Defines the element the controls should be listened from
  41154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41155. */
  41156. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41157. private _orientationChanged;
  41158. private _deviceOrientation;
  41159. /**
  41160. * Detach the current controls from the specified dom element.
  41161. * @param element Defines the element to stop listening the inputs from
  41162. */
  41163. detachControl(element: Nullable<HTMLElement>): void;
  41164. /**
  41165. * Update the current camera state depending on the inputs that have been used this frame.
  41166. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41167. */
  41168. checkInputs(): void;
  41169. /**
  41170. * Gets the class name of the current intput.
  41171. * @returns the class name
  41172. */
  41173. getClassName(): string;
  41174. /**
  41175. * Get the friendly name associated with the input class.
  41176. * @returns the input friendly name
  41177. */
  41178. getSimpleName(): string;
  41179. }
  41180. }
  41181. declare module BABYLON {
  41182. /**
  41183. * Manage the gamepad inputs to control a free camera.
  41184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41185. */
  41186. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41187. /**
  41188. * Define the camera the input is attached to.
  41189. */
  41190. camera: FreeCamera;
  41191. /**
  41192. * Define the Gamepad controlling the input
  41193. */
  41194. gamepad: Nullable<Gamepad>;
  41195. /**
  41196. * Defines the gamepad rotation sensiblity.
  41197. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41198. */
  41199. gamepadAngularSensibility: number;
  41200. /**
  41201. * Defines the gamepad move sensiblity.
  41202. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41203. */
  41204. gamepadMoveSensibility: number;
  41205. private _yAxisScale;
  41206. /**
  41207. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41208. */
  41209. get invertYAxis(): boolean;
  41210. set invertYAxis(value: boolean);
  41211. private _onGamepadConnectedObserver;
  41212. private _onGamepadDisconnectedObserver;
  41213. private _cameraTransform;
  41214. private _deltaTransform;
  41215. private _vector3;
  41216. private _vector2;
  41217. /**
  41218. * Attach the input controls to a specific dom element to get the input from.
  41219. * @param element Defines the element the controls should be listened from
  41220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41221. */
  41222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41223. /**
  41224. * Detach the current controls from the specified dom element.
  41225. * @param element Defines the element to stop listening the inputs from
  41226. */
  41227. detachControl(element: Nullable<HTMLElement>): void;
  41228. /**
  41229. * Update the current camera state depending on the inputs that have been used this frame.
  41230. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41231. */
  41232. checkInputs(): void;
  41233. /**
  41234. * Gets the class name of the current intput.
  41235. * @returns the class name
  41236. */
  41237. getClassName(): string;
  41238. /**
  41239. * Get the friendly name associated with the input class.
  41240. * @returns the input friendly name
  41241. */
  41242. getSimpleName(): string;
  41243. }
  41244. }
  41245. declare module BABYLON {
  41246. /**
  41247. * Defines the potential axis of a Joystick
  41248. */
  41249. export enum JoystickAxis {
  41250. /** X axis */
  41251. X = 0,
  41252. /** Y axis */
  41253. Y = 1,
  41254. /** Z axis */
  41255. Z = 2
  41256. }
  41257. /**
  41258. * Class used to define virtual joystick (used in touch mode)
  41259. */
  41260. export class VirtualJoystick {
  41261. /**
  41262. * Gets or sets a boolean indicating that left and right values must be inverted
  41263. */
  41264. reverseLeftRight: boolean;
  41265. /**
  41266. * Gets or sets a boolean indicating that up and down values must be inverted
  41267. */
  41268. reverseUpDown: boolean;
  41269. /**
  41270. * Gets the offset value for the position (ie. the change of the position value)
  41271. */
  41272. deltaPosition: Vector3;
  41273. /**
  41274. * Gets a boolean indicating if the virtual joystick was pressed
  41275. */
  41276. pressed: boolean;
  41277. /**
  41278. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41279. */
  41280. static Canvas: Nullable<HTMLCanvasElement>;
  41281. private static _globalJoystickIndex;
  41282. private static vjCanvasContext;
  41283. private static vjCanvasWidth;
  41284. private static vjCanvasHeight;
  41285. private static halfWidth;
  41286. private _action;
  41287. private _axisTargetedByLeftAndRight;
  41288. private _axisTargetedByUpAndDown;
  41289. private _joystickSensibility;
  41290. private _inversedSensibility;
  41291. private _joystickPointerID;
  41292. private _joystickColor;
  41293. private _joystickPointerPos;
  41294. private _joystickPreviousPointerPos;
  41295. private _joystickPointerStartPos;
  41296. private _deltaJoystickVector;
  41297. private _leftJoystick;
  41298. private _touches;
  41299. private _onPointerDownHandlerRef;
  41300. private _onPointerMoveHandlerRef;
  41301. private _onPointerUpHandlerRef;
  41302. private _onResize;
  41303. /**
  41304. * Creates a new virtual joystick
  41305. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41306. */
  41307. constructor(leftJoystick?: boolean);
  41308. /**
  41309. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41310. * @param newJoystickSensibility defines the new sensibility
  41311. */
  41312. setJoystickSensibility(newJoystickSensibility: number): void;
  41313. private _onPointerDown;
  41314. private _onPointerMove;
  41315. private _onPointerUp;
  41316. /**
  41317. * Change the color of the virtual joystick
  41318. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41319. */
  41320. setJoystickColor(newColor: string): void;
  41321. /**
  41322. * Defines a callback to call when the joystick is touched
  41323. * @param action defines the callback
  41324. */
  41325. setActionOnTouch(action: () => any): void;
  41326. /**
  41327. * Defines which axis you'd like to control for left & right
  41328. * @param axis defines the axis to use
  41329. */
  41330. setAxisForLeftRight(axis: JoystickAxis): void;
  41331. /**
  41332. * Defines which axis you'd like to control for up & down
  41333. * @param axis defines the axis to use
  41334. */
  41335. setAxisForUpDown(axis: JoystickAxis): void;
  41336. private _drawVirtualJoystick;
  41337. /**
  41338. * Release internal HTML canvas
  41339. */
  41340. releaseCanvas(): void;
  41341. }
  41342. }
  41343. declare module BABYLON {
  41344. interface FreeCameraInputsManager {
  41345. /**
  41346. * Add virtual joystick input support to the input manager.
  41347. * @returns the current input manager
  41348. */
  41349. addVirtualJoystick(): FreeCameraInputsManager;
  41350. }
  41351. /**
  41352. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41354. */
  41355. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41356. /**
  41357. * Defines the camera the input is attached to.
  41358. */
  41359. camera: FreeCamera;
  41360. private _leftjoystick;
  41361. private _rightjoystick;
  41362. /**
  41363. * Gets the left stick of the virtual joystick.
  41364. * @returns The virtual Joystick
  41365. */
  41366. getLeftJoystick(): VirtualJoystick;
  41367. /**
  41368. * Gets the right stick of the virtual joystick.
  41369. * @returns The virtual Joystick
  41370. */
  41371. getRightJoystick(): VirtualJoystick;
  41372. /**
  41373. * Update the current camera state depending on the inputs that have been used this frame.
  41374. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41375. */
  41376. checkInputs(): void;
  41377. /**
  41378. * Attach the input controls to a specific dom element to get the input from.
  41379. * @param element Defines the element the controls should be listened from
  41380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41381. */
  41382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41383. /**
  41384. * Detach the current controls from the specified dom element.
  41385. * @param element Defines the element to stop listening the inputs from
  41386. */
  41387. detachControl(element: Nullable<HTMLElement>): void;
  41388. /**
  41389. * Gets the class name of the current intput.
  41390. * @returns the class name
  41391. */
  41392. getClassName(): string;
  41393. /**
  41394. * Get the friendly name associated with the input class.
  41395. * @returns the input friendly name
  41396. */
  41397. getSimpleName(): string;
  41398. }
  41399. }
  41400. declare module BABYLON {
  41401. /**
  41402. * This represents a FPS type of camera controlled by touch.
  41403. * This is like a universal camera minus the Gamepad controls.
  41404. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41405. */
  41406. export class TouchCamera extends FreeCamera {
  41407. /**
  41408. * Defines the touch sensibility for rotation.
  41409. * The higher the faster.
  41410. */
  41411. get touchAngularSensibility(): number;
  41412. set touchAngularSensibility(value: number);
  41413. /**
  41414. * Defines the touch sensibility for move.
  41415. * The higher the faster.
  41416. */
  41417. get touchMoveSensibility(): number;
  41418. set touchMoveSensibility(value: number);
  41419. /**
  41420. * Instantiates a new touch camera.
  41421. * This represents a FPS type of camera controlled by touch.
  41422. * This is like a universal camera minus the Gamepad controls.
  41423. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41424. * @param name Define the name of the camera in the scene
  41425. * @param position Define the start position of the camera in the scene
  41426. * @param scene Define the scene the camera belongs to
  41427. */
  41428. constructor(name: string, position: Vector3, scene: Scene);
  41429. /**
  41430. * Gets the current object class name.
  41431. * @return the class name
  41432. */
  41433. getClassName(): string;
  41434. /** @hidden */
  41435. _setupInputs(): void;
  41436. }
  41437. }
  41438. declare module BABYLON {
  41439. /**
  41440. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41441. * being tilted forward or back and left or right.
  41442. */
  41443. export class DeviceOrientationCamera extends FreeCamera {
  41444. private _initialQuaternion;
  41445. private _quaternionCache;
  41446. private _tmpDragQuaternion;
  41447. private _disablePointerInputWhenUsingDeviceOrientation;
  41448. /**
  41449. * Creates a new device orientation camera
  41450. * @param name The name of the camera
  41451. * @param position The start position camera
  41452. * @param scene The scene the camera belongs to
  41453. */
  41454. constructor(name: string, position: Vector3, scene: Scene);
  41455. /**
  41456. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41457. */
  41458. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41459. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41460. private _dragFactor;
  41461. /**
  41462. * Enabled turning on the y axis when the orientation sensor is active
  41463. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41464. */
  41465. enableHorizontalDragging(dragFactor?: number): void;
  41466. /**
  41467. * Gets the current instance class name ("DeviceOrientationCamera").
  41468. * This helps avoiding instanceof at run time.
  41469. * @returns the class name
  41470. */
  41471. getClassName(): string;
  41472. /**
  41473. * @hidden
  41474. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41475. */
  41476. _checkInputs(): void;
  41477. /**
  41478. * Reset the camera to its default orientation on the specified axis only.
  41479. * @param axis The axis to reset
  41480. */
  41481. resetToCurrentRotation(axis?: Axis): void;
  41482. }
  41483. }
  41484. declare module BABYLON {
  41485. /**
  41486. * Defines supported buttons for XBox360 compatible gamepads
  41487. */
  41488. export enum Xbox360Button {
  41489. /** A */
  41490. A = 0,
  41491. /** B */
  41492. B = 1,
  41493. /** X */
  41494. X = 2,
  41495. /** Y */
  41496. Y = 3,
  41497. /** Left button */
  41498. LB = 4,
  41499. /** Right button */
  41500. RB = 5,
  41501. /** Back */
  41502. Back = 8,
  41503. /** Start */
  41504. Start = 9,
  41505. /** Left stick */
  41506. LeftStick = 10,
  41507. /** Right stick */
  41508. RightStick = 11
  41509. }
  41510. /** Defines values for XBox360 DPad */
  41511. export enum Xbox360Dpad {
  41512. /** Up */
  41513. Up = 12,
  41514. /** Down */
  41515. Down = 13,
  41516. /** Left */
  41517. Left = 14,
  41518. /** Right */
  41519. Right = 15
  41520. }
  41521. /**
  41522. * Defines a XBox360 gamepad
  41523. */
  41524. export class Xbox360Pad extends Gamepad {
  41525. private _leftTrigger;
  41526. private _rightTrigger;
  41527. private _onlefttriggerchanged;
  41528. private _onrighttriggerchanged;
  41529. private _onbuttondown;
  41530. private _onbuttonup;
  41531. private _ondpaddown;
  41532. private _ondpadup;
  41533. /** Observable raised when a button is pressed */
  41534. onButtonDownObservable: Observable<Xbox360Button>;
  41535. /** Observable raised when a button is released */
  41536. onButtonUpObservable: Observable<Xbox360Button>;
  41537. /** Observable raised when a pad is pressed */
  41538. onPadDownObservable: Observable<Xbox360Dpad>;
  41539. /** Observable raised when a pad is released */
  41540. onPadUpObservable: Observable<Xbox360Dpad>;
  41541. private _buttonA;
  41542. private _buttonB;
  41543. private _buttonX;
  41544. private _buttonY;
  41545. private _buttonBack;
  41546. private _buttonStart;
  41547. private _buttonLB;
  41548. private _buttonRB;
  41549. private _buttonLeftStick;
  41550. private _buttonRightStick;
  41551. private _dPadUp;
  41552. private _dPadDown;
  41553. private _dPadLeft;
  41554. private _dPadRight;
  41555. private _isXboxOnePad;
  41556. /**
  41557. * Creates a new XBox360 gamepad object
  41558. * @param id defines the id of this gamepad
  41559. * @param index defines its index
  41560. * @param gamepad defines the internal HTML gamepad object
  41561. * @param xboxOne defines if it is a XBox One gamepad
  41562. */
  41563. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41564. /**
  41565. * Defines the callback to call when left trigger is pressed
  41566. * @param callback defines the callback to use
  41567. */
  41568. onlefttriggerchanged(callback: (value: number) => void): void;
  41569. /**
  41570. * Defines the callback to call when right trigger is pressed
  41571. * @param callback defines the callback to use
  41572. */
  41573. onrighttriggerchanged(callback: (value: number) => void): void;
  41574. /**
  41575. * Gets the left trigger value
  41576. */
  41577. get leftTrigger(): number;
  41578. /**
  41579. * Sets the left trigger value
  41580. */
  41581. set leftTrigger(newValue: number);
  41582. /**
  41583. * Gets the right trigger value
  41584. */
  41585. get rightTrigger(): number;
  41586. /**
  41587. * Sets the right trigger value
  41588. */
  41589. set rightTrigger(newValue: number);
  41590. /**
  41591. * Defines the callback to call when a button is pressed
  41592. * @param callback defines the callback to use
  41593. */
  41594. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41595. /**
  41596. * Defines the callback to call when a button is released
  41597. * @param callback defines the callback to use
  41598. */
  41599. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41600. /**
  41601. * Defines the callback to call when a pad is pressed
  41602. * @param callback defines the callback to use
  41603. */
  41604. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41605. /**
  41606. * Defines the callback to call when a pad is released
  41607. * @param callback defines the callback to use
  41608. */
  41609. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41610. private _setButtonValue;
  41611. private _setDPadValue;
  41612. /**
  41613. * Gets the value of the `A` button
  41614. */
  41615. get buttonA(): number;
  41616. /**
  41617. * Sets the value of the `A` button
  41618. */
  41619. set buttonA(value: number);
  41620. /**
  41621. * Gets the value of the `B` button
  41622. */
  41623. get buttonB(): number;
  41624. /**
  41625. * Sets the value of the `B` button
  41626. */
  41627. set buttonB(value: number);
  41628. /**
  41629. * Gets the value of the `X` button
  41630. */
  41631. get buttonX(): number;
  41632. /**
  41633. * Sets the value of the `X` button
  41634. */
  41635. set buttonX(value: number);
  41636. /**
  41637. * Gets the value of the `Y` button
  41638. */
  41639. get buttonY(): number;
  41640. /**
  41641. * Sets the value of the `Y` button
  41642. */
  41643. set buttonY(value: number);
  41644. /**
  41645. * Gets the value of the `Start` button
  41646. */
  41647. get buttonStart(): number;
  41648. /**
  41649. * Sets the value of the `Start` button
  41650. */
  41651. set buttonStart(value: number);
  41652. /**
  41653. * Gets the value of the `Back` button
  41654. */
  41655. get buttonBack(): number;
  41656. /**
  41657. * Sets the value of the `Back` button
  41658. */
  41659. set buttonBack(value: number);
  41660. /**
  41661. * Gets the value of the `Left` button
  41662. */
  41663. get buttonLB(): number;
  41664. /**
  41665. * Sets the value of the `Left` button
  41666. */
  41667. set buttonLB(value: number);
  41668. /**
  41669. * Gets the value of the `Right` button
  41670. */
  41671. get buttonRB(): number;
  41672. /**
  41673. * Sets the value of the `Right` button
  41674. */
  41675. set buttonRB(value: number);
  41676. /**
  41677. * Gets the value of the Left joystick
  41678. */
  41679. get buttonLeftStick(): number;
  41680. /**
  41681. * Sets the value of the Left joystick
  41682. */
  41683. set buttonLeftStick(value: number);
  41684. /**
  41685. * Gets the value of the Right joystick
  41686. */
  41687. get buttonRightStick(): number;
  41688. /**
  41689. * Sets the value of the Right joystick
  41690. */
  41691. set buttonRightStick(value: number);
  41692. /**
  41693. * Gets the value of D-pad up
  41694. */
  41695. get dPadUp(): number;
  41696. /**
  41697. * Sets the value of D-pad up
  41698. */
  41699. set dPadUp(value: number);
  41700. /**
  41701. * Gets the value of D-pad down
  41702. */
  41703. get dPadDown(): number;
  41704. /**
  41705. * Sets the value of D-pad down
  41706. */
  41707. set dPadDown(value: number);
  41708. /**
  41709. * Gets the value of D-pad left
  41710. */
  41711. get dPadLeft(): number;
  41712. /**
  41713. * Sets the value of D-pad left
  41714. */
  41715. set dPadLeft(value: number);
  41716. /**
  41717. * Gets the value of D-pad right
  41718. */
  41719. get dPadRight(): number;
  41720. /**
  41721. * Sets the value of D-pad right
  41722. */
  41723. set dPadRight(value: number);
  41724. /**
  41725. * Force the gamepad to synchronize with device values
  41726. */
  41727. update(): void;
  41728. /**
  41729. * Disposes the gamepad
  41730. */
  41731. dispose(): void;
  41732. }
  41733. }
  41734. declare module BABYLON {
  41735. /**
  41736. * Defines supported buttons for DualShock compatible gamepads
  41737. */
  41738. export enum DualShockButton {
  41739. /** Cross */
  41740. Cross = 0,
  41741. /** Circle */
  41742. Circle = 1,
  41743. /** Square */
  41744. Square = 2,
  41745. /** Triangle */
  41746. Triangle = 3,
  41747. /** L1 */
  41748. L1 = 4,
  41749. /** R1 */
  41750. R1 = 5,
  41751. /** Share */
  41752. Share = 8,
  41753. /** Options */
  41754. Options = 9,
  41755. /** Left stick */
  41756. LeftStick = 10,
  41757. /** Right stick */
  41758. RightStick = 11
  41759. }
  41760. /** Defines values for DualShock DPad */
  41761. export enum DualShockDpad {
  41762. /** Up */
  41763. Up = 12,
  41764. /** Down */
  41765. Down = 13,
  41766. /** Left */
  41767. Left = 14,
  41768. /** Right */
  41769. Right = 15
  41770. }
  41771. /**
  41772. * Defines a DualShock gamepad
  41773. */
  41774. export class DualShockPad extends Gamepad {
  41775. private _leftTrigger;
  41776. private _rightTrigger;
  41777. private _onlefttriggerchanged;
  41778. private _onrighttriggerchanged;
  41779. private _onbuttondown;
  41780. private _onbuttonup;
  41781. private _ondpaddown;
  41782. private _ondpadup;
  41783. /** Observable raised when a button is pressed */
  41784. onButtonDownObservable: Observable<DualShockButton>;
  41785. /** Observable raised when a button is released */
  41786. onButtonUpObservable: Observable<DualShockButton>;
  41787. /** Observable raised when a pad is pressed */
  41788. onPadDownObservable: Observable<DualShockDpad>;
  41789. /** Observable raised when a pad is released */
  41790. onPadUpObservable: Observable<DualShockDpad>;
  41791. private _buttonCross;
  41792. private _buttonCircle;
  41793. private _buttonSquare;
  41794. private _buttonTriangle;
  41795. private _buttonShare;
  41796. private _buttonOptions;
  41797. private _buttonL1;
  41798. private _buttonR1;
  41799. private _buttonLeftStick;
  41800. private _buttonRightStick;
  41801. private _dPadUp;
  41802. private _dPadDown;
  41803. private _dPadLeft;
  41804. private _dPadRight;
  41805. /**
  41806. * Creates a new DualShock gamepad object
  41807. * @param id defines the id of this gamepad
  41808. * @param index defines its index
  41809. * @param gamepad defines the internal HTML gamepad object
  41810. */
  41811. constructor(id: string, index: number, gamepad: any);
  41812. /**
  41813. * Defines the callback to call when left trigger is pressed
  41814. * @param callback defines the callback to use
  41815. */
  41816. onlefttriggerchanged(callback: (value: number) => void): void;
  41817. /**
  41818. * Defines the callback to call when right trigger is pressed
  41819. * @param callback defines the callback to use
  41820. */
  41821. onrighttriggerchanged(callback: (value: number) => void): void;
  41822. /**
  41823. * Gets the left trigger value
  41824. */
  41825. get leftTrigger(): number;
  41826. /**
  41827. * Sets the left trigger value
  41828. */
  41829. set leftTrigger(newValue: number);
  41830. /**
  41831. * Gets the right trigger value
  41832. */
  41833. get rightTrigger(): number;
  41834. /**
  41835. * Sets the right trigger value
  41836. */
  41837. set rightTrigger(newValue: number);
  41838. /**
  41839. * Defines the callback to call when a button is pressed
  41840. * @param callback defines the callback to use
  41841. */
  41842. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41843. /**
  41844. * Defines the callback to call when a button is released
  41845. * @param callback defines the callback to use
  41846. */
  41847. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41848. /**
  41849. * Defines the callback to call when a pad is pressed
  41850. * @param callback defines the callback to use
  41851. */
  41852. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41853. /**
  41854. * Defines the callback to call when a pad is released
  41855. * @param callback defines the callback to use
  41856. */
  41857. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41858. private _setButtonValue;
  41859. private _setDPadValue;
  41860. /**
  41861. * Gets the value of the `Cross` button
  41862. */
  41863. get buttonCross(): number;
  41864. /**
  41865. * Sets the value of the `Cross` button
  41866. */
  41867. set buttonCross(value: number);
  41868. /**
  41869. * Gets the value of the `Circle` button
  41870. */
  41871. get buttonCircle(): number;
  41872. /**
  41873. * Sets the value of the `Circle` button
  41874. */
  41875. set buttonCircle(value: number);
  41876. /**
  41877. * Gets the value of the `Square` button
  41878. */
  41879. get buttonSquare(): number;
  41880. /**
  41881. * Sets the value of the `Square` button
  41882. */
  41883. set buttonSquare(value: number);
  41884. /**
  41885. * Gets the value of the `Triangle` button
  41886. */
  41887. get buttonTriangle(): number;
  41888. /**
  41889. * Sets the value of the `Triangle` button
  41890. */
  41891. set buttonTriangle(value: number);
  41892. /**
  41893. * Gets the value of the `Options` button
  41894. */
  41895. get buttonOptions(): number;
  41896. /**
  41897. * Sets the value of the `Options` button
  41898. */
  41899. set buttonOptions(value: number);
  41900. /**
  41901. * Gets the value of the `Share` button
  41902. */
  41903. get buttonShare(): number;
  41904. /**
  41905. * Sets the value of the `Share` button
  41906. */
  41907. set buttonShare(value: number);
  41908. /**
  41909. * Gets the value of the `L1` button
  41910. */
  41911. get buttonL1(): number;
  41912. /**
  41913. * Sets the value of the `L1` button
  41914. */
  41915. set buttonL1(value: number);
  41916. /**
  41917. * Gets the value of the `R1` button
  41918. */
  41919. get buttonR1(): number;
  41920. /**
  41921. * Sets the value of the `R1` button
  41922. */
  41923. set buttonR1(value: number);
  41924. /**
  41925. * Gets the value of the Left joystick
  41926. */
  41927. get buttonLeftStick(): number;
  41928. /**
  41929. * Sets the value of the Left joystick
  41930. */
  41931. set buttonLeftStick(value: number);
  41932. /**
  41933. * Gets the value of the Right joystick
  41934. */
  41935. get buttonRightStick(): number;
  41936. /**
  41937. * Sets the value of the Right joystick
  41938. */
  41939. set buttonRightStick(value: number);
  41940. /**
  41941. * Gets the value of D-pad up
  41942. */
  41943. get dPadUp(): number;
  41944. /**
  41945. * Sets the value of D-pad up
  41946. */
  41947. set dPadUp(value: number);
  41948. /**
  41949. * Gets the value of D-pad down
  41950. */
  41951. get dPadDown(): number;
  41952. /**
  41953. * Sets the value of D-pad down
  41954. */
  41955. set dPadDown(value: number);
  41956. /**
  41957. * Gets the value of D-pad left
  41958. */
  41959. get dPadLeft(): number;
  41960. /**
  41961. * Sets the value of D-pad left
  41962. */
  41963. set dPadLeft(value: number);
  41964. /**
  41965. * Gets the value of D-pad right
  41966. */
  41967. get dPadRight(): number;
  41968. /**
  41969. * Sets the value of D-pad right
  41970. */
  41971. set dPadRight(value: number);
  41972. /**
  41973. * Force the gamepad to synchronize with device values
  41974. */
  41975. update(): void;
  41976. /**
  41977. * Disposes the gamepad
  41978. */
  41979. dispose(): void;
  41980. }
  41981. }
  41982. declare module BABYLON {
  41983. /**
  41984. * Manager for handling gamepads
  41985. */
  41986. export class GamepadManager {
  41987. private _scene?;
  41988. private _babylonGamepads;
  41989. private _oneGamepadConnected;
  41990. /** @hidden */
  41991. _isMonitoring: boolean;
  41992. private _gamepadEventSupported;
  41993. private _gamepadSupport?;
  41994. /**
  41995. * observable to be triggered when the gamepad controller has been connected
  41996. */
  41997. onGamepadConnectedObservable: Observable<Gamepad>;
  41998. /**
  41999. * observable to be triggered when the gamepad controller has been disconnected
  42000. */
  42001. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42002. private _onGamepadConnectedEvent;
  42003. private _onGamepadDisconnectedEvent;
  42004. /**
  42005. * Initializes the gamepad manager
  42006. * @param _scene BabylonJS scene
  42007. */
  42008. constructor(_scene?: Scene | undefined);
  42009. /**
  42010. * The gamepads in the game pad manager
  42011. */
  42012. get gamepads(): Gamepad[];
  42013. /**
  42014. * Get the gamepad controllers based on type
  42015. * @param type The type of gamepad controller
  42016. * @returns Nullable gamepad
  42017. */
  42018. getGamepadByType(type?: number): Nullable<Gamepad>;
  42019. /**
  42020. * Disposes the gamepad manager
  42021. */
  42022. dispose(): void;
  42023. private _addNewGamepad;
  42024. private _startMonitoringGamepads;
  42025. private _stopMonitoringGamepads;
  42026. /** @hidden */
  42027. _checkGamepadsStatus(): void;
  42028. private _updateGamepadObjects;
  42029. }
  42030. }
  42031. declare module BABYLON {
  42032. interface Scene {
  42033. /** @hidden */
  42034. _gamepadManager: Nullable<GamepadManager>;
  42035. /**
  42036. * Gets the gamepad manager associated with the scene
  42037. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42038. */
  42039. gamepadManager: GamepadManager;
  42040. }
  42041. /**
  42042. * Interface representing a free camera inputs manager
  42043. */
  42044. interface FreeCameraInputsManager {
  42045. /**
  42046. * Adds gamepad input support to the FreeCameraInputsManager.
  42047. * @returns the FreeCameraInputsManager
  42048. */
  42049. addGamepad(): FreeCameraInputsManager;
  42050. }
  42051. /**
  42052. * Interface representing an arc rotate camera inputs manager
  42053. */
  42054. interface ArcRotateCameraInputsManager {
  42055. /**
  42056. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42057. * @returns the camera inputs manager
  42058. */
  42059. addGamepad(): ArcRotateCameraInputsManager;
  42060. }
  42061. /**
  42062. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42063. */
  42064. export class GamepadSystemSceneComponent implements ISceneComponent {
  42065. /**
  42066. * The component name helpfull to identify the component in the list of scene components.
  42067. */
  42068. readonly name: string;
  42069. /**
  42070. * The scene the component belongs to.
  42071. */
  42072. scene: Scene;
  42073. /**
  42074. * Creates a new instance of the component for the given scene
  42075. * @param scene Defines the scene to register the component in
  42076. */
  42077. constructor(scene: Scene);
  42078. /**
  42079. * Registers the component in a given scene
  42080. */
  42081. register(): void;
  42082. /**
  42083. * Rebuilds the elements related to this component in case of
  42084. * context lost for instance.
  42085. */
  42086. rebuild(): void;
  42087. /**
  42088. * Disposes the component and the associated ressources
  42089. */
  42090. dispose(): void;
  42091. private _beforeCameraUpdate;
  42092. }
  42093. }
  42094. declare module BABYLON {
  42095. /**
  42096. * 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,
  42097. * which still works and will still be found in many Playgrounds.
  42098. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42099. */
  42100. export class UniversalCamera extends TouchCamera {
  42101. /**
  42102. * Defines the gamepad rotation sensiblity.
  42103. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42104. */
  42105. get gamepadAngularSensibility(): number;
  42106. set gamepadAngularSensibility(value: number);
  42107. /**
  42108. * Defines the gamepad move sensiblity.
  42109. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42110. */
  42111. get gamepadMoveSensibility(): number;
  42112. set gamepadMoveSensibility(value: number);
  42113. /**
  42114. * 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,
  42115. * which still works and will still be found in many Playgrounds.
  42116. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42117. * @param name Define the name of the camera in the scene
  42118. * @param position Define the start position of the camera in the scene
  42119. * @param scene Define the scene the camera belongs to
  42120. */
  42121. constructor(name: string, position: Vector3, scene: Scene);
  42122. /**
  42123. * Gets the current object class name.
  42124. * @return the class name
  42125. */
  42126. getClassName(): string;
  42127. }
  42128. }
  42129. declare module BABYLON {
  42130. /**
  42131. * This represents a FPS type of camera. This is only here for back compat purpose.
  42132. * Please use the UniversalCamera instead as both are identical.
  42133. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42134. */
  42135. export class GamepadCamera extends UniversalCamera {
  42136. /**
  42137. * Instantiates a new Gamepad Camera
  42138. * This represents a FPS type of camera. This is only here for back compat purpose.
  42139. * Please use the UniversalCamera instead as both are identical.
  42140. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42141. * @param name Define the name of the camera in the scene
  42142. * @param position Define the start position of the camera in the scene
  42143. * @param scene Define the scene the camera belongs to
  42144. */
  42145. constructor(name: string, position: Vector3, scene: Scene);
  42146. /**
  42147. * Gets the current object class name.
  42148. * @return the class name
  42149. */
  42150. getClassName(): string;
  42151. }
  42152. }
  42153. declare module BABYLON {
  42154. /** @hidden */
  42155. export var passPixelShader: {
  42156. name: string;
  42157. shader: string;
  42158. };
  42159. }
  42160. declare module BABYLON {
  42161. /** @hidden */
  42162. export var passCubePixelShader: {
  42163. name: string;
  42164. shader: string;
  42165. };
  42166. }
  42167. declare module BABYLON {
  42168. /**
  42169. * PassPostProcess which produces an output the same as it's input
  42170. */
  42171. export class PassPostProcess extends PostProcess {
  42172. /**
  42173. * Creates the PassPostProcess
  42174. * @param name The name of the effect.
  42175. * @param options The required width/height ratio to downsize to before computing the render pass.
  42176. * @param camera The camera to apply the render pass to.
  42177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42178. * @param engine The engine which the post process will be applied. (default: current engine)
  42179. * @param reusable If the post process can be reused on the same frame. (default: false)
  42180. * @param textureType The type of texture to be used when performing the post processing.
  42181. * @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)
  42182. */
  42183. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42184. }
  42185. /**
  42186. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42187. */
  42188. export class PassCubePostProcess extends PostProcess {
  42189. private _face;
  42190. /**
  42191. * Gets or sets the cube face to display.
  42192. * * 0 is +X
  42193. * * 1 is -X
  42194. * * 2 is +Y
  42195. * * 3 is -Y
  42196. * * 4 is +Z
  42197. * * 5 is -Z
  42198. */
  42199. get face(): number;
  42200. set face(value: number);
  42201. /**
  42202. * Creates the PassCubePostProcess
  42203. * @param name The name of the effect.
  42204. * @param options The required width/height ratio to downsize to before computing the render pass.
  42205. * @param camera The camera to apply the render pass to.
  42206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42207. * @param engine The engine which the post process will be applied. (default: current engine)
  42208. * @param reusable If the post process can be reused on the same frame. (default: false)
  42209. * @param textureType The type of texture to be used when performing the post processing.
  42210. * @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)
  42211. */
  42212. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42213. }
  42214. }
  42215. declare module BABYLON {
  42216. /** @hidden */
  42217. export var anaglyphPixelShader: {
  42218. name: string;
  42219. shader: string;
  42220. };
  42221. }
  42222. declare module BABYLON {
  42223. /**
  42224. * Postprocess used to generate anaglyphic rendering
  42225. */
  42226. export class AnaglyphPostProcess extends PostProcess {
  42227. private _passedProcess;
  42228. /**
  42229. * Creates a new AnaglyphPostProcess
  42230. * @param name defines postprocess name
  42231. * @param options defines creation options or target ratio scale
  42232. * @param rigCameras defines cameras using this postprocess
  42233. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42234. * @param engine defines hosting engine
  42235. * @param reusable defines if the postprocess will be reused multiple times per frame
  42236. */
  42237. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42238. }
  42239. }
  42240. declare module BABYLON {
  42241. /**
  42242. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42243. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42244. */
  42245. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42246. /**
  42247. * Creates a new AnaglyphArcRotateCamera
  42248. * @param name defines camera name
  42249. * @param alpha defines alpha angle (in radians)
  42250. * @param beta defines beta angle (in radians)
  42251. * @param radius defines radius
  42252. * @param target defines camera target
  42253. * @param interaxialDistance defines distance between each color axis
  42254. * @param scene defines the hosting scene
  42255. */
  42256. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42257. /**
  42258. * Gets camera class name
  42259. * @returns AnaglyphArcRotateCamera
  42260. */
  42261. getClassName(): string;
  42262. }
  42263. }
  42264. declare module BABYLON {
  42265. /**
  42266. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42267. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42268. */
  42269. export class AnaglyphFreeCamera extends FreeCamera {
  42270. /**
  42271. * Creates a new AnaglyphFreeCamera
  42272. * @param name defines camera name
  42273. * @param position defines initial position
  42274. * @param interaxialDistance defines distance between each color axis
  42275. * @param scene defines the hosting scene
  42276. */
  42277. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42278. /**
  42279. * Gets camera class name
  42280. * @returns AnaglyphFreeCamera
  42281. */
  42282. getClassName(): string;
  42283. }
  42284. }
  42285. declare module BABYLON {
  42286. /**
  42287. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42288. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42289. */
  42290. export class AnaglyphGamepadCamera extends GamepadCamera {
  42291. /**
  42292. * Creates a new AnaglyphGamepadCamera
  42293. * @param name defines camera name
  42294. * @param position defines initial position
  42295. * @param interaxialDistance defines distance between each color axis
  42296. * @param scene defines the hosting scene
  42297. */
  42298. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42299. /**
  42300. * Gets camera class name
  42301. * @returns AnaglyphGamepadCamera
  42302. */
  42303. getClassName(): string;
  42304. }
  42305. }
  42306. declare module BABYLON {
  42307. /**
  42308. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42309. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42310. */
  42311. export class AnaglyphUniversalCamera extends UniversalCamera {
  42312. /**
  42313. * Creates a new AnaglyphUniversalCamera
  42314. * @param name defines camera name
  42315. * @param position defines initial position
  42316. * @param interaxialDistance defines distance between each color axis
  42317. * @param scene defines the hosting scene
  42318. */
  42319. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42320. /**
  42321. * Gets camera class name
  42322. * @returns AnaglyphUniversalCamera
  42323. */
  42324. getClassName(): string;
  42325. }
  42326. }
  42327. declare module BABYLON {
  42328. /**
  42329. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42330. * @see http://doc.babylonjs.com/features/cameras
  42331. */
  42332. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42333. /**
  42334. * Creates a new StereoscopicArcRotateCamera
  42335. * @param name defines camera name
  42336. * @param alpha defines alpha angle (in radians)
  42337. * @param beta defines beta angle (in radians)
  42338. * @param radius defines radius
  42339. * @param target defines camera target
  42340. * @param interaxialDistance defines distance between each color axis
  42341. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42342. * @param scene defines the hosting scene
  42343. */
  42344. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42345. /**
  42346. * Gets camera class name
  42347. * @returns StereoscopicArcRotateCamera
  42348. */
  42349. getClassName(): string;
  42350. }
  42351. }
  42352. declare module BABYLON {
  42353. /**
  42354. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42355. * @see http://doc.babylonjs.com/features/cameras
  42356. */
  42357. export class StereoscopicFreeCamera extends FreeCamera {
  42358. /**
  42359. * Creates a new StereoscopicFreeCamera
  42360. * @param name defines camera name
  42361. * @param position defines initial position
  42362. * @param interaxialDistance defines distance between each color axis
  42363. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42364. * @param scene defines the hosting scene
  42365. */
  42366. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42367. /**
  42368. * Gets camera class name
  42369. * @returns StereoscopicFreeCamera
  42370. */
  42371. getClassName(): string;
  42372. }
  42373. }
  42374. declare module BABYLON {
  42375. /**
  42376. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42377. * @see http://doc.babylonjs.com/features/cameras
  42378. */
  42379. export class StereoscopicGamepadCamera extends GamepadCamera {
  42380. /**
  42381. * Creates a new StereoscopicGamepadCamera
  42382. * @param name defines camera name
  42383. * @param position defines initial position
  42384. * @param interaxialDistance defines distance between each color axis
  42385. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42386. * @param scene defines the hosting scene
  42387. */
  42388. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42389. /**
  42390. * Gets camera class name
  42391. * @returns StereoscopicGamepadCamera
  42392. */
  42393. getClassName(): string;
  42394. }
  42395. }
  42396. declare module BABYLON {
  42397. /**
  42398. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42399. * @see http://doc.babylonjs.com/features/cameras
  42400. */
  42401. export class StereoscopicUniversalCamera extends UniversalCamera {
  42402. /**
  42403. * Creates a new StereoscopicUniversalCamera
  42404. * @param name defines camera name
  42405. * @param position defines initial position
  42406. * @param interaxialDistance defines distance between each color axis
  42407. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42408. * @param scene defines the hosting scene
  42409. */
  42410. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42411. /**
  42412. * Gets camera class name
  42413. * @returns StereoscopicUniversalCamera
  42414. */
  42415. getClassName(): string;
  42416. }
  42417. }
  42418. declare module BABYLON {
  42419. /**
  42420. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42421. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42422. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42423. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42424. */
  42425. export class VirtualJoysticksCamera extends FreeCamera {
  42426. /**
  42427. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42428. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42429. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42430. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42431. * @param name Define the name of the camera in the scene
  42432. * @param position Define the start position of the camera in the scene
  42433. * @param scene Define the scene the camera belongs to
  42434. */
  42435. constructor(name: string, position: Vector3, scene: Scene);
  42436. /**
  42437. * Gets the current object class name.
  42438. * @return the class name
  42439. */
  42440. getClassName(): string;
  42441. }
  42442. }
  42443. declare module BABYLON {
  42444. /**
  42445. * This represents all the required metrics to create a VR camera.
  42446. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42447. */
  42448. export class VRCameraMetrics {
  42449. /**
  42450. * Define the horizontal resolution off the screen.
  42451. */
  42452. hResolution: number;
  42453. /**
  42454. * Define the vertical resolution off the screen.
  42455. */
  42456. vResolution: number;
  42457. /**
  42458. * Define the horizontal screen size.
  42459. */
  42460. hScreenSize: number;
  42461. /**
  42462. * Define the vertical screen size.
  42463. */
  42464. vScreenSize: number;
  42465. /**
  42466. * Define the vertical screen center position.
  42467. */
  42468. vScreenCenter: number;
  42469. /**
  42470. * Define the distance of the eyes to the screen.
  42471. */
  42472. eyeToScreenDistance: number;
  42473. /**
  42474. * Define the distance between both lenses
  42475. */
  42476. lensSeparationDistance: number;
  42477. /**
  42478. * Define the distance between both viewer's eyes.
  42479. */
  42480. interpupillaryDistance: number;
  42481. /**
  42482. * Define the distortion factor of the VR postprocess.
  42483. * Please, touch with care.
  42484. */
  42485. distortionK: number[];
  42486. /**
  42487. * Define the chromatic aberration correction factors for the VR post process.
  42488. */
  42489. chromaAbCorrection: number[];
  42490. /**
  42491. * Define the scale factor of the post process.
  42492. * The smaller the better but the slower.
  42493. */
  42494. postProcessScaleFactor: number;
  42495. /**
  42496. * Define an offset for the lens center.
  42497. */
  42498. lensCenterOffset: number;
  42499. /**
  42500. * Define if the current vr camera should compensate the distortion of the lense or not.
  42501. */
  42502. compensateDistortion: boolean;
  42503. /**
  42504. * Defines if multiview should be enabled when rendering (Default: false)
  42505. */
  42506. multiviewEnabled: boolean;
  42507. /**
  42508. * Gets the rendering aspect ratio based on the provided resolutions.
  42509. */
  42510. get aspectRatio(): number;
  42511. /**
  42512. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42513. */
  42514. get aspectRatioFov(): number;
  42515. /**
  42516. * @hidden
  42517. */
  42518. get leftHMatrix(): Matrix;
  42519. /**
  42520. * @hidden
  42521. */
  42522. get rightHMatrix(): Matrix;
  42523. /**
  42524. * @hidden
  42525. */
  42526. get leftPreViewMatrix(): Matrix;
  42527. /**
  42528. * @hidden
  42529. */
  42530. get rightPreViewMatrix(): Matrix;
  42531. /**
  42532. * Get the default VRMetrics based on the most generic setup.
  42533. * @returns the default vr metrics
  42534. */
  42535. static GetDefault(): VRCameraMetrics;
  42536. }
  42537. }
  42538. declare module BABYLON {
  42539. /** @hidden */
  42540. export var vrDistortionCorrectionPixelShader: {
  42541. name: string;
  42542. shader: string;
  42543. };
  42544. }
  42545. declare module BABYLON {
  42546. /**
  42547. * VRDistortionCorrectionPostProcess used for mobile VR
  42548. */
  42549. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42550. private _isRightEye;
  42551. private _distortionFactors;
  42552. private _postProcessScaleFactor;
  42553. private _lensCenterOffset;
  42554. private _scaleIn;
  42555. private _scaleFactor;
  42556. private _lensCenter;
  42557. /**
  42558. * Initializes the VRDistortionCorrectionPostProcess
  42559. * @param name The name of the effect.
  42560. * @param camera The camera to apply the render pass to.
  42561. * @param isRightEye If this is for the right eye distortion
  42562. * @param vrMetrics All the required metrics for the VR camera
  42563. */
  42564. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42565. }
  42566. }
  42567. declare module BABYLON {
  42568. /**
  42569. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42570. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42571. */
  42572. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42573. /**
  42574. * Creates a new VRDeviceOrientationArcRotateCamera
  42575. * @param name defines camera name
  42576. * @param alpha defines the camera rotation along the logitudinal axis
  42577. * @param beta defines the camera rotation along the latitudinal axis
  42578. * @param radius defines the camera distance from its target
  42579. * @param target defines the camera target
  42580. * @param scene defines the scene the camera belongs to
  42581. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42582. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42583. */
  42584. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42585. /**
  42586. * Gets camera class name
  42587. * @returns VRDeviceOrientationArcRotateCamera
  42588. */
  42589. getClassName(): string;
  42590. }
  42591. }
  42592. declare module BABYLON {
  42593. /**
  42594. * Camera used to simulate VR rendering (based on FreeCamera)
  42595. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42596. */
  42597. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42598. /**
  42599. * Creates a new VRDeviceOrientationFreeCamera
  42600. * @param name defines camera name
  42601. * @param position defines the start position of the camera
  42602. * @param scene defines the scene the camera belongs to
  42603. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42604. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42605. */
  42606. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42607. /**
  42608. * Gets camera class name
  42609. * @returns VRDeviceOrientationFreeCamera
  42610. */
  42611. getClassName(): string;
  42612. }
  42613. }
  42614. declare module BABYLON {
  42615. /**
  42616. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42617. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42618. */
  42619. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42620. /**
  42621. * Creates a new VRDeviceOrientationGamepadCamera
  42622. * @param name defines camera name
  42623. * @param position defines the start position of the camera
  42624. * @param scene defines the scene the camera belongs to
  42625. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42626. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42627. */
  42628. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42629. /**
  42630. * Gets camera class name
  42631. * @returns VRDeviceOrientationGamepadCamera
  42632. */
  42633. getClassName(): string;
  42634. }
  42635. }
  42636. declare module BABYLON {
  42637. /** @hidden */
  42638. export var imageProcessingPixelShader: {
  42639. name: string;
  42640. shader: string;
  42641. };
  42642. }
  42643. declare module BABYLON {
  42644. /**
  42645. * ImageProcessingPostProcess
  42646. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42647. */
  42648. export class ImageProcessingPostProcess extends PostProcess {
  42649. /**
  42650. * Default configuration related to image processing available in the PBR Material.
  42651. */
  42652. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42653. /**
  42654. * Gets the image processing configuration used either in this material.
  42655. */
  42656. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42657. /**
  42658. * Sets the Default image processing configuration used either in the this material.
  42659. *
  42660. * If sets to null, the scene one is in use.
  42661. */
  42662. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42663. /**
  42664. * Keep track of the image processing observer to allow dispose and replace.
  42665. */
  42666. private _imageProcessingObserver;
  42667. /**
  42668. * Attaches a new image processing configuration to the PBR Material.
  42669. * @param configuration
  42670. */
  42671. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42672. /**
  42673. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42674. */
  42675. get colorCurves(): Nullable<ColorCurves>;
  42676. /**
  42677. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42678. */
  42679. set colorCurves(value: Nullable<ColorCurves>);
  42680. /**
  42681. * Gets wether the color curves effect is enabled.
  42682. */
  42683. get colorCurvesEnabled(): boolean;
  42684. /**
  42685. * Sets wether the color curves effect is enabled.
  42686. */
  42687. set colorCurvesEnabled(value: boolean);
  42688. /**
  42689. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42690. */
  42691. get colorGradingTexture(): Nullable<BaseTexture>;
  42692. /**
  42693. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42694. */
  42695. set colorGradingTexture(value: Nullable<BaseTexture>);
  42696. /**
  42697. * Gets wether the color grading effect is enabled.
  42698. */
  42699. get colorGradingEnabled(): boolean;
  42700. /**
  42701. * Gets wether the color grading effect is enabled.
  42702. */
  42703. set colorGradingEnabled(value: boolean);
  42704. /**
  42705. * Gets exposure used in the effect.
  42706. */
  42707. get exposure(): number;
  42708. /**
  42709. * Sets exposure used in the effect.
  42710. */
  42711. set exposure(value: number);
  42712. /**
  42713. * Gets wether tonemapping is enabled or not.
  42714. */
  42715. get toneMappingEnabled(): boolean;
  42716. /**
  42717. * Sets wether tonemapping is enabled or not
  42718. */
  42719. set toneMappingEnabled(value: boolean);
  42720. /**
  42721. * Gets the type of tone mapping effect.
  42722. */
  42723. get toneMappingType(): number;
  42724. /**
  42725. * Sets the type of tone mapping effect.
  42726. */
  42727. set toneMappingType(value: number);
  42728. /**
  42729. * Gets contrast used in the effect.
  42730. */
  42731. get contrast(): number;
  42732. /**
  42733. * Sets contrast used in the effect.
  42734. */
  42735. set contrast(value: number);
  42736. /**
  42737. * Gets Vignette stretch size.
  42738. */
  42739. get vignetteStretch(): number;
  42740. /**
  42741. * Sets Vignette stretch size.
  42742. */
  42743. set vignetteStretch(value: number);
  42744. /**
  42745. * Gets Vignette centre X Offset.
  42746. */
  42747. get vignetteCentreX(): number;
  42748. /**
  42749. * Sets Vignette centre X Offset.
  42750. */
  42751. set vignetteCentreX(value: number);
  42752. /**
  42753. * Gets Vignette centre Y Offset.
  42754. */
  42755. get vignetteCentreY(): number;
  42756. /**
  42757. * Sets Vignette centre Y Offset.
  42758. */
  42759. set vignetteCentreY(value: number);
  42760. /**
  42761. * Gets Vignette weight or intensity of the vignette effect.
  42762. */
  42763. get vignetteWeight(): number;
  42764. /**
  42765. * Sets Vignette weight or intensity of the vignette effect.
  42766. */
  42767. set vignetteWeight(value: number);
  42768. /**
  42769. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42770. * if vignetteEnabled is set to true.
  42771. */
  42772. get vignetteColor(): Color4;
  42773. /**
  42774. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42775. * if vignetteEnabled is set to true.
  42776. */
  42777. set vignetteColor(value: Color4);
  42778. /**
  42779. * Gets Camera field of view used by the Vignette effect.
  42780. */
  42781. get vignetteCameraFov(): number;
  42782. /**
  42783. * Sets Camera field of view used by the Vignette effect.
  42784. */
  42785. set vignetteCameraFov(value: number);
  42786. /**
  42787. * Gets the vignette blend mode allowing different kind of effect.
  42788. */
  42789. get vignetteBlendMode(): number;
  42790. /**
  42791. * Sets the vignette blend mode allowing different kind of effect.
  42792. */
  42793. set vignetteBlendMode(value: number);
  42794. /**
  42795. * Gets wether the vignette effect is enabled.
  42796. */
  42797. get vignetteEnabled(): boolean;
  42798. /**
  42799. * Sets wether the vignette effect is enabled.
  42800. */
  42801. set vignetteEnabled(value: boolean);
  42802. private _fromLinearSpace;
  42803. /**
  42804. * Gets wether the input of the processing is in Gamma or Linear Space.
  42805. */
  42806. get fromLinearSpace(): boolean;
  42807. /**
  42808. * Sets wether the input of the processing is in Gamma or Linear Space.
  42809. */
  42810. set fromLinearSpace(value: boolean);
  42811. /**
  42812. * Defines cache preventing GC.
  42813. */
  42814. private _defines;
  42815. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42816. /**
  42817. * "ImageProcessingPostProcess"
  42818. * @returns "ImageProcessingPostProcess"
  42819. */
  42820. getClassName(): string;
  42821. protected _updateParameters(): void;
  42822. dispose(camera?: Camera): void;
  42823. }
  42824. }
  42825. declare module BABYLON {
  42826. /**
  42827. * Class containing static functions to help procedurally build meshes
  42828. */
  42829. export class GroundBuilder {
  42830. /**
  42831. * Creates a ground mesh
  42832. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42833. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42835. * @param name defines the name of the mesh
  42836. * @param options defines the options used to create the mesh
  42837. * @param scene defines the hosting scene
  42838. * @returns the ground mesh
  42839. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42840. */
  42841. static CreateGround(name: string, options: {
  42842. width?: number;
  42843. height?: number;
  42844. subdivisions?: number;
  42845. subdivisionsX?: number;
  42846. subdivisionsY?: number;
  42847. updatable?: boolean;
  42848. }, scene: any): Mesh;
  42849. /**
  42850. * Creates a tiled ground mesh
  42851. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42852. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42853. * * 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
  42854. * * 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
  42855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42856. * @param name defines the name of the mesh
  42857. * @param options defines the options used to create the mesh
  42858. * @param scene defines the hosting scene
  42859. * @returns the tiled ground mesh
  42860. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42861. */
  42862. static CreateTiledGround(name: string, options: {
  42863. xmin: number;
  42864. zmin: number;
  42865. xmax: number;
  42866. zmax: number;
  42867. subdivisions?: {
  42868. w: number;
  42869. h: number;
  42870. };
  42871. precision?: {
  42872. w: number;
  42873. h: number;
  42874. };
  42875. updatable?: boolean;
  42876. }, scene?: Nullable<Scene>): Mesh;
  42877. /**
  42878. * Creates a ground mesh from a height map
  42879. * * The parameter `url` sets the URL of the height map image resource.
  42880. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42881. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42882. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42883. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42884. * * 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.
  42885. * * 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).
  42886. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42888. * @param name defines the name of the mesh
  42889. * @param url defines the url to the height map
  42890. * @param options defines the options used to create the mesh
  42891. * @param scene defines the hosting scene
  42892. * @returns the ground mesh
  42893. * @see https://doc.babylonjs.com/babylon101/height_map
  42894. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42895. */
  42896. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42897. width?: number;
  42898. height?: number;
  42899. subdivisions?: number;
  42900. minHeight?: number;
  42901. maxHeight?: number;
  42902. colorFilter?: Color3;
  42903. alphaFilter?: number;
  42904. updatable?: boolean;
  42905. onReady?: (mesh: GroundMesh) => void;
  42906. }, scene?: Nullable<Scene>): GroundMesh;
  42907. }
  42908. }
  42909. declare module BABYLON {
  42910. /**
  42911. * Class containing static functions to help procedurally build meshes
  42912. */
  42913. export class TorusBuilder {
  42914. /**
  42915. * Creates a torus mesh
  42916. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42917. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42918. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42920. * * 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
  42921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42922. * @param name defines the name of the mesh
  42923. * @param options defines the options used to create the mesh
  42924. * @param scene defines the hosting scene
  42925. * @returns the torus mesh
  42926. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42927. */
  42928. static CreateTorus(name: string, options: {
  42929. diameter?: number;
  42930. thickness?: number;
  42931. tessellation?: number;
  42932. updatable?: boolean;
  42933. sideOrientation?: number;
  42934. frontUVs?: Vector4;
  42935. backUVs?: Vector4;
  42936. }, scene: any): Mesh;
  42937. }
  42938. }
  42939. declare module BABYLON {
  42940. /**
  42941. * Class containing static functions to help procedurally build meshes
  42942. */
  42943. export class CylinderBuilder {
  42944. /**
  42945. * Creates a cylinder or a cone mesh
  42946. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42947. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42948. * * 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.
  42949. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42950. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42951. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42952. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42953. * * 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).
  42954. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42955. * * 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).
  42956. * * 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
  42957. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42958. * * 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
  42959. * * 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.
  42960. * * If `enclose` is false, a ring surface is one element.
  42961. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42962. * * 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
  42963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42964. * * 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
  42965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42966. * @param name defines the name of the mesh
  42967. * @param options defines the options used to create the mesh
  42968. * @param scene defines the hosting scene
  42969. * @returns the cylinder mesh
  42970. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42971. */
  42972. static CreateCylinder(name: string, options: {
  42973. height?: number;
  42974. diameterTop?: number;
  42975. diameterBottom?: number;
  42976. diameter?: number;
  42977. tessellation?: number;
  42978. subdivisions?: number;
  42979. arc?: number;
  42980. faceColors?: Color4[];
  42981. faceUV?: Vector4[];
  42982. updatable?: boolean;
  42983. hasRings?: boolean;
  42984. enclose?: boolean;
  42985. cap?: number;
  42986. sideOrientation?: number;
  42987. frontUVs?: Vector4;
  42988. backUVs?: Vector4;
  42989. }, scene: any): Mesh;
  42990. }
  42991. }
  42992. declare module BABYLON {
  42993. /**
  42994. * States of the webXR experience
  42995. */
  42996. export enum WebXRState {
  42997. /**
  42998. * Transitioning to being in XR mode
  42999. */
  43000. ENTERING_XR = 0,
  43001. /**
  43002. * Transitioning to non XR mode
  43003. */
  43004. EXITING_XR = 1,
  43005. /**
  43006. * In XR mode and presenting
  43007. */
  43008. IN_XR = 2,
  43009. /**
  43010. * Not entered XR mode
  43011. */
  43012. NOT_IN_XR = 3
  43013. }
  43014. /**
  43015. * Abstraction of the XR render target
  43016. */
  43017. export interface WebXRRenderTarget extends IDisposable {
  43018. /**
  43019. * xrpresent context of the canvas which can be used to display/mirror xr content
  43020. */
  43021. canvasContext: WebGLRenderingContext;
  43022. /**
  43023. * xr layer for the canvas
  43024. */
  43025. xrLayer: Nullable<XRWebGLLayer>;
  43026. /**
  43027. * Initializes the xr layer for the session
  43028. * @param xrSession xr session
  43029. * @returns a promise that will resolve once the XR Layer has been created
  43030. */
  43031. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43032. }
  43033. }
  43034. declare module BABYLON {
  43035. /**
  43036. * COnfiguration object for WebXR output canvas
  43037. */
  43038. export class WebXRManagedOutputCanvasOptions {
  43039. /**
  43040. * An optional canvas in case you wish to create it yourself and provide it here.
  43041. * If not provided, a new canvas will be created
  43042. */
  43043. canvasElement?: HTMLCanvasElement;
  43044. /**
  43045. * Options for this XR Layer output
  43046. */
  43047. canvasOptions?: XRWebGLLayerOptions;
  43048. /**
  43049. * CSS styling for a newly created canvas (if not provided)
  43050. */
  43051. newCanvasCssStyle?: string;
  43052. /**
  43053. * Get the default values of the configuration object
  43054. * @returns default values of this configuration object
  43055. */
  43056. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43057. }
  43058. /**
  43059. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43060. */
  43061. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43062. private _options;
  43063. private _canvas;
  43064. private _engine;
  43065. /**
  43066. * Rendering context of the canvas which can be used to display/mirror xr content
  43067. */
  43068. canvasContext: WebGLRenderingContext;
  43069. /**
  43070. * xr layer for the canvas
  43071. */
  43072. xrLayer: Nullable<XRWebGLLayer>;
  43073. /**
  43074. * Initializes the canvas to be added/removed upon entering/exiting xr
  43075. * @param _xrSessionManager The XR Session manager
  43076. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43077. */
  43078. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43079. /**
  43080. * Disposes of the object
  43081. */
  43082. dispose(): void;
  43083. /**
  43084. * Initializes the xr layer for the session
  43085. * @param xrSession xr session
  43086. * @returns a promise that will resolve once the XR Layer has been created
  43087. */
  43088. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43089. private _addCanvas;
  43090. private _removeCanvas;
  43091. private _setManagedOutputCanvas;
  43092. }
  43093. }
  43094. declare module BABYLON {
  43095. /**
  43096. * Manages an XRSession to work with Babylon's engine
  43097. * @see https://doc.babylonjs.com/how_to/webxr
  43098. */
  43099. export class WebXRSessionManager implements IDisposable {
  43100. /** The scene which the session should be created for */
  43101. scene: Scene;
  43102. private _referenceSpace;
  43103. private _rttProvider;
  43104. private _sessionEnded;
  43105. private _xrNavigator;
  43106. private baseLayer;
  43107. /**
  43108. * The base reference space from which the session started. good if you want to reset your
  43109. * reference space
  43110. */
  43111. baseReferenceSpace: XRReferenceSpace;
  43112. /**
  43113. * Current XR frame
  43114. */
  43115. currentFrame: Nullable<XRFrame>;
  43116. /** WebXR timestamp updated every frame */
  43117. currentTimestamp: number;
  43118. /**
  43119. * Used just in case of a failure to initialize an immersive session.
  43120. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43121. */
  43122. defaultHeightCompensation: number;
  43123. /**
  43124. * Fires every time a new xrFrame arrives which can be used to update the camera
  43125. */
  43126. onXRFrameObservable: Observable<XRFrame>;
  43127. /**
  43128. * Fires when the reference space changed
  43129. */
  43130. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43131. /**
  43132. * Fires when the xr session is ended either by the device or manually done
  43133. */
  43134. onXRSessionEnded: Observable<any>;
  43135. /**
  43136. * Fires when the xr session is ended either by the device or manually done
  43137. */
  43138. onXRSessionInit: Observable<XRSession>;
  43139. /**
  43140. * Underlying xr session
  43141. */
  43142. session: XRSession;
  43143. /**
  43144. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43145. * or get the offset the player is currently at.
  43146. */
  43147. viewerReferenceSpace: XRReferenceSpace;
  43148. /**
  43149. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43150. * @param scene The scene which the session should be created for
  43151. */
  43152. constructor(
  43153. /** The scene which the session should be created for */
  43154. scene: Scene);
  43155. /**
  43156. * The current reference space used in this session. This reference space can constantly change!
  43157. * It is mainly used to offset the camera's position.
  43158. */
  43159. get referenceSpace(): XRReferenceSpace;
  43160. /**
  43161. * Set a new reference space and triggers the observable
  43162. */
  43163. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43164. /**
  43165. * Disposes of the session manager
  43166. */
  43167. dispose(): void;
  43168. /**
  43169. * Stops the xrSession and restores the render loop
  43170. * @returns Promise which resolves after it exits XR
  43171. */
  43172. exitXRAsync(): Promise<void>;
  43173. /**
  43174. * Gets the correct render target texture to be rendered this frame for this eye
  43175. * @param eye the eye for which to get the render target
  43176. * @returns the render target for the specified eye
  43177. */
  43178. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43179. /**
  43180. * Creates a WebXRRenderTarget object for the XR session
  43181. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43182. * @param options optional options to provide when creating a new render target
  43183. * @returns a WebXR render target to which the session can render
  43184. */
  43185. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43186. /**
  43187. * Initializes the manager
  43188. * After initialization enterXR can be called to start an XR session
  43189. * @returns Promise which resolves after it is initialized
  43190. */
  43191. initializeAsync(): Promise<void>;
  43192. /**
  43193. * Initializes an xr session
  43194. * @param xrSessionMode mode to initialize
  43195. * @param xrSessionInit defines optional and required values to pass to the session builder
  43196. * @returns a promise which will resolve once the session has been initialized
  43197. */
  43198. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43199. /**
  43200. * Checks if a session would be supported for the creation options specified
  43201. * @param sessionMode session mode to check if supported eg. immersive-vr
  43202. * @returns A Promise that resolves to true if supported and false if not
  43203. */
  43204. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43205. /**
  43206. * Resets the reference space to the one started the session
  43207. */
  43208. resetReferenceSpace(): void;
  43209. /**
  43210. * Starts rendering to the xr layer
  43211. */
  43212. runXRRenderLoop(): void;
  43213. /**
  43214. * Sets the reference space on the xr session
  43215. * @param referenceSpaceType space to set
  43216. * @returns a promise that will resolve once the reference space has been set
  43217. */
  43218. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43219. /**
  43220. * Updates the render state of the session
  43221. * @param state state to set
  43222. * @returns a promise that resolves once the render state has been updated
  43223. */
  43224. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43225. /**
  43226. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43227. * @param sessionMode defines the session to test
  43228. * @returns a promise with boolean as final value
  43229. */
  43230. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43231. private _createRenderTargetTexture;
  43232. }
  43233. }
  43234. declare module BABYLON {
  43235. /**
  43236. * WebXR Camera which holds the views for the xrSession
  43237. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43238. */
  43239. export class WebXRCamera extends FreeCamera {
  43240. private _xrSessionManager;
  43241. private _firstFrame;
  43242. private _referenceQuaternion;
  43243. private _referencedPosition;
  43244. private _xrInvPositionCache;
  43245. private _xrInvQuaternionCache;
  43246. /**
  43247. * Should position compensation execute on first frame.
  43248. * This is used when copying the position from a native (non XR) camera
  43249. */
  43250. compensateOnFirstFrame: boolean;
  43251. /**
  43252. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43253. * @param name the name of the camera
  43254. * @param scene the scene to add the camera to
  43255. * @param _xrSessionManager a constructed xr session manager
  43256. */
  43257. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43258. /**
  43259. * Return the user's height, unrelated to the current ground.
  43260. * This will be the y position of this camera, when ground level is 0.
  43261. */
  43262. get realWorldHeight(): number;
  43263. /** @hidden */
  43264. _updateForDualEyeDebugging(): void;
  43265. /**
  43266. * Sets this camera's transformation based on a non-vr camera
  43267. * @param otherCamera the non-vr camera to copy the transformation from
  43268. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43269. */
  43270. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43271. /**
  43272. * Gets the current instance class name ("WebXRCamera").
  43273. * @returns the class name
  43274. */
  43275. getClassName(): string;
  43276. private _updateFromXRSession;
  43277. private _updateNumberOfRigCameras;
  43278. private _updateReferenceSpace;
  43279. private _updateReferenceSpaceOffset;
  43280. }
  43281. }
  43282. declare module BABYLON {
  43283. /**
  43284. * Defining the interface required for a (webxr) feature
  43285. */
  43286. export interface IWebXRFeature extends IDisposable {
  43287. /**
  43288. * Is this feature attached
  43289. */
  43290. attached: boolean;
  43291. /**
  43292. * Should auto-attach be disabled?
  43293. */
  43294. disableAutoAttach: boolean;
  43295. /**
  43296. * Attach the feature to the session
  43297. * Will usually be called by the features manager
  43298. *
  43299. * @param force should attachment be forced (even when already attached)
  43300. * @returns true if successful.
  43301. */
  43302. attach(force?: boolean): boolean;
  43303. /**
  43304. * Detach the feature from the session
  43305. * Will usually be called by the features manager
  43306. *
  43307. * @returns true if successful.
  43308. */
  43309. detach(): boolean;
  43310. }
  43311. /**
  43312. * A list of the currently available features without referencing them
  43313. */
  43314. export class WebXRFeatureName {
  43315. /**
  43316. * The name of the anchor system feature
  43317. */
  43318. static ANCHOR_SYSTEM: string;
  43319. /**
  43320. * The name of the background remover feature
  43321. */
  43322. static BACKGROUND_REMOVER: string;
  43323. /**
  43324. * The name of the hit test feature
  43325. */
  43326. static HIT_TEST: string;
  43327. /**
  43328. * physics impostors for xr controllers feature
  43329. */
  43330. static PHYSICS_CONTROLLERS: string;
  43331. /**
  43332. * The name of the plane detection feature
  43333. */
  43334. static PLANE_DETECTION: string;
  43335. /**
  43336. * The name of the pointer selection feature
  43337. */
  43338. static POINTER_SELECTION: string;
  43339. /**
  43340. * The name of the teleportation feature
  43341. */
  43342. static TELEPORTATION: string;
  43343. }
  43344. /**
  43345. * Defining the constructor of a feature. Used to register the modules.
  43346. */
  43347. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43348. /**
  43349. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43350. * It is mainly used in AR sessions.
  43351. *
  43352. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43353. */
  43354. export class WebXRFeaturesManager implements IDisposable {
  43355. private _xrSessionManager;
  43356. private static readonly _AvailableFeatures;
  43357. private _features;
  43358. /**
  43359. * constructs a new features manages.
  43360. *
  43361. * @param _xrSessionManager an instance of WebXRSessionManager
  43362. */
  43363. constructor(_xrSessionManager: WebXRSessionManager);
  43364. /**
  43365. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43366. * Mainly used internally.
  43367. *
  43368. * @param featureName the name of the feature to register
  43369. * @param constructorFunction the function used to construct the module
  43370. * @param version the (babylon) version of the module
  43371. * @param stable is that a stable version of this module
  43372. */
  43373. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43374. /**
  43375. * Returns a constructor of a specific feature.
  43376. *
  43377. * @param featureName the name of the feature to construct
  43378. * @param version the version of the feature to load
  43379. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43380. * @param options optional options provided to the module.
  43381. * @returns a function that, when called, will return a new instance of this feature
  43382. */
  43383. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43384. /**
  43385. * Can be used to return the list of features currently registered
  43386. *
  43387. * @returns an Array of available features
  43388. */
  43389. static GetAvailableFeatures(): string[];
  43390. /**
  43391. * Gets the versions available for a specific feature
  43392. * @param featureName the name of the feature
  43393. * @returns an array with the available versions
  43394. */
  43395. static GetAvailableVersions(featureName: string): string[];
  43396. /**
  43397. * Return the latest unstable version of this feature
  43398. * @param featureName the name of the feature to search
  43399. * @returns the version number. if not found will return -1
  43400. */
  43401. static GetLatestVersionOfFeature(featureName: string): number;
  43402. /**
  43403. * Return the latest stable version of this feature
  43404. * @param featureName the name of the feature to search
  43405. * @returns the version number. if not found will return -1
  43406. */
  43407. static GetStableVersionOfFeature(featureName: string): number;
  43408. /**
  43409. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43410. * Can be used during a session to start a feature
  43411. * @param featureName the name of feature to attach
  43412. */
  43413. attachFeature(featureName: string): void;
  43414. /**
  43415. * Can be used inside a session or when the session ends to detach a specific feature
  43416. * @param featureName the name of the feature to detach
  43417. */
  43418. detachFeature(featureName: string): void;
  43419. /**
  43420. * Used to disable an already-enabled feature
  43421. * The feature will be disposed and will be recreated once enabled.
  43422. * @param featureName the feature to disable
  43423. * @returns true if disable was successful
  43424. */
  43425. disableFeature(featureName: string | {
  43426. Name: string;
  43427. }): boolean;
  43428. /**
  43429. * dispose this features manager
  43430. */
  43431. dispose(): void;
  43432. /**
  43433. * 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.
  43434. * 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.
  43435. *
  43436. * @param featureName the name of the feature to load or the class of the feature
  43437. * @param version optional version to load. if not provided the latest version will be enabled
  43438. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43439. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43440. * @returns a new constructed feature or throws an error if feature not found.
  43441. */
  43442. enableFeature(featureName: string | {
  43443. Name: string;
  43444. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43445. /**
  43446. * get the implementation of an enabled feature.
  43447. * @param featureName the name of the feature to load
  43448. * @returns the feature class, if found
  43449. */
  43450. getEnabledFeature(featureName: string): IWebXRFeature;
  43451. /**
  43452. * Get the list of enabled features
  43453. * @returns an array of enabled features
  43454. */
  43455. getEnabledFeatures(): string[];
  43456. }
  43457. }
  43458. declare module BABYLON {
  43459. /**
  43460. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43461. * @see https://doc.babylonjs.com/how_to/webxr
  43462. */
  43463. export class WebXRExperienceHelper implements IDisposable {
  43464. private scene;
  43465. private _nonVRCamera;
  43466. private _originalSceneAutoClear;
  43467. private _supported;
  43468. /**
  43469. * Camera used to render xr content
  43470. */
  43471. camera: WebXRCamera;
  43472. /** A features manager for this xr session */
  43473. featuresManager: WebXRFeaturesManager;
  43474. /**
  43475. * Observers registered here will be triggered after the camera's initial transformation is set
  43476. * This can be used to set a different ground level or an extra rotation.
  43477. *
  43478. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43479. * to the position set after this observable is done executing.
  43480. */
  43481. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43482. /**
  43483. * Fires when the state of the experience helper has changed
  43484. */
  43485. onStateChangedObservable: Observable<WebXRState>;
  43486. /** Session manager used to keep track of xr session */
  43487. sessionManager: WebXRSessionManager;
  43488. /**
  43489. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43490. */
  43491. state: WebXRState;
  43492. /**
  43493. * Creates a WebXRExperienceHelper
  43494. * @param scene The scene the helper should be created in
  43495. */
  43496. private constructor();
  43497. /**
  43498. * Creates the experience helper
  43499. * @param scene the scene to attach the experience helper to
  43500. * @returns a promise for the experience helper
  43501. */
  43502. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43503. /**
  43504. * Disposes of the experience helper
  43505. */
  43506. dispose(): void;
  43507. /**
  43508. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43509. * @param sessionMode options for the XR session
  43510. * @param referenceSpaceType frame of reference of the XR session
  43511. * @param renderTarget the output canvas that will be used to enter XR mode
  43512. * @returns promise that resolves after xr mode has entered
  43513. */
  43514. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43515. /**
  43516. * Exits XR mode and returns the scene to its original state
  43517. * @returns promise that resolves after xr mode has exited
  43518. */
  43519. exitXRAsync(): Promise<void>;
  43520. private _nonXRToXRCamera;
  43521. private _setState;
  43522. }
  43523. }
  43524. declare module BABYLON {
  43525. /**
  43526. * X-Y values for axes in WebXR
  43527. */
  43528. export interface IWebXRMotionControllerAxesValue {
  43529. /**
  43530. * The value of the x axis
  43531. */
  43532. x: number;
  43533. /**
  43534. * The value of the y-axis
  43535. */
  43536. y: number;
  43537. }
  43538. /**
  43539. * changed / previous values for the values of this component
  43540. */
  43541. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43542. /**
  43543. * current (this frame) value
  43544. */
  43545. current: T;
  43546. /**
  43547. * previous (last change) value
  43548. */
  43549. previous: T;
  43550. }
  43551. /**
  43552. * Represents changes in the component between current frame and last values recorded
  43553. */
  43554. export interface IWebXRMotionControllerComponentChanges {
  43555. /**
  43556. * will be populated with previous and current values if axes changed
  43557. */
  43558. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43559. /**
  43560. * will be populated with previous and current values if pressed changed
  43561. */
  43562. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43563. /**
  43564. * will be populated with previous and current values if touched changed
  43565. */
  43566. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43567. /**
  43568. * will be populated with previous and current values if value changed
  43569. */
  43570. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43571. }
  43572. /**
  43573. * This class represents a single component (for example button or thumbstick) of a motion controller
  43574. */
  43575. export class WebXRControllerComponent implements IDisposable {
  43576. /**
  43577. * the id of this component
  43578. */
  43579. id: string;
  43580. /**
  43581. * the type of the component
  43582. */
  43583. type: MotionControllerComponentType;
  43584. private _buttonIndex;
  43585. private _axesIndices;
  43586. private _axes;
  43587. private _changes;
  43588. private _currentValue;
  43589. private _hasChanges;
  43590. private _pressed;
  43591. private _touched;
  43592. /**
  43593. * button component type
  43594. */
  43595. static BUTTON_TYPE: MotionControllerComponentType;
  43596. /**
  43597. * squeeze component type
  43598. */
  43599. static SQUEEZE_TYPE: MotionControllerComponentType;
  43600. /**
  43601. * Thumbstick component type
  43602. */
  43603. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43604. /**
  43605. * Touchpad component type
  43606. */
  43607. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43608. /**
  43609. * trigger component type
  43610. */
  43611. static TRIGGER_TYPE: MotionControllerComponentType;
  43612. /**
  43613. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43614. * the axes data changes
  43615. */
  43616. onAxisValueChangedObservable: Observable<{
  43617. x: number;
  43618. y: number;
  43619. }>;
  43620. /**
  43621. * Observers registered here will be triggered when the state of a button changes
  43622. * State change is either pressed / touched / value
  43623. */
  43624. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43625. /**
  43626. * Creates a new component for a motion controller.
  43627. * It is created by the motion controller itself
  43628. *
  43629. * @param id the id of this component
  43630. * @param type the type of the component
  43631. * @param _buttonIndex index in the buttons array of the gamepad
  43632. * @param _axesIndices indices of the values in the axes array of the gamepad
  43633. */
  43634. constructor(
  43635. /**
  43636. * the id of this component
  43637. */
  43638. id: string,
  43639. /**
  43640. * the type of the component
  43641. */
  43642. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43643. /**
  43644. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43645. */
  43646. get axes(): IWebXRMotionControllerAxesValue;
  43647. /**
  43648. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43649. */
  43650. get changes(): IWebXRMotionControllerComponentChanges;
  43651. /**
  43652. * Return whether or not the component changed the last frame
  43653. */
  43654. get hasChanges(): boolean;
  43655. /**
  43656. * is the button currently pressed
  43657. */
  43658. get pressed(): boolean;
  43659. /**
  43660. * is the button currently touched
  43661. */
  43662. get touched(): boolean;
  43663. /**
  43664. * Get the current value of this component
  43665. */
  43666. get value(): number;
  43667. /**
  43668. * Dispose this component
  43669. */
  43670. dispose(): void;
  43671. /**
  43672. * Are there axes correlating to this component
  43673. * @return true is axes data is available
  43674. */
  43675. isAxes(): boolean;
  43676. /**
  43677. * Is this component a button (hence - pressable)
  43678. * @returns true if can be pressed
  43679. */
  43680. isButton(): boolean;
  43681. /**
  43682. * update this component using the gamepad object it is in. Called on every frame
  43683. * @param nativeController the native gamepad controller object
  43684. */
  43685. update(nativeController: IMinimalMotionControllerObject): void;
  43686. }
  43687. }
  43688. declare module BABYLON {
  43689. /**
  43690. * Class used to represent data loading progression
  43691. */
  43692. export class SceneLoaderProgressEvent {
  43693. /** defines if data length to load can be evaluated */
  43694. readonly lengthComputable: boolean;
  43695. /** defines the loaded data length */
  43696. readonly loaded: number;
  43697. /** defines the data length to load */
  43698. readonly total: number;
  43699. /**
  43700. * Create a new progress event
  43701. * @param lengthComputable defines if data length to load can be evaluated
  43702. * @param loaded defines the loaded data length
  43703. * @param total defines the data length to load
  43704. */
  43705. constructor(
  43706. /** defines if data length to load can be evaluated */
  43707. lengthComputable: boolean,
  43708. /** defines the loaded data length */
  43709. loaded: number,
  43710. /** defines the data length to load */
  43711. total: number);
  43712. /**
  43713. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43714. * @param event defines the source event
  43715. * @returns a new SceneLoaderProgressEvent
  43716. */
  43717. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43718. }
  43719. /**
  43720. * Interface used by SceneLoader plugins to define supported file extensions
  43721. */
  43722. export interface ISceneLoaderPluginExtensions {
  43723. /**
  43724. * Defines the list of supported extensions
  43725. */
  43726. [extension: string]: {
  43727. isBinary: boolean;
  43728. };
  43729. }
  43730. /**
  43731. * Interface used by SceneLoader plugin factory
  43732. */
  43733. export interface ISceneLoaderPluginFactory {
  43734. /**
  43735. * Defines the name of the factory
  43736. */
  43737. name: string;
  43738. /**
  43739. * Function called to create a new plugin
  43740. * @return the new plugin
  43741. */
  43742. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43743. /**
  43744. * The callback that returns true if the data can be directly loaded.
  43745. * @param data string containing the file data
  43746. * @returns if the data can be loaded directly
  43747. */
  43748. canDirectLoad?(data: string): boolean;
  43749. }
  43750. /**
  43751. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43752. */
  43753. export interface ISceneLoaderPluginBase {
  43754. /**
  43755. * The friendly name of this plugin.
  43756. */
  43757. name: string;
  43758. /**
  43759. * The file extensions supported by this plugin.
  43760. */
  43761. extensions: string | ISceneLoaderPluginExtensions;
  43762. /**
  43763. * The callback called when loading from a url.
  43764. * @param scene scene loading this url
  43765. * @param url url to load
  43766. * @param onSuccess callback called when the file successfully loads
  43767. * @param onProgress callback called while file is loading (if the server supports this mode)
  43768. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43769. * @param onError callback called when the file fails to load
  43770. * @returns a file request object
  43771. */
  43772. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43773. /**
  43774. * The callback called when loading from a file object.
  43775. * @param scene scene loading this file
  43776. * @param file defines the file to load
  43777. * @param onSuccess defines the callback to call when data is loaded
  43778. * @param onProgress defines the callback to call during loading process
  43779. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43780. * @param onError defines the callback to call when an error occurs
  43781. * @returns a file request object
  43782. */
  43783. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43784. /**
  43785. * The callback that returns true if the data can be directly loaded.
  43786. * @param data string containing the file data
  43787. * @returns if the data can be loaded directly
  43788. */
  43789. canDirectLoad?(data: string): boolean;
  43790. /**
  43791. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43792. * @param scene scene loading this data
  43793. * @param data string containing the data
  43794. * @returns data to pass to the plugin
  43795. */
  43796. directLoad?(scene: Scene, data: string): any;
  43797. /**
  43798. * The callback that allows custom handling of the root url based on the response url.
  43799. * @param rootUrl the original root url
  43800. * @param responseURL the response url if available
  43801. * @returns the new root url
  43802. */
  43803. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43804. }
  43805. /**
  43806. * Interface used to define a SceneLoader plugin
  43807. */
  43808. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43809. /**
  43810. * Import meshes into a scene.
  43811. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43812. * @param scene The scene to import into
  43813. * @param data The data to import
  43814. * @param rootUrl The root url for scene and resources
  43815. * @param meshes The meshes array to import into
  43816. * @param particleSystems The particle systems array to import into
  43817. * @param skeletons The skeletons array to import into
  43818. * @param onError The callback when import fails
  43819. * @returns True if successful or false otherwise
  43820. */
  43821. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43822. /**
  43823. * Load into a scene.
  43824. * @param scene The scene to load into
  43825. * @param data The data to import
  43826. * @param rootUrl The root url for scene and resources
  43827. * @param onError The callback when import fails
  43828. * @returns True if successful or false otherwise
  43829. */
  43830. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43831. /**
  43832. * Load into an asset container.
  43833. * @param scene The scene to load into
  43834. * @param data The data to import
  43835. * @param rootUrl The root url for scene and resources
  43836. * @param onError The callback when import fails
  43837. * @returns The loaded asset container
  43838. */
  43839. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43840. }
  43841. /**
  43842. * Interface used to define an async SceneLoader plugin
  43843. */
  43844. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43845. /**
  43846. * Import meshes into a scene.
  43847. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43848. * @param scene The scene to import into
  43849. * @param data The data to import
  43850. * @param rootUrl The root url for scene and resources
  43851. * @param onProgress The callback when the load progresses
  43852. * @param fileName Defines the name of the file to load
  43853. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43854. */
  43855. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43856. meshes: AbstractMesh[];
  43857. particleSystems: IParticleSystem[];
  43858. skeletons: Skeleton[];
  43859. animationGroups: AnimationGroup[];
  43860. }>;
  43861. /**
  43862. * Load into a scene.
  43863. * @param scene The scene to load into
  43864. * @param data The data to import
  43865. * @param rootUrl The root url for scene and resources
  43866. * @param onProgress The callback when the load progresses
  43867. * @param fileName Defines the name of the file to load
  43868. * @returns Nothing
  43869. */
  43870. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43871. /**
  43872. * Load into an asset container.
  43873. * @param scene The scene to load into
  43874. * @param data The data to import
  43875. * @param rootUrl The root url for scene and resources
  43876. * @param onProgress The callback when the load progresses
  43877. * @param fileName Defines the name of the file to load
  43878. * @returns The loaded asset container
  43879. */
  43880. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43881. }
  43882. /**
  43883. * Mode that determines how to handle old animation groups before loading new ones.
  43884. */
  43885. export enum SceneLoaderAnimationGroupLoadingMode {
  43886. /**
  43887. * Reset all old animations to initial state then dispose them.
  43888. */
  43889. Clean = 0,
  43890. /**
  43891. * Stop all old animations.
  43892. */
  43893. Stop = 1,
  43894. /**
  43895. * Restart old animations from first frame.
  43896. */
  43897. Sync = 2,
  43898. /**
  43899. * Old animations remains untouched.
  43900. */
  43901. NoSync = 3
  43902. }
  43903. /**
  43904. * Class used to load scene from various file formats using registered plugins
  43905. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43906. */
  43907. export class SceneLoader {
  43908. /**
  43909. * No logging while loading
  43910. */
  43911. static readonly NO_LOGGING: number;
  43912. /**
  43913. * Minimal logging while loading
  43914. */
  43915. static readonly MINIMAL_LOGGING: number;
  43916. /**
  43917. * Summary logging while loading
  43918. */
  43919. static readonly SUMMARY_LOGGING: number;
  43920. /**
  43921. * Detailled logging while loading
  43922. */
  43923. static readonly DETAILED_LOGGING: number;
  43924. /**
  43925. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43926. */
  43927. static get ForceFullSceneLoadingForIncremental(): boolean;
  43928. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43929. /**
  43930. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43931. */
  43932. static get ShowLoadingScreen(): boolean;
  43933. static set ShowLoadingScreen(value: boolean);
  43934. /**
  43935. * Defines the current logging level (while loading the scene)
  43936. * @ignorenaming
  43937. */
  43938. static get loggingLevel(): number;
  43939. static set loggingLevel(value: number);
  43940. /**
  43941. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43942. */
  43943. static get CleanBoneMatrixWeights(): boolean;
  43944. static set CleanBoneMatrixWeights(value: boolean);
  43945. /**
  43946. * Event raised when a plugin is used to load a scene
  43947. */
  43948. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43949. private static _registeredPlugins;
  43950. private static _getDefaultPlugin;
  43951. private static _getPluginForExtension;
  43952. private static _getPluginForDirectLoad;
  43953. private static _getPluginForFilename;
  43954. private static _getDirectLoad;
  43955. private static _loadData;
  43956. private static _getFileInfo;
  43957. /**
  43958. * Gets a plugin that can load the given extension
  43959. * @param extension defines the extension to load
  43960. * @returns a plugin or null if none works
  43961. */
  43962. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43963. /**
  43964. * Gets a boolean indicating that the given extension can be loaded
  43965. * @param extension defines the extension to load
  43966. * @returns true if the extension is supported
  43967. */
  43968. static IsPluginForExtensionAvailable(extension: string): boolean;
  43969. /**
  43970. * Adds a new plugin to the list of registered plugins
  43971. * @param plugin defines the plugin to add
  43972. */
  43973. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43974. /**
  43975. * Import meshes into a scene
  43976. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43977. * @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)
  43978. * @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)
  43979. * @param scene the instance of BABYLON.Scene to append to
  43980. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43981. * @param onProgress a callback with a progress event for each file being loaded
  43982. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43983. * @param pluginExtension the extension used to determine the plugin
  43984. * @returns The loaded plugin
  43985. */
  43986. 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>;
  43987. /**
  43988. * Import meshes into a scene
  43989. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43990. * @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)
  43991. * @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)
  43992. * @param scene the instance of BABYLON.Scene to append to
  43993. * @param onProgress a callback with a progress event for each file being loaded
  43994. * @param pluginExtension the extension used to determine the plugin
  43995. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43996. */
  43997. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43998. meshes: AbstractMesh[];
  43999. particleSystems: IParticleSystem[];
  44000. skeletons: Skeleton[];
  44001. animationGroups: AnimationGroup[];
  44002. }>;
  44003. /**
  44004. * Load a scene
  44005. * @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)
  44006. * @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)
  44007. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44008. * @param onSuccess a callback with the scene when import succeeds
  44009. * @param onProgress a callback with a progress event for each file being loaded
  44010. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44011. * @param pluginExtension the extension used to determine the plugin
  44012. * @returns The loaded plugin
  44013. */
  44014. 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>;
  44015. /**
  44016. * Load a scene
  44017. * @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)
  44018. * @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)
  44019. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44020. * @param onProgress a callback with a progress event for each file being loaded
  44021. * @param pluginExtension the extension used to determine the plugin
  44022. * @returns The loaded scene
  44023. */
  44024. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44025. /**
  44026. * Append a scene
  44027. * @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)
  44028. * @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)
  44029. * @param scene is the instance of BABYLON.Scene to append to
  44030. * @param onSuccess a callback with the scene when import succeeds
  44031. * @param onProgress a callback with a progress event for each file being loaded
  44032. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44033. * @param pluginExtension the extension used to determine the plugin
  44034. * @returns The loaded plugin
  44035. */
  44036. 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>;
  44037. /**
  44038. * Append a scene
  44039. * @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)
  44040. * @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)
  44041. * @param scene is the instance of BABYLON.Scene to append to
  44042. * @param onProgress a callback with a progress event for each file being loaded
  44043. * @param pluginExtension the extension used to determine the plugin
  44044. * @returns The given scene
  44045. */
  44046. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44047. /**
  44048. * Load a scene into an asset container
  44049. * @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)
  44050. * @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)
  44051. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44052. * @param onSuccess a callback with the scene when import succeeds
  44053. * @param onProgress a callback with a progress event for each file being loaded
  44054. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44055. * @param pluginExtension the extension used to determine the plugin
  44056. * @returns The loaded plugin
  44057. */
  44058. 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>;
  44059. /**
  44060. * Load a scene into an asset container
  44061. * @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)
  44062. * @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)
  44063. * @param scene is the instance of Scene to append to
  44064. * @param onProgress a callback with a progress event for each file being loaded
  44065. * @param pluginExtension the extension used to determine the plugin
  44066. * @returns The loaded asset container
  44067. */
  44068. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44069. /**
  44070. * Import animations from a file into a scene
  44071. * @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)
  44072. * @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)
  44073. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44074. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44075. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44076. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44077. * @param onSuccess a callback with the scene when import succeeds
  44078. * @param onProgress a callback with a progress event for each file being loaded
  44079. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44080. */
  44081. 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;
  44082. /**
  44083. * Import animations from a file into a scene
  44084. * @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)
  44085. * @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)
  44086. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44087. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44088. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44089. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44090. * @param onSuccess a callback with the scene when import succeeds
  44091. * @param onProgress a callback with a progress event for each file being loaded
  44092. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44093. * @returns the updated scene with imported animations
  44094. */
  44095. 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>;
  44096. }
  44097. }
  44098. declare module BABYLON {
  44099. /**
  44100. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44101. */
  44102. export type MotionControllerHandedness = "none" | "left" | "right";
  44103. /**
  44104. * The type of components available in motion controllers.
  44105. * This is not the name of the component.
  44106. */
  44107. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44108. /**
  44109. * The state of a controller component
  44110. */
  44111. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44112. /**
  44113. * The schema of motion controller layout.
  44114. * No object will be initialized using this interface
  44115. * This is used just to define the profile.
  44116. */
  44117. export interface IMotionControllerLayout {
  44118. /**
  44119. * Path to load the assets. Usually relative to the base path
  44120. */
  44121. assetPath: string;
  44122. /**
  44123. * Available components (unsorted)
  44124. */
  44125. components: {
  44126. /**
  44127. * A map of component Ids
  44128. */
  44129. [componentId: string]: {
  44130. /**
  44131. * The type of input the component outputs
  44132. */
  44133. type: MotionControllerComponentType;
  44134. /**
  44135. * The indices of this component in the gamepad object
  44136. */
  44137. gamepadIndices: {
  44138. /**
  44139. * Index of button
  44140. */
  44141. button?: number;
  44142. /**
  44143. * If available, index of x-axis
  44144. */
  44145. xAxis?: number;
  44146. /**
  44147. * If available, index of y-axis
  44148. */
  44149. yAxis?: number;
  44150. };
  44151. /**
  44152. * The mesh's root node name
  44153. */
  44154. rootNodeName: string;
  44155. /**
  44156. * Animation definitions for this model
  44157. */
  44158. visualResponses: {
  44159. [stateKey: string]: {
  44160. /**
  44161. * What property will be animated
  44162. */
  44163. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44164. /**
  44165. * What states influence this visual response
  44166. */
  44167. states: MotionControllerComponentStateType[];
  44168. /**
  44169. * Type of animation - movement or visibility
  44170. */
  44171. valueNodeProperty: "transform" | "visibility";
  44172. /**
  44173. * Base node name to move. Its position will be calculated according to the min and max nodes
  44174. */
  44175. valueNodeName?: string;
  44176. /**
  44177. * Minimum movement node
  44178. */
  44179. minNodeName?: string;
  44180. /**
  44181. * Max movement node
  44182. */
  44183. maxNodeName?: string;
  44184. };
  44185. };
  44186. /**
  44187. * If touch enabled, what is the name of node to display user feedback
  44188. */
  44189. touchPointNodeName?: string;
  44190. };
  44191. };
  44192. /**
  44193. * Is it xr standard mapping or not
  44194. */
  44195. gamepadMapping: "" | "xr-standard";
  44196. /**
  44197. * Base root node of this entire model
  44198. */
  44199. rootNodeName: string;
  44200. /**
  44201. * Defines the main button component id
  44202. */
  44203. selectComponentId: string;
  44204. }
  44205. /**
  44206. * A definition for the layout map in the input profile
  44207. */
  44208. export interface IMotionControllerLayoutMap {
  44209. /**
  44210. * Layouts with handedness type as a key
  44211. */
  44212. [handedness: string]: IMotionControllerLayout;
  44213. }
  44214. /**
  44215. * The XR Input profile schema
  44216. * Profiles can be found here:
  44217. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44218. */
  44219. export interface IMotionControllerProfile {
  44220. /**
  44221. * fallback profiles for this profileId
  44222. */
  44223. fallbackProfileIds: string[];
  44224. /**
  44225. * The layout map, with handedness as key
  44226. */
  44227. layouts: IMotionControllerLayoutMap;
  44228. /**
  44229. * The id of this profile
  44230. * correlates to the profile(s) in the xrInput.profiles array
  44231. */
  44232. profileId: string;
  44233. }
  44234. /**
  44235. * A helper-interface for the 3 meshes needed for controller button animation
  44236. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44237. */
  44238. export interface IMotionControllerButtonMeshMap {
  44239. /**
  44240. * the mesh that defines the pressed value mesh position.
  44241. * This is used to find the max-position of this button
  44242. */
  44243. pressedMesh: AbstractMesh;
  44244. /**
  44245. * the mesh that defines the unpressed value mesh position.
  44246. * This is used to find the min (or initial) position of this button
  44247. */
  44248. unpressedMesh: AbstractMesh;
  44249. /**
  44250. * The mesh that will be changed when value changes
  44251. */
  44252. valueMesh: AbstractMesh;
  44253. }
  44254. /**
  44255. * A helper-interface for the 3 meshes needed for controller axis animation.
  44256. * This will be expanded when touchpad animations are fully supported
  44257. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44258. */
  44259. export interface IMotionControllerMeshMap {
  44260. /**
  44261. * the mesh that defines the maximum value mesh position.
  44262. */
  44263. maxMesh?: AbstractMesh;
  44264. /**
  44265. * the mesh that defines the minimum value mesh position.
  44266. */
  44267. minMesh?: AbstractMesh;
  44268. /**
  44269. * The mesh that will be changed when axis value changes
  44270. */
  44271. valueMesh: AbstractMesh;
  44272. }
  44273. /**
  44274. * The elements needed for change-detection of the gamepad objects in motion controllers
  44275. */
  44276. export interface IMinimalMotionControllerObject {
  44277. /**
  44278. * Available axes of this controller
  44279. */
  44280. axes: number[];
  44281. /**
  44282. * An array of available buttons
  44283. */
  44284. buttons: Array<{
  44285. /**
  44286. * Value of the button/trigger
  44287. */
  44288. value: number;
  44289. /**
  44290. * If the button/trigger is currently touched
  44291. */
  44292. touched: boolean;
  44293. /**
  44294. * If the button/trigger is currently pressed
  44295. */
  44296. pressed: boolean;
  44297. }>;
  44298. }
  44299. /**
  44300. * An Abstract Motion controller
  44301. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44302. * Each component has an observable to check for changes in value and state
  44303. */
  44304. export abstract class WebXRAbstractMotionController implements IDisposable {
  44305. protected scene: Scene;
  44306. protected layout: IMotionControllerLayout;
  44307. /**
  44308. * The gamepad object correlating to this controller
  44309. */
  44310. gamepadObject: IMinimalMotionControllerObject;
  44311. /**
  44312. * handedness (left/right/none) of this controller
  44313. */
  44314. handedness: MotionControllerHandedness;
  44315. private _initComponent;
  44316. private _modelReady;
  44317. /**
  44318. * A map of components (WebXRControllerComponent) in this motion controller
  44319. * Components have a ComponentType and can also have both button and axis definitions
  44320. */
  44321. readonly components: {
  44322. [id: string]: WebXRControllerComponent;
  44323. };
  44324. /**
  44325. * Disable the model's animation. Can be set at any time.
  44326. */
  44327. disableAnimation: boolean;
  44328. /**
  44329. * Observers registered here will be triggered when the model of this controller is done loading
  44330. */
  44331. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44332. /**
  44333. * The profile id of this motion controller
  44334. */
  44335. abstract profileId: string;
  44336. /**
  44337. * The root mesh of the model. It is null if the model was not yet initialized
  44338. */
  44339. rootMesh: Nullable<AbstractMesh>;
  44340. /**
  44341. * constructs a new abstract motion controller
  44342. * @param scene the scene to which the model of the controller will be added
  44343. * @param layout The profile layout to load
  44344. * @param gamepadObject The gamepad object correlating to this controller
  44345. * @param handedness handedness (left/right/none) of this controller
  44346. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44347. */
  44348. constructor(scene: Scene, layout: IMotionControllerLayout,
  44349. /**
  44350. * The gamepad object correlating to this controller
  44351. */
  44352. gamepadObject: IMinimalMotionControllerObject,
  44353. /**
  44354. * handedness (left/right/none) of this controller
  44355. */
  44356. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  44357. /**
  44358. * Dispose this controller, the model mesh and all its components
  44359. */
  44360. dispose(): void;
  44361. /**
  44362. * Returns all components of specific type
  44363. * @param type the type to search for
  44364. * @return an array of components with this type
  44365. */
  44366. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44367. /**
  44368. * get a component based an its component id as defined in layout.components
  44369. * @param id the id of the component
  44370. * @returns the component correlates to the id or undefined if not found
  44371. */
  44372. getComponent(id: string): WebXRControllerComponent;
  44373. /**
  44374. * Get the list of components available in this motion controller
  44375. * @returns an array of strings correlating to available components
  44376. */
  44377. getComponentIds(): string[];
  44378. /**
  44379. * Get the first component of specific type
  44380. * @param type type of component to find
  44381. * @return a controller component or null if not found
  44382. */
  44383. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44384. /**
  44385. * Get the main (Select) component of this controller as defined in the layout
  44386. * @returns the main component of this controller
  44387. */
  44388. getMainComponent(): WebXRControllerComponent;
  44389. /**
  44390. * Loads the model correlating to this controller
  44391. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44392. * @returns A promise fulfilled with the result of the model loading
  44393. */
  44394. loadModel(): Promise<boolean>;
  44395. /**
  44396. * Update this model using the current XRFrame
  44397. * @param xrFrame the current xr frame to use and update the model
  44398. */
  44399. updateFromXRFrame(xrFrame: XRFrame): void;
  44400. /**
  44401. * Backwards compatibility due to a deeply-integrated typo
  44402. */
  44403. get handness(): XREye;
  44404. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44405. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44406. /**
  44407. * Moves the axis on the controller mesh based on its current state
  44408. * @param axis the index of the axis
  44409. * @param axisValue the value of the axis which determines the meshes new position
  44410. * @hidden
  44411. */
  44412. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44413. /**
  44414. * Update the model itself with the current frame data
  44415. * @param xrFrame the frame to use for updating the model mesh
  44416. */
  44417. protected updateModel(xrFrame: XRFrame): void;
  44418. /**
  44419. * Get the filename and path for this controller's model
  44420. * @returns a map of filename and path
  44421. */
  44422. protected abstract _getFilenameAndPath(): {
  44423. filename: string;
  44424. path: string;
  44425. };
  44426. /**
  44427. * This function is called before the mesh is loaded. It checks for loading constraints.
  44428. * For example, this function can check if the GLB loader is available
  44429. * If this function returns false, the generic controller will be loaded instead
  44430. * @returns Is the client ready to load the mesh
  44431. */
  44432. protected abstract _getModelLoadingConstraints(): boolean;
  44433. /**
  44434. * This function will be called after the model was successfully loaded and can be used
  44435. * for mesh transformations before it is available for the user
  44436. * @param meshes the loaded meshes
  44437. */
  44438. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44439. /**
  44440. * Set the root mesh for this controller. Important for the WebXR controller class
  44441. * @param meshes the loaded meshes
  44442. */
  44443. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44444. /**
  44445. * A function executed each frame that updates the mesh (if needed)
  44446. * @param xrFrame the current xrFrame
  44447. */
  44448. protected abstract _updateModel(xrFrame: XRFrame): void;
  44449. private _getGenericFilenameAndPath;
  44450. private _getGenericParentMesh;
  44451. }
  44452. }
  44453. declare module BABYLON {
  44454. /**
  44455. * A generic trigger-only motion controller for WebXR
  44456. */
  44457. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44458. /**
  44459. * Static version of the profile id of this controller
  44460. */
  44461. static ProfileId: string;
  44462. profileId: string;
  44463. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  44464. protected _getFilenameAndPath(): {
  44465. filename: string;
  44466. path: string;
  44467. };
  44468. protected _getModelLoadingConstraints(): boolean;
  44469. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44470. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44471. protected _updateModel(): void;
  44472. }
  44473. }
  44474. declare module BABYLON {
  44475. /**
  44476. * Class containing static functions to help procedurally build meshes
  44477. */
  44478. export class SphereBuilder {
  44479. /**
  44480. * Creates a sphere mesh
  44481. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44482. * * 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`)
  44483. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44484. * * 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
  44485. * * 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)
  44486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44487. * * 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
  44488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44489. * @param name defines the name of the mesh
  44490. * @param options defines the options used to create the mesh
  44491. * @param scene defines the hosting scene
  44492. * @returns the sphere mesh
  44493. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44494. */
  44495. static CreateSphere(name: string, options: {
  44496. segments?: number;
  44497. diameter?: number;
  44498. diameterX?: number;
  44499. diameterY?: number;
  44500. diameterZ?: number;
  44501. arc?: number;
  44502. slice?: number;
  44503. sideOrientation?: number;
  44504. frontUVs?: Vector4;
  44505. backUVs?: Vector4;
  44506. updatable?: boolean;
  44507. }, scene?: Nullable<Scene>): Mesh;
  44508. }
  44509. }
  44510. declare module BABYLON {
  44511. /**
  44512. * A profiled motion controller has its profile loaded from an online repository.
  44513. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44514. */
  44515. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44516. private _repositoryUrl;
  44517. private _buttonMeshMapping;
  44518. private _touchDots;
  44519. /**
  44520. * The profile ID of this controller. Will be populated when the controller initializes.
  44521. */
  44522. profileId: string;
  44523. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44524. dispose(): void;
  44525. protected _getFilenameAndPath(): {
  44526. filename: string;
  44527. path: string;
  44528. };
  44529. protected _getModelLoadingConstraints(): boolean;
  44530. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44531. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44532. protected _updateModel(_xrFrame: XRFrame): void;
  44533. }
  44534. }
  44535. declare module BABYLON {
  44536. /**
  44537. * A construction function type to create a new controller based on an xrInput object
  44538. */
  44539. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44540. /**
  44541. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44542. *
  44543. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44544. * it should be replaced with auto-loaded controllers.
  44545. *
  44546. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44547. */
  44548. export class WebXRMotionControllerManager {
  44549. private static _AvailableControllers;
  44550. private static _Fallbacks;
  44551. private static _ProfileLoadingPromises;
  44552. private static _ProfilesList;
  44553. /**
  44554. * The base URL of the online controller repository. Can be changed at any time.
  44555. */
  44556. static BaseRepositoryUrl: string;
  44557. /**
  44558. * Which repository gets priority - local or online
  44559. */
  44560. static PrioritizeOnlineRepository: boolean;
  44561. /**
  44562. * Use the online repository, or use only locally-defined controllers
  44563. */
  44564. static UseOnlineRepository: boolean;
  44565. /**
  44566. * Clear the cache used for profile loading and reload when requested again
  44567. */
  44568. static ClearProfilesCache(): void;
  44569. /**
  44570. * Register the default fallbacks.
  44571. * This function is called automatically when this file is imported.
  44572. */
  44573. static DefaultFallbacks(): void;
  44574. /**
  44575. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44576. * @param profileId the profile to which a fallback needs to be found
  44577. * @return an array with corresponding fallback profiles
  44578. */
  44579. static FindFallbackWithProfileId(profileId: string): string[];
  44580. /**
  44581. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44582. * The order of search:
  44583. *
  44584. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44585. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44586. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44587. * 4) return the generic trigger controller if none were found
  44588. *
  44589. * @param xrInput the xrInput to which a new controller is initialized
  44590. * @param scene the scene to which the model will be added
  44591. * @param forceProfile force a certain profile for this controller
  44592. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44593. */
  44594. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44595. /**
  44596. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44597. *
  44598. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44599. *
  44600. * @param type the profile type to register
  44601. * @param constructFunction the function to be called when loading this profile
  44602. */
  44603. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44604. /**
  44605. * Register a fallback to a specific profile.
  44606. * @param profileId the profileId that will receive the fallbacks
  44607. * @param fallbacks A list of fallback profiles
  44608. */
  44609. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44610. /**
  44611. * Will update the list of profiles available in the repository
  44612. * @return a promise that resolves to a map of profiles available online
  44613. */
  44614. static UpdateProfilesList(): Promise<{
  44615. [profile: string]: string;
  44616. }>;
  44617. private static _LoadProfileFromRepository;
  44618. private static _LoadProfilesFromAvailableControllers;
  44619. }
  44620. }
  44621. declare module BABYLON {
  44622. /**
  44623. * Configuration options for the WebXR controller creation
  44624. */
  44625. export interface IWebXRControllerOptions {
  44626. /**
  44627. * Should the controller mesh be animated when a user interacts with it
  44628. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44629. */
  44630. disableMotionControllerAnimation?: boolean;
  44631. /**
  44632. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44633. */
  44634. doNotLoadControllerMesh?: boolean;
  44635. /**
  44636. * Force a specific controller type for this controller.
  44637. * This can be used when creating your own profile or when testing different controllers
  44638. */
  44639. forceControllerProfile?: string;
  44640. }
  44641. /**
  44642. * Represents an XR controller
  44643. */
  44644. export class WebXRInputSource {
  44645. private _scene;
  44646. /** The underlying input source for the controller */
  44647. inputSource: XRInputSource;
  44648. private _options;
  44649. private _tmpQuaternion;
  44650. private _tmpVector;
  44651. private _uniqueId;
  44652. /**
  44653. * 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
  44654. */
  44655. grip?: AbstractMesh;
  44656. /**
  44657. * If available, this is the gamepad object related to this controller.
  44658. * Using this object it is possible to get click events and trackpad changes of the
  44659. * webxr controller that is currently being used.
  44660. */
  44661. motionController?: WebXRAbstractMotionController;
  44662. /**
  44663. * Event that fires when the controller is removed/disposed.
  44664. * The object provided as event data is this controller, after associated assets were disposed.
  44665. * uniqueId is still available.
  44666. */
  44667. onDisposeObservable: Observable<WebXRInputSource>;
  44668. /**
  44669. * Will be triggered when the mesh associated with the motion controller is done loading.
  44670. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44671. * A shortened version of controller -> motion controller -> on mesh loaded.
  44672. */
  44673. onMeshLoadedObservable: Observable<AbstractMesh>;
  44674. /**
  44675. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44676. */
  44677. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44678. /**
  44679. * Pointer which can be used to select objects or attach a visible laser to
  44680. */
  44681. pointer: AbstractMesh;
  44682. /**
  44683. * Creates the controller
  44684. * @see https://doc.babylonjs.com/how_to/webxr
  44685. * @param _scene the scene which the controller should be associated to
  44686. * @param inputSource the underlying input source for the controller
  44687. * @param _options options for this controller creation
  44688. */
  44689. constructor(_scene: Scene,
  44690. /** The underlying input source for the controller */
  44691. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44692. /**
  44693. * Get this controllers unique id
  44694. */
  44695. get uniqueId(): string;
  44696. /**
  44697. * Disposes of the object
  44698. */
  44699. dispose(): void;
  44700. /**
  44701. * Gets a world space ray coming from the pointer or grip
  44702. * @param result the resulting ray
  44703. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44704. */
  44705. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44706. /**
  44707. * Updates the controller pose based on the given XRFrame
  44708. * @param xrFrame xr frame to update the pose with
  44709. * @param referenceSpace reference space to use
  44710. */
  44711. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44712. }
  44713. }
  44714. declare module BABYLON {
  44715. /**
  44716. * The schema for initialization options of the XR Input class
  44717. */
  44718. export interface IWebXRInputOptions {
  44719. /**
  44720. * If set to true no model will be automatically loaded
  44721. */
  44722. doNotLoadControllerMeshes?: boolean;
  44723. /**
  44724. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44725. * If not found, the xr input profile data will be used.
  44726. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44727. */
  44728. forceInputProfile?: string;
  44729. /**
  44730. * Do not send a request to the controller repository to load the profile.
  44731. *
  44732. * Instead, use the controllers available in babylon itself.
  44733. */
  44734. disableOnlineControllerRepository?: boolean;
  44735. /**
  44736. * A custom URL for the controllers repository
  44737. */
  44738. customControllersRepositoryURL?: string;
  44739. /**
  44740. * Should the controller model's components not move according to the user input
  44741. */
  44742. disableControllerAnimation?: boolean;
  44743. }
  44744. /**
  44745. * XR input used to track XR inputs such as controllers/rays
  44746. */
  44747. export class WebXRInput implements IDisposable {
  44748. /**
  44749. * the xr session manager for this session
  44750. */
  44751. xrSessionManager: WebXRSessionManager;
  44752. /**
  44753. * the WebXR camera for this session. Mainly used for teleportation
  44754. */
  44755. xrCamera: WebXRCamera;
  44756. private readonly options;
  44757. /**
  44758. * XR controllers being tracked
  44759. */
  44760. controllers: Array<WebXRInputSource>;
  44761. private _frameObserver;
  44762. private _sessionEndedObserver;
  44763. private _sessionInitObserver;
  44764. /**
  44765. * Event when a controller has been connected/added
  44766. */
  44767. onControllerAddedObservable: Observable<WebXRInputSource>;
  44768. /**
  44769. * Event when a controller has been removed/disconnected
  44770. */
  44771. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44772. /**
  44773. * Initializes the WebXRInput
  44774. * @param xrSessionManager the xr session manager for this session
  44775. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44776. * @param options = initialization options for this xr input
  44777. */
  44778. constructor(
  44779. /**
  44780. * the xr session manager for this session
  44781. */
  44782. xrSessionManager: WebXRSessionManager,
  44783. /**
  44784. * the WebXR camera for this session. Mainly used for teleportation
  44785. */
  44786. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44787. private _onInputSourcesChange;
  44788. private _addAndRemoveControllers;
  44789. /**
  44790. * Disposes of the object
  44791. */
  44792. dispose(): void;
  44793. }
  44794. }
  44795. declare module BABYLON {
  44796. /**
  44797. * This is the base class for all WebXR features.
  44798. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44799. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44800. */
  44801. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44802. protected _xrSessionManager: WebXRSessionManager;
  44803. private _attached;
  44804. private _removeOnDetach;
  44805. /**
  44806. * Should auto-attach be disabled?
  44807. */
  44808. disableAutoAttach: boolean;
  44809. /**
  44810. * Construct a new (abstract) WebXR feature
  44811. * @param _xrSessionManager the xr session manager for this feature
  44812. */
  44813. constructor(_xrSessionManager: WebXRSessionManager);
  44814. /**
  44815. * Is this feature attached
  44816. */
  44817. get attached(): boolean;
  44818. /**
  44819. * attach this feature
  44820. *
  44821. * @param force should attachment be forced (even when already attached)
  44822. * @returns true if successful, false is failed or already attached
  44823. */
  44824. attach(force?: boolean): boolean;
  44825. /**
  44826. * detach this feature.
  44827. *
  44828. * @returns true if successful, false if failed or already detached
  44829. */
  44830. detach(): boolean;
  44831. /**
  44832. * Dispose this feature and all of the resources attached
  44833. */
  44834. dispose(): void;
  44835. /**
  44836. * This is used to register callbacks that will automatically be removed when detach is called.
  44837. * @param observable the observable to which the observer will be attached
  44838. * @param callback the callback to register
  44839. */
  44840. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44841. /**
  44842. * Code in this function will be executed on each xrFrame received from the browser.
  44843. * This function will not execute after the feature is detached.
  44844. * @param _xrFrame the current frame
  44845. */
  44846. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44847. }
  44848. }
  44849. declare module BABYLON {
  44850. /**
  44851. * Renders a layer on top of an existing scene
  44852. */
  44853. export class UtilityLayerRenderer implements IDisposable {
  44854. /** the original scene that will be rendered on top of */
  44855. originalScene: Scene;
  44856. private _pointerCaptures;
  44857. private _lastPointerEvents;
  44858. private static _DefaultUtilityLayer;
  44859. private static _DefaultKeepDepthUtilityLayer;
  44860. private _sharedGizmoLight;
  44861. private _renderCamera;
  44862. /**
  44863. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44864. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44865. * @returns the camera that is used when rendering the utility layer
  44866. */
  44867. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44868. /**
  44869. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44870. * @param cam the camera that should be used when rendering the utility layer
  44871. */
  44872. setRenderCamera(cam: Nullable<Camera>): void;
  44873. /**
  44874. * @hidden
  44875. * Light which used by gizmos to get light shading
  44876. */
  44877. _getSharedGizmoLight(): HemisphericLight;
  44878. /**
  44879. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44880. */
  44881. pickUtilitySceneFirst: boolean;
  44882. /**
  44883. * 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)
  44884. */
  44885. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44886. /**
  44887. * 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)
  44888. */
  44889. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44890. /**
  44891. * The scene that is rendered on top of the original scene
  44892. */
  44893. utilityLayerScene: Scene;
  44894. /**
  44895. * If the utility layer should automatically be rendered on top of existing scene
  44896. */
  44897. shouldRender: boolean;
  44898. /**
  44899. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44900. */
  44901. onlyCheckPointerDownEvents: boolean;
  44902. /**
  44903. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44904. */
  44905. processAllEvents: boolean;
  44906. /**
  44907. * Observable raised when the pointer move from the utility layer scene to the main scene
  44908. */
  44909. onPointerOutObservable: Observable<number>;
  44910. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44911. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44912. private _afterRenderObserver;
  44913. private _sceneDisposeObserver;
  44914. private _originalPointerObserver;
  44915. /**
  44916. * Instantiates a UtilityLayerRenderer
  44917. * @param originalScene the original scene that will be rendered on top of
  44918. * @param handleEvents boolean indicating if the utility layer should handle events
  44919. */
  44920. constructor(
  44921. /** the original scene that will be rendered on top of */
  44922. originalScene: Scene, handleEvents?: boolean);
  44923. private _notifyObservers;
  44924. /**
  44925. * Renders the utility layers scene on top of the original scene
  44926. */
  44927. render(): void;
  44928. /**
  44929. * Disposes of the renderer
  44930. */
  44931. dispose(): void;
  44932. private _updateCamera;
  44933. }
  44934. }
  44935. declare module BABYLON {
  44936. /**
  44937. * Options interface for the pointer selection module
  44938. */
  44939. export interface IWebXRControllerPointerSelectionOptions {
  44940. /**
  44941. * if provided, this scene will be used to render meshes.
  44942. */
  44943. customUtilityLayerScene?: Scene;
  44944. /**
  44945. * 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)
  44946. * If not disabled, the last picked point will be used to execute a pointer up event
  44947. * If disabled, pointer up event will be triggered right after the pointer down event.
  44948. * Used in screen and gaze target ray mode only
  44949. */
  44950. disablePointerUpOnTouchOut: boolean;
  44951. /**
  44952. * For gaze mode (time to select instead of press)
  44953. */
  44954. forceGazeMode: boolean;
  44955. /**
  44956. * 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
  44957. * to start a new countdown to the pointer down event.
  44958. * Defaults to 1.
  44959. */
  44960. gazeModePointerMovedFactor?: number;
  44961. /**
  44962. * Different button type to use instead of the main component
  44963. */
  44964. overrideButtonId?: string;
  44965. /**
  44966. * use this rendering group id for the meshes (optional)
  44967. */
  44968. renderingGroupId?: number;
  44969. /**
  44970. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44971. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44972. * 3000 means 3 seconds between pointing at something and selecting it
  44973. */
  44974. timeToSelect?: number;
  44975. /**
  44976. * Should meshes created here be added to a utility layer or the main scene
  44977. */
  44978. useUtilityLayer?: boolean;
  44979. /**
  44980. * the xr input to use with this pointer selection
  44981. */
  44982. xrInput: WebXRInput;
  44983. }
  44984. /**
  44985. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44986. */
  44987. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44988. private readonly _options;
  44989. private static _idCounter;
  44990. private _attachController;
  44991. private _controllers;
  44992. private _scene;
  44993. private _tmpVectorForPickCompare;
  44994. /**
  44995. * The module's name
  44996. */
  44997. static readonly Name: string;
  44998. /**
  44999. * The (Babylon) version of this module.
  45000. * This is an integer representing the implementation version.
  45001. * This number does not correspond to the WebXR specs version
  45002. */
  45003. static readonly Version: number;
  45004. /**
  45005. * Disable lighting on the laser pointer (so it will always be visible)
  45006. */
  45007. disablePointerLighting: boolean;
  45008. /**
  45009. * Disable lighting on the selection mesh (so it will always be visible)
  45010. */
  45011. disableSelectionMeshLighting: boolean;
  45012. /**
  45013. * Should the laser pointer be displayed
  45014. */
  45015. displayLaserPointer: boolean;
  45016. /**
  45017. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45018. */
  45019. displaySelectionMesh: boolean;
  45020. /**
  45021. * This color will be set to the laser pointer when selection is triggered
  45022. */
  45023. laserPointerPickedColor: Color3;
  45024. /**
  45025. * Default color of the laser pointer
  45026. */
  45027. lasterPointerDefaultColor: Color3;
  45028. /**
  45029. * default color of the selection ring
  45030. */
  45031. selectionMeshDefaultColor: Color3;
  45032. /**
  45033. * This color will be applied to the selection ring when selection is triggered
  45034. */
  45035. selectionMeshPickedColor: Color3;
  45036. /**
  45037. * Optional filter to be used for ray selection. This predicate shares behavior with
  45038. * scene.pointerMovePredicate which takes priority if it is also assigned.
  45039. */
  45040. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45041. /**
  45042. * constructs a new background remover module
  45043. * @param _xrSessionManager the session manager for this module
  45044. * @param _options read-only options to be used in this module
  45045. */
  45046. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45047. /**
  45048. * attach this feature
  45049. * Will usually be called by the features manager
  45050. *
  45051. * @returns true if successful.
  45052. */
  45053. attach(): boolean;
  45054. /**
  45055. * detach this feature.
  45056. * Will usually be called by the features manager
  45057. *
  45058. * @returns true if successful.
  45059. */
  45060. detach(): boolean;
  45061. /**
  45062. * Will get the mesh under a specific pointer.
  45063. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  45064. * @param controllerId the controllerId to check
  45065. * @returns The mesh under pointer or null if no mesh is under the pointer
  45066. */
  45067. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  45068. /**
  45069. * Get the xr controller that correlates to the pointer id in the pointer event
  45070. *
  45071. * @param id the pointer id to search for
  45072. * @returns the controller that correlates to this id or null if not found
  45073. */
  45074. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  45075. protected _onXRFrame(_xrFrame: XRFrame): void;
  45076. private _attachGazeMode;
  45077. private _attachScreenRayMode;
  45078. private _attachTrackedPointerRayMode;
  45079. private _convertNormalToDirectionOfRay;
  45080. private _detachController;
  45081. private _generateNewMeshPair;
  45082. private _pickingMoved;
  45083. private _updatePointerDistance;
  45084. }
  45085. }
  45086. declare module BABYLON {
  45087. /**
  45088. * Button which can be used to enter a different mode of XR
  45089. */
  45090. export class WebXREnterExitUIButton {
  45091. /** button element */
  45092. element: HTMLElement;
  45093. /** XR initialization options for the button */
  45094. sessionMode: XRSessionMode;
  45095. /** Reference space type */
  45096. referenceSpaceType: XRReferenceSpaceType;
  45097. /**
  45098. * Creates a WebXREnterExitUIButton
  45099. * @param element button element
  45100. * @param sessionMode XR initialization session mode
  45101. * @param referenceSpaceType the type of reference space to be used
  45102. */
  45103. constructor(
  45104. /** button element */
  45105. element: HTMLElement,
  45106. /** XR initialization options for the button */
  45107. sessionMode: XRSessionMode,
  45108. /** Reference space type */
  45109. referenceSpaceType: XRReferenceSpaceType);
  45110. /**
  45111. * Extendable function which can be used to update the button's visuals when the state changes
  45112. * @param activeButton the current active button in the UI
  45113. */
  45114. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45115. }
  45116. /**
  45117. * Options to create the webXR UI
  45118. */
  45119. export class WebXREnterExitUIOptions {
  45120. /**
  45121. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45122. */
  45123. customButtons?: Array<WebXREnterExitUIButton>;
  45124. /**
  45125. * A reference space type to use when creating the default button.
  45126. * Default is local-floor
  45127. */
  45128. referenceSpaceType?: XRReferenceSpaceType;
  45129. /**
  45130. * Context to enter xr with
  45131. */
  45132. renderTarget?: Nullable<WebXRRenderTarget>;
  45133. /**
  45134. * A session mode to use when creating the default button.
  45135. * Default is immersive-vr
  45136. */
  45137. sessionMode?: XRSessionMode;
  45138. }
  45139. /**
  45140. * UI to allow the user to enter/exit XR mode
  45141. */
  45142. export class WebXREnterExitUI implements IDisposable {
  45143. private scene;
  45144. /** version of the options passed to this UI */
  45145. options: WebXREnterExitUIOptions;
  45146. private _activeButton;
  45147. private _buttons;
  45148. private _overlay;
  45149. /**
  45150. * Fired every time the active button is changed.
  45151. *
  45152. * When xr is entered via a button that launches xr that button will be the callback parameter
  45153. *
  45154. * When exiting xr the callback parameter will be null)
  45155. */
  45156. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45157. /**
  45158. *
  45159. * @param scene babylon scene object to use
  45160. * @param options (read-only) version of the options passed to this UI
  45161. */
  45162. private constructor();
  45163. /**
  45164. * Creates UI to allow the user to enter/exit XR mode
  45165. * @param scene the scene to add the ui to
  45166. * @param helper the xr experience helper to enter/exit xr with
  45167. * @param options options to configure the UI
  45168. * @returns the created ui
  45169. */
  45170. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45171. /**
  45172. * Disposes of the XR UI component
  45173. */
  45174. dispose(): void;
  45175. private _updateButtons;
  45176. }
  45177. }
  45178. declare module BABYLON {
  45179. /**
  45180. * Class containing static functions to help procedurally build meshes
  45181. */
  45182. export class LinesBuilder {
  45183. /**
  45184. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45185. * * 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
  45186. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45187. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45188. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45189. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45190. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45191. * * 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
  45192. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45194. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45195. * @param name defines the name of the new line system
  45196. * @param options defines the options used to create the line system
  45197. * @param scene defines the hosting scene
  45198. * @returns a new line system mesh
  45199. */
  45200. static CreateLineSystem(name: string, options: {
  45201. lines: Vector3[][];
  45202. updatable?: boolean;
  45203. instance?: Nullable<LinesMesh>;
  45204. colors?: Nullable<Color4[][]>;
  45205. useVertexAlpha?: boolean;
  45206. }, scene: Nullable<Scene>): LinesMesh;
  45207. /**
  45208. * Creates a line mesh
  45209. * 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
  45210. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45211. * * The parameter `points` is an array successive Vector3
  45212. * * 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
  45213. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45214. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45215. * * When updating an instance, remember that only point positions can change, not the number of points
  45216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45218. * @param name defines the name of the new line system
  45219. * @param options defines the options used to create the line system
  45220. * @param scene defines the hosting scene
  45221. * @returns a new line mesh
  45222. */
  45223. static CreateLines(name: string, options: {
  45224. points: Vector3[];
  45225. updatable?: boolean;
  45226. instance?: Nullable<LinesMesh>;
  45227. colors?: Color4[];
  45228. useVertexAlpha?: boolean;
  45229. }, scene?: Nullable<Scene>): LinesMesh;
  45230. /**
  45231. * Creates a dashed line mesh
  45232. * * 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
  45233. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45234. * * The parameter `points` is an array successive Vector3
  45235. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45236. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45237. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45238. * * 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
  45239. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45240. * * When updating an instance, remember that only point positions can change, not the number of points
  45241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45242. * @param name defines the name of the mesh
  45243. * @param options defines the options used to create the mesh
  45244. * @param scene defines the hosting scene
  45245. * @returns the dashed line mesh
  45246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45247. */
  45248. static CreateDashedLines(name: string, options: {
  45249. points: Vector3[];
  45250. dashSize?: number;
  45251. gapSize?: number;
  45252. dashNb?: number;
  45253. updatable?: boolean;
  45254. instance?: LinesMesh;
  45255. useVertexAlpha?: boolean;
  45256. }, scene?: Nullable<Scene>): LinesMesh;
  45257. }
  45258. }
  45259. declare module BABYLON {
  45260. /**
  45261. * The options container for the teleportation module
  45262. */
  45263. export interface IWebXRTeleportationOptions {
  45264. /**
  45265. * if provided, this scene will be used to render meshes.
  45266. */
  45267. customUtilityLayerScene?: Scene;
  45268. /**
  45269. * Values to configure the default target mesh
  45270. */
  45271. defaultTargetMeshOptions?: {
  45272. /**
  45273. * Fill color of the teleportation area
  45274. */
  45275. teleportationFillColor?: string;
  45276. /**
  45277. * Border color for the teleportation area
  45278. */
  45279. teleportationBorderColor?: string;
  45280. /**
  45281. * Disable the mesh's animation sequence
  45282. */
  45283. disableAnimation?: boolean;
  45284. /**
  45285. * Disable lighting on the material or the ring and arrow
  45286. */
  45287. disableLighting?: boolean;
  45288. /**
  45289. * Override the default material of the torus and arrow
  45290. */
  45291. torusArrowMaterial?: Material;
  45292. };
  45293. /**
  45294. * A list of meshes to use as floor meshes.
  45295. * Meshes can be added and removed after initializing the feature using the
  45296. * addFloorMesh and removeFloorMesh functions
  45297. * If empty, rotation will still work
  45298. */
  45299. floorMeshes?: AbstractMesh[];
  45300. /**
  45301. * use this rendering group id for the meshes (optional)
  45302. */
  45303. renderingGroupId?: number;
  45304. /**
  45305. * Should teleportation move only to snap points
  45306. */
  45307. snapPointsOnly?: boolean;
  45308. /**
  45309. * An array of points to which the teleportation will snap to.
  45310. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45311. */
  45312. snapPositions?: Vector3[];
  45313. /**
  45314. * How close should the teleportation ray be in order to snap to position.
  45315. * Default to 0.8 units (meters)
  45316. */
  45317. snapToPositionRadius?: number;
  45318. /**
  45319. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45320. * If you want to support rotation, make sure your mesh has a direction indicator.
  45321. *
  45322. * When left untouched, the default mesh will be initialized.
  45323. */
  45324. teleportationTargetMesh?: AbstractMesh;
  45325. /**
  45326. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45327. */
  45328. timeToTeleport?: number;
  45329. /**
  45330. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45331. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45332. */
  45333. useMainComponentOnly?: boolean;
  45334. /**
  45335. * Should meshes created here be added to a utility layer or the main scene
  45336. */
  45337. useUtilityLayer?: boolean;
  45338. /**
  45339. * Babylon XR Input class for controller
  45340. */
  45341. xrInput: WebXRInput;
  45342. }
  45343. /**
  45344. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45345. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45346. * the input of the attached controllers.
  45347. */
  45348. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45349. private _options;
  45350. private _controllers;
  45351. private _currentTeleportationControllerId;
  45352. private _floorMeshes;
  45353. private _quadraticBezierCurve;
  45354. private _selectionFeature;
  45355. private _snapToPositions;
  45356. private _snappedToPoint;
  45357. private _teleportationRingMaterial?;
  45358. private _tmpRay;
  45359. private _tmpVector;
  45360. /**
  45361. * The module's name
  45362. */
  45363. static readonly Name: string;
  45364. /**
  45365. * The (Babylon) version of this module.
  45366. * This is an integer representing the implementation version.
  45367. * This number does not correspond to the webxr specs version
  45368. */
  45369. static readonly Version: number;
  45370. /**
  45371. * Is movement backwards enabled
  45372. */
  45373. backwardsMovementEnabled: boolean;
  45374. /**
  45375. * Distance to travel when moving backwards
  45376. */
  45377. backwardsTeleportationDistance: number;
  45378. /**
  45379. * The distance from the user to the inspection point in the direction of the controller
  45380. * A higher number will allow the user to move further
  45381. * defaults to 5 (meters, in xr units)
  45382. */
  45383. parabolicCheckRadius: number;
  45384. /**
  45385. * Should the module support parabolic ray on top of direct ray
  45386. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45387. * Very helpful when moving between floors / different heights
  45388. */
  45389. parabolicRayEnabled: boolean;
  45390. /**
  45391. * How much rotation should be applied when rotating right and left
  45392. */
  45393. rotationAngle: number;
  45394. /**
  45395. * Is rotation enabled when moving forward?
  45396. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45397. */
  45398. rotationEnabled: boolean;
  45399. /**
  45400. * constructs a new anchor system
  45401. * @param _xrSessionManager an instance of WebXRSessionManager
  45402. * @param _options configuration object for this feature
  45403. */
  45404. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45405. /**
  45406. * Get the snapPointsOnly flag
  45407. */
  45408. get snapPointsOnly(): boolean;
  45409. /**
  45410. * Sets the snapPointsOnly flag
  45411. * @param snapToPoints should teleportation be exclusively to snap points
  45412. */
  45413. set snapPointsOnly(snapToPoints: boolean);
  45414. /**
  45415. * Add a new mesh to the floor meshes array
  45416. * @param mesh the mesh to use as floor mesh
  45417. */
  45418. addFloorMesh(mesh: AbstractMesh): void;
  45419. /**
  45420. * Add a new snap-to point to fix teleportation to this position
  45421. * @param newSnapPoint The new Snap-To point
  45422. */
  45423. addSnapPoint(newSnapPoint: Vector3): void;
  45424. attach(): boolean;
  45425. detach(): boolean;
  45426. dispose(): void;
  45427. /**
  45428. * Remove a mesh from the floor meshes array
  45429. * @param mesh the mesh to remove
  45430. */
  45431. removeFloorMesh(mesh: AbstractMesh): void;
  45432. /**
  45433. * Remove a mesh from the floor meshes array using its name
  45434. * @param name the mesh name to remove
  45435. */
  45436. removeFloorMeshByName(name: string): void;
  45437. /**
  45438. * 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
  45439. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45440. * @returns was the point found and removed or not
  45441. */
  45442. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45443. /**
  45444. * This function sets a selection feature that will be disabled when
  45445. * the forward ray is shown and will be reattached when hidden.
  45446. * This is used to remove the selection rays when moving.
  45447. * @param selectionFeature the feature to disable when forward movement is enabled
  45448. */
  45449. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45450. protected _onXRFrame(_xrFrame: XRFrame): void;
  45451. private _attachController;
  45452. private _createDefaultTargetMesh;
  45453. private _detachController;
  45454. private _findClosestSnapPointWithRadius;
  45455. private _setTargetMeshPosition;
  45456. private _setTargetMeshVisibility;
  45457. private _showParabolicPath;
  45458. private _teleportForward;
  45459. }
  45460. }
  45461. declare module BABYLON {
  45462. /**
  45463. * Options for the default xr helper
  45464. */
  45465. export class WebXRDefaultExperienceOptions {
  45466. /**
  45467. * Enable or disable default UI to enter XR
  45468. */
  45469. disableDefaultUI?: boolean;
  45470. /**
  45471. * Should teleportation not initialize. defaults to false.
  45472. */
  45473. disableTeleportation?: boolean;
  45474. /**
  45475. * Floor meshes that will be used for teleport
  45476. */
  45477. floorMeshes?: Array<AbstractMesh>;
  45478. /**
  45479. * If set to true, the first frame will not be used to reset position
  45480. * The first frame is mainly used when copying transformation from the old camera
  45481. * Mainly used in AR
  45482. */
  45483. ignoreNativeCameraTransformation?: boolean;
  45484. /**
  45485. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45486. */
  45487. inputOptions?: IWebXRInputOptions;
  45488. /**
  45489. * optional configuration for the output canvas
  45490. */
  45491. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45492. /**
  45493. * optional UI options. This can be used among other to change session mode and reference space type
  45494. */
  45495. uiOptions?: WebXREnterExitUIOptions;
  45496. /**
  45497. * When loading teleportation and pointer select, use stable versions instead of latest.
  45498. */
  45499. useStablePlugins?: boolean;
  45500. }
  45501. /**
  45502. * Default experience which provides a similar setup to the previous webVRExperience
  45503. */
  45504. export class WebXRDefaultExperience {
  45505. /**
  45506. * Base experience
  45507. */
  45508. baseExperience: WebXRExperienceHelper;
  45509. /**
  45510. * Enables ui for entering/exiting xr
  45511. */
  45512. enterExitUI: WebXREnterExitUI;
  45513. /**
  45514. * Input experience extension
  45515. */
  45516. input: WebXRInput;
  45517. /**
  45518. * Enables laser pointer and selection
  45519. */
  45520. pointerSelection: WebXRControllerPointerSelection;
  45521. /**
  45522. * Default target xr should render to
  45523. */
  45524. renderTarget: WebXRRenderTarget;
  45525. /**
  45526. * Enables teleportation
  45527. */
  45528. teleportation: WebXRMotionControllerTeleportation;
  45529. private constructor();
  45530. /**
  45531. * Creates the default xr experience
  45532. * @param scene scene
  45533. * @param options options for basic configuration
  45534. * @returns resulting WebXRDefaultExperience
  45535. */
  45536. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45537. /**
  45538. * DIsposes of the experience helper
  45539. */
  45540. dispose(): void;
  45541. }
  45542. }
  45543. declare module BABYLON {
  45544. /**
  45545. * Options to modify the vr teleportation behavior.
  45546. */
  45547. export interface VRTeleportationOptions {
  45548. /**
  45549. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45550. */
  45551. floorMeshName?: string;
  45552. /**
  45553. * A list of meshes to be used as the teleportation floor. (default: empty)
  45554. */
  45555. floorMeshes?: Mesh[];
  45556. /**
  45557. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45558. */
  45559. teleportationMode?: number;
  45560. /**
  45561. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45562. */
  45563. teleportationTime?: number;
  45564. /**
  45565. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45566. */
  45567. teleportationSpeed?: number;
  45568. /**
  45569. * The easing function used in the animation or null for Linear. (default CircleEase)
  45570. */
  45571. easingFunction?: EasingFunction;
  45572. }
  45573. /**
  45574. * Options to modify the vr experience helper's behavior.
  45575. */
  45576. export interface VRExperienceHelperOptions extends WebVROptions {
  45577. /**
  45578. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45579. */
  45580. createDeviceOrientationCamera?: boolean;
  45581. /**
  45582. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45583. */
  45584. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45585. /**
  45586. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45587. */
  45588. laserToggle?: boolean;
  45589. /**
  45590. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45591. */
  45592. floorMeshes?: Mesh[];
  45593. /**
  45594. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45595. */
  45596. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45597. /**
  45598. * Defines if WebXR should be used instead of WebVR (if available)
  45599. */
  45600. useXR?: boolean;
  45601. }
  45602. /**
  45603. * Event containing information after VR has been entered
  45604. */
  45605. export class OnAfterEnteringVRObservableEvent {
  45606. /**
  45607. * If entering vr was successful
  45608. */
  45609. success: boolean;
  45610. }
  45611. /**
  45612. * Helps to quickly add VR support to an existing scene.
  45613. * See http://doc.babylonjs.com/how_to/webvr_helper
  45614. */
  45615. export class VRExperienceHelper {
  45616. /** Options to modify the vr experience helper's behavior. */
  45617. webVROptions: VRExperienceHelperOptions;
  45618. private _scene;
  45619. private _position;
  45620. private _btnVR;
  45621. private _btnVRDisplayed;
  45622. private _webVRsupported;
  45623. private _webVRready;
  45624. private _webVRrequesting;
  45625. private _webVRpresenting;
  45626. private _hasEnteredVR;
  45627. private _fullscreenVRpresenting;
  45628. private _inputElement;
  45629. private _webVRCamera;
  45630. private _vrDeviceOrientationCamera;
  45631. private _deviceOrientationCamera;
  45632. private _existingCamera;
  45633. private _onKeyDown;
  45634. private _onVrDisplayPresentChange;
  45635. private _onVRDisplayChanged;
  45636. private _onVRRequestPresentStart;
  45637. private _onVRRequestPresentComplete;
  45638. /**
  45639. * 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)
  45640. */
  45641. enableGazeEvenWhenNoPointerLock: boolean;
  45642. /**
  45643. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45644. */
  45645. exitVROnDoubleTap: boolean;
  45646. /**
  45647. * Observable raised right before entering VR.
  45648. */
  45649. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45650. /**
  45651. * Observable raised when entering VR has completed.
  45652. */
  45653. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45654. /**
  45655. * Observable raised when exiting VR.
  45656. */
  45657. onExitingVRObservable: Observable<VRExperienceHelper>;
  45658. /**
  45659. * Observable raised when controller mesh is loaded.
  45660. */
  45661. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45662. /** Return this.onEnteringVRObservable
  45663. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45664. */
  45665. get onEnteringVR(): Observable<VRExperienceHelper>;
  45666. /** Return this.onExitingVRObservable
  45667. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45668. */
  45669. get onExitingVR(): Observable<VRExperienceHelper>;
  45670. /** Return this.onControllerMeshLoadedObservable
  45671. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45672. */
  45673. get onControllerMeshLoaded(): Observable<WebVRController>;
  45674. private _rayLength;
  45675. private _useCustomVRButton;
  45676. private _teleportationRequested;
  45677. private _teleportActive;
  45678. private _floorMeshName;
  45679. private _floorMeshesCollection;
  45680. private _teleportationMode;
  45681. private _teleportationTime;
  45682. private _teleportationSpeed;
  45683. private _teleportationEasing;
  45684. private _rotationAllowed;
  45685. private _teleportBackwardsVector;
  45686. private _teleportationTarget;
  45687. private _isDefaultTeleportationTarget;
  45688. private _postProcessMove;
  45689. private _teleportationFillColor;
  45690. private _teleportationBorderColor;
  45691. private _rotationAngle;
  45692. private _haloCenter;
  45693. private _cameraGazer;
  45694. private _padSensibilityUp;
  45695. private _padSensibilityDown;
  45696. private _leftController;
  45697. private _rightController;
  45698. private _gazeColor;
  45699. private _laserColor;
  45700. private _pickedLaserColor;
  45701. private _pickedGazeColor;
  45702. /**
  45703. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45704. */
  45705. onNewMeshSelected: Observable<AbstractMesh>;
  45706. /**
  45707. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45708. * This observable will provide the mesh and the controller used to select the mesh
  45709. */
  45710. onMeshSelectedWithController: Observable<{
  45711. mesh: AbstractMesh;
  45712. controller: WebVRController;
  45713. }>;
  45714. /**
  45715. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45716. */
  45717. onNewMeshPicked: Observable<PickingInfo>;
  45718. private _circleEase;
  45719. /**
  45720. * Observable raised before camera teleportation
  45721. */
  45722. onBeforeCameraTeleport: Observable<Vector3>;
  45723. /**
  45724. * Observable raised after camera teleportation
  45725. */
  45726. onAfterCameraTeleport: Observable<Vector3>;
  45727. /**
  45728. * Observable raised when current selected mesh gets unselected
  45729. */
  45730. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45731. private _raySelectionPredicate;
  45732. /**
  45733. * To be optionaly changed by user to define custom ray selection
  45734. */
  45735. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45736. /**
  45737. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45738. */
  45739. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45740. /**
  45741. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45742. */
  45743. teleportationEnabled: boolean;
  45744. private _defaultHeight;
  45745. private _teleportationInitialized;
  45746. private _interactionsEnabled;
  45747. private _interactionsRequested;
  45748. private _displayGaze;
  45749. private _displayLaserPointer;
  45750. /**
  45751. * The mesh used to display where the user is going to teleport.
  45752. */
  45753. get teleportationTarget(): Mesh;
  45754. /**
  45755. * Sets the mesh to be used to display where the user is going to teleport.
  45756. */
  45757. set teleportationTarget(value: Mesh);
  45758. /**
  45759. * 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
  45760. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45761. * See http://doc.babylonjs.com/resources/baking_transformations
  45762. */
  45763. get gazeTrackerMesh(): Mesh;
  45764. set gazeTrackerMesh(value: Mesh);
  45765. /**
  45766. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45767. */
  45768. updateGazeTrackerScale: boolean;
  45769. /**
  45770. * If the gaze trackers color should be updated when selecting meshes
  45771. */
  45772. updateGazeTrackerColor: boolean;
  45773. /**
  45774. * If the controller laser color should be updated when selecting meshes
  45775. */
  45776. updateControllerLaserColor: boolean;
  45777. /**
  45778. * The gaze tracking mesh corresponding to the left controller
  45779. */
  45780. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45781. /**
  45782. * The gaze tracking mesh corresponding to the right controller
  45783. */
  45784. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45785. /**
  45786. * If the ray of the gaze should be displayed.
  45787. */
  45788. get displayGaze(): boolean;
  45789. /**
  45790. * Sets if the ray of the gaze should be displayed.
  45791. */
  45792. set displayGaze(value: boolean);
  45793. /**
  45794. * If the ray of the LaserPointer should be displayed.
  45795. */
  45796. get displayLaserPointer(): boolean;
  45797. /**
  45798. * Sets if the ray of the LaserPointer should be displayed.
  45799. */
  45800. set displayLaserPointer(value: boolean);
  45801. /**
  45802. * The deviceOrientationCamera used as the camera when not in VR.
  45803. */
  45804. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45805. /**
  45806. * Based on the current WebVR support, returns the current VR camera used.
  45807. */
  45808. get currentVRCamera(): Nullable<Camera>;
  45809. /**
  45810. * The webVRCamera which is used when in VR.
  45811. */
  45812. get webVRCamera(): WebVRFreeCamera;
  45813. /**
  45814. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45815. */
  45816. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45817. /**
  45818. * The html button that is used to trigger entering into VR.
  45819. */
  45820. get vrButton(): Nullable<HTMLButtonElement>;
  45821. private get _teleportationRequestInitiated();
  45822. /**
  45823. * Defines whether or not Pointer lock should be requested when switching to
  45824. * full screen.
  45825. */
  45826. requestPointerLockOnFullScreen: boolean;
  45827. /**
  45828. * If asking to force XR, this will be populated with the default xr experience
  45829. */
  45830. xr: WebXRDefaultExperience;
  45831. /**
  45832. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45833. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45834. */
  45835. xrTestDone: boolean;
  45836. /**
  45837. * Instantiates a VRExperienceHelper.
  45838. * Helps to quickly add VR support to an existing scene.
  45839. * @param scene The scene the VRExperienceHelper belongs to.
  45840. * @param webVROptions Options to modify the vr experience helper's behavior.
  45841. */
  45842. constructor(scene: Scene,
  45843. /** Options to modify the vr experience helper's behavior. */
  45844. webVROptions?: VRExperienceHelperOptions);
  45845. private completeVRInit;
  45846. private _onDefaultMeshLoaded;
  45847. private _onResize;
  45848. private _onFullscreenChange;
  45849. /**
  45850. * Gets a value indicating if we are currently in VR mode.
  45851. */
  45852. get isInVRMode(): boolean;
  45853. private onVrDisplayPresentChange;
  45854. private onVRDisplayChanged;
  45855. private moveButtonToBottomRight;
  45856. private displayVRButton;
  45857. private updateButtonVisibility;
  45858. private _cachedAngularSensibility;
  45859. /**
  45860. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45861. * Otherwise, will use the fullscreen API.
  45862. */
  45863. enterVR(): void;
  45864. /**
  45865. * Attempt to exit VR, or fullscreen.
  45866. */
  45867. exitVR(): void;
  45868. /**
  45869. * The position of the vr experience helper.
  45870. */
  45871. get position(): Vector3;
  45872. /**
  45873. * Sets the position of the vr experience helper.
  45874. */
  45875. set position(value: Vector3);
  45876. /**
  45877. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45878. */
  45879. enableInteractions(): void;
  45880. private get _noControllerIsActive();
  45881. private beforeRender;
  45882. private _isTeleportationFloor;
  45883. /**
  45884. * Adds a floor mesh to be used for teleportation.
  45885. * @param floorMesh the mesh to be used for teleportation.
  45886. */
  45887. addFloorMesh(floorMesh: Mesh): void;
  45888. /**
  45889. * Removes a floor mesh from being used for teleportation.
  45890. * @param floorMesh the mesh to be removed.
  45891. */
  45892. removeFloorMesh(floorMesh: Mesh): void;
  45893. /**
  45894. * Enables interactions and teleportation using the VR controllers and gaze.
  45895. * @param vrTeleportationOptions options to modify teleportation behavior.
  45896. */
  45897. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45898. private _onNewGamepadConnected;
  45899. private _tryEnableInteractionOnController;
  45900. private _onNewGamepadDisconnected;
  45901. private _enableInteractionOnController;
  45902. private _checkTeleportWithRay;
  45903. private _checkRotate;
  45904. private _checkTeleportBackwards;
  45905. private _enableTeleportationOnController;
  45906. private _createTeleportationCircles;
  45907. private _displayTeleportationTarget;
  45908. private _hideTeleportationTarget;
  45909. private _rotateCamera;
  45910. private _moveTeleportationSelectorTo;
  45911. private _workingVector;
  45912. private _workingQuaternion;
  45913. private _workingMatrix;
  45914. /**
  45915. * Time Constant Teleportation Mode
  45916. */
  45917. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45918. /**
  45919. * Speed Constant Teleportation Mode
  45920. */
  45921. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45922. /**
  45923. * Teleports the users feet to the desired location
  45924. * @param location The location where the user's feet should be placed
  45925. */
  45926. teleportCamera(location: Vector3): void;
  45927. private _convertNormalToDirectionOfRay;
  45928. private _castRayAndSelectObject;
  45929. private _notifySelectedMeshUnselected;
  45930. /**
  45931. * Permanently set new colors for the laser pointer
  45932. * @param color the new laser color
  45933. * @param pickedColor the new laser color when picked mesh detected
  45934. */
  45935. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45936. /**
  45937. * Set lighting enabled / disabled on the laser pointer of both controllers
  45938. * @param enabled should the lighting be enabled on the laser pointer
  45939. */
  45940. setLaserLightingState(enabled?: boolean): void;
  45941. /**
  45942. * Permanently set new colors for the gaze pointer
  45943. * @param color the new gaze color
  45944. * @param pickedColor the new gaze color when picked mesh detected
  45945. */
  45946. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45947. /**
  45948. * Sets the color of the laser ray from the vr controllers.
  45949. * @param color new color for the ray.
  45950. */
  45951. changeLaserColor(color: Color3): void;
  45952. /**
  45953. * Sets the color of the ray from the vr headsets gaze.
  45954. * @param color new color for the ray.
  45955. */
  45956. changeGazeColor(color: Color3): void;
  45957. /**
  45958. * Exits VR and disposes of the vr experience helper
  45959. */
  45960. dispose(): void;
  45961. /**
  45962. * Gets the name of the VRExperienceHelper class
  45963. * @returns "VRExperienceHelper"
  45964. */
  45965. getClassName(): string;
  45966. }
  45967. }
  45968. declare module BABYLON {
  45969. /**
  45970. * Contains an array of blocks representing the octree
  45971. */
  45972. export interface IOctreeContainer<T> {
  45973. /**
  45974. * Blocks within the octree
  45975. */
  45976. blocks: Array<OctreeBlock<T>>;
  45977. }
  45978. /**
  45979. * Class used to store a cell in an octree
  45980. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45981. */
  45982. export class OctreeBlock<T> {
  45983. /**
  45984. * Gets the content of the current block
  45985. */
  45986. entries: T[];
  45987. /**
  45988. * Gets the list of block children
  45989. */
  45990. blocks: Array<OctreeBlock<T>>;
  45991. private _depth;
  45992. private _maxDepth;
  45993. private _capacity;
  45994. private _minPoint;
  45995. private _maxPoint;
  45996. private _boundingVectors;
  45997. private _creationFunc;
  45998. /**
  45999. * Creates a new block
  46000. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46001. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46002. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46003. * @param depth defines the current depth of this block in the octree
  46004. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46005. * @param creationFunc defines a callback to call when an element is added to the block
  46006. */
  46007. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46008. /**
  46009. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46010. */
  46011. get capacity(): number;
  46012. /**
  46013. * Gets the minimum vector (in world space) of the block's bounding box
  46014. */
  46015. get minPoint(): Vector3;
  46016. /**
  46017. * Gets the maximum vector (in world space) of the block's bounding box
  46018. */
  46019. get maxPoint(): Vector3;
  46020. /**
  46021. * Add a new element to this block
  46022. * @param entry defines the element to add
  46023. */
  46024. addEntry(entry: T): void;
  46025. /**
  46026. * Remove an element from this block
  46027. * @param entry defines the element to remove
  46028. */
  46029. removeEntry(entry: T): void;
  46030. /**
  46031. * Add an array of elements to this block
  46032. * @param entries defines the array of elements to add
  46033. */
  46034. addEntries(entries: T[]): void;
  46035. /**
  46036. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46037. * @param frustumPlanes defines the frustum planes to test
  46038. * @param selection defines the array to store current content if selection is positive
  46039. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46040. */
  46041. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46042. /**
  46043. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46044. * @param sphereCenter defines the bounding sphere center
  46045. * @param sphereRadius defines the bounding sphere radius
  46046. * @param selection defines the array to store current content if selection is positive
  46047. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46048. */
  46049. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46050. /**
  46051. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46052. * @param ray defines the ray to test with
  46053. * @param selection defines the array to store current content if selection is positive
  46054. */
  46055. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46056. /**
  46057. * Subdivide the content into child blocks (this block will then be empty)
  46058. */
  46059. createInnerBlocks(): void;
  46060. /**
  46061. * @hidden
  46062. */
  46063. 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;
  46064. }
  46065. }
  46066. declare module BABYLON {
  46067. /**
  46068. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46069. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46070. */
  46071. export class Octree<T> {
  46072. /** 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.) */
  46073. maxDepth: number;
  46074. /**
  46075. * Blocks within the octree containing objects
  46076. */
  46077. blocks: Array<OctreeBlock<T>>;
  46078. /**
  46079. * Content stored in the octree
  46080. */
  46081. dynamicContent: T[];
  46082. private _maxBlockCapacity;
  46083. private _selectionContent;
  46084. private _creationFunc;
  46085. /**
  46086. * Creates a octree
  46087. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46088. * @param creationFunc function to be used to instatiate the octree
  46089. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46090. * @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.)
  46091. */
  46092. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46093. /** 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.) */
  46094. maxDepth?: number);
  46095. /**
  46096. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46097. * @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);
  46098. * @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);
  46099. * @param entries meshes to be added to the octree blocks
  46100. */
  46101. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46102. /**
  46103. * Adds a mesh to the octree
  46104. * @param entry Mesh to add to the octree
  46105. */
  46106. addMesh(entry: T): void;
  46107. /**
  46108. * Remove an element from the octree
  46109. * @param entry defines the element to remove
  46110. */
  46111. removeMesh(entry: T): void;
  46112. /**
  46113. * Selects an array of meshes within the frustum
  46114. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46115. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46116. * @returns array of meshes within the frustum
  46117. */
  46118. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46119. /**
  46120. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46121. * @param sphereCenter defines the bounding sphere center
  46122. * @param sphereRadius defines the bounding sphere radius
  46123. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46124. * @returns an array of objects that intersect the sphere
  46125. */
  46126. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46127. /**
  46128. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46129. * @param ray defines the ray to test with
  46130. * @returns array of intersected objects
  46131. */
  46132. intersectsRay(ray: Ray): SmartArray<T>;
  46133. /**
  46134. * Adds a mesh into the octree block if it intersects the block
  46135. */
  46136. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46137. /**
  46138. * Adds a submesh into the octree block if it intersects the block
  46139. */
  46140. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46141. }
  46142. }
  46143. declare module BABYLON {
  46144. interface Scene {
  46145. /**
  46146. * @hidden
  46147. * Backing Filed
  46148. */
  46149. _selectionOctree: Octree<AbstractMesh>;
  46150. /**
  46151. * Gets the octree used to boost mesh selection (picking)
  46152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46153. */
  46154. selectionOctree: Octree<AbstractMesh>;
  46155. /**
  46156. * Creates or updates the octree used to boost selection (picking)
  46157. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46158. * @param maxCapacity defines the maximum capacity per leaf
  46159. * @param maxDepth defines the maximum depth of the octree
  46160. * @returns an octree of AbstractMesh
  46161. */
  46162. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46163. }
  46164. interface AbstractMesh {
  46165. /**
  46166. * @hidden
  46167. * Backing Field
  46168. */
  46169. _submeshesOctree: Octree<SubMesh>;
  46170. /**
  46171. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46172. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46173. * @param maxCapacity defines the maximum size of each block (64 by default)
  46174. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46175. * @returns the new octree
  46176. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46177. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46178. */
  46179. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46180. }
  46181. /**
  46182. * Defines the octree scene component responsible to manage any octrees
  46183. * in a given scene.
  46184. */
  46185. export class OctreeSceneComponent {
  46186. /**
  46187. * The component name help to identify the component in the list of scene components.
  46188. */
  46189. readonly name: string;
  46190. /**
  46191. * The scene the component belongs to.
  46192. */
  46193. scene: Scene;
  46194. /**
  46195. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46196. */
  46197. readonly checksIsEnabled: boolean;
  46198. /**
  46199. * Creates a new instance of the component for the given scene
  46200. * @param scene Defines the scene to register the component in
  46201. */
  46202. constructor(scene: Scene);
  46203. /**
  46204. * Registers the component in a given scene
  46205. */
  46206. register(): void;
  46207. /**
  46208. * Return the list of active meshes
  46209. * @returns the list of active meshes
  46210. */
  46211. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46212. /**
  46213. * Return the list of active sub meshes
  46214. * @param mesh The mesh to get the candidates sub meshes from
  46215. * @returns the list of active sub meshes
  46216. */
  46217. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46218. private _tempRay;
  46219. /**
  46220. * Return the list of sub meshes intersecting with a given local ray
  46221. * @param mesh defines the mesh to find the submesh for
  46222. * @param localRay defines the ray in local space
  46223. * @returns the list of intersecting sub meshes
  46224. */
  46225. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46226. /**
  46227. * Return the list of sub meshes colliding with a collider
  46228. * @param mesh defines the mesh to find the submesh for
  46229. * @param collider defines the collider to evaluate the collision against
  46230. * @returns the list of colliding sub meshes
  46231. */
  46232. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46233. /**
  46234. * Rebuilds the elements related to this component in case of
  46235. * context lost for instance.
  46236. */
  46237. rebuild(): void;
  46238. /**
  46239. * Disposes the component and the associated ressources.
  46240. */
  46241. dispose(): void;
  46242. }
  46243. }
  46244. declare module BABYLON {
  46245. /**
  46246. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46247. */
  46248. export class Gizmo implements IDisposable {
  46249. /** The utility layer the gizmo will be added to */
  46250. gizmoLayer: UtilityLayerRenderer;
  46251. /**
  46252. * The root mesh of the gizmo
  46253. */
  46254. _rootMesh: Mesh;
  46255. private _attachedMesh;
  46256. /**
  46257. * Ratio for the scale of the gizmo (Default: 1)
  46258. */
  46259. scaleRatio: number;
  46260. /**
  46261. * If a custom mesh has been set (Default: false)
  46262. */
  46263. protected _customMeshSet: boolean;
  46264. /**
  46265. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46266. * * When set, interactions will be enabled
  46267. */
  46268. get attachedMesh(): Nullable<AbstractMesh>;
  46269. set attachedMesh(value: Nullable<AbstractMesh>);
  46270. /**
  46271. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46272. * @param mesh The mesh to replace the default mesh of the gizmo
  46273. */
  46274. setCustomMesh(mesh: Mesh): void;
  46275. /**
  46276. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46277. */
  46278. updateGizmoRotationToMatchAttachedMesh: boolean;
  46279. /**
  46280. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46281. */
  46282. updateGizmoPositionToMatchAttachedMesh: boolean;
  46283. /**
  46284. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46285. */
  46286. updateScale: boolean;
  46287. protected _interactionsEnabled: boolean;
  46288. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46289. private _beforeRenderObserver;
  46290. private _tempVector;
  46291. /**
  46292. * Creates a gizmo
  46293. * @param gizmoLayer The utility layer the gizmo will be added to
  46294. */
  46295. constructor(
  46296. /** The utility layer the gizmo will be added to */
  46297. gizmoLayer?: UtilityLayerRenderer);
  46298. /**
  46299. * Updates the gizmo to match the attached mesh's position/rotation
  46300. */
  46301. protected _update(): void;
  46302. /**
  46303. * Disposes of the gizmo
  46304. */
  46305. dispose(): void;
  46306. }
  46307. }
  46308. declare module BABYLON {
  46309. /**
  46310. * Single plane drag gizmo
  46311. */
  46312. export class PlaneDragGizmo extends Gizmo {
  46313. /**
  46314. * Drag behavior responsible for the gizmos dragging interactions
  46315. */
  46316. dragBehavior: PointerDragBehavior;
  46317. private _pointerObserver;
  46318. /**
  46319. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46320. */
  46321. snapDistance: number;
  46322. /**
  46323. * Event that fires each time the gizmo snaps to a new location.
  46324. * * snapDistance is the the change in distance
  46325. */
  46326. onSnapObservable: Observable<{
  46327. snapDistance: number;
  46328. }>;
  46329. private _plane;
  46330. private _coloredMaterial;
  46331. private _hoverMaterial;
  46332. private _isEnabled;
  46333. private _parent;
  46334. /** @hidden */
  46335. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46336. /** @hidden */
  46337. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46338. /**
  46339. * Creates a PlaneDragGizmo
  46340. * @param gizmoLayer The utility layer the gizmo will be added to
  46341. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46342. * @param color The color of the gizmo
  46343. */
  46344. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46345. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46346. /**
  46347. * If the gizmo is enabled
  46348. */
  46349. set isEnabled(value: boolean);
  46350. get isEnabled(): boolean;
  46351. /**
  46352. * Disposes of the gizmo
  46353. */
  46354. dispose(): void;
  46355. }
  46356. }
  46357. declare module BABYLON {
  46358. /**
  46359. * Gizmo that enables dragging a mesh along 3 axis
  46360. */
  46361. export class PositionGizmo extends Gizmo {
  46362. /**
  46363. * Internal gizmo used for interactions on the x axis
  46364. */
  46365. xGizmo: AxisDragGizmo;
  46366. /**
  46367. * Internal gizmo used for interactions on the y axis
  46368. */
  46369. yGizmo: AxisDragGizmo;
  46370. /**
  46371. * Internal gizmo used for interactions on the z axis
  46372. */
  46373. zGizmo: AxisDragGizmo;
  46374. /**
  46375. * Internal gizmo used for interactions on the yz plane
  46376. */
  46377. xPlaneGizmo: PlaneDragGizmo;
  46378. /**
  46379. * Internal gizmo used for interactions on the xz plane
  46380. */
  46381. yPlaneGizmo: PlaneDragGizmo;
  46382. /**
  46383. * Internal gizmo used for interactions on the xy plane
  46384. */
  46385. zPlaneGizmo: PlaneDragGizmo;
  46386. /**
  46387. * private variables
  46388. */
  46389. private _meshAttached;
  46390. private _updateGizmoRotationToMatchAttachedMesh;
  46391. private _snapDistance;
  46392. private _scaleRatio;
  46393. /** Fires an event when any of it's sub gizmos are dragged */
  46394. onDragStartObservable: Observable<unknown>;
  46395. /** Fires an event when any of it's sub gizmos are released from dragging */
  46396. onDragEndObservable: Observable<unknown>;
  46397. /**
  46398. * If set to true, planar drag is enabled
  46399. */
  46400. private _planarGizmoEnabled;
  46401. get attachedMesh(): Nullable<AbstractMesh>;
  46402. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46403. /**
  46404. * Creates a PositionGizmo
  46405. * @param gizmoLayer The utility layer the gizmo will be added to
  46406. */
  46407. constructor(gizmoLayer?: UtilityLayerRenderer);
  46408. /**
  46409. * If the planar drag gizmo is enabled
  46410. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46411. */
  46412. set planarGizmoEnabled(value: boolean);
  46413. get planarGizmoEnabled(): boolean;
  46414. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46415. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46416. /**
  46417. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46418. */
  46419. set snapDistance(value: number);
  46420. get snapDistance(): number;
  46421. /**
  46422. * Ratio for the scale of the gizmo (Default: 1)
  46423. */
  46424. set scaleRatio(value: number);
  46425. get scaleRatio(): number;
  46426. /**
  46427. * Disposes of the gizmo
  46428. */
  46429. dispose(): void;
  46430. /**
  46431. * CustomMeshes are not supported by this gizmo
  46432. * @param mesh The mesh to replace the default mesh of the gizmo
  46433. */
  46434. setCustomMesh(mesh: Mesh): void;
  46435. }
  46436. }
  46437. declare module BABYLON {
  46438. /**
  46439. * Single axis drag gizmo
  46440. */
  46441. export class AxisDragGizmo extends Gizmo {
  46442. /**
  46443. * Drag behavior responsible for the gizmos dragging interactions
  46444. */
  46445. dragBehavior: PointerDragBehavior;
  46446. private _pointerObserver;
  46447. /**
  46448. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46449. */
  46450. snapDistance: number;
  46451. /**
  46452. * Event that fires each time the gizmo snaps to a new location.
  46453. * * snapDistance is the the change in distance
  46454. */
  46455. onSnapObservable: Observable<{
  46456. snapDistance: number;
  46457. }>;
  46458. private _isEnabled;
  46459. private _parent;
  46460. private _arrow;
  46461. private _coloredMaterial;
  46462. private _hoverMaterial;
  46463. /** @hidden */
  46464. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46465. /** @hidden */
  46466. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46467. /**
  46468. * Creates an AxisDragGizmo
  46469. * @param gizmoLayer The utility layer the gizmo will be added to
  46470. * @param dragAxis The axis which the gizmo will be able to drag on
  46471. * @param color The color of the gizmo
  46472. */
  46473. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46474. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46475. /**
  46476. * If the gizmo is enabled
  46477. */
  46478. set isEnabled(value: boolean);
  46479. get isEnabled(): boolean;
  46480. /**
  46481. * Disposes of the gizmo
  46482. */
  46483. dispose(): void;
  46484. }
  46485. }
  46486. declare module BABYLON.Debug {
  46487. /**
  46488. * The Axes viewer will show 3 axes in a specific point in space
  46489. */
  46490. export class AxesViewer {
  46491. private _xAxis;
  46492. private _yAxis;
  46493. private _zAxis;
  46494. private _scaleLinesFactor;
  46495. private _instanced;
  46496. /**
  46497. * Gets the hosting scene
  46498. */
  46499. scene: Scene;
  46500. /**
  46501. * Gets or sets a number used to scale line length
  46502. */
  46503. scaleLines: number;
  46504. /** Gets the node hierarchy used to render x-axis */
  46505. get xAxis(): TransformNode;
  46506. /** Gets the node hierarchy used to render y-axis */
  46507. get yAxis(): TransformNode;
  46508. /** Gets the node hierarchy used to render z-axis */
  46509. get zAxis(): TransformNode;
  46510. /**
  46511. * Creates a new AxesViewer
  46512. * @param scene defines the hosting scene
  46513. * @param scaleLines defines a number used to scale line length (1 by default)
  46514. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46515. * @param xAxis defines the node hierarchy used to render the x-axis
  46516. * @param yAxis defines the node hierarchy used to render the y-axis
  46517. * @param zAxis defines the node hierarchy used to render the z-axis
  46518. */
  46519. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46520. /**
  46521. * Force the viewer to update
  46522. * @param position defines the position of the viewer
  46523. * @param xaxis defines the x axis of the viewer
  46524. * @param yaxis defines the y axis of the viewer
  46525. * @param zaxis defines the z axis of the viewer
  46526. */
  46527. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46528. /**
  46529. * Creates an instance of this axes viewer.
  46530. * @returns a new axes viewer with instanced meshes
  46531. */
  46532. createInstance(): AxesViewer;
  46533. /** Releases resources */
  46534. dispose(): void;
  46535. private static _SetRenderingGroupId;
  46536. }
  46537. }
  46538. declare module BABYLON.Debug {
  46539. /**
  46540. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46541. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46542. */
  46543. export class BoneAxesViewer extends AxesViewer {
  46544. /**
  46545. * Gets or sets the target mesh where to display the axes viewer
  46546. */
  46547. mesh: Nullable<Mesh>;
  46548. /**
  46549. * Gets or sets the target bone where to display the axes viewer
  46550. */
  46551. bone: Nullable<Bone>;
  46552. /** Gets current position */
  46553. pos: Vector3;
  46554. /** Gets direction of X axis */
  46555. xaxis: Vector3;
  46556. /** Gets direction of Y axis */
  46557. yaxis: Vector3;
  46558. /** Gets direction of Z axis */
  46559. zaxis: Vector3;
  46560. /**
  46561. * Creates a new BoneAxesViewer
  46562. * @param scene defines the hosting scene
  46563. * @param bone defines the target bone
  46564. * @param mesh defines the target mesh
  46565. * @param scaleLines defines a scaling factor for line length (1 by default)
  46566. */
  46567. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46568. /**
  46569. * Force the viewer to update
  46570. */
  46571. update(): void;
  46572. /** Releases resources */
  46573. dispose(): void;
  46574. }
  46575. }
  46576. declare module BABYLON {
  46577. /**
  46578. * Interface used to define scene explorer extensibility option
  46579. */
  46580. export interface IExplorerExtensibilityOption {
  46581. /**
  46582. * Define the option label
  46583. */
  46584. label: string;
  46585. /**
  46586. * Defines the action to execute on click
  46587. */
  46588. action: (entity: any) => void;
  46589. }
  46590. /**
  46591. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46592. */
  46593. export interface IExplorerExtensibilityGroup {
  46594. /**
  46595. * Defines a predicate to test if a given type mut be extended
  46596. */
  46597. predicate: (entity: any) => boolean;
  46598. /**
  46599. * Gets the list of options added to a type
  46600. */
  46601. entries: IExplorerExtensibilityOption[];
  46602. }
  46603. /**
  46604. * Interface used to define the options to use to create the Inspector
  46605. */
  46606. export interface IInspectorOptions {
  46607. /**
  46608. * Display in overlay mode (default: false)
  46609. */
  46610. overlay?: boolean;
  46611. /**
  46612. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46613. */
  46614. globalRoot?: HTMLElement;
  46615. /**
  46616. * Display the Scene explorer
  46617. */
  46618. showExplorer?: boolean;
  46619. /**
  46620. * Display the property inspector
  46621. */
  46622. showInspector?: boolean;
  46623. /**
  46624. * Display in embed mode (both panes on the right)
  46625. */
  46626. embedMode?: boolean;
  46627. /**
  46628. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46629. */
  46630. handleResize?: boolean;
  46631. /**
  46632. * Allow the panes to popup (default: true)
  46633. */
  46634. enablePopup?: boolean;
  46635. /**
  46636. * Allow the panes to be closed by users (default: true)
  46637. */
  46638. enableClose?: boolean;
  46639. /**
  46640. * Optional list of extensibility entries
  46641. */
  46642. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46643. /**
  46644. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46645. */
  46646. inspectorURL?: string;
  46647. /**
  46648. * Optional initial tab (default to DebugLayerTab.Properties)
  46649. */
  46650. initialTab?: DebugLayerTab;
  46651. }
  46652. interface Scene {
  46653. /**
  46654. * @hidden
  46655. * Backing field
  46656. */
  46657. _debugLayer: DebugLayer;
  46658. /**
  46659. * Gets the debug layer (aka Inspector) associated with the scene
  46660. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46661. */
  46662. debugLayer: DebugLayer;
  46663. }
  46664. /**
  46665. * Enum of inspector action tab
  46666. */
  46667. export enum DebugLayerTab {
  46668. /**
  46669. * Properties tag (default)
  46670. */
  46671. Properties = 0,
  46672. /**
  46673. * Debug tab
  46674. */
  46675. Debug = 1,
  46676. /**
  46677. * Statistics tab
  46678. */
  46679. Statistics = 2,
  46680. /**
  46681. * Tools tab
  46682. */
  46683. Tools = 3,
  46684. /**
  46685. * Settings tab
  46686. */
  46687. Settings = 4
  46688. }
  46689. /**
  46690. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46691. * what is happening in your scene
  46692. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46693. */
  46694. export class DebugLayer {
  46695. /**
  46696. * Define the url to get the inspector script from.
  46697. * By default it uses the babylonjs CDN.
  46698. * @ignoreNaming
  46699. */
  46700. static InspectorURL: string;
  46701. private _scene;
  46702. private BJSINSPECTOR;
  46703. private _onPropertyChangedObservable?;
  46704. /**
  46705. * Observable triggered when a property is changed through the inspector.
  46706. */
  46707. get onPropertyChangedObservable(): any;
  46708. /**
  46709. * Instantiates a new debug layer.
  46710. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46711. * what is happening in your scene
  46712. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46713. * @param scene Defines the scene to inspect
  46714. */
  46715. constructor(scene: Scene);
  46716. /** Creates the inspector window. */
  46717. private _createInspector;
  46718. /**
  46719. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46720. * @param entity defines the entity to select
  46721. * @param lineContainerTitle defines the specific block to highlight
  46722. */
  46723. select(entity: any, lineContainerTitle?: string): void;
  46724. /** Get the inspector from bundle or global */
  46725. private _getGlobalInspector;
  46726. /**
  46727. * Get if the inspector is visible or not.
  46728. * @returns true if visible otherwise, false
  46729. */
  46730. isVisible(): boolean;
  46731. /**
  46732. * Hide the inspector and close its window.
  46733. */
  46734. hide(): void;
  46735. /**
  46736. * Launch the debugLayer.
  46737. * @param config Define the configuration of the inspector
  46738. * @return a promise fulfilled when the debug layer is visible
  46739. */
  46740. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46741. }
  46742. }
  46743. declare module BABYLON {
  46744. /**
  46745. * Class containing static functions to help procedurally build meshes
  46746. */
  46747. export class BoxBuilder {
  46748. /**
  46749. * Creates a box mesh
  46750. * * The parameter `size` sets the size (float) of each box side (default 1)
  46751. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46752. * * 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)
  46753. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46755. * * 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
  46756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46757. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46758. * @param name defines the name of the mesh
  46759. * @param options defines the options used to create the mesh
  46760. * @param scene defines the hosting scene
  46761. * @returns the box mesh
  46762. */
  46763. static CreateBox(name: string, options: {
  46764. size?: number;
  46765. width?: number;
  46766. height?: number;
  46767. depth?: number;
  46768. faceUV?: Vector4[];
  46769. faceColors?: Color4[];
  46770. sideOrientation?: number;
  46771. frontUVs?: Vector4;
  46772. backUVs?: Vector4;
  46773. wrap?: boolean;
  46774. topBaseAt?: number;
  46775. bottomBaseAt?: number;
  46776. updatable?: boolean;
  46777. }, scene?: Nullable<Scene>): Mesh;
  46778. }
  46779. }
  46780. declare module BABYLON.Debug {
  46781. /**
  46782. * Used to show the physics impostor around the specific mesh
  46783. */
  46784. export class PhysicsViewer {
  46785. /** @hidden */
  46786. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46787. /** @hidden */
  46788. protected _meshes: Array<Nullable<AbstractMesh>>;
  46789. /** @hidden */
  46790. protected _scene: Nullable<Scene>;
  46791. /** @hidden */
  46792. protected _numMeshes: number;
  46793. /** @hidden */
  46794. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46795. private _renderFunction;
  46796. private _utilityLayer;
  46797. private _debugBoxMesh;
  46798. private _debugSphereMesh;
  46799. private _debugCylinderMesh;
  46800. private _debugMaterial;
  46801. private _debugMeshMeshes;
  46802. /**
  46803. * Creates a new PhysicsViewer
  46804. * @param scene defines the hosting scene
  46805. */
  46806. constructor(scene: Scene);
  46807. /** @hidden */
  46808. protected _updateDebugMeshes(): void;
  46809. /**
  46810. * Renders a specified physic impostor
  46811. * @param impostor defines the impostor to render
  46812. * @param targetMesh defines the mesh represented by the impostor
  46813. * @returns the new debug mesh used to render the impostor
  46814. */
  46815. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46816. /**
  46817. * Hides a specified physic impostor
  46818. * @param impostor defines the impostor to hide
  46819. */
  46820. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46821. private _getDebugMaterial;
  46822. private _getDebugBoxMesh;
  46823. private _getDebugSphereMesh;
  46824. private _getDebugCylinderMesh;
  46825. private _getDebugMeshMesh;
  46826. private _getDebugMesh;
  46827. /** Releases all resources */
  46828. dispose(): void;
  46829. }
  46830. }
  46831. declare module BABYLON {
  46832. /**
  46833. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46834. * in order to better appreciate the issue one might have.
  46835. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46836. */
  46837. export class RayHelper {
  46838. /**
  46839. * Defines the ray we are currently tryin to visualize.
  46840. */
  46841. ray: Nullable<Ray>;
  46842. private _renderPoints;
  46843. private _renderLine;
  46844. private _renderFunction;
  46845. private _scene;
  46846. private _updateToMeshFunction;
  46847. private _attachedToMesh;
  46848. private _meshSpaceDirection;
  46849. private _meshSpaceOrigin;
  46850. /**
  46851. * Helper function to create a colored helper in a scene in one line.
  46852. * @param ray Defines the ray we are currently tryin to visualize
  46853. * @param scene Defines the scene the ray is used in
  46854. * @param color Defines the color we want to see the ray in
  46855. * @returns The newly created ray helper.
  46856. */
  46857. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46858. /**
  46859. * Instantiate a new ray helper.
  46860. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46861. * in order to better appreciate the issue one might have.
  46862. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46863. * @param ray Defines the ray we are currently tryin to visualize
  46864. */
  46865. constructor(ray: Ray);
  46866. /**
  46867. * Shows the ray we are willing to debug.
  46868. * @param scene Defines the scene the ray needs to be rendered in
  46869. * @param color Defines the color the ray needs to be rendered in
  46870. */
  46871. show(scene: Scene, color?: Color3): void;
  46872. /**
  46873. * Hides the ray we are debugging.
  46874. */
  46875. hide(): void;
  46876. private _render;
  46877. /**
  46878. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46879. * @param mesh Defines the mesh we want the helper attached to
  46880. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46881. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46882. * @param length Defines the length of the ray
  46883. */
  46884. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46885. /**
  46886. * Detach the ray helper from the mesh it has previously been attached to.
  46887. */
  46888. detachFromMesh(): void;
  46889. private _updateToMesh;
  46890. /**
  46891. * Dispose the helper and release its associated resources.
  46892. */
  46893. dispose(): void;
  46894. }
  46895. }
  46896. declare module BABYLON.Debug {
  46897. /**
  46898. * Class used to render a debug view of a given skeleton
  46899. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46900. */
  46901. export class SkeletonViewer {
  46902. /** defines the skeleton to render */
  46903. skeleton: Skeleton;
  46904. /** defines the mesh attached to the skeleton */
  46905. mesh: AbstractMesh;
  46906. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46907. autoUpdateBonesMatrices: boolean;
  46908. /** defines the rendering group id to use with the viewer */
  46909. renderingGroupId: number;
  46910. /** Gets or sets the color used to render the skeleton */
  46911. color: Color3;
  46912. private _scene;
  46913. private _debugLines;
  46914. private _debugMesh;
  46915. private _isEnabled;
  46916. private _renderFunction;
  46917. private _utilityLayer;
  46918. /**
  46919. * Returns the mesh used to render the bones
  46920. */
  46921. get debugMesh(): Nullable<LinesMesh>;
  46922. /**
  46923. * Creates a new SkeletonViewer
  46924. * @param skeleton defines the skeleton to render
  46925. * @param mesh defines the mesh attached to the skeleton
  46926. * @param scene defines the hosting scene
  46927. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46928. * @param renderingGroupId defines the rendering group id to use with the viewer
  46929. */
  46930. constructor(
  46931. /** defines the skeleton to render */
  46932. skeleton: Skeleton,
  46933. /** defines the mesh attached to the skeleton */
  46934. mesh: AbstractMesh, scene: Scene,
  46935. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46936. autoUpdateBonesMatrices?: boolean,
  46937. /** defines the rendering group id to use with the viewer */
  46938. renderingGroupId?: number);
  46939. /** Gets or sets a boolean indicating if the viewer is enabled */
  46940. set isEnabled(value: boolean);
  46941. get isEnabled(): boolean;
  46942. private _getBonePosition;
  46943. private _getLinesForBonesWithLength;
  46944. private _getLinesForBonesNoLength;
  46945. /** Update the viewer to sync with current skeleton state */
  46946. update(): void;
  46947. /** Release associated resources */
  46948. dispose(): void;
  46949. }
  46950. }
  46951. declare module BABYLON {
  46952. /**
  46953. * This class will take all inputs from Keyboard, Pointer, and
  46954. * any Gamepads and provide a polling system that all devices
  46955. * will use. This class assumes that there will only be one
  46956. * pointer device and one keyboard.
  46957. */
  46958. export class DeviceInputSystem implements IDisposable {
  46959. /** POINTER_DEVICE */
  46960. static readonly POINTER_DEVICE: string;
  46961. /** KEYBOARD_DEVICE */
  46962. static readonly KEYBOARD_DEVICE: string;
  46963. /**
  46964. * Observable to be triggered when a device is connected
  46965. */
  46966. onDeviceConnectedObservable: Observable<string>;
  46967. /**
  46968. * Observable to be triggered when a device is disconnected
  46969. */
  46970. onDeviceDisconnectedObservable: Observable<string>;
  46971. private _inputs;
  46972. private _gamepads;
  46973. private _keyboardActive;
  46974. private _pointerActive;
  46975. private _elementToAttachTo;
  46976. private _keyboardDownEvent;
  46977. private _keyboardUpEvent;
  46978. private _pointerMoveEvent;
  46979. private _pointerDownEvent;
  46980. private _pointerUpEvent;
  46981. private _gamepadConnectedEvent;
  46982. private _gamepadDisconnectedEvent;
  46983. private static _MAX_KEYCODES;
  46984. private static _MAX_POINTER_INPUTS;
  46985. /**
  46986. * Default Constructor
  46987. * @param engine - engine to pull input element from
  46988. */
  46989. constructor(engine: Engine);
  46990. /**
  46991. * Checks for current device input value, given an id and input index
  46992. * @param deviceName Id of connected device
  46993. * @param inputIndex Index of device input
  46994. * @returns Current value of input
  46995. */
  46996. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  46997. /**
  46998. * Dispose of all the eventlisteners and clears the observables
  46999. */
  47000. dispose(): void;
  47001. /**
  47002. * Add device and inputs to device map
  47003. * @param deviceName Assigned name of device (may be SN)
  47004. * @param numberOfInputs Number of input entries to create for given device
  47005. */
  47006. private _registerDevice;
  47007. /**
  47008. * Given a specific device name, remove that device from the device map
  47009. * @param deviceName Name of device to be removed
  47010. */
  47011. private _unregisterDevice;
  47012. /**
  47013. * Handle all actions that come from keyboard interaction
  47014. */
  47015. private _handleKeyActions;
  47016. /**
  47017. * Handle all actions that come from pointer interaction
  47018. */
  47019. private _handlePointerActions;
  47020. /**
  47021. * Handle all actions that come from gamepad interaction
  47022. */
  47023. private _handleGamepadActions;
  47024. /**
  47025. * Update all non-event based devices with each frame
  47026. */
  47027. private _updateDevice;
  47028. }
  47029. }
  47030. declare module BABYLON {
  47031. /**
  47032. * Options to create the null engine
  47033. */
  47034. export class NullEngineOptions {
  47035. /**
  47036. * Render width (Default: 512)
  47037. */
  47038. renderWidth: number;
  47039. /**
  47040. * Render height (Default: 256)
  47041. */
  47042. renderHeight: number;
  47043. /**
  47044. * Texture size (Default: 512)
  47045. */
  47046. textureSize: number;
  47047. /**
  47048. * If delta time between frames should be constant
  47049. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47050. */
  47051. deterministicLockstep: boolean;
  47052. /**
  47053. * Maximum about of steps between frames (Default: 4)
  47054. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47055. */
  47056. lockstepMaxSteps: number;
  47057. }
  47058. /**
  47059. * The null engine class provides support for headless version of babylon.js.
  47060. * This can be used in server side scenario or for testing purposes
  47061. */
  47062. export class NullEngine extends Engine {
  47063. private _options;
  47064. /**
  47065. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47066. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47067. * @returns true if engine is in deterministic lock step mode
  47068. */
  47069. isDeterministicLockStep(): boolean;
  47070. /**
  47071. * Gets the max steps when engine is running in deterministic lock step
  47072. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47073. * @returns the max steps
  47074. */
  47075. getLockstepMaxSteps(): number;
  47076. /**
  47077. * Gets the current hardware scaling level.
  47078. * By default the hardware scaling level is computed from the window device ratio.
  47079. * 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.
  47080. * @returns a number indicating the current hardware scaling level
  47081. */
  47082. getHardwareScalingLevel(): number;
  47083. constructor(options?: NullEngineOptions);
  47084. /**
  47085. * Creates a vertex buffer
  47086. * @param vertices the data for the vertex buffer
  47087. * @returns the new WebGL static buffer
  47088. */
  47089. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47090. /**
  47091. * Creates a new index buffer
  47092. * @param indices defines the content of the index buffer
  47093. * @param updatable defines if the index buffer must be updatable
  47094. * @returns a new webGL buffer
  47095. */
  47096. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47097. /**
  47098. * Clear the current render buffer or the current render target (if any is set up)
  47099. * @param color defines the color to use
  47100. * @param backBuffer defines if the back buffer must be cleared
  47101. * @param depth defines if the depth buffer must be cleared
  47102. * @param stencil defines if the stencil buffer must be cleared
  47103. */
  47104. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47105. /**
  47106. * Gets the current render width
  47107. * @param useScreen defines if screen size must be used (or the current render target if any)
  47108. * @returns a number defining the current render width
  47109. */
  47110. getRenderWidth(useScreen?: boolean): number;
  47111. /**
  47112. * Gets the current render height
  47113. * @param useScreen defines if screen size must be used (or the current render target if any)
  47114. * @returns a number defining the current render height
  47115. */
  47116. getRenderHeight(useScreen?: boolean): number;
  47117. /**
  47118. * Set the WebGL's viewport
  47119. * @param viewport defines the viewport element to be used
  47120. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47121. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47122. */
  47123. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47124. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47125. /**
  47126. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47127. * @param pipelineContext defines the pipeline context to use
  47128. * @param uniformsNames defines the list of uniform names
  47129. * @returns an array of webGL uniform locations
  47130. */
  47131. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47132. /**
  47133. * Gets the lsit of active attributes for a given webGL program
  47134. * @param pipelineContext defines the pipeline context to use
  47135. * @param attributesNames defines the list of attribute names to get
  47136. * @returns an array of indices indicating the offset of each attribute
  47137. */
  47138. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47139. /**
  47140. * Binds an effect to the webGL context
  47141. * @param effect defines the effect to bind
  47142. */
  47143. bindSamplers(effect: Effect): void;
  47144. /**
  47145. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47146. * @param effect defines the effect to activate
  47147. */
  47148. enableEffect(effect: Effect): void;
  47149. /**
  47150. * Set various states to the webGL context
  47151. * @param culling defines backface culling state
  47152. * @param zOffset defines the value to apply to zOffset (0 by default)
  47153. * @param force defines if states must be applied even if cache is up to date
  47154. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47155. */
  47156. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47157. /**
  47158. * Set the value of an uniform to an array of int32
  47159. * @param uniform defines the webGL uniform location where to store the value
  47160. * @param array defines the array of int32 to store
  47161. */
  47162. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47163. /**
  47164. * Set the value of an uniform to an array of int32 (stored as vec2)
  47165. * @param uniform defines the webGL uniform location where to store the value
  47166. * @param array defines the array of int32 to store
  47167. */
  47168. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47169. /**
  47170. * Set the value of an uniform to an array of int32 (stored as vec3)
  47171. * @param uniform defines the webGL uniform location where to store the value
  47172. * @param array defines the array of int32 to store
  47173. */
  47174. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47175. /**
  47176. * Set the value of an uniform to an array of int32 (stored as vec4)
  47177. * @param uniform defines the webGL uniform location where to store the value
  47178. * @param array defines the array of int32 to store
  47179. */
  47180. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47181. /**
  47182. * Set the value of an uniform to an array of float32
  47183. * @param uniform defines the webGL uniform location where to store the value
  47184. * @param array defines the array of float32 to store
  47185. */
  47186. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47187. /**
  47188. * Set the value of an uniform to an array of float32 (stored as vec2)
  47189. * @param uniform defines the webGL uniform location where to store the value
  47190. * @param array defines the array of float32 to store
  47191. */
  47192. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47193. /**
  47194. * Set the value of an uniform to an array of float32 (stored as vec3)
  47195. * @param uniform defines the webGL uniform location where to store the value
  47196. * @param array defines the array of float32 to store
  47197. */
  47198. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47199. /**
  47200. * Set the value of an uniform to an array of float32 (stored as vec4)
  47201. * @param uniform defines the webGL uniform location where to store the value
  47202. * @param array defines the array of float32 to store
  47203. */
  47204. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47205. /**
  47206. * Set the value of an uniform to an array of number
  47207. * @param uniform defines the webGL uniform location where to store the value
  47208. * @param array defines the array of number to store
  47209. */
  47210. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47211. /**
  47212. * Set the value of an uniform to an array of number (stored as vec2)
  47213. * @param uniform defines the webGL uniform location where to store the value
  47214. * @param array defines the array of number to store
  47215. */
  47216. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47217. /**
  47218. * Set the value of an uniform to an array of number (stored as vec3)
  47219. * @param uniform defines the webGL uniform location where to store the value
  47220. * @param array defines the array of number to store
  47221. */
  47222. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47223. /**
  47224. * Set the value of an uniform to an array of number (stored as vec4)
  47225. * @param uniform defines the webGL uniform location where to store the value
  47226. * @param array defines the array of number to store
  47227. */
  47228. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47229. /**
  47230. * Set the value of an uniform to an array of float32 (stored as matrices)
  47231. * @param uniform defines the webGL uniform location where to store the value
  47232. * @param matrices defines the array of float32 to store
  47233. */
  47234. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47235. /**
  47236. * Set the value of an uniform to a matrix (3x3)
  47237. * @param uniform defines the webGL uniform location where to store the value
  47238. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47239. */
  47240. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47241. /**
  47242. * Set the value of an uniform to a matrix (2x2)
  47243. * @param uniform defines the webGL uniform location where to store the value
  47244. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47245. */
  47246. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47247. /**
  47248. * Set the value of an uniform to a number (float)
  47249. * @param uniform defines the webGL uniform location where to store the value
  47250. * @param value defines the float number to store
  47251. */
  47252. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47253. /**
  47254. * Set the value of an uniform to a vec2
  47255. * @param uniform defines the webGL uniform location where to store the value
  47256. * @param x defines the 1st component of the value
  47257. * @param y defines the 2nd component of the value
  47258. */
  47259. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47260. /**
  47261. * Set the value of an uniform to a vec3
  47262. * @param uniform defines the webGL uniform location where to store the value
  47263. * @param x defines the 1st component of the value
  47264. * @param y defines the 2nd component of the value
  47265. * @param z defines the 3rd component of the value
  47266. */
  47267. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47268. /**
  47269. * Set the value of an uniform to a boolean
  47270. * @param uniform defines the webGL uniform location where to store the value
  47271. * @param bool defines the boolean to store
  47272. */
  47273. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47274. /**
  47275. * Set the value of an uniform to a vec4
  47276. * @param uniform defines the webGL uniform location where to store the value
  47277. * @param x defines the 1st component of the value
  47278. * @param y defines the 2nd component of the value
  47279. * @param z defines the 3rd component of the value
  47280. * @param w defines the 4th component of the value
  47281. */
  47282. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47283. /**
  47284. * Sets the current alpha mode
  47285. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47286. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47287. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47288. */
  47289. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47290. /**
  47291. * Bind webGl buffers directly to the webGL context
  47292. * @param vertexBuffers defines the vertex buffer to bind
  47293. * @param indexBuffer defines the index buffer to bind
  47294. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47295. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47296. * @param effect defines the effect associated with the vertex buffer
  47297. */
  47298. bindBuffers(vertexBuffers: {
  47299. [key: string]: VertexBuffer;
  47300. }, indexBuffer: DataBuffer, effect: Effect): void;
  47301. /**
  47302. * Force the entire cache to be cleared
  47303. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47304. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47305. */
  47306. wipeCaches(bruteForce?: boolean): void;
  47307. /**
  47308. * Send a draw order
  47309. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47310. * @param indexStart defines the starting index
  47311. * @param indexCount defines the number of index to draw
  47312. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47313. */
  47314. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47315. /**
  47316. * Draw a list of indexed primitives
  47317. * @param fillMode defines the primitive to use
  47318. * @param indexStart defines the starting index
  47319. * @param indexCount defines the number of index to draw
  47320. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47321. */
  47322. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47323. /**
  47324. * Draw a list of unindexed primitives
  47325. * @param fillMode defines the primitive to use
  47326. * @param verticesStart defines the index of first vertex to draw
  47327. * @param verticesCount defines the count of vertices to draw
  47328. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47329. */
  47330. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47331. /** @hidden */
  47332. _createTexture(): WebGLTexture;
  47333. /** @hidden */
  47334. _releaseTexture(texture: InternalTexture): void;
  47335. /**
  47336. * Usually called from Texture.ts.
  47337. * Passed information to create a WebGLTexture
  47338. * @param urlArg defines a value which contains one of the following:
  47339. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47340. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47341. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47342. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47343. * @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)
  47344. * @param scene needed for loading to the correct scene
  47345. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47346. * @param onLoad optional callback to be called upon successful completion
  47347. * @param onError optional callback to be called upon failure
  47348. * @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
  47349. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47350. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47351. * @param forcedExtension defines the extension to use to pick the right loader
  47352. * @param mimeType defines an optional mime type
  47353. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47354. */
  47355. 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;
  47356. /**
  47357. * Creates a new render target texture
  47358. * @param size defines the size of the texture
  47359. * @param options defines the options used to create the texture
  47360. * @returns a new render target texture stored in an InternalTexture
  47361. */
  47362. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47363. /**
  47364. * Update the sampling mode of a given texture
  47365. * @param samplingMode defines the required sampling mode
  47366. * @param texture defines the texture to update
  47367. */
  47368. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47369. /**
  47370. * Binds the frame buffer to the specified texture.
  47371. * @param texture The texture to render to or null for the default canvas
  47372. * @param faceIndex The face of the texture to render to in case of cube texture
  47373. * @param requiredWidth The width of the target to render to
  47374. * @param requiredHeight The height of the target to render to
  47375. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47376. * @param lodLevel defines le lod level to bind to the frame buffer
  47377. */
  47378. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47379. /**
  47380. * Unbind the current render target texture from the webGL context
  47381. * @param texture defines the render target texture to unbind
  47382. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47383. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47384. */
  47385. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47386. /**
  47387. * Creates a dynamic vertex buffer
  47388. * @param vertices the data for the dynamic vertex buffer
  47389. * @returns the new WebGL dynamic buffer
  47390. */
  47391. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47392. /**
  47393. * Update the content of a dynamic texture
  47394. * @param texture defines the texture to update
  47395. * @param canvas defines the canvas containing the source
  47396. * @param invertY defines if data must be stored with Y axis inverted
  47397. * @param premulAlpha defines if alpha is stored as premultiplied
  47398. * @param format defines the format of the data
  47399. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47400. */
  47401. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47402. /**
  47403. * Gets a boolean indicating if all created effects are ready
  47404. * @returns true if all effects are ready
  47405. */
  47406. areAllEffectsReady(): boolean;
  47407. /**
  47408. * @hidden
  47409. * Get the current error code of the webGL context
  47410. * @returns the error code
  47411. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47412. */
  47413. getError(): number;
  47414. /** @hidden */
  47415. _getUnpackAlignement(): number;
  47416. /** @hidden */
  47417. _unpackFlipY(value: boolean): void;
  47418. /**
  47419. * Update a dynamic index buffer
  47420. * @param indexBuffer defines the target index buffer
  47421. * @param indices defines the data to update
  47422. * @param offset defines the offset in the target index buffer where update should start
  47423. */
  47424. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47425. /**
  47426. * Updates a dynamic vertex buffer.
  47427. * @param vertexBuffer the vertex buffer to update
  47428. * @param vertices the data used to update the vertex buffer
  47429. * @param byteOffset the byte offset of the data (optional)
  47430. * @param byteLength the byte length of the data (optional)
  47431. */
  47432. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47433. /** @hidden */
  47434. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47435. /** @hidden */
  47436. _bindTexture(channel: number, texture: InternalTexture): void;
  47437. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47438. /**
  47439. * 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
  47440. */
  47441. releaseEffects(): void;
  47442. displayLoadingUI(): void;
  47443. hideLoadingUI(): void;
  47444. /** @hidden */
  47445. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47446. /** @hidden */
  47447. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47448. /** @hidden */
  47449. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47450. /** @hidden */
  47451. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47452. }
  47453. }
  47454. declare module BABYLON {
  47455. /**
  47456. * @hidden
  47457. **/
  47458. export class _TimeToken {
  47459. _startTimeQuery: Nullable<WebGLQuery>;
  47460. _endTimeQuery: Nullable<WebGLQuery>;
  47461. _timeElapsedQuery: Nullable<WebGLQuery>;
  47462. _timeElapsedQueryEnded: boolean;
  47463. }
  47464. }
  47465. declare module BABYLON {
  47466. /** @hidden */
  47467. export class _OcclusionDataStorage {
  47468. /** @hidden */
  47469. occlusionInternalRetryCounter: number;
  47470. /** @hidden */
  47471. isOcclusionQueryInProgress: boolean;
  47472. /** @hidden */
  47473. isOccluded: boolean;
  47474. /** @hidden */
  47475. occlusionRetryCount: number;
  47476. /** @hidden */
  47477. occlusionType: number;
  47478. /** @hidden */
  47479. occlusionQueryAlgorithmType: number;
  47480. }
  47481. interface Engine {
  47482. /**
  47483. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47484. * @return the new query
  47485. */
  47486. createQuery(): WebGLQuery;
  47487. /**
  47488. * Delete and release a webGL query
  47489. * @param query defines the query to delete
  47490. * @return the current engine
  47491. */
  47492. deleteQuery(query: WebGLQuery): Engine;
  47493. /**
  47494. * Check if a given query has resolved and got its value
  47495. * @param query defines the query to check
  47496. * @returns true if the query got its value
  47497. */
  47498. isQueryResultAvailable(query: WebGLQuery): boolean;
  47499. /**
  47500. * Gets the value of a given query
  47501. * @param query defines the query to check
  47502. * @returns the value of the query
  47503. */
  47504. getQueryResult(query: WebGLQuery): number;
  47505. /**
  47506. * Initiates an occlusion query
  47507. * @param algorithmType defines the algorithm to use
  47508. * @param query defines the query to use
  47509. * @returns the current engine
  47510. * @see http://doc.babylonjs.com/features/occlusionquery
  47511. */
  47512. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47513. /**
  47514. * Ends an occlusion query
  47515. * @see http://doc.babylonjs.com/features/occlusionquery
  47516. * @param algorithmType defines the algorithm to use
  47517. * @returns the current engine
  47518. */
  47519. endOcclusionQuery(algorithmType: number): Engine;
  47520. /**
  47521. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47522. * Please note that only one query can be issued at a time
  47523. * @returns a time token used to track the time span
  47524. */
  47525. startTimeQuery(): Nullable<_TimeToken>;
  47526. /**
  47527. * Ends a time query
  47528. * @param token defines the token used to measure the time span
  47529. * @returns the time spent (in ns)
  47530. */
  47531. endTimeQuery(token: _TimeToken): int;
  47532. /** @hidden */
  47533. _currentNonTimestampToken: Nullable<_TimeToken>;
  47534. /** @hidden */
  47535. _createTimeQuery(): WebGLQuery;
  47536. /** @hidden */
  47537. _deleteTimeQuery(query: WebGLQuery): void;
  47538. /** @hidden */
  47539. _getGlAlgorithmType(algorithmType: number): number;
  47540. /** @hidden */
  47541. _getTimeQueryResult(query: WebGLQuery): any;
  47542. /** @hidden */
  47543. _getTimeQueryAvailability(query: WebGLQuery): any;
  47544. }
  47545. interface AbstractMesh {
  47546. /**
  47547. * Backing filed
  47548. * @hidden
  47549. */
  47550. __occlusionDataStorage: _OcclusionDataStorage;
  47551. /**
  47552. * Access property
  47553. * @hidden
  47554. */
  47555. _occlusionDataStorage: _OcclusionDataStorage;
  47556. /**
  47557. * 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.
  47558. * The default value is -1 which means don't break the query and wait till the result
  47559. * @see http://doc.babylonjs.com/features/occlusionquery
  47560. */
  47561. occlusionRetryCount: number;
  47562. /**
  47563. * 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:
  47564. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47565. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47566. * * 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.
  47567. * @see http://doc.babylonjs.com/features/occlusionquery
  47568. */
  47569. occlusionType: number;
  47570. /**
  47571. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47572. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47573. * * 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.
  47574. * @see http://doc.babylonjs.com/features/occlusionquery
  47575. */
  47576. occlusionQueryAlgorithmType: number;
  47577. /**
  47578. * 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
  47579. * @see http://doc.babylonjs.com/features/occlusionquery
  47580. */
  47581. isOccluded: boolean;
  47582. /**
  47583. * Flag to check the progress status of the query
  47584. * @see http://doc.babylonjs.com/features/occlusionquery
  47585. */
  47586. isOcclusionQueryInProgress: boolean;
  47587. }
  47588. }
  47589. declare module BABYLON {
  47590. /** @hidden */
  47591. export var _forceTransformFeedbackToBundle: boolean;
  47592. interface Engine {
  47593. /**
  47594. * Creates a webGL transform feedback object
  47595. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47596. * @returns the webGL transform feedback object
  47597. */
  47598. createTransformFeedback(): WebGLTransformFeedback;
  47599. /**
  47600. * Delete a webGL transform feedback object
  47601. * @param value defines the webGL transform feedback object to delete
  47602. */
  47603. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47604. /**
  47605. * Bind a webGL transform feedback object to the webgl context
  47606. * @param value defines the webGL transform feedback object to bind
  47607. */
  47608. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47609. /**
  47610. * Begins a transform feedback operation
  47611. * @param usePoints defines if points or triangles must be used
  47612. */
  47613. beginTransformFeedback(usePoints: boolean): void;
  47614. /**
  47615. * Ends a transform feedback operation
  47616. */
  47617. endTransformFeedback(): void;
  47618. /**
  47619. * Specify the varyings to use with transform feedback
  47620. * @param program defines the associated webGL program
  47621. * @param value defines the list of strings representing the varying names
  47622. */
  47623. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47624. /**
  47625. * Bind a webGL buffer for a transform feedback operation
  47626. * @param value defines the webGL buffer to bind
  47627. */
  47628. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47629. }
  47630. }
  47631. declare module BABYLON {
  47632. /**
  47633. * Creation options of the multi render target texture.
  47634. */
  47635. export interface IMultiRenderTargetOptions {
  47636. /**
  47637. * Define if the texture needs to create mip maps after render.
  47638. */
  47639. generateMipMaps?: boolean;
  47640. /**
  47641. * Define the types of all the draw buffers we want to create
  47642. */
  47643. types?: number[];
  47644. /**
  47645. * Define the sampling modes of all the draw buffers we want to create
  47646. */
  47647. samplingModes?: number[];
  47648. /**
  47649. * Define if a depth buffer is required
  47650. */
  47651. generateDepthBuffer?: boolean;
  47652. /**
  47653. * Define if a stencil buffer is required
  47654. */
  47655. generateStencilBuffer?: boolean;
  47656. /**
  47657. * Define if a depth texture is required instead of a depth buffer
  47658. */
  47659. generateDepthTexture?: boolean;
  47660. /**
  47661. * Define the number of desired draw buffers
  47662. */
  47663. textureCount?: number;
  47664. /**
  47665. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47666. */
  47667. doNotChangeAspectRatio?: boolean;
  47668. /**
  47669. * Define the default type of the buffers we are creating
  47670. */
  47671. defaultType?: number;
  47672. }
  47673. /**
  47674. * A multi render target, like a render target provides the ability to render to a texture.
  47675. * Unlike the render target, it can render to several draw buffers in one draw.
  47676. * This is specially interesting in deferred rendering or for any effects requiring more than
  47677. * just one color from a single pass.
  47678. */
  47679. export class MultiRenderTarget extends RenderTargetTexture {
  47680. private _internalTextures;
  47681. private _textures;
  47682. private _multiRenderTargetOptions;
  47683. /**
  47684. * Get if draw buffers are currently supported by the used hardware and browser.
  47685. */
  47686. get isSupported(): boolean;
  47687. /**
  47688. * Get the list of textures generated by the multi render target.
  47689. */
  47690. get textures(): Texture[];
  47691. /**
  47692. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47693. */
  47694. get depthTexture(): Texture;
  47695. /**
  47696. * Set the wrapping mode on U of all the textures we are rendering to.
  47697. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47698. */
  47699. set wrapU(wrap: number);
  47700. /**
  47701. * Set the wrapping mode on V of all the textures we are rendering to.
  47702. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47703. */
  47704. set wrapV(wrap: number);
  47705. /**
  47706. * Instantiate a new multi render target texture.
  47707. * A multi render target, like a render target provides the ability to render to a texture.
  47708. * Unlike the render target, it can render to several draw buffers in one draw.
  47709. * This is specially interesting in deferred rendering or for any effects requiring more than
  47710. * just one color from a single pass.
  47711. * @param name Define the name of the texture
  47712. * @param size Define the size of the buffers to render to
  47713. * @param count Define the number of target we are rendering into
  47714. * @param scene Define the scene the texture belongs to
  47715. * @param options Define the options used to create the multi render target
  47716. */
  47717. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47718. /** @hidden */
  47719. _rebuild(): void;
  47720. private _createInternalTextures;
  47721. private _createTextures;
  47722. /**
  47723. * Define the number of samples used if MSAA is enabled.
  47724. */
  47725. get samples(): number;
  47726. set samples(value: number);
  47727. /**
  47728. * Resize all the textures in the multi render target.
  47729. * Be carrefull as it will recreate all the data in the new texture.
  47730. * @param size Define the new size
  47731. */
  47732. resize(size: any): void;
  47733. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47734. /**
  47735. * Dispose the render targets and their associated resources
  47736. */
  47737. dispose(): void;
  47738. /**
  47739. * Release all the underlying texture used as draw buffers.
  47740. */
  47741. releaseInternalTextures(): void;
  47742. }
  47743. }
  47744. declare module BABYLON {
  47745. interface ThinEngine {
  47746. /**
  47747. * Unbind a list of render target textures from the webGL context
  47748. * This is used only when drawBuffer extension or webGL2 are active
  47749. * @param textures defines the render target textures to unbind
  47750. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47751. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47752. */
  47753. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47754. /**
  47755. * Create a multi render target texture
  47756. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47757. * @param size defines the size of the texture
  47758. * @param options defines the creation options
  47759. * @returns the cube texture as an InternalTexture
  47760. */
  47761. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47762. /**
  47763. * Update the sample count for a given multiple render target texture
  47764. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47765. * @param textures defines the textures to update
  47766. * @param samples defines the sample count to set
  47767. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47768. */
  47769. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47770. }
  47771. }
  47772. declare module BABYLON {
  47773. /**
  47774. * Class used to define an additional view for the engine
  47775. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47776. */
  47777. export class EngineView {
  47778. /** Defines the canvas where to render the view */
  47779. target: HTMLCanvasElement;
  47780. /** Defines an optional camera used to render the view (will use active camera else) */
  47781. camera?: Camera;
  47782. }
  47783. interface Engine {
  47784. /**
  47785. * Gets or sets the HTML element to use for attaching events
  47786. */
  47787. inputElement: Nullable<HTMLElement>;
  47788. /**
  47789. * Gets the current engine view
  47790. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47791. */
  47792. activeView: Nullable<EngineView>;
  47793. /** Gets or sets the list of views */
  47794. views: EngineView[];
  47795. /**
  47796. * Register a new child canvas
  47797. * @param canvas defines the canvas to register
  47798. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47799. * @returns the associated view
  47800. */
  47801. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47802. /**
  47803. * Remove a registered child canvas
  47804. * @param canvas defines the canvas to remove
  47805. * @returns the current engine
  47806. */
  47807. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47808. }
  47809. }
  47810. declare module BABYLON {
  47811. interface Engine {
  47812. /** @hidden */
  47813. _excludedCompressedTextures: string[];
  47814. /** @hidden */
  47815. _textureFormatInUse: string;
  47816. /**
  47817. * Gets the list of texture formats supported
  47818. */
  47819. readonly texturesSupported: Array<string>;
  47820. /**
  47821. * Gets the texture format in use
  47822. */
  47823. readonly textureFormatInUse: Nullable<string>;
  47824. /**
  47825. * Set the compressed texture extensions or file names to skip.
  47826. *
  47827. * @param skippedFiles defines the list of those texture files you want to skip
  47828. * Example: [".dds", ".env", "myfile.png"]
  47829. */
  47830. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47831. /**
  47832. * Set the compressed texture format to use, based on the formats you have, and the formats
  47833. * supported by the hardware / browser.
  47834. *
  47835. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47836. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47837. * to API arguments needed to compressed textures. This puts the burden on the container
  47838. * generator to house the arcane code for determining these for current & future formats.
  47839. *
  47840. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47841. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47842. *
  47843. * Note: The result of this call is not taken into account when a texture is base64.
  47844. *
  47845. * @param formatsAvailable defines the list of those format families you have created
  47846. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47847. *
  47848. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47849. * @returns The extension selected.
  47850. */
  47851. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47852. }
  47853. }
  47854. declare module BABYLON {
  47855. /**
  47856. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47857. */
  47858. export interface CubeMapInfo {
  47859. /**
  47860. * The pixel array for the front face.
  47861. * This is stored in format, left to right, up to down format.
  47862. */
  47863. front: Nullable<ArrayBufferView>;
  47864. /**
  47865. * The pixel array for the back face.
  47866. * This is stored in format, left to right, up to down format.
  47867. */
  47868. back: Nullable<ArrayBufferView>;
  47869. /**
  47870. * The pixel array for the left face.
  47871. * This is stored in format, left to right, up to down format.
  47872. */
  47873. left: Nullable<ArrayBufferView>;
  47874. /**
  47875. * The pixel array for the right face.
  47876. * This is stored in format, left to right, up to down format.
  47877. */
  47878. right: Nullable<ArrayBufferView>;
  47879. /**
  47880. * The pixel array for the up face.
  47881. * This is stored in format, left to right, up to down format.
  47882. */
  47883. up: Nullable<ArrayBufferView>;
  47884. /**
  47885. * The pixel array for the down face.
  47886. * This is stored in format, left to right, up to down format.
  47887. */
  47888. down: Nullable<ArrayBufferView>;
  47889. /**
  47890. * The size of the cubemap stored.
  47891. *
  47892. * Each faces will be size * size pixels.
  47893. */
  47894. size: number;
  47895. /**
  47896. * The format of the texture.
  47897. *
  47898. * RGBA, RGB.
  47899. */
  47900. format: number;
  47901. /**
  47902. * The type of the texture data.
  47903. *
  47904. * UNSIGNED_INT, FLOAT.
  47905. */
  47906. type: number;
  47907. /**
  47908. * Specifies whether the texture is in gamma space.
  47909. */
  47910. gammaSpace: boolean;
  47911. }
  47912. /**
  47913. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47914. */
  47915. export class PanoramaToCubeMapTools {
  47916. private static FACE_FRONT;
  47917. private static FACE_BACK;
  47918. private static FACE_RIGHT;
  47919. private static FACE_LEFT;
  47920. private static FACE_DOWN;
  47921. private static FACE_UP;
  47922. /**
  47923. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47924. *
  47925. * @param float32Array The source data.
  47926. * @param inputWidth The width of the input panorama.
  47927. * @param inputHeight The height of the input panorama.
  47928. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47929. * @return The cubemap data
  47930. */
  47931. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47932. private static CreateCubemapTexture;
  47933. private static CalcProjectionSpherical;
  47934. }
  47935. }
  47936. declare module BABYLON {
  47937. /**
  47938. * Helper class dealing with the extraction of spherical polynomial dataArray
  47939. * from a cube map.
  47940. */
  47941. export class CubeMapToSphericalPolynomialTools {
  47942. private static FileFaces;
  47943. /**
  47944. * Converts a texture to the according Spherical Polynomial data.
  47945. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47946. *
  47947. * @param texture The texture to extract the information from.
  47948. * @return The Spherical Polynomial data.
  47949. */
  47950. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47951. /**
  47952. * Converts a cubemap to the according Spherical Polynomial data.
  47953. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47954. *
  47955. * @param cubeInfo The Cube map to extract the information from.
  47956. * @return The Spherical Polynomial data.
  47957. */
  47958. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47959. }
  47960. }
  47961. declare module BABYLON {
  47962. interface BaseTexture {
  47963. /**
  47964. * Get the polynomial representation of the texture data.
  47965. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47966. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47967. */
  47968. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47969. }
  47970. }
  47971. declare module BABYLON {
  47972. /** @hidden */
  47973. export var rgbdEncodePixelShader: {
  47974. name: string;
  47975. shader: string;
  47976. };
  47977. }
  47978. declare module BABYLON {
  47979. /** @hidden */
  47980. export var rgbdDecodePixelShader: {
  47981. name: string;
  47982. shader: string;
  47983. };
  47984. }
  47985. declare module BABYLON {
  47986. /**
  47987. * Raw texture data and descriptor sufficient for WebGL texture upload
  47988. */
  47989. export interface EnvironmentTextureInfo {
  47990. /**
  47991. * Version of the environment map
  47992. */
  47993. version: number;
  47994. /**
  47995. * Width of image
  47996. */
  47997. width: number;
  47998. /**
  47999. * Irradiance information stored in the file.
  48000. */
  48001. irradiance: any;
  48002. /**
  48003. * Specular information stored in the file.
  48004. */
  48005. specular: any;
  48006. }
  48007. /**
  48008. * Defines One Image in the file. It requires only the position in the file
  48009. * as well as the length.
  48010. */
  48011. interface BufferImageData {
  48012. /**
  48013. * Length of the image data.
  48014. */
  48015. length: number;
  48016. /**
  48017. * Position of the data from the null terminator delimiting the end of the JSON.
  48018. */
  48019. position: number;
  48020. }
  48021. /**
  48022. * Defines the specular data enclosed in the file.
  48023. * This corresponds to the version 1 of the data.
  48024. */
  48025. export interface EnvironmentTextureSpecularInfoV1 {
  48026. /**
  48027. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48028. */
  48029. specularDataPosition?: number;
  48030. /**
  48031. * This contains all the images data needed to reconstruct the cubemap.
  48032. */
  48033. mipmaps: Array<BufferImageData>;
  48034. /**
  48035. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48036. */
  48037. lodGenerationScale: number;
  48038. }
  48039. /**
  48040. * Sets of helpers addressing the serialization and deserialization of environment texture
  48041. * stored in a BabylonJS env file.
  48042. * Those files are usually stored as .env files.
  48043. */
  48044. export class EnvironmentTextureTools {
  48045. /**
  48046. * Magic number identifying the env file.
  48047. */
  48048. private static _MagicBytes;
  48049. /**
  48050. * Gets the environment info from an env file.
  48051. * @param data The array buffer containing the .env bytes.
  48052. * @returns the environment file info (the json header) if successfully parsed.
  48053. */
  48054. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  48055. /**
  48056. * Creates an environment texture from a loaded cube texture.
  48057. * @param texture defines the cube texture to convert in env file
  48058. * @return a promise containing the environment data if succesfull.
  48059. */
  48060. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48061. /**
  48062. * Creates a JSON representation of the spherical data.
  48063. * @param texture defines the texture containing the polynomials
  48064. * @return the JSON representation of the spherical info
  48065. */
  48066. private static _CreateEnvTextureIrradiance;
  48067. /**
  48068. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48069. * @param data the image data
  48070. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48071. * @return the views described by info providing access to the underlying buffer
  48072. */
  48073. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48074. /**
  48075. * Uploads the texture info contained in the env file to the GPU.
  48076. * @param texture defines the internal texture to upload to
  48077. * @param data defines the data to load
  48078. * @param info defines the texture info retrieved through the GetEnvInfo method
  48079. * @returns a promise
  48080. */
  48081. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  48082. private static _OnImageReadyAsync;
  48083. /**
  48084. * Uploads the levels of image data to the GPU.
  48085. * @param texture defines the internal texture to upload to
  48086. * @param imageData defines the array buffer views of image data [mipmap][face]
  48087. * @returns a promise
  48088. */
  48089. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48090. /**
  48091. * Uploads spherical polynomials information to the texture.
  48092. * @param texture defines the texture we are trying to upload the information to
  48093. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48094. */
  48095. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48096. /** @hidden */
  48097. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48098. }
  48099. }
  48100. declare module BABYLON {
  48101. /**
  48102. * Contains position and normal vectors for a vertex
  48103. */
  48104. export class PositionNormalVertex {
  48105. /** the position of the vertex (defaut: 0,0,0) */
  48106. position: Vector3;
  48107. /** the normal of the vertex (defaut: 0,1,0) */
  48108. normal: Vector3;
  48109. /**
  48110. * Creates a PositionNormalVertex
  48111. * @param position the position of the vertex (defaut: 0,0,0)
  48112. * @param normal the normal of the vertex (defaut: 0,1,0)
  48113. */
  48114. constructor(
  48115. /** the position of the vertex (defaut: 0,0,0) */
  48116. position?: Vector3,
  48117. /** the normal of the vertex (defaut: 0,1,0) */
  48118. normal?: Vector3);
  48119. /**
  48120. * Clones the PositionNormalVertex
  48121. * @returns the cloned PositionNormalVertex
  48122. */
  48123. clone(): PositionNormalVertex;
  48124. }
  48125. /**
  48126. * Contains position, normal and uv vectors for a vertex
  48127. */
  48128. export class PositionNormalTextureVertex {
  48129. /** the position of the vertex (defaut: 0,0,0) */
  48130. position: Vector3;
  48131. /** the normal of the vertex (defaut: 0,1,0) */
  48132. normal: Vector3;
  48133. /** the uv of the vertex (default: 0,0) */
  48134. uv: Vector2;
  48135. /**
  48136. * Creates a PositionNormalTextureVertex
  48137. * @param position the position of the vertex (defaut: 0,0,0)
  48138. * @param normal the normal of the vertex (defaut: 0,1,0)
  48139. * @param uv the uv of the vertex (default: 0,0)
  48140. */
  48141. constructor(
  48142. /** the position of the vertex (defaut: 0,0,0) */
  48143. position?: Vector3,
  48144. /** the normal of the vertex (defaut: 0,1,0) */
  48145. normal?: Vector3,
  48146. /** the uv of the vertex (default: 0,0) */
  48147. uv?: Vector2);
  48148. /**
  48149. * Clones the PositionNormalTextureVertex
  48150. * @returns the cloned PositionNormalTextureVertex
  48151. */
  48152. clone(): PositionNormalTextureVertex;
  48153. }
  48154. }
  48155. declare module BABYLON {
  48156. /** @hidden */
  48157. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48158. private _genericAttributeLocation;
  48159. private _varyingLocationCount;
  48160. private _varyingLocationMap;
  48161. private _replacements;
  48162. private _textureCount;
  48163. private _uniforms;
  48164. lineProcessor(line: string): string;
  48165. attributeProcessor(attribute: string): string;
  48166. varyingProcessor(varying: string, isFragment: boolean): string;
  48167. uniformProcessor(uniform: string): string;
  48168. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48169. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48170. }
  48171. }
  48172. declare module BABYLON {
  48173. /**
  48174. * Container for accessors for natively-stored mesh data buffers.
  48175. */
  48176. class NativeDataBuffer extends DataBuffer {
  48177. /**
  48178. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48179. */
  48180. nativeIndexBuffer?: any;
  48181. /**
  48182. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48183. */
  48184. nativeVertexBuffer?: any;
  48185. }
  48186. /** @hidden */
  48187. class NativeTexture extends InternalTexture {
  48188. getInternalTexture(): InternalTexture;
  48189. getViewCount(): number;
  48190. }
  48191. /** @hidden */
  48192. export class NativeEngine extends Engine {
  48193. private readonly _native;
  48194. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48195. private readonly INVALID_HANDLE;
  48196. getHardwareScalingLevel(): number;
  48197. constructor();
  48198. dispose(): void;
  48199. /**
  48200. * Can be used to override the current requestAnimationFrame requester.
  48201. * @hidden
  48202. */
  48203. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48204. /**
  48205. * Override default engine behavior.
  48206. * @param color
  48207. * @param backBuffer
  48208. * @param depth
  48209. * @param stencil
  48210. */
  48211. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48212. /**
  48213. * Gets host document
  48214. * @returns the host document object
  48215. */
  48216. getHostDocument(): Nullable<Document>;
  48217. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48218. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48219. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48220. recordVertexArrayObject(vertexBuffers: {
  48221. [key: string]: VertexBuffer;
  48222. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48223. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48224. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48225. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48226. /**
  48227. * Draw a list of indexed primitives
  48228. * @param fillMode defines the primitive to use
  48229. * @param indexStart defines the starting index
  48230. * @param indexCount defines the number of index to draw
  48231. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48232. */
  48233. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48234. /**
  48235. * Draw a list of unindexed primitives
  48236. * @param fillMode defines the primitive to use
  48237. * @param verticesStart defines the index of first vertex to draw
  48238. * @param verticesCount defines the count of vertices to draw
  48239. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48240. */
  48241. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48242. createPipelineContext(): IPipelineContext;
  48243. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48244. /** @hidden */
  48245. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48246. /** @hidden */
  48247. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48248. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48249. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48250. protected _setProgram(program: WebGLProgram): void;
  48251. _releaseEffect(effect: Effect): void;
  48252. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48253. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48254. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48255. bindSamplers(effect: Effect): void;
  48256. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48257. getRenderWidth(useScreen?: boolean): number;
  48258. getRenderHeight(useScreen?: boolean): number;
  48259. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48260. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48261. /**
  48262. * Set the z offset to apply to current rendering
  48263. * @param value defines the offset to apply
  48264. */
  48265. setZOffset(value: number): void;
  48266. /**
  48267. * Gets the current value of the zOffset
  48268. * @returns the current zOffset state
  48269. */
  48270. getZOffset(): number;
  48271. /**
  48272. * Enable or disable depth buffering
  48273. * @param enable defines the state to set
  48274. */
  48275. setDepthBuffer(enable: boolean): void;
  48276. /**
  48277. * Gets a boolean indicating if depth writing is enabled
  48278. * @returns the current depth writing state
  48279. */
  48280. getDepthWrite(): boolean;
  48281. /**
  48282. * Enable or disable depth writing
  48283. * @param enable defines the state to set
  48284. */
  48285. setDepthWrite(enable: boolean): void;
  48286. /**
  48287. * Enable or disable color writing
  48288. * @param enable defines the state to set
  48289. */
  48290. setColorWrite(enable: boolean): void;
  48291. /**
  48292. * Gets a boolean indicating if color writing is enabled
  48293. * @returns the current color writing state
  48294. */
  48295. getColorWrite(): boolean;
  48296. /**
  48297. * Sets alpha constants used by some alpha blending modes
  48298. * @param r defines the red component
  48299. * @param g defines the green component
  48300. * @param b defines the blue component
  48301. * @param a defines the alpha component
  48302. */
  48303. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48304. /**
  48305. * Sets the current alpha mode
  48306. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48307. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48308. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48309. */
  48310. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48311. /**
  48312. * Gets the current alpha mode
  48313. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48314. * @returns the current alpha mode
  48315. */
  48316. getAlphaMode(): number;
  48317. setInt(uniform: WebGLUniformLocation, int: number): void;
  48318. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48319. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48320. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48321. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48322. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48323. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48324. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48325. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48326. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48327. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48328. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48329. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48330. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48331. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48332. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48333. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48334. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48335. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48336. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48337. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48338. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48339. wipeCaches(bruteForce?: boolean): void;
  48340. _createTexture(): WebGLTexture;
  48341. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48342. /**
  48343. * Usually called from Texture.ts.
  48344. * Passed information to create a WebGLTexture
  48345. * @param url defines a value which contains one of the following:
  48346. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48347. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48348. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48349. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48350. * @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)
  48351. * @param scene needed for loading to the correct scene
  48352. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48353. * @param onLoad optional callback to be called upon successful completion
  48354. * @param onError optional callback to be called upon failure
  48355. * @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
  48356. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48357. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48358. * @param forcedExtension defines the extension to use to pick the right loader
  48359. * @param mimeType defines an optional mime type
  48360. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48361. */
  48362. createTexture(url: 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;
  48363. /**
  48364. * Creates a cube texture
  48365. * @param rootUrl defines the url where the files to load is located
  48366. * @param scene defines the current scene
  48367. * @param files defines the list of files to load (1 per face)
  48368. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48369. * @param onLoad defines an optional callback raised when the texture is loaded
  48370. * @param onError defines an optional callback raised if there is an issue to load the texture
  48371. * @param format defines the format of the data
  48372. * @param forcedExtension defines the extension to use to pick the right loader
  48373. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48374. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48375. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48376. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48377. * @returns the cube texture as an InternalTexture
  48378. */
  48379. 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;
  48380. private _getSamplingFilter;
  48381. private static _GetNativeTextureFormat;
  48382. createRenderTargetTexture(size: number | {
  48383. width: number;
  48384. height: number;
  48385. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48386. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48387. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48388. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48389. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48390. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48391. /**
  48392. * Updates a dynamic vertex buffer.
  48393. * @param vertexBuffer the vertex buffer to update
  48394. * @param data the data used to update the vertex buffer
  48395. * @param byteOffset the byte offset of the data (optional)
  48396. * @param byteLength the byte length of the data (optional)
  48397. */
  48398. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48399. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48400. private _updateAnisotropicLevel;
  48401. private _getAddressMode;
  48402. /** @hidden */
  48403. _bindTexture(channel: number, texture: InternalTexture): void;
  48404. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48405. releaseEffects(): void;
  48406. /** @hidden */
  48407. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48408. /** @hidden */
  48409. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48410. /** @hidden */
  48411. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48412. /** @hidden */
  48413. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48414. }
  48415. }
  48416. declare module BABYLON {
  48417. /**
  48418. * Gather the list of clipboard event types as constants.
  48419. */
  48420. export class ClipboardEventTypes {
  48421. /**
  48422. * The clipboard event is fired when a copy command is active (pressed).
  48423. */
  48424. static readonly COPY: number;
  48425. /**
  48426. * The clipboard event is fired when a cut command is active (pressed).
  48427. */
  48428. static readonly CUT: number;
  48429. /**
  48430. * The clipboard event is fired when a paste command is active (pressed).
  48431. */
  48432. static readonly PASTE: number;
  48433. }
  48434. /**
  48435. * This class is used to store clipboard related info for the onClipboardObservable event.
  48436. */
  48437. export class ClipboardInfo {
  48438. /**
  48439. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48440. */
  48441. type: number;
  48442. /**
  48443. * Defines the related dom event
  48444. */
  48445. event: ClipboardEvent;
  48446. /**
  48447. *Creates an instance of ClipboardInfo.
  48448. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48449. * @param event Defines the related dom event
  48450. */
  48451. constructor(
  48452. /**
  48453. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48454. */
  48455. type: number,
  48456. /**
  48457. * Defines the related dom event
  48458. */
  48459. event: ClipboardEvent);
  48460. /**
  48461. * Get the clipboard event's type from the keycode.
  48462. * @param keyCode Defines the keyCode for the current keyboard event.
  48463. * @return {number}
  48464. */
  48465. static GetTypeFromCharacter(keyCode: number): number;
  48466. }
  48467. }
  48468. declare module BABYLON {
  48469. /**
  48470. * Google Daydream controller
  48471. */
  48472. export class DaydreamController extends WebVRController {
  48473. /**
  48474. * Base Url for the controller model.
  48475. */
  48476. static MODEL_BASE_URL: string;
  48477. /**
  48478. * File name for the controller model.
  48479. */
  48480. static MODEL_FILENAME: string;
  48481. /**
  48482. * Gamepad Id prefix used to identify Daydream Controller.
  48483. */
  48484. static readonly GAMEPAD_ID_PREFIX: string;
  48485. /**
  48486. * Creates a new DaydreamController from a gamepad
  48487. * @param vrGamepad the gamepad that the controller should be created from
  48488. */
  48489. constructor(vrGamepad: any);
  48490. /**
  48491. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48492. * @param scene scene in which to add meshes
  48493. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48494. */
  48495. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48496. /**
  48497. * Called once for each button that changed state since the last frame
  48498. * @param buttonIdx Which button index changed
  48499. * @param state New state of the button
  48500. * @param changes Which properties on the state changed since last frame
  48501. */
  48502. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48503. }
  48504. }
  48505. declare module BABYLON {
  48506. /**
  48507. * Gear VR Controller
  48508. */
  48509. export class GearVRController extends WebVRController {
  48510. /**
  48511. * Base Url for the controller model.
  48512. */
  48513. static MODEL_BASE_URL: string;
  48514. /**
  48515. * File name for the controller model.
  48516. */
  48517. static MODEL_FILENAME: string;
  48518. /**
  48519. * Gamepad Id prefix used to identify this controller.
  48520. */
  48521. static readonly GAMEPAD_ID_PREFIX: string;
  48522. private readonly _buttonIndexToObservableNameMap;
  48523. /**
  48524. * Creates a new GearVRController from a gamepad
  48525. * @param vrGamepad the gamepad that the controller should be created from
  48526. */
  48527. constructor(vrGamepad: any);
  48528. /**
  48529. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48530. * @param scene scene in which to add meshes
  48531. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48532. */
  48533. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48534. /**
  48535. * Called once for each button that changed state since the last frame
  48536. * @param buttonIdx Which button index changed
  48537. * @param state New state of the button
  48538. * @param changes Which properties on the state changed since last frame
  48539. */
  48540. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48541. }
  48542. }
  48543. declare module BABYLON {
  48544. /**
  48545. * Generic Controller
  48546. */
  48547. export class GenericController extends WebVRController {
  48548. /**
  48549. * Base Url for the controller model.
  48550. */
  48551. static readonly MODEL_BASE_URL: string;
  48552. /**
  48553. * File name for the controller model.
  48554. */
  48555. static readonly MODEL_FILENAME: string;
  48556. /**
  48557. * Creates a new GenericController from a gamepad
  48558. * @param vrGamepad the gamepad that the controller should be created from
  48559. */
  48560. constructor(vrGamepad: any);
  48561. /**
  48562. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48563. * @param scene scene in which to add meshes
  48564. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48565. */
  48566. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48567. /**
  48568. * Called once for each button that changed state since the last frame
  48569. * @param buttonIdx Which button index changed
  48570. * @param state New state of the button
  48571. * @param changes Which properties on the state changed since last frame
  48572. */
  48573. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48574. }
  48575. }
  48576. declare module BABYLON {
  48577. /**
  48578. * Oculus Touch Controller
  48579. */
  48580. export class OculusTouchController extends WebVRController {
  48581. /**
  48582. * Base Url for the controller model.
  48583. */
  48584. static MODEL_BASE_URL: string;
  48585. /**
  48586. * File name for the left controller model.
  48587. */
  48588. static MODEL_LEFT_FILENAME: string;
  48589. /**
  48590. * File name for the right controller model.
  48591. */
  48592. static MODEL_RIGHT_FILENAME: string;
  48593. /**
  48594. * Base Url for the Quest controller model.
  48595. */
  48596. static QUEST_MODEL_BASE_URL: string;
  48597. /**
  48598. * @hidden
  48599. * If the controllers are running on a device that needs the updated Quest controller models
  48600. */
  48601. static _IsQuest: boolean;
  48602. /**
  48603. * Fired when the secondary trigger on this controller is modified
  48604. */
  48605. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48606. /**
  48607. * Fired when the thumb rest on this controller is modified
  48608. */
  48609. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48610. /**
  48611. * Creates a new OculusTouchController from a gamepad
  48612. * @param vrGamepad the gamepad that the controller should be created from
  48613. */
  48614. constructor(vrGamepad: any);
  48615. /**
  48616. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48617. * @param scene scene in which to add meshes
  48618. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48619. */
  48620. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48621. /**
  48622. * Fired when the A button on this controller is modified
  48623. */
  48624. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48625. /**
  48626. * Fired when the B button on this controller is modified
  48627. */
  48628. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48629. /**
  48630. * Fired when the X button on this controller is modified
  48631. */
  48632. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48633. /**
  48634. * Fired when the Y button on this controller is modified
  48635. */
  48636. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48637. /**
  48638. * Called once for each button that changed state since the last frame
  48639. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48640. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48641. * 2) secondary trigger (same)
  48642. * 3) A (right) X (left), touch, pressed = value
  48643. * 4) B / Y
  48644. * 5) thumb rest
  48645. * @param buttonIdx Which button index changed
  48646. * @param state New state of the button
  48647. * @param changes Which properties on the state changed since last frame
  48648. */
  48649. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48650. }
  48651. }
  48652. declare module BABYLON {
  48653. /**
  48654. * Vive Controller
  48655. */
  48656. export class ViveController extends WebVRController {
  48657. /**
  48658. * Base Url for the controller model.
  48659. */
  48660. static MODEL_BASE_URL: string;
  48661. /**
  48662. * File name for the controller model.
  48663. */
  48664. static MODEL_FILENAME: string;
  48665. /**
  48666. * Creates a new ViveController from a gamepad
  48667. * @param vrGamepad the gamepad that the controller should be created from
  48668. */
  48669. constructor(vrGamepad: any);
  48670. /**
  48671. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48672. * @param scene scene in which to add meshes
  48673. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48674. */
  48675. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48676. /**
  48677. * Fired when the left button on this controller is modified
  48678. */
  48679. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48680. /**
  48681. * Fired when the right button on this controller is modified
  48682. */
  48683. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48684. /**
  48685. * Fired when the menu button on this controller is modified
  48686. */
  48687. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48688. /**
  48689. * Called once for each button that changed state since the last frame
  48690. * Vive mapping:
  48691. * 0: touchpad
  48692. * 1: trigger
  48693. * 2: left AND right buttons
  48694. * 3: menu button
  48695. * @param buttonIdx Which button index changed
  48696. * @param state New state of the button
  48697. * @param changes Which properties on the state changed since last frame
  48698. */
  48699. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48700. }
  48701. }
  48702. declare module BABYLON {
  48703. /**
  48704. * Defines the WindowsMotionController object that the state of the windows motion controller
  48705. */
  48706. export class WindowsMotionController extends WebVRController {
  48707. /**
  48708. * The base url used to load the left and right controller models
  48709. */
  48710. static MODEL_BASE_URL: string;
  48711. /**
  48712. * The name of the left controller model file
  48713. */
  48714. static MODEL_LEFT_FILENAME: string;
  48715. /**
  48716. * The name of the right controller model file
  48717. */
  48718. static MODEL_RIGHT_FILENAME: string;
  48719. /**
  48720. * The controller name prefix for this controller type
  48721. */
  48722. static readonly GAMEPAD_ID_PREFIX: string;
  48723. /**
  48724. * The controller id pattern for this controller type
  48725. */
  48726. private static readonly GAMEPAD_ID_PATTERN;
  48727. private _loadedMeshInfo;
  48728. protected readonly _mapping: {
  48729. buttons: string[];
  48730. buttonMeshNames: {
  48731. trigger: string;
  48732. menu: string;
  48733. grip: string;
  48734. thumbstick: string;
  48735. trackpad: string;
  48736. };
  48737. buttonObservableNames: {
  48738. trigger: string;
  48739. menu: string;
  48740. grip: string;
  48741. thumbstick: string;
  48742. trackpad: string;
  48743. };
  48744. axisMeshNames: string[];
  48745. pointingPoseMeshName: string;
  48746. };
  48747. /**
  48748. * Fired when the trackpad on this controller is clicked
  48749. */
  48750. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48751. /**
  48752. * Fired when the trackpad on this controller is modified
  48753. */
  48754. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48755. /**
  48756. * The current x and y values of this controller's trackpad
  48757. */
  48758. trackpad: StickValues;
  48759. /**
  48760. * Creates a new WindowsMotionController from a gamepad
  48761. * @param vrGamepad the gamepad that the controller should be created from
  48762. */
  48763. constructor(vrGamepad: any);
  48764. /**
  48765. * Fired when the trigger on this controller is modified
  48766. */
  48767. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48768. /**
  48769. * Fired when the menu button on this controller is modified
  48770. */
  48771. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48772. /**
  48773. * Fired when the grip button on this controller is modified
  48774. */
  48775. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48776. /**
  48777. * Fired when the thumbstick button on this controller is modified
  48778. */
  48779. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48780. /**
  48781. * Fired when the touchpad button on this controller is modified
  48782. */
  48783. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48784. /**
  48785. * Fired when the touchpad values on this controller are modified
  48786. */
  48787. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48788. protected _updateTrackpad(): void;
  48789. /**
  48790. * Called once per frame by the engine.
  48791. */
  48792. update(): void;
  48793. /**
  48794. * Called once for each button that changed state since the last frame
  48795. * @param buttonIdx Which button index changed
  48796. * @param state New state of the button
  48797. * @param changes Which properties on the state changed since last frame
  48798. */
  48799. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48800. /**
  48801. * Moves the buttons on the controller mesh based on their current state
  48802. * @param buttonName the name of the button to move
  48803. * @param buttonValue the value of the button which determines the buttons new position
  48804. */
  48805. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48806. /**
  48807. * Moves the axis on the controller mesh based on its current state
  48808. * @param axis the index of the axis
  48809. * @param axisValue the value of the axis which determines the meshes new position
  48810. * @hidden
  48811. */
  48812. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48813. /**
  48814. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48815. * @param scene scene in which to add meshes
  48816. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48817. */
  48818. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48819. /**
  48820. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48821. * can be transformed by button presses and axes values, based on this._mapping.
  48822. *
  48823. * @param scene scene in which the meshes exist
  48824. * @param meshes list of meshes that make up the controller model to process
  48825. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48826. */
  48827. private processModel;
  48828. private createMeshInfo;
  48829. /**
  48830. * Gets the ray of the controller in the direction the controller is pointing
  48831. * @param length the length the resulting ray should be
  48832. * @returns a ray in the direction the controller is pointing
  48833. */
  48834. getForwardRay(length?: number): Ray;
  48835. /**
  48836. * Disposes of the controller
  48837. */
  48838. dispose(): void;
  48839. }
  48840. /**
  48841. * This class represents a new windows motion controller in XR.
  48842. */
  48843. export class XRWindowsMotionController extends WindowsMotionController {
  48844. /**
  48845. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48846. */
  48847. protected readonly _mapping: {
  48848. buttons: string[];
  48849. buttonMeshNames: {
  48850. trigger: string;
  48851. menu: string;
  48852. grip: string;
  48853. thumbstick: string;
  48854. trackpad: string;
  48855. };
  48856. buttonObservableNames: {
  48857. trigger: string;
  48858. menu: string;
  48859. grip: string;
  48860. thumbstick: string;
  48861. trackpad: string;
  48862. };
  48863. axisMeshNames: string[];
  48864. pointingPoseMeshName: string;
  48865. };
  48866. /**
  48867. * Construct a new XR-Based windows motion controller
  48868. *
  48869. * @param gamepadInfo the gamepad object from the browser
  48870. */
  48871. constructor(gamepadInfo: any);
  48872. /**
  48873. * holds the thumbstick values (X,Y)
  48874. */
  48875. thumbstickValues: StickValues;
  48876. /**
  48877. * Fired when the thumbstick on this controller is clicked
  48878. */
  48879. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48880. /**
  48881. * Fired when the thumbstick on this controller is modified
  48882. */
  48883. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48884. /**
  48885. * Fired when the touchpad button on this controller is modified
  48886. */
  48887. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48888. /**
  48889. * Fired when the touchpad values on this controller are modified
  48890. */
  48891. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48892. /**
  48893. * Fired when the thumbstick button on this controller is modified
  48894. * here to prevent breaking changes
  48895. */
  48896. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48897. /**
  48898. * updating the thumbstick(!) and not the trackpad.
  48899. * This is named this way due to the difference between WebVR and XR and to avoid
  48900. * changing the parent class.
  48901. */
  48902. protected _updateTrackpad(): void;
  48903. /**
  48904. * Disposes the class with joy
  48905. */
  48906. dispose(): void;
  48907. }
  48908. }
  48909. declare module BABYLON {
  48910. /**
  48911. * Class containing static functions to help procedurally build meshes
  48912. */
  48913. export class PolyhedronBuilder {
  48914. /**
  48915. * Creates a polyhedron mesh
  48916. * * 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
  48917. * * The parameter `size` (positive float, default 1) sets the polygon size
  48918. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48919. * * 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`
  48920. * * 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
  48921. * * 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)`)
  48922. * * 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
  48923. * * 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
  48924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48925. * * 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
  48926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48927. * @param name defines the name of the mesh
  48928. * @param options defines the options used to create the mesh
  48929. * @param scene defines the hosting scene
  48930. * @returns the polyhedron mesh
  48931. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48932. */
  48933. static CreatePolyhedron(name: string, options: {
  48934. type?: number;
  48935. size?: number;
  48936. sizeX?: number;
  48937. sizeY?: number;
  48938. sizeZ?: number;
  48939. custom?: any;
  48940. faceUV?: Vector4[];
  48941. faceColors?: Color4[];
  48942. flat?: boolean;
  48943. updatable?: boolean;
  48944. sideOrientation?: number;
  48945. frontUVs?: Vector4;
  48946. backUVs?: Vector4;
  48947. }, scene?: Nullable<Scene>): Mesh;
  48948. }
  48949. }
  48950. declare module BABYLON {
  48951. /**
  48952. * Gizmo that enables scaling a mesh along 3 axis
  48953. */
  48954. export class ScaleGizmo extends Gizmo {
  48955. /**
  48956. * Internal gizmo used for interactions on the x axis
  48957. */
  48958. xGizmo: AxisScaleGizmo;
  48959. /**
  48960. * Internal gizmo used for interactions on the y axis
  48961. */
  48962. yGizmo: AxisScaleGizmo;
  48963. /**
  48964. * Internal gizmo used for interactions on the z axis
  48965. */
  48966. zGizmo: AxisScaleGizmo;
  48967. /**
  48968. * Internal gizmo used to scale all axis equally
  48969. */
  48970. uniformScaleGizmo: AxisScaleGizmo;
  48971. private _meshAttached;
  48972. private _updateGizmoRotationToMatchAttachedMesh;
  48973. private _snapDistance;
  48974. private _scaleRatio;
  48975. private _uniformScalingMesh;
  48976. private _octahedron;
  48977. private _sensitivity;
  48978. /** Fires an event when any of it's sub gizmos are dragged */
  48979. onDragStartObservable: Observable<unknown>;
  48980. /** Fires an event when any of it's sub gizmos are released from dragging */
  48981. onDragEndObservable: Observable<unknown>;
  48982. get attachedMesh(): Nullable<AbstractMesh>;
  48983. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48984. /**
  48985. * Creates a ScaleGizmo
  48986. * @param gizmoLayer The utility layer the gizmo will be added to
  48987. */
  48988. constructor(gizmoLayer?: UtilityLayerRenderer);
  48989. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48990. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48991. /**
  48992. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48993. */
  48994. set snapDistance(value: number);
  48995. get snapDistance(): number;
  48996. /**
  48997. * Ratio for the scale of the gizmo (Default: 1)
  48998. */
  48999. set scaleRatio(value: number);
  49000. get scaleRatio(): number;
  49001. /**
  49002. * Sensitivity factor for dragging (Default: 1)
  49003. */
  49004. set sensitivity(value: number);
  49005. get sensitivity(): number;
  49006. /**
  49007. * Disposes of the gizmo
  49008. */
  49009. dispose(): void;
  49010. }
  49011. }
  49012. declare module BABYLON {
  49013. /**
  49014. * Single axis scale gizmo
  49015. */
  49016. export class AxisScaleGizmo extends Gizmo {
  49017. /**
  49018. * Drag behavior responsible for the gizmos dragging interactions
  49019. */
  49020. dragBehavior: PointerDragBehavior;
  49021. private _pointerObserver;
  49022. /**
  49023. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49024. */
  49025. snapDistance: number;
  49026. /**
  49027. * Event that fires each time the gizmo snaps to a new location.
  49028. * * snapDistance is the the change in distance
  49029. */
  49030. onSnapObservable: Observable<{
  49031. snapDistance: number;
  49032. }>;
  49033. /**
  49034. * If the scaling operation should be done on all axis (default: false)
  49035. */
  49036. uniformScaling: boolean;
  49037. /**
  49038. * Custom sensitivity value for the drag strength
  49039. */
  49040. sensitivity: number;
  49041. private _isEnabled;
  49042. private _parent;
  49043. private _arrow;
  49044. private _coloredMaterial;
  49045. private _hoverMaterial;
  49046. /**
  49047. * Creates an AxisScaleGizmo
  49048. * @param gizmoLayer The utility layer the gizmo will be added to
  49049. * @param dragAxis The axis which the gizmo will be able to scale on
  49050. * @param color The color of the gizmo
  49051. */
  49052. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49053. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49054. /**
  49055. * If the gizmo is enabled
  49056. */
  49057. set isEnabled(value: boolean);
  49058. get isEnabled(): boolean;
  49059. /**
  49060. * Disposes of the gizmo
  49061. */
  49062. dispose(): void;
  49063. /**
  49064. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49065. * @param mesh The mesh to replace the default mesh of the gizmo
  49066. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49067. */
  49068. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49069. }
  49070. }
  49071. declare module BABYLON {
  49072. /**
  49073. * Bounding box gizmo
  49074. */
  49075. export class BoundingBoxGizmo extends Gizmo {
  49076. private _lineBoundingBox;
  49077. private _rotateSpheresParent;
  49078. private _scaleBoxesParent;
  49079. private _boundingDimensions;
  49080. private _renderObserver;
  49081. private _pointerObserver;
  49082. private _scaleDragSpeed;
  49083. private _tmpQuaternion;
  49084. private _tmpVector;
  49085. private _tmpRotationMatrix;
  49086. /**
  49087. * 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)
  49088. */
  49089. ignoreChildren: boolean;
  49090. /**
  49091. * 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)
  49092. */
  49093. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49094. /**
  49095. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49096. */
  49097. rotationSphereSize: number;
  49098. /**
  49099. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49100. */
  49101. scaleBoxSize: number;
  49102. /**
  49103. * 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)
  49104. */
  49105. fixedDragMeshScreenSize: boolean;
  49106. /**
  49107. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49108. */
  49109. fixedDragMeshScreenSizeDistanceFactor: number;
  49110. /**
  49111. * Fired when a rotation sphere or scale box is dragged
  49112. */
  49113. onDragStartObservable: Observable<{}>;
  49114. /**
  49115. * Fired when a scale box is dragged
  49116. */
  49117. onScaleBoxDragObservable: Observable<{}>;
  49118. /**
  49119. * Fired when a scale box drag is ended
  49120. */
  49121. onScaleBoxDragEndObservable: Observable<{}>;
  49122. /**
  49123. * Fired when a rotation sphere is dragged
  49124. */
  49125. onRotationSphereDragObservable: Observable<{}>;
  49126. /**
  49127. * Fired when a rotation sphere drag is ended
  49128. */
  49129. onRotationSphereDragEndObservable: Observable<{}>;
  49130. /**
  49131. * 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)
  49132. */
  49133. scalePivot: Nullable<Vector3>;
  49134. /**
  49135. * Mesh used as a pivot to rotate the attached mesh
  49136. */
  49137. private _anchorMesh;
  49138. private _existingMeshScale;
  49139. private _dragMesh;
  49140. private pointerDragBehavior;
  49141. private coloredMaterial;
  49142. private hoverColoredMaterial;
  49143. /**
  49144. * Sets the color of the bounding box gizmo
  49145. * @param color the color to set
  49146. */
  49147. setColor(color: Color3): void;
  49148. /**
  49149. * Creates an BoundingBoxGizmo
  49150. * @param gizmoLayer The utility layer the gizmo will be added to
  49151. * @param color The color of the gizmo
  49152. */
  49153. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49154. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49155. private _selectNode;
  49156. /**
  49157. * Updates the bounding box information for the Gizmo
  49158. */
  49159. updateBoundingBox(): void;
  49160. private _updateRotationSpheres;
  49161. private _updateScaleBoxes;
  49162. /**
  49163. * Enables rotation on the specified axis and disables rotation on the others
  49164. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49165. */
  49166. setEnabledRotationAxis(axis: string): void;
  49167. /**
  49168. * Enables/disables scaling
  49169. * @param enable if scaling should be enabled
  49170. * @param homogeneousScaling defines if scaling should only be homogeneous
  49171. */
  49172. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49173. private _updateDummy;
  49174. /**
  49175. * Enables a pointer drag behavior on the bounding box of the gizmo
  49176. */
  49177. enableDragBehavior(): void;
  49178. /**
  49179. * Disposes of the gizmo
  49180. */
  49181. dispose(): void;
  49182. /**
  49183. * 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)
  49184. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49185. * @returns the bounding box mesh with the passed in mesh as a child
  49186. */
  49187. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49188. /**
  49189. * CustomMeshes are not supported by this gizmo
  49190. * @param mesh The mesh to replace the default mesh of the gizmo
  49191. */
  49192. setCustomMesh(mesh: Mesh): void;
  49193. }
  49194. }
  49195. declare module BABYLON {
  49196. /**
  49197. * Single plane rotation gizmo
  49198. */
  49199. export class PlaneRotationGizmo extends Gizmo {
  49200. /**
  49201. * Drag behavior responsible for the gizmos dragging interactions
  49202. */
  49203. dragBehavior: PointerDragBehavior;
  49204. private _pointerObserver;
  49205. /**
  49206. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49207. */
  49208. snapDistance: number;
  49209. /**
  49210. * Event that fires each time the gizmo snaps to a new location.
  49211. * * snapDistance is the the change in distance
  49212. */
  49213. onSnapObservable: Observable<{
  49214. snapDistance: number;
  49215. }>;
  49216. private _isEnabled;
  49217. private _parent;
  49218. /**
  49219. * Creates a PlaneRotationGizmo
  49220. * @param gizmoLayer The utility layer the gizmo will be added to
  49221. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49222. * @param color The color of the gizmo
  49223. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49224. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49225. */
  49226. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49227. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49228. /**
  49229. * If the gizmo is enabled
  49230. */
  49231. set isEnabled(value: boolean);
  49232. get isEnabled(): boolean;
  49233. /**
  49234. * Disposes of the gizmo
  49235. */
  49236. dispose(): void;
  49237. }
  49238. }
  49239. declare module BABYLON {
  49240. /**
  49241. * Gizmo that enables rotating a mesh along 3 axis
  49242. */
  49243. export class RotationGizmo extends Gizmo {
  49244. /**
  49245. * Internal gizmo used for interactions on the x axis
  49246. */
  49247. xGizmo: PlaneRotationGizmo;
  49248. /**
  49249. * Internal gizmo used for interactions on the y axis
  49250. */
  49251. yGizmo: PlaneRotationGizmo;
  49252. /**
  49253. * Internal gizmo used for interactions on the z axis
  49254. */
  49255. zGizmo: PlaneRotationGizmo;
  49256. /** Fires an event when any of it's sub gizmos are dragged */
  49257. onDragStartObservable: Observable<unknown>;
  49258. /** Fires an event when any of it's sub gizmos are released from dragging */
  49259. onDragEndObservable: Observable<unknown>;
  49260. private _meshAttached;
  49261. get attachedMesh(): Nullable<AbstractMesh>;
  49262. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49263. /**
  49264. * Creates a RotationGizmo
  49265. * @param gizmoLayer The utility layer the gizmo will be added to
  49266. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49267. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49268. */
  49269. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49270. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49271. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49272. /**
  49273. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49274. */
  49275. set snapDistance(value: number);
  49276. get snapDistance(): number;
  49277. /**
  49278. * Ratio for the scale of the gizmo (Default: 1)
  49279. */
  49280. set scaleRatio(value: number);
  49281. get scaleRatio(): number;
  49282. /**
  49283. * Disposes of the gizmo
  49284. */
  49285. dispose(): void;
  49286. /**
  49287. * CustomMeshes are not supported by this gizmo
  49288. * @param mesh The mesh to replace the default mesh of the gizmo
  49289. */
  49290. setCustomMesh(mesh: Mesh): void;
  49291. }
  49292. }
  49293. declare module BABYLON {
  49294. /**
  49295. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49296. */
  49297. export class GizmoManager implements IDisposable {
  49298. private scene;
  49299. /**
  49300. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49301. */
  49302. gizmos: {
  49303. positionGizmo: Nullable<PositionGizmo>;
  49304. rotationGizmo: Nullable<RotationGizmo>;
  49305. scaleGizmo: Nullable<ScaleGizmo>;
  49306. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49307. };
  49308. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49309. clearGizmoOnEmptyPointerEvent: boolean;
  49310. /** Fires an event when the manager is attached to a mesh */
  49311. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49312. private _gizmosEnabled;
  49313. private _pointerObserver;
  49314. private _attachedMesh;
  49315. private _boundingBoxColor;
  49316. private _defaultUtilityLayer;
  49317. private _defaultKeepDepthUtilityLayer;
  49318. /**
  49319. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49320. */
  49321. boundingBoxDragBehavior: SixDofDragBehavior;
  49322. /**
  49323. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49324. */
  49325. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49326. /**
  49327. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49328. */
  49329. usePointerToAttachGizmos: boolean;
  49330. /**
  49331. * Utility layer that the bounding box gizmo belongs to
  49332. */
  49333. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49334. /**
  49335. * Utility layer that all gizmos besides bounding box belong to
  49336. */
  49337. get utilityLayer(): UtilityLayerRenderer;
  49338. /**
  49339. * Instatiates a gizmo manager
  49340. * @param scene the scene to overlay the gizmos on top of
  49341. */
  49342. constructor(scene: Scene);
  49343. /**
  49344. * Attaches a set of gizmos to the specified mesh
  49345. * @param mesh The mesh the gizmo's should be attached to
  49346. */
  49347. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49348. /**
  49349. * If the position gizmo is enabled
  49350. */
  49351. set positionGizmoEnabled(value: boolean);
  49352. get positionGizmoEnabled(): boolean;
  49353. /**
  49354. * If the rotation gizmo is enabled
  49355. */
  49356. set rotationGizmoEnabled(value: boolean);
  49357. get rotationGizmoEnabled(): boolean;
  49358. /**
  49359. * If the scale gizmo is enabled
  49360. */
  49361. set scaleGizmoEnabled(value: boolean);
  49362. get scaleGizmoEnabled(): boolean;
  49363. /**
  49364. * If the boundingBox gizmo is enabled
  49365. */
  49366. set boundingBoxGizmoEnabled(value: boolean);
  49367. get boundingBoxGizmoEnabled(): boolean;
  49368. /**
  49369. * Disposes of the gizmo manager
  49370. */
  49371. dispose(): void;
  49372. }
  49373. }
  49374. declare module BABYLON {
  49375. /**
  49376. * A directional light is defined by a direction (what a surprise!).
  49377. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49378. * 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.
  49379. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49380. */
  49381. export class DirectionalLight extends ShadowLight {
  49382. private _shadowFrustumSize;
  49383. /**
  49384. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49385. */
  49386. get shadowFrustumSize(): number;
  49387. /**
  49388. * Specifies a fix frustum size for the shadow generation.
  49389. */
  49390. set shadowFrustumSize(value: number);
  49391. private _shadowOrthoScale;
  49392. /**
  49393. * Gets the shadow projection scale against the optimal computed one.
  49394. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49395. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49396. */
  49397. get shadowOrthoScale(): number;
  49398. /**
  49399. * Sets the shadow projection scale against the optimal computed one.
  49400. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49401. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49402. */
  49403. set shadowOrthoScale(value: number);
  49404. /**
  49405. * Automatically compute the projection matrix to best fit (including all the casters)
  49406. * on each frame.
  49407. */
  49408. autoUpdateExtends: boolean;
  49409. /**
  49410. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49411. * on each frame. autoUpdateExtends must be set to true for this to work
  49412. */
  49413. autoCalcShadowZBounds: boolean;
  49414. private _orthoLeft;
  49415. private _orthoRight;
  49416. private _orthoTop;
  49417. private _orthoBottom;
  49418. /**
  49419. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49420. * The directional light is emitted from everywhere in the given direction.
  49421. * It can cast shadows.
  49422. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49423. * @param name The friendly name of the light
  49424. * @param direction The direction of the light
  49425. * @param scene The scene the light belongs to
  49426. */
  49427. constructor(name: string, direction: Vector3, scene: Scene);
  49428. /**
  49429. * Returns the string "DirectionalLight".
  49430. * @return The class name
  49431. */
  49432. getClassName(): string;
  49433. /**
  49434. * Returns the integer 1.
  49435. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49436. */
  49437. getTypeID(): number;
  49438. /**
  49439. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49440. * Returns the DirectionalLight Shadow projection matrix.
  49441. */
  49442. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49443. /**
  49444. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49445. * Returns the DirectionalLight Shadow projection matrix.
  49446. */
  49447. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49448. /**
  49449. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49450. * Returns the DirectionalLight Shadow projection matrix.
  49451. */
  49452. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49453. protected _buildUniformLayout(): void;
  49454. /**
  49455. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49456. * @param effect The effect to update
  49457. * @param lightIndex The index of the light in the effect to update
  49458. * @returns The directional light
  49459. */
  49460. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49461. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49462. /**
  49463. * Gets the minZ used for shadow according to both the scene and the light.
  49464. *
  49465. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49466. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49467. * @param activeCamera The camera we are returning the min for
  49468. * @returns the depth min z
  49469. */
  49470. getDepthMinZ(activeCamera: Camera): number;
  49471. /**
  49472. * Gets the maxZ used for shadow according to both the scene and the light.
  49473. *
  49474. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49475. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49476. * @param activeCamera The camera we are returning the max for
  49477. * @returns the depth max z
  49478. */
  49479. getDepthMaxZ(activeCamera: Camera): number;
  49480. /**
  49481. * Prepares the list of defines specific to the light type.
  49482. * @param defines the list of defines
  49483. * @param lightIndex defines the index of the light for the effect
  49484. */
  49485. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49486. }
  49487. }
  49488. declare module BABYLON {
  49489. /**
  49490. * Class containing static functions to help procedurally build meshes
  49491. */
  49492. export class HemisphereBuilder {
  49493. /**
  49494. * Creates a hemisphere mesh
  49495. * @param name defines the name of the mesh
  49496. * @param options defines the options used to create the mesh
  49497. * @param scene defines the hosting scene
  49498. * @returns the hemisphere mesh
  49499. */
  49500. static CreateHemisphere(name: string, options: {
  49501. segments?: number;
  49502. diameter?: number;
  49503. sideOrientation?: number;
  49504. }, scene: any): Mesh;
  49505. }
  49506. }
  49507. declare module BABYLON {
  49508. /**
  49509. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49510. * These values define a cone of light starting from the position, emitting toward the direction.
  49511. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49512. * and the exponent defines the speed of the decay of the light with distance (reach).
  49513. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49514. */
  49515. export class SpotLight extends ShadowLight {
  49516. private _angle;
  49517. private _innerAngle;
  49518. private _cosHalfAngle;
  49519. private _lightAngleScale;
  49520. private _lightAngleOffset;
  49521. /**
  49522. * Gets the cone angle of the spot light in Radians.
  49523. */
  49524. get angle(): number;
  49525. /**
  49526. * Sets the cone angle of the spot light in Radians.
  49527. */
  49528. set angle(value: number);
  49529. /**
  49530. * Only used in gltf falloff mode, this defines the angle where
  49531. * the directional falloff will start before cutting at angle which could be seen
  49532. * as outer angle.
  49533. */
  49534. get innerAngle(): number;
  49535. /**
  49536. * Only used in gltf falloff mode, this defines the angle where
  49537. * the directional falloff will start before cutting at angle which could be seen
  49538. * as outer angle.
  49539. */
  49540. set innerAngle(value: number);
  49541. private _shadowAngleScale;
  49542. /**
  49543. * Allows scaling the angle of the light for shadow generation only.
  49544. */
  49545. get shadowAngleScale(): number;
  49546. /**
  49547. * Allows scaling the angle of the light for shadow generation only.
  49548. */
  49549. set shadowAngleScale(value: number);
  49550. /**
  49551. * The light decay speed with the distance from the emission spot.
  49552. */
  49553. exponent: number;
  49554. private _projectionTextureMatrix;
  49555. /**
  49556. * Allows reading the projecton texture
  49557. */
  49558. get projectionTextureMatrix(): Matrix;
  49559. protected _projectionTextureLightNear: number;
  49560. /**
  49561. * Gets the near clip of the Spotlight for texture projection.
  49562. */
  49563. get projectionTextureLightNear(): number;
  49564. /**
  49565. * Sets the near clip of the Spotlight for texture projection.
  49566. */
  49567. set projectionTextureLightNear(value: number);
  49568. protected _projectionTextureLightFar: number;
  49569. /**
  49570. * Gets the far clip of the Spotlight for texture projection.
  49571. */
  49572. get projectionTextureLightFar(): number;
  49573. /**
  49574. * Sets the far clip of the Spotlight for texture projection.
  49575. */
  49576. set projectionTextureLightFar(value: number);
  49577. protected _projectionTextureUpDirection: Vector3;
  49578. /**
  49579. * Gets the Up vector of the Spotlight for texture projection.
  49580. */
  49581. get projectionTextureUpDirection(): Vector3;
  49582. /**
  49583. * Sets the Up vector of the Spotlight for texture projection.
  49584. */
  49585. set projectionTextureUpDirection(value: Vector3);
  49586. private _projectionTexture;
  49587. /**
  49588. * Gets the projection texture of the light.
  49589. */
  49590. get projectionTexture(): Nullable<BaseTexture>;
  49591. /**
  49592. * Sets the projection texture of the light.
  49593. */
  49594. set projectionTexture(value: Nullable<BaseTexture>);
  49595. private _projectionTextureViewLightDirty;
  49596. private _projectionTextureProjectionLightDirty;
  49597. private _projectionTextureDirty;
  49598. private _projectionTextureViewTargetVector;
  49599. private _projectionTextureViewLightMatrix;
  49600. private _projectionTextureProjectionLightMatrix;
  49601. private _projectionTextureScalingMatrix;
  49602. /**
  49603. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49604. * It can cast shadows.
  49605. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49606. * @param name The light friendly name
  49607. * @param position The position of the spot light in the scene
  49608. * @param direction The direction of the light in the scene
  49609. * @param angle The cone angle of the light in Radians
  49610. * @param exponent The light decay speed with the distance from the emission spot
  49611. * @param scene The scene the lights belongs to
  49612. */
  49613. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49614. /**
  49615. * Returns the string "SpotLight".
  49616. * @returns the class name
  49617. */
  49618. getClassName(): string;
  49619. /**
  49620. * Returns the integer 2.
  49621. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49622. */
  49623. getTypeID(): number;
  49624. /**
  49625. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49626. */
  49627. protected _setDirection(value: Vector3): void;
  49628. /**
  49629. * Overrides the position setter to recompute the projection texture view light Matrix.
  49630. */
  49631. protected _setPosition(value: Vector3): void;
  49632. /**
  49633. * 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.
  49634. * Returns the SpotLight.
  49635. */
  49636. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49637. protected _computeProjectionTextureViewLightMatrix(): void;
  49638. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49639. /**
  49640. * Main function for light texture projection matrix computing.
  49641. */
  49642. protected _computeProjectionTextureMatrix(): void;
  49643. protected _buildUniformLayout(): void;
  49644. private _computeAngleValues;
  49645. /**
  49646. * Sets the passed Effect "effect" with the Light textures.
  49647. * @param effect The effect to update
  49648. * @param lightIndex The index of the light in the effect to update
  49649. * @returns The light
  49650. */
  49651. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49652. /**
  49653. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49654. * @param effect The effect to update
  49655. * @param lightIndex The index of the light in the effect to update
  49656. * @returns The spot light
  49657. */
  49658. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49659. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49660. /**
  49661. * Disposes the light and the associated resources.
  49662. */
  49663. dispose(): void;
  49664. /**
  49665. * Prepares the list of defines specific to the light type.
  49666. * @param defines the list of defines
  49667. * @param lightIndex defines the index of the light for the effect
  49668. */
  49669. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49670. }
  49671. }
  49672. declare module BABYLON {
  49673. /**
  49674. * Gizmo that enables viewing a light
  49675. */
  49676. export class LightGizmo extends Gizmo {
  49677. private _lightMesh;
  49678. private _material;
  49679. private _cachedPosition;
  49680. private _cachedForward;
  49681. private _attachedMeshParent;
  49682. /**
  49683. * Creates a LightGizmo
  49684. * @param gizmoLayer The utility layer the gizmo will be added to
  49685. */
  49686. constructor(gizmoLayer?: UtilityLayerRenderer);
  49687. private _light;
  49688. /**
  49689. * The light that the gizmo is attached to
  49690. */
  49691. set light(light: Nullable<Light>);
  49692. get light(): Nullable<Light>;
  49693. /**
  49694. * Gets the material used to render the light gizmo
  49695. */
  49696. get material(): StandardMaterial;
  49697. /**
  49698. * @hidden
  49699. * Updates the gizmo to match the attached mesh's position/rotation
  49700. */
  49701. protected _update(): void;
  49702. private static _Scale;
  49703. /**
  49704. * Creates the lines for a light mesh
  49705. */
  49706. private static _CreateLightLines;
  49707. /**
  49708. * Disposes of the light gizmo
  49709. */
  49710. dispose(): void;
  49711. private static _CreateHemisphericLightMesh;
  49712. private static _CreatePointLightMesh;
  49713. private static _CreateSpotLightMesh;
  49714. private static _CreateDirectionalLightMesh;
  49715. }
  49716. }
  49717. declare module BABYLON {
  49718. /** @hidden */
  49719. export var backgroundFragmentDeclaration: {
  49720. name: string;
  49721. shader: string;
  49722. };
  49723. }
  49724. declare module BABYLON {
  49725. /** @hidden */
  49726. export var backgroundUboDeclaration: {
  49727. name: string;
  49728. shader: string;
  49729. };
  49730. }
  49731. declare module BABYLON {
  49732. /** @hidden */
  49733. export var backgroundPixelShader: {
  49734. name: string;
  49735. shader: string;
  49736. };
  49737. }
  49738. declare module BABYLON {
  49739. /** @hidden */
  49740. export var backgroundVertexDeclaration: {
  49741. name: string;
  49742. shader: string;
  49743. };
  49744. }
  49745. declare module BABYLON {
  49746. /** @hidden */
  49747. export var backgroundVertexShader: {
  49748. name: string;
  49749. shader: string;
  49750. };
  49751. }
  49752. declare module BABYLON {
  49753. /**
  49754. * Background material used to create an efficient environement around your scene.
  49755. */
  49756. export class BackgroundMaterial extends PushMaterial {
  49757. /**
  49758. * Standard reflectance value at parallel view angle.
  49759. */
  49760. static StandardReflectance0: number;
  49761. /**
  49762. * Standard reflectance value at grazing angle.
  49763. */
  49764. static StandardReflectance90: number;
  49765. protected _primaryColor: Color3;
  49766. /**
  49767. * Key light Color (multiply against the environement texture)
  49768. */
  49769. primaryColor: Color3;
  49770. protected __perceptualColor: Nullable<Color3>;
  49771. /**
  49772. * Experimental Internal Use Only.
  49773. *
  49774. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49775. * This acts as a helper to set the primary color to a more "human friendly" value.
  49776. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49777. * output color as close as possible from the chosen value.
  49778. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49779. * part of lighting setup.)
  49780. */
  49781. get _perceptualColor(): Nullable<Color3>;
  49782. set _perceptualColor(value: Nullable<Color3>);
  49783. protected _primaryColorShadowLevel: float;
  49784. /**
  49785. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49786. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49787. */
  49788. get primaryColorShadowLevel(): float;
  49789. set primaryColorShadowLevel(value: float);
  49790. protected _primaryColorHighlightLevel: float;
  49791. /**
  49792. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49793. * The primary color is used at the level chosen to define what the white area would look.
  49794. */
  49795. get primaryColorHighlightLevel(): float;
  49796. set primaryColorHighlightLevel(value: float);
  49797. protected _reflectionTexture: Nullable<BaseTexture>;
  49798. /**
  49799. * Reflection Texture used in the material.
  49800. * Should be author in a specific way for the best result (refer to the documentation).
  49801. */
  49802. reflectionTexture: Nullable<BaseTexture>;
  49803. protected _reflectionBlur: float;
  49804. /**
  49805. * Reflection Texture level of blur.
  49806. *
  49807. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49808. * texture twice.
  49809. */
  49810. reflectionBlur: float;
  49811. protected _diffuseTexture: Nullable<BaseTexture>;
  49812. /**
  49813. * Diffuse Texture used in the material.
  49814. * Should be author in a specific way for the best result (refer to the documentation).
  49815. */
  49816. diffuseTexture: Nullable<BaseTexture>;
  49817. protected _shadowLights: Nullable<IShadowLight[]>;
  49818. /**
  49819. * Specify the list of lights casting shadow on the material.
  49820. * All scene shadow lights will be included if null.
  49821. */
  49822. shadowLights: Nullable<IShadowLight[]>;
  49823. protected _shadowLevel: float;
  49824. /**
  49825. * Helps adjusting the shadow to a softer level if required.
  49826. * 0 means black shadows and 1 means no shadows.
  49827. */
  49828. shadowLevel: float;
  49829. protected _sceneCenter: Vector3;
  49830. /**
  49831. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49832. * It is usually zero but might be interesting to modify according to your setup.
  49833. */
  49834. sceneCenter: Vector3;
  49835. protected _opacityFresnel: boolean;
  49836. /**
  49837. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49838. * This helps ensuring a nice transition when the camera goes under the ground.
  49839. */
  49840. opacityFresnel: boolean;
  49841. protected _reflectionFresnel: boolean;
  49842. /**
  49843. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49844. * This helps adding a mirror texture on the ground.
  49845. */
  49846. reflectionFresnel: boolean;
  49847. protected _reflectionFalloffDistance: number;
  49848. /**
  49849. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49850. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49851. */
  49852. reflectionFalloffDistance: number;
  49853. protected _reflectionAmount: number;
  49854. /**
  49855. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49856. */
  49857. reflectionAmount: number;
  49858. protected _reflectionReflectance0: number;
  49859. /**
  49860. * This specifies the weight of the reflection at grazing angle.
  49861. */
  49862. reflectionReflectance0: number;
  49863. protected _reflectionReflectance90: number;
  49864. /**
  49865. * This specifies the weight of the reflection at a perpendicular point of view.
  49866. */
  49867. reflectionReflectance90: number;
  49868. /**
  49869. * Sets the reflection reflectance fresnel values according to the default standard
  49870. * empirically know to work well :-)
  49871. */
  49872. set reflectionStandardFresnelWeight(value: number);
  49873. protected _useRGBColor: boolean;
  49874. /**
  49875. * Helps to directly use the maps channels instead of their level.
  49876. */
  49877. useRGBColor: boolean;
  49878. protected _enableNoise: boolean;
  49879. /**
  49880. * This helps reducing the banding effect that could occur on the background.
  49881. */
  49882. enableNoise: boolean;
  49883. /**
  49884. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49885. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49886. * Recommended to be keep at 1.0 except for special cases.
  49887. */
  49888. get fovMultiplier(): number;
  49889. set fovMultiplier(value: number);
  49890. private _fovMultiplier;
  49891. /**
  49892. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49893. */
  49894. useEquirectangularFOV: boolean;
  49895. private _maxSimultaneousLights;
  49896. /**
  49897. * Number of Simultaneous lights allowed on the material.
  49898. */
  49899. maxSimultaneousLights: int;
  49900. /**
  49901. * Default configuration related to image processing available in the Background Material.
  49902. */
  49903. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49904. /**
  49905. * Keep track of the image processing observer to allow dispose and replace.
  49906. */
  49907. private _imageProcessingObserver;
  49908. /**
  49909. * Attaches a new image processing configuration to the PBR Material.
  49910. * @param configuration (if null the scene configuration will be use)
  49911. */
  49912. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49913. /**
  49914. * Gets the image processing configuration used either in this material.
  49915. */
  49916. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49917. /**
  49918. * Sets the Default image processing configuration used either in the this material.
  49919. *
  49920. * If sets to null, the scene one is in use.
  49921. */
  49922. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49923. /**
  49924. * Gets wether the color curves effect is enabled.
  49925. */
  49926. get cameraColorCurvesEnabled(): boolean;
  49927. /**
  49928. * Sets wether the color curves effect is enabled.
  49929. */
  49930. set cameraColorCurvesEnabled(value: boolean);
  49931. /**
  49932. * Gets wether the color grading effect is enabled.
  49933. */
  49934. get cameraColorGradingEnabled(): boolean;
  49935. /**
  49936. * Gets wether the color grading effect is enabled.
  49937. */
  49938. set cameraColorGradingEnabled(value: boolean);
  49939. /**
  49940. * Gets wether tonemapping is enabled or not.
  49941. */
  49942. get cameraToneMappingEnabled(): boolean;
  49943. /**
  49944. * Sets wether tonemapping is enabled or not
  49945. */
  49946. set cameraToneMappingEnabled(value: boolean);
  49947. /**
  49948. * The camera exposure used on this material.
  49949. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49950. * This corresponds to a photographic exposure.
  49951. */
  49952. get cameraExposure(): float;
  49953. /**
  49954. * The camera exposure used on this material.
  49955. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49956. * This corresponds to a photographic exposure.
  49957. */
  49958. set cameraExposure(value: float);
  49959. /**
  49960. * Gets The camera contrast used on this material.
  49961. */
  49962. get cameraContrast(): float;
  49963. /**
  49964. * Sets The camera contrast used on this material.
  49965. */
  49966. set cameraContrast(value: float);
  49967. /**
  49968. * Gets the Color Grading 2D Lookup Texture.
  49969. */
  49970. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49971. /**
  49972. * Sets the Color Grading 2D Lookup Texture.
  49973. */
  49974. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49975. /**
  49976. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49977. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49978. * 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;
  49979. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49980. */
  49981. get cameraColorCurves(): Nullable<ColorCurves>;
  49982. /**
  49983. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49984. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49985. * 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;
  49986. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49987. */
  49988. set cameraColorCurves(value: Nullable<ColorCurves>);
  49989. /**
  49990. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49991. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49992. */
  49993. switchToBGR: boolean;
  49994. private _renderTargets;
  49995. private _reflectionControls;
  49996. private _white;
  49997. private _primaryShadowColor;
  49998. private _primaryHighlightColor;
  49999. /**
  50000. * Instantiates a Background Material in the given scene
  50001. * @param name The friendly name of the material
  50002. * @param scene The scene to add the material to
  50003. */
  50004. constructor(name: string, scene: Scene);
  50005. /**
  50006. * Gets a boolean indicating that current material needs to register RTT
  50007. */
  50008. get hasRenderTargetTextures(): boolean;
  50009. /**
  50010. * The entire material has been created in order to prevent overdraw.
  50011. * @returns false
  50012. */
  50013. needAlphaTesting(): boolean;
  50014. /**
  50015. * The entire material has been created in order to prevent overdraw.
  50016. * @returns true if blending is enable
  50017. */
  50018. needAlphaBlending(): boolean;
  50019. /**
  50020. * Checks wether the material is ready to be rendered for a given mesh.
  50021. * @param mesh The mesh to render
  50022. * @param subMesh The submesh to check against
  50023. * @param useInstances Specify wether or not the material is used with instances
  50024. * @returns true if all the dependencies are ready (Textures, Effects...)
  50025. */
  50026. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50027. /**
  50028. * Compute the primary color according to the chosen perceptual color.
  50029. */
  50030. private _computePrimaryColorFromPerceptualColor;
  50031. /**
  50032. * Compute the highlights and shadow colors according to their chosen levels.
  50033. */
  50034. private _computePrimaryColors;
  50035. /**
  50036. * Build the uniform buffer used in the material.
  50037. */
  50038. buildUniformLayout(): void;
  50039. /**
  50040. * Unbind the material.
  50041. */
  50042. unbind(): void;
  50043. /**
  50044. * Bind only the world matrix to the material.
  50045. * @param world The world matrix to bind.
  50046. */
  50047. bindOnlyWorldMatrix(world: Matrix): void;
  50048. /**
  50049. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50050. * @param world The world matrix to bind.
  50051. * @param subMesh The submesh to bind for.
  50052. */
  50053. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50054. /**
  50055. * Checks to see if a texture is used in the material.
  50056. * @param texture - Base texture to use.
  50057. * @returns - Boolean specifying if a texture is used in the material.
  50058. */
  50059. hasTexture(texture: BaseTexture): boolean;
  50060. /**
  50061. * Dispose the material.
  50062. * @param forceDisposeEffect Force disposal of the associated effect.
  50063. * @param forceDisposeTextures Force disposal of the associated textures.
  50064. */
  50065. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50066. /**
  50067. * Clones the material.
  50068. * @param name The cloned name.
  50069. * @returns The cloned material.
  50070. */
  50071. clone(name: string): BackgroundMaterial;
  50072. /**
  50073. * Serializes the current material to its JSON representation.
  50074. * @returns The JSON representation.
  50075. */
  50076. serialize(): any;
  50077. /**
  50078. * Gets the class name of the material
  50079. * @returns "BackgroundMaterial"
  50080. */
  50081. getClassName(): string;
  50082. /**
  50083. * Parse a JSON input to create back a background material.
  50084. * @param source The JSON data to parse
  50085. * @param scene The scene to create the parsed material in
  50086. * @param rootUrl The root url of the assets the material depends upon
  50087. * @returns the instantiated BackgroundMaterial.
  50088. */
  50089. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50090. }
  50091. }
  50092. declare module BABYLON {
  50093. /**
  50094. * Represents the different options available during the creation of
  50095. * a Environment helper.
  50096. *
  50097. * This can control the default ground, skybox and image processing setup of your scene.
  50098. */
  50099. export interface IEnvironmentHelperOptions {
  50100. /**
  50101. * Specifies whether or not to create a ground.
  50102. * True by default.
  50103. */
  50104. createGround: boolean;
  50105. /**
  50106. * Specifies the ground size.
  50107. * 15 by default.
  50108. */
  50109. groundSize: number;
  50110. /**
  50111. * The texture used on the ground for the main color.
  50112. * Comes from the BabylonJS CDN by default.
  50113. *
  50114. * Remarks: Can be either a texture or a url.
  50115. */
  50116. groundTexture: string | BaseTexture;
  50117. /**
  50118. * The color mixed in the ground texture by default.
  50119. * BabylonJS clearColor by default.
  50120. */
  50121. groundColor: Color3;
  50122. /**
  50123. * Specifies the ground opacity.
  50124. * 1 by default.
  50125. */
  50126. groundOpacity: number;
  50127. /**
  50128. * Enables the ground to receive shadows.
  50129. * True by default.
  50130. */
  50131. enableGroundShadow: boolean;
  50132. /**
  50133. * Helps preventing the shadow to be fully black on the ground.
  50134. * 0.5 by default.
  50135. */
  50136. groundShadowLevel: number;
  50137. /**
  50138. * Creates a mirror texture attach to the ground.
  50139. * false by default.
  50140. */
  50141. enableGroundMirror: boolean;
  50142. /**
  50143. * Specifies the ground mirror size ratio.
  50144. * 0.3 by default as the default kernel is 64.
  50145. */
  50146. groundMirrorSizeRatio: number;
  50147. /**
  50148. * Specifies the ground mirror blur kernel size.
  50149. * 64 by default.
  50150. */
  50151. groundMirrorBlurKernel: number;
  50152. /**
  50153. * Specifies the ground mirror visibility amount.
  50154. * 1 by default
  50155. */
  50156. groundMirrorAmount: number;
  50157. /**
  50158. * Specifies the ground mirror reflectance weight.
  50159. * This uses the standard weight of the background material to setup the fresnel effect
  50160. * of the mirror.
  50161. * 1 by default.
  50162. */
  50163. groundMirrorFresnelWeight: number;
  50164. /**
  50165. * Specifies the ground mirror Falloff distance.
  50166. * This can helps reducing the size of the reflection.
  50167. * 0 by Default.
  50168. */
  50169. groundMirrorFallOffDistance: number;
  50170. /**
  50171. * Specifies the ground mirror texture type.
  50172. * Unsigned Int by Default.
  50173. */
  50174. groundMirrorTextureType: number;
  50175. /**
  50176. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50177. * the shown objects.
  50178. */
  50179. groundYBias: number;
  50180. /**
  50181. * Specifies whether or not to create a skybox.
  50182. * True by default.
  50183. */
  50184. createSkybox: boolean;
  50185. /**
  50186. * Specifies the skybox size.
  50187. * 20 by default.
  50188. */
  50189. skyboxSize: number;
  50190. /**
  50191. * The texture used on the skybox for the main color.
  50192. * Comes from the BabylonJS CDN by default.
  50193. *
  50194. * Remarks: Can be either a texture or a url.
  50195. */
  50196. skyboxTexture: string | BaseTexture;
  50197. /**
  50198. * The color mixed in the skybox texture by default.
  50199. * BabylonJS clearColor by default.
  50200. */
  50201. skyboxColor: Color3;
  50202. /**
  50203. * The background rotation around the Y axis of the scene.
  50204. * This helps aligning the key lights of your scene with the background.
  50205. * 0 by default.
  50206. */
  50207. backgroundYRotation: number;
  50208. /**
  50209. * Compute automatically the size of the elements to best fit with the scene.
  50210. */
  50211. sizeAuto: boolean;
  50212. /**
  50213. * Default position of the rootMesh if autoSize is not true.
  50214. */
  50215. rootPosition: Vector3;
  50216. /**
  50217. * Sets up the image processing in the scene.
  50218. * true by default.
  50219. */
  50220. setupImageProcessing: boolean;
  50221. /**
  50222. * The texture used as your environment texture in the scene.
  50223. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50224. *
  50225. * Remarks: Can be either a texture or a url.
  50226. */
  50227. environmentTexture: string | BaseTexture;
  50228. /**
  50229. * The value of the exposure to apply to the scene.
  50230. * 0.6 by default if setupImageProcessing is true.
  50231. */
  50232. cameraExposure: number;
  50233. /**
  50234. * The value of the contrast to apply to the scene.
  50235. * 1.6 by default if setupImageProcessing is true.
  50236. */
  50237. cameraContrast: number;
  50238. /**
  50239. * Specifies whether or not tonemapping should be enabled in the scene.
  50240. * true by default if setupImageProcessing is true.
  50241. */
  50242. toneMappingEnabled: boolean;
  50243. }
  50244. /**
  50245. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50246. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50247. * It also helps with the default setup of your imageProcessing configuration.
  50248. */
  50249. export class EnvironmentHelper {
  50250. /**
  50251. * Default ground texture URL.
  50252. */
  50253. private static _groundTextureCDNUrl;
  50254. /**
  50255. * Default skybox texture URL.
  50256. */
  50257. private static _skyboxTextureCDNUrl;
  50258. /**
  50259. * Default environment texture URL.
  50260. */
  50261. private static _environmentTextureCDNUrl;
  50262. /**
  50263. * Creates the default options for the helper.
  50264. */
  50265. private static _getDefaultOptions;
  50266. private _rootMesh;
  50267. /**
  50268. * Gets the root mesh created by the helper.
  50269. */
  50270. get rootMesh(): Mesh;
  50271. private _skybox;
  50272. /**
  50273. * Gets the skybox created by the helper.
  50274. */
  50275. get skybox(): Nullable<Mesh>;
  50276. private _skyboxTexture;
  50277. /**
  50278. * Gets the skybox texture created by the helper.
  50279. */
  50280. get skyboxTexture(): Nullable<BaseTexture>;
  50281. private _skyboxMaterial;
  50282. /**
  50283. * Gets the skybox material created by the helper.
  50284. */
  50285. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50286. private _ground;
  50287. /**
  50288. * Gets the ground mesh created by the helper.
  50289. */
  50290. get ground(): Nullable<Mesh>;
  50291. private _groundTexture;
  50292. /**
  50293. * Gets the ground texture created by the helper.
  50294. */
  50295. get groundTexture(): Nullable<BaseTexture>;
  50296. private _groundMirror;
  50297. /**
  50298. * Gets the ground mirror created by the helper.
  50299. */
  50300. get groundMirror(): Nullable<MirrorTexture>;
  50301. /**
  50302. * Gets the ground mirror render list to helps pushing the meshes
  50303. * you wish in the ground reflection.
  50304. */
  50305. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50306. private _groundMaterial;
  50307. /**
  50308. * Gets the ground material created by the helper.
  50309. */
  50310. get groundMaterial(): Nullable<BackgroundMaterial>;
  50311. /**
  50312. * Stores the creation options.
  50313. */
  50314. private readonly _scene;
  50315. private _options;
  50316. /**
  50317. * This observable will be notified with any error during the creation of the environment,
  50318. * mainly texture creation errors.
  50319. */
  50320. onErrorObservable: Observable<{
  50321. message?: string;
  50322. exception?: any;
  50323. }>;
  50324. /**
  50325. * constructor
  50326. * @param options Defines the options we want to customize the helper
  50327. * @param scene The scene to add the material to
  50328. */
  50329. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50330. /**
  50331. * Updates the background according to the new options
  50332. * @param options
  50333. */
  50334. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50335. /**
  50336. * Sets the primary color of all the available elements.
  50337. * @param color the main color to affect to the ground and the background
  50338. */
  50339. setMainColor(color: Color3): void;
  50340. /**
  50341. * Setup the image processing according to the specified options.
  50342. */
  50343. private _setupImageProcessing;
  50344. /**
  50345. * Setup the environment texture according to the specified options.
  50346. */
  50347. private _setupEnvironmentTexture;
  50348. /**
  50349. * Setup the background according to the specified options.
  50350. */
  50351. private _setupBackground;
  50352. /**
  50353. * Get the scene sizes according to the setup.
  50354. */
  50355. private _getSceneSize;
  50356. /**
  50357. * Setup the ground according to the specified options.
  50358. */
  50359. private _setupGround;
  50360. /**
  50361. * Setup the ground material according to the specified options.
  50362. */
  50363. private _setupGroundMaterial;
  50364. /**
  50365. * Setup the ground diffuse texture according to the specified options.
  50366. */
  50367. private _setupGroundDiffuseTexture;
  50368. /**
  50369. * Setup the ground mirror texture according to the specified options.
  50370. */
  50371. private _setupGroundMirrorTexture;
  50372. /**
  50373. * Setup the ground to receive the mirror texture.
  50374. */
  50375. private _setupMirrorInGroundMaterial;
  50376. /**
  50377. * Setup the skybox according to the specified options.
  50378. */
  50379. private _setupSkybox;
  50380. /**
  50381. * Setup the skybox material according to the specified options.
  50382. */
  50383. private _setupSkyboxMaterial;
  50384. /**
  50385. * Setup the skybox reflection texture according to the specified options.
  50386. */
  50387. private _setupSkyboxReflectionTexture;
  50388. private _errorHandler;
  50389. /**
  50390. * Dispose all the elements created by the Helper.
  50391. */
  50392. dispose(): void;
  50393. }
  50394. }
  50395. declare module BABYLON {
  50396. /**
  50397. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50398. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50399. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50400. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50401. */
  50402. export class PhotoDome extends TransformNode {
  50403. /**
  50404. * Define the image as a Monoscopic panoramic 360 image.
  50405. */
  50406. static readonly MODE_MONOSCOPIC: number;
  50407. /**
  50408. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50409. */
  50410. static readonly MODE_TOPBOTTOM: number;
  50411. /**
  50412. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50413. */
  50414. static readonly MODE_SIDEBYSIDE: number;
  50415. private _useDirectMapping;
  50416. /**
  50417. * The texture being displayed on the sphere
  50418. */
  50419. protected _photoTexture: Texture;
  50420. /**
  50421. * Gets or sets the texture being displayed on the sphere
  50422. */
  50423. get photoTexture(): Texture;
  50424. set photoTexture(value: Texture);
  50425. /**
  50426. * Observable raised when an error occured while loading the 360 image
  50427. */
  50428. onLoadErrorObservable: Observable<string>;
  50429. /**
  50430. * The skybox material
  50431. */
  50432. protected _material: BackgroundMaterial;
  50433. /**
  50434. * The surface used for the skybox
  50435. */
  50436. protected _mesh: Mesh;
  50437. /**
  50438. * Gets the mesh used for the skybox.
  50439. */
  50440. get mesh(): Mesh;
  50441. /**
  50442. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50443. * Also see the options.resolution property.
  50444. */
  50445. get fovMultiplier(): number;
  50446. set fovMultiplier(value: number);
  50447. private _imageMode;
  50448. /**
  50449. * Gets or set the current video mode for the video. It can be:
  50450. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50451. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50452. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50453. */
  50454. get imageMode(): number;
  50455. set imageMode(value: number);
  50456. /**
  50457. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50458. * @param name Element's name, child elements will append suffixes for their own names.
  50459. * @param urlsOfPhoto defines the url of the photo to display
  50460. * @param options defines an object containing optional or exposed sub element properties
  50461. * @param onError defines a callback called when an error occured while loading the texture
  50462. */
  50463. constructor(name: string, urlOfPhoto: string, options: {
  50464. resolution?: number;
  50465. size?: number;
  50466. useDirectMapping?: boolean;
  50467. faceForward?: boolean;
  50468. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50469. private _onBeforeCameraRenderObserver;
  50470. private _changeImageMode;
  50471. /**
  50472. * Releases resources associated with this node.
  50473. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50474. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50475. */
  50476. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50477. }
  50478. }
  50479. declare module BABYLON {
  50480. /**
  50481. * Class used to host RGBD texture specific utilities
  50482. */
  50483. export class RGBDTextureTools {
  50484. /**
  50485. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50486. * @param texture the texture to expand.
  50487. */
  50488. static ExpandRGBDTexture(texture: Texture): void;
  50489. }
  50490. }
  50491. declare module BABYLON {
  50492. /**
  50493. * Class used to host texture specific utilities
  50494. */
  50495. export class BRDFTextureTools {
  50496. /**
  50497. * Prevents texture cache collision
  50498. */
  50499. private static _instanceNumber;
  50500. /**
  50501. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50502. * @param scene defines the hosting scene
  50503. * @returns the environment BRDF texture
  50504. */
  50505. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50506. private static _environmentBRDFBase64Texture;
  50507. }
  50508. }
  50509. declare module BABYLON {
  50510. /**
  50511. * @hidden
  50512. */
  50513. export interface IMaterialClearCoatDefines {
  50514. CLEARCOAT: boolean;
  50515. CLEARCOAT_DEFAULTIOR: boolean;
  50516. CLEARCOAT_TEXTURE: boolean;
  50517. CLEARCOAT_TEXTUREDIRECTUV: number;
  50518. CLEARCOAT_BUMP: boolean;
  50519. CLEARCOAT_BUMPDIRECTUV: number;
  50520. CLEARCOAT_TINT: boolean;
  50521. CLEARCOAT_TINT_TEXTURE: boolean;
  50522. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50523. /** @hidden */
  50524. _areTexturesDirty: boolean;
  50525. }
  50526. /**
  50527. * Define the code related to the clear coat parameters of the pbr material.
  50528. */
  50529. export class PBRClearCoatConfiguration {
  50530. /**
  50531. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50532. * The default fits with a polyurethane material.
  50533. */
  50534. private static readonly _DefaultIndexOfRefraction;
  50535. private _isEnabled;
  50536. /**
  50537. * Defines if the clear coat is enabled in the material.
  50538. */
  50539. isEnabled: boolean;
  50540. /**
  50541. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50542. */
  50543. intensity: number;
  50544. /**
  50545. * Defines the clear coat layer roughness.
  50546. */
  50547. roughness: number;
  50548. private _indexOfRefraction;
  50549. /**
  50550. * Defines the index of refraction of the clear coat.
  50551. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50552. * The default fits with a polyurethane material.
  50553. * Changing the default value is more performance intensive.
  50554. */
  50555. indexOfRefraction: number;
  50556. private _texture;
  50557. /**
  50558. * Stores the clear coat values in a texture.
  50559. */
  50560. texture: Nullable<BaseTexture>;
  50561. private _bumpTexture;
  50562. /**
  50563. * Define the clear coat specific bump texture.
  50564. */
  50565. bumpTexture: Nullable<BaseTexture>;
  50566. private _isTintEnabled;
  50567. /**
  50568. * Defines if the clear coat tint is enabled in the material.
  50569. */
  50570. isTintEnabled: boolean;
  50571. /**
  50572. * Defines the clear coat tint of the material.
  50573. * This is only use if tint is enabled
  50574. */
  50575. tintColor: Color3;
  50576. /**
  50577. * Defines the distance at which the tint color should be found in the
  50578. * clear coat media.
  50579. * This is only use if tint is enabled
  50580. */
  50581. tintColorAtDistance: number;
  50582. /**
  50583. * Defines the clear coat layer thickness.
  50584. * This is only use if tint is enabled
  50585. */
  50586. tintThickness: number;
  50587. private _tintTexture;
  50588. /**
  50589. * Stores the clear tint values in a texture.
  50590. * rgb is tint
  50591. * a is a thickness factor
  50592. */
  50593. tintTexture: Nullable<BaseTexture>;
  50594. /** @hidden */
  50595. private _internalMarkAllSubMeshesAsTexturesDirty;
  50596. /** @hidden */
  50597. _markAllSubMeshesAsTexturesDirty(): void;
  50598. /**
  50599. * Instantiate a new istance of clear coat configuration.
  50600. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50601. */
  50602. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50603. /**
  50604. * Gets wehter the submesh is ready to be used or not.
  50605. * @param defines the list of "defines" to update.
  50606. * @param scene defines the scene the material belongs to.
  50607. * @param engine defines the engine the material belongs to.
  50608. * @param disableBumpMap defines wether the material disables bump or not.
  50609. * @returns - boolean indicating that the submesh is ready or not.
  50610. */
  50611. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50612. /**
  50613. * Checks to see if a texture is used in the material.
  50614. * @param defines the list of "defines" to update.
  50615. * @param scene defines the scene to the material belongs to.
  50616. */
  50617. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50618. /**
  50619. * Binds the material data.
  50620. * @param uniformBuffer defines the Uniform buffer to fill in.
  50621. * @param scene defines the scene the material belongs to.
  50622. * @param engine defines the engine the material belongs to.
  50623. * @param disableBumpMap defines wether the material disables bump or not.
  50624. * @param isFrozen defines wether the material is frozen or not.
  50625. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50626. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50627. */
  50628. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50629. /**
  50630. * Checks to see if a texture is used in the material.
  50631. * @param texture - Base texture to use.
  50632. * @returns - Boolean specifying if a texture is used in the material.
  50633. */
  50634. hasTexture(texture: BaseTexture): boolean;
  50635. /**
  50636. * Returns an array of the actively used textures.
  50637. * @param activeTextures Array of BaseTextures
  50638. */
  50639. getActiveTextures(activeTextures: BaseTexture[]): void;
  50640. /**
  50641. * Returns the animatable textures.
  50642. * @param animatables Array of animatable textures.
  50643. */
  50644. getAnimatables(animatables: IAnimatable[]): void;
  50645. /**
  50646. * Disposes the resources of the material.
  50647. * @param forceDisposeTextures - Forces the disposal of all textures.
  50648. */
  50649. dispose(forceDisposeTextures?: boolean): void;
  50650. /**
  50651. * Get the current class name of the texture useful for serialization or dynamic coding.
  50652. * @returns "PBRClearCoatConfiguration"
  50653. */
  50654. getClassName(): string;
  50655. /**
  50656. * Add fallbacks to the effect fallbacks list.
  50657. * @param defines defines the Base texture to use.
  50658. * @param fallbacks defines the current fallback list.
  50659. * @param currentRank defines the current fallback rank.
  50660. * @returns the new fallback rank.
  50661. */
  50662. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50663. /**
  50664. * Add the required uniforms to the current list.
  50665. * @param uniforms defines the current uniform list.
  50666. */
  50667. static AddUniforms(uniforms: string[]): void;
  50668. /**
  50669. * Add the required samplers to the current list.
  50670. * @param samplers defines the current sampler list.
  50671. */
  50672. static AddSamplers(samplers: string[]): void;
  50673. /**
  50674. * Add the required uniforms to the current buffer.
  50675. * @param uniformBuffer defines the current uniform buffer.
  50676. */
  50677. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50678. /**
  50679. * Makes a duplicate of the current configuration into another one.
  50680. * @param clearCoatConfiguration define the config where to copy the info
  50681. */
  50682. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50683. /**
  50684. * Serializes this clear coat configuration.
  50685. * @returns - An object with the serialized config.
  50686. */
  50687. serialize(): any;
  50688. /**
  50689. * Parses a anisotropy Configuration from a serialized object.
  50690. * @param source - Serialized object.
  50691. * @param scene Defines the scene we are parsing for
  50692. * @param rootUrl Defines the rootUrl to load from
  50693. */
  50694. parse(source: any, scene: Scene, rootUrl: string): void;
  50695. }
  50696. }
  50697. declare module BABYLON {
  50698. /**
  50699. * @hidden
  50700. */
  50701. export interface IMaterialAnisotropicDefines {
  50702. ANISOTROPIC: boolean;
  50703. ANISOTROPIC_TEXTURE: boolean;
  50704. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50705. MAINUV1: boolean;
  50706. _areTexturesDirty: boolean;
  50707. _needUVs: boolean;
  50708. }
  50709. /**
  50710. * Define the code related to the anisotropic parameters of the pbr material.
  50711. */
  50712. export class PBRAnisotropicConfiguration {
  50713. private _isEnabled;
  50714. /**
  50715. * Defines if the anisotropy is enabled in the material.
  50716. */
  50717. isEnabled: boolean;
  50718. /**
  50719. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50720. */
  50721. intensity: number;
  50722. /**
  50723. * Defines if the effect is along the tangents, bitangents or in between.
  50724. * By default, the effect is "strectching" the highlights along the tangents.
  50725. */
  50726. direction: Vector2;
  50727. private _texture;
  50728. /**
  50729. * Stores the anisotropy values in a texture.
  50730. * rg is direction (like normal from -1 to 1)
  50731. * b is a intensity
  50732. */
  50733. texture: Nullable<BaseTexture>;
  50734. /** @hidden */
  50735. private _internalMarkAllSubMeshesAsTexturesDirty;
  50736. /** @hidden */
  50737. _markAllSubMeshesAsTexturesDirty(): void;
  50738. /**
  50739. * Instantiate a new istance of anisotropy configuration.
  50740. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50741. */
  50742. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50743. /**
  50744. * Specifies that the submesh is ready to be used.
  50745. * @param defines the list of "defines" to update.
  50746. * @param scene defines the scene the material belongs to.
  50747. * @returns - boolean indicating that the submesh is ready or not.
  50748. */
  50749. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50750. /**
  50751. * Checks to see if a texture is used in the material.
  50752. * @param defines the list of "defines" to update.
  50753. * @param mesh the mesh we are preparing the defines for.
  50754. * @param scene defines the scene the material belongs to.
  50755. */
  50756. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50757. /**
  50758. * Binds the material data.
  50759. * @param uniformBuffer defines the Uniform buffer to fill in.
  50760. * @param scene defines the scene the material belongs to.
  50761. * @param isFrozen defines wether the material is frozen or not.
  50762. */
  50763. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50764. /**
  50765. * Checks to see if a texture is used in the material.
  50766. * @param texture - Base texture to use.
  50767. * @returns - Boolean specifying if a texture is used in the material.
  50768. */
  50769. hasTexture(texture: BaseTexture): boolean;
  50770. /**
  50771. * Returns an array of the actively used textures.
  50772. * @param activeTextures Array of BaseTextures
  50773. */
  50774. getActiveTextures(activeTextures: BaseTexture[]): void;
  50775. /**
  50776. * Returns the animatable textures.
  50777. * @param animatables Array of animatable textures.
  50778. */
  50779. getAnimatables(animatables: IAnimatable[]): void;
  50780. /**
  50781. * Disposes the resources of the material.
  50782. * @param forceDisposeTextures - Forces the disposal of all textures.
  50783. */
  50784. dispose(forceDisposeTextures?: boolean): void;
  50785. /**
  50786. * Get the current class name of the texture useful for serialization or dynamic coding.
  50787. * @returns "PBRAnisotropicConfiguration"
  50788. */
  50789. getClassName(): string;
  50790. /**
  50791. * Add fallbacks to the effect fallbacks list.
  50792. * @param defines defines the Base texture to use.
  50793. * @param fallbacks defines the current fallback list.
  50794. * @param currentRank defines the current fallback rank.
  50795. * @returns the new fallback rank.
  50796. */
  50797. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50798. /**
  50799. * Add the required uniforms to the current list.
  50800. * @param uniforms defines the current uniform list.
  50801. */
  50802. static AddUniforms(uniforms: string[]): void;
  50803. /**
  50804. * Add the required uniforms to the current buffer.
  50805. * @param uniformBuffer defines the current uniform buffer.
  50806. */
  50807. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50808. /**
  50809. * Add the required samplers to the current list.
  50810. * @param samplers defines the current sampler list.
  50811. */
  50812. static AddSamplers(samplers: string[]): void;
  50813. /**
  50814. * Makes a duplicate of the current configuration into another one.
  50815. * @param anisotropicConfiguration define the config where to copy the info
  50816. */
  50817. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50818. /**
  50819. * Serializes this anisotropy configuration.
  50820. * @returns - An object with the serialized config.
  50821. */
  50822. serialize(): any;
  50823. /**
  50824. * Parses a anisotropy Configuration from a serialized object.
  50825. * @param source - Serialized object.
  50826. * @param scene Defines the scene we are parsing for
  50827. * @param rootUrl Defines the rootUrl to load from
  50828. */
  50829. parse(source: any, scene: Scene, rootUrl: string): void;
  50830. }
  50831. }
  50832. declare module BABYLON {
  50833. /**
  50834. * @hidden
  50835. */
  50836. export interface IMaterialBRDFDefines {
  50837. BRDF_V_HEIGHT_CORRELATED: boolean;
  50838. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50839. SPHERICAL_HARMONICS: boolean;
  50840. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50841. /** @hidden */
  50842. _areMiscDirty: boolean;
  50843. }
  50844. /**
  50845. * Define the code related to the BRDF parameters of the pbr material.
  50846. */
  50847. export class PBRBRDFConfiguration {
  50848. /**
  50849. * Default value used for the energy conservation.
  50850. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50851. */
  50852. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50853. /**
  50854. * Default value used for the Smith Visibility Height Correlated mode.
  50855. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50856. */
  50857. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50858. /**
  50859. * Default value used for the IBL diffuse part.
  50860. * This can help switching back to the polynomials mode globally which is a tiny bit
  50861. * less GPU intensive at the drawback of a lower quality.
  50862. */
  50863. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50864. /**
  50865. * Default value used for activating energy conservation for the specular workflow.
  50866. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50867. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50868. */
  50869. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50870. private _useEnergyConservation;
  50871. /**
  50872. * Defines if the material uses energy conservation.
  50873. */
  50874. useEnergyConservation: boolean;
  50875. private _useSmithVisibilityHeightCorrelated;
  50876. /**
  50877. * LEGACY Mode set to false
  50878. * Defines if the material uses height smith correlated visibility term.
  50879. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50880. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50881. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50882. * Not relying on height correlated will also disable energy conservation.
  50883. */
  50884. useSmithVisibilityHeightCorrelated: boolean;
  50885. private _useSphericalHarmonics;
  50886. /**
  50887. * LEGACY Mode set to false
  50888. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50889. * diffuse part of the IBL.
  50890. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50891. * to the ground truth.
  50892. */
  50893. useSphericalHarmonics: boolean;
  50894. private _useSpecularGlossinessInputEnergyConservation;
  50895. /**
  50896. * Defines if the material uses energy conservation, when the specular workflow is active.
  50897. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50898. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50899. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50900. */
  50901. useSpecularGlossinessInputEnergyConservation: boolean;
  50902. /** @hidden */
  50903. private _internalMarkAllSubMeshesAsMiscDirty;
  50904. /** @hidden */
  50905. _markAllSubMeshesAsMiscDirty(): void;
  50906. /**
  50907. * Instantiate a new istance of clear coat configuration.
  50908. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50909. */
  50910. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50911. /**
  50912. * Checks to see if a texture is used in the material.
  50913. * @param defines the list of "defines" to update.
  50914. */
  50915. prepareDefines(defines: IMaterialBRDFDefines): void;
  50916. /**
  50917. * Get the current class name of the texture useful for serialization or dynamic coding.
  50918. * @returns "PBRClearCoatConfiguration"
  50919. */
  50920. getClassName(): string;
  50921. /**
  50922. * Makes a duplicate of the current configuration into another one.
  50923. * @param brdfConfiguration define the config where to copy the info
  50924. */
  50925. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50926. /**
  50927. * Serializes this BRDF configuration.
  50928. * @returns - An object with the serialized config.
  50929. */
  50930. serialize(): any;
  50931. /**
  50932. * Parses a anisotropy Configuration from a serialized object.
  50933. * @param source - Serialized object.
  50934. * @param scene Defines the scene we are parsing for
  50935. * @param rootUrl Defines the rootUrl to load from
  50936. */
  50937. parse(source: any, scene: Scene, rootUrl: string): void;
  50938. }
  50939. }
  50940. declare module BABYLON {
  50941. /**
  50942. * @hidden
  50943. */
  50944. export interface IMaterialSheenDefines {
  50945. SHEEN: boolean;
  50946. SHEEN_TEXTURE: boolean;
  50947. SHEEN_TEXTUREDIRECTUV: number;
  50948. SHEEN_LINKWITHALBEDO: boolean;
  50949. SHEEN_ROUGHNESS: boolean;
  50950. SHEEN_ALBEDOSCALING: boolean;
  50951. /** @hidden */
  50952. _areTexturesDirty: boolean;
  50953. }
  50954. /**
  50955. * Define the code related to the Sheen parameters of the pbr material.
  50956. */
  50957. export class PBRSheenConfiguration {
  50958. private _isEnabled;
  50959. /**
  50960. * Defines if the material uses sheen.
  50961. */
  50962. isEnabled: boolean;
  50963. private _linkSheenWithAlbedo;
  50964. /**
  50965. * Defines if the sheen is linked to the sheen color.
  50966. */
  50967. linkSheenWithAlbedo: boolean;
  50968. /**
  50969. * Defines the sheen intensity.
  50970. */
  50971. intensity: number;
  50972. /**
  50973. * Defines the sheen color.
  50974. */
  50975. color: Color3;
  50976. private _texture;
  50977. /**
  50978. * Stores the sheen tint values in a texture.
  50979. * rgb is tint
  50980. * a is a intensity
  50981. */
  50982. texture: Nullable<BaseTexture>;
  50983. private _roughness;
  50984. /**
  50985. * Defines the sheen roughness.
  50986. * It is not taken into account if linkSheenWithAlbedo is true.
  50987. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50988. */
  50989. roughness: Nullable<number>;
  50990. private _albedoScaling;
  50991. /**
  50992. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50993. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50994. * making it easier to setup and tweak the effect
  50995. */
  50996. albedoScaling: boolean;
  50997. /** @hidden */
  50998. private _internalMarkAllSubMeshesAsTexturesDirty;
  50999. /** @hidden */
  51000. _markAllSubMeshesAsTexturesDirty(): void;
  51001. /**
  51002. * Instantiate a new istance of clear coat configuration.
  51003. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51004. */
  51005. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51006. /**
  51007. * Specifies that the submesh is ready to be used.
  51008. * @param defines the list of "defines" to update.
  51009. * @param scene defines the scene the material belongs to.
  51010. * @returns - boolean indicating that the submesh is ready or not.
  51011. */
  51012. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51013. /**
  51014. * Checks to see if a texture is used in the material.
  51015. * @param defines the list of "defines" to update.
  51016. * @param scene defines the scene the material belongs to.
  51017. */
  51018. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51019. /**
  51020. * Binds the material data.
  51021. * @param uniformBuffer defines the Uniform buffer to fill in.
  51022. * @param scene defines the scene the material belongs to.
  51023. * @param isFrozen defines wether the material is frozen or not.
  51024. */
  51025. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51026. /**
  51027. * Checks to see if a texture is used in the material.
  51028. * @param texture - Base texture to use.
  51029. * @returns - Boolean specifying if a texture is used in the material.
  51030. */
  51031. hasTexture(texture: BaseTexture): boolean;
  51032. /**
  51033. * Returns an array of the actively used textures.
  51034. * @param activeTextures Array of BaseTextures
  51035. */
  51036. getActiveTextures(activeTextures: BaseTexture[]): void;
  51037. /**
  51038. * Returns the animatable textures.
  51039. * @param animatables Array of animatable textures.
  51040. */
  51041. getAnimatables(animatables: IAnimatable[]): void;
  51042. /**
  51043. * Disposes the resources of the material.
  51044. * @param forceDisposeTextures - Forces the disposal of all textures.
  51045. */
  51046. dispose(forceDisposeTextures?: boolean): void;
  51047. /**
  51048. * Get the current class name of the texture useful for serialization or dynamic coding.
  51049. * @returns "PBRSheenConfiguration"
  51050. */
  51051. getClassName(): string;
  51052. /**
  51053. * Add fallbacks to the effect fallbacks list.
  51054. * @param defines defines the Base texture to use.
  51055. * @param fallbacks defines the current fallback list.
  51056. * @param currentRank defines the current fallback rank.
  51057. * @returns the new fallback rank.
  51058. */
  51059. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51060. /**
  51061. * Add the required uniforms to the current list.
  51062. * @param uniforms defines the current uniform list.
  51063. */
  51064. static AddUniforms(uniforms: string[]): void;
  51065. /**
  51066. * Add the required uniforms to the current buffer.
  51067. * @param uniformBuffer defines the current uniform buffer.
  51068. */
  51069. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51070. /**
  51071. * Add the required samplers to the current list.
  51072. * @param samplers defines the current sampler list.
  51073. */
  51074. static AddSamplers(samplers: string[]): void;
  51075. /**
  51076. * Makes a duplicate of the current configuration into another one.
  51077. * @param sheenConfiguration define the config where to copy the info
  51078. */
  51079. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51080. /**
  51081. * Serializes this BRDF configuration.
  51082. * @returns - An object with the serialized config.
  51083. */
  51084. serialize(): any;
  51085. /**
  51086. * Parses a anisotropy Configuration from a serialized object.
  51087. * @param source - Serialized object.
  51088. * @param scene Defines the scene we are parsing for
  51089. * @param rootUrl Defines the rootUrl to load from
  51090. */
  51091. parse(source: any, scene: Scene, rootUrl: string): void;
  51092. }
  51093. }
  51094. declare module BABYLON {
  51095. /**
  51096. * @hidden
  51097. */
  51098. export interface IMaterialSubSurfaceDefines {
  51099. SUBSURFACE: boolean;
  51100. SS_REFRACTION: boolean;
  51101. SS_TRANSLUCENCY: boolean;
  51102. SS_SCATERRING: boolean;
  51103. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51104. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51105. SS_REFRACTIONMAP_3D: boolean;
  51106. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51107. SS_LODINREFRACTIONALPHA: boolean;
  51108. SS_GAMMAREFRACTION: boolean;
  51109. SS_RGBDREFRACTION: boolean;
  51110. SS_LINEARSPECULARREFRACTION: boolean;
  51111. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51112. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51113. /** @hidden */
  51114. _areTexturesDirty: boolean;
  51115. }
  51116. /**
  51117. * Define the code related to the sub surface parameters of the pbr material.
  51118. */
  51119. export class PBRSubSurfaceConfiguration {
  51120. private _isRefractionEnabled;
  51121. /**
  51122. * Defines if the refraction is enabled in the material.
  51123. */
  51124. isRefractionEnabled: boolean;
  51125. private _isTranslucencyEnabled;
  51126. /**
  51127. * Defines if the translucency is enabled in the material.
  51128. */
  51129. isTranslucencyEnabled: boolean;
  51130. private _isScatteringEnabled;
  51131. /**
  51132. * Defines the refraction intensity of the material.
  51133. * The refraction when enabled replaces the Diffuse part of the material.
  51134. * The intensity helps transitionning between diffuse and refraction.
  51135. */
  51136. refractionIntensity: number;
  51137. /**
  51138. * Defines the translucency intensity of the material.
  51139. * When translucency has been enabled, this defines how much of the "translucency"
  51140. * is addded to the diffuse part of the material.
  51141. */
  51142. translucencyIntensity: number;
  51143. /**
  51144. * Defines the scattering intensity of the material.
  51145. * When scattering has been enabled, this defines how much of the "scattered light"
  51146. * is addded to the diffuse part of the material.
  51147. */
  51148. scatteringIntensity: number;
  51149. private _thicknessTexture;
  51150. /**
  51151. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51152. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51153. * 0 would mean minimumThickness
  51154. * 1 would mean maximumThickness
  51155. * The other channels might be use as a mask to vary the different effects intensity.
  51156. */
  51157. thicknessTexture: Nullable<BaseTexture>;
  51158. private _refractionTexture;
  51159. /**
  51160. * Defines the texture to use for refraction.
  51161. */
  51162. refractionTexture: Nullable<BaseTexture>;
  51163. private _indexOfRefraction;
  51164. /**
  51165. * Defines the index of refraction used in the material.
  51166. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51167. */
  51168. indexOfRefraction: number;
  51169. private _invertRefractionY;
  51170. /**
  51171. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51172. */
  51173. invertRefractionY: boolean;
  51174. private _linkRefractionWithTransparency;
  51175. /**
  51176. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51177. * Materials half opaque for instance using refraction could benefit from this control.
  51178. */
  51179. linkRefractionWithTransparency: boolean;
  51180. /**
  51181. * Defines the minimum thickness stored in the thickness map.
  51182. * If no thickness map is defined, this value will be used to simulate thickness.
  51183. */
  51184. minimumThickness: number;
  51185. /**
  51186. * Defines the maximum thickness stored in the thickness map.
  51187. */
  51188. maximumThickness: number;
  51189. /**
  51190. * Defines the volume tint of the material.
  51191. * This is used for both translucency and scattering.
  51192. */
  51193. tintColor: Color3;
  51194. /**
  51195. * Defines the distance at which the tint color should be found in the media.
  51196. * This is used for refraction only.
  51197. */
  51198. tintColorAtDistance: number;
  51199. /**
  51200. * Defines how far each channel transmit through the media.
  51201. * It is defined as a color to simplify it selection.
  51202. */
  51203. diffusionDistance: Color3;
  51204. private _useMaskFromThicknessTexture;
  51205. /**
  51206. * Stores the intensity of the different subsurface effects in the thickness texture.
  51207. * * the green channel is the translucency intensity.
  51208. * * the blue channel is the scattering intensity.
  51209. * * the alpha channel is the refraction intensity.
  51210. */
  51211. useMaskFromThicknessTexture: boolean;
  51212. /** @hidden */
  51213. private _internalMarkAllSubMeshesAsTexturesDirty;
  51214. /** @hidden */
  51215. _markAllSubMeshesAsTexturesDirty(): void;
  51216. /**
  51217. * Instantiate a new istance of sub surface configuration.
  51218. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51219. */
  51220. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51221. /**
  51222. * Gets wehter the submesh is ready to be used or not.
  51223. * @param defines the list of "defines" to update.
  51224. * @param scene defines the scene the material belongs to.
  51225. * @returns - boolean indicating that the submesh is ready or not.
  51226. */
  51227. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51228. /**
  51229. * Checks to see if a texture is used in the material.
  51230. * @param defines the list of "defines" to update.
  51231. * @param scene defines the scene to the material belongs to.
  51232. */
  51233. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51234. /**
  51235. * Binds the material data.
  51236. * @param uniformBuffer defines the Uniform buffer to fill in.
  51237. * @param scene defines the scene the material belongs to.
  51238. * @param engine defines the engine the material belongs to.
  51239. * @param isFrozen defines wether the material is frozen or not.
  51240. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51241. */
  51242. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51243. /**
  51244. * Unbinds the material from the mesh.
  51245. * @param activeEffect defines the effect that should be unbound from.
  51246. * @returns true if unbound, otherwise false
  51247. */
  51248. unbind(activeEffect: Effect): boolean;
  51249. /**
  51250. * Returns the texture used for refraction or null if none is used.
  51251. * @param scene defines the scene the material belongs to.
  51252. * @returns - Refraction texture if present. If no refraction texture and refraction
  51253. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51254. */
  51255. private _getRefractionTexture;
  51256. /**
  51257. * Returns true if alpha blending should be disabled.
  51258. */
  51259. get disableAlphaBlending(): boolean;
  51260. /**
  51261. * Fills the list of render target textures.
  51262. * @param renderTargets the list of render targets to update
  51263. */
  51264. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51265. /**
  51266. * Checks to see if a texture is used in the material.
  51267. * @param texture - Base texture to use.
  51268. * @returns - Boolean specifying if a texture is used in the material.
  51269. */
  51270. hasTexture(texture: BaseTexture): boolean;
  51271. /**
  51272. * Gets a boolean indicating that current material needs to register RTT
  51273. * @returns true if this uses a render target otherwise false.
  51274. */
  51275. hasRenderTargetTextures(): boolean;
  51276. /**
  51277. * Returns an array of the actively used textures.
  51278. * @param activeTextures Array of BaseTextures
  51279. */
  51280. getActiveTextures(activeTextures: BaseTexture[]): void;
  51281. /**
  51282. * Returns the animatable textures.
  51283. * @param animatables Array of animatable textures.
  51284. */
  51285. getAnimatables(animatables: IAnimatable[]): void;
  51286. /**
  51287. * Disposes the resources of the material.
  51288. * @param forceDisposeTextures - Forces the disposal of all textures.
  51289. */
  51290. dispose(forceDisposeTextures?: boolean): void;
  51291. /**
  51292. * Get the current class name of the texture useful for serialization or dynamic coding.
  51293. * @returns "PBRSubSurfaceConfiguration"
  51294. */
  51295. getClassName(): string;
  51296. /**
  51297. * Add fallbacks to the effect fallbacks list.
  51298. * @param defines defines the Base texture to use.
  51299. * @param fallbacks defines the current fallback list.
  51300. * @param currentRank defines the current fallback rank.
  51301. * @returns the new fallback rank.
  51302. */
  51303. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51304. /**
  51305. * Add the required uniforms to the current list.
  51306. * @param uniforms defines the current uniform list.
  51307. */
  51308. static AddUniforms(uniforms: string[]): void;
  51309. /**
  51310. * Add the required samplers to the current list.
  51311. * @param samplers defines the current sampler list.
  51312. */
  51313. static AddSamplers(samplers: string[]): void;
  51314. /**
  51315. * Add the required uniforms to the current buffer.
  51316. * @param uniformBuffer defines the current uniform buffer.
  51317. */
  51318. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51319. /**
  51320. * Makes a duplicate of the current configuration into another one.
  51321. * @param configuration define the config where to copy the info
  51322. */
  51323. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51324. /**
  51325. * Serializes this Sub Surface configuration.
  51326. * @returns - An object with the serialized config.
  51327. */
  51328. serialize(): any;
  51329. /**
  51330. * Parses a anisotropy Configuration from a serialized object.
  51331. * @param source - Serialized object.
  51332. * @param scene Defines the scene we are parsing for
  51333. * @param rootUrl Defines the rootUrl to load from
  51334. */
  51335. parse(source: any, scene: Scene, rootUrl: string): void;
  51336. }
  51337. }
  51338. declare module BABYLON {
  51339. /** @hidden */
  51340. export var pbrFragmentDeclaration: {
  51341. name: string;
  51342. shader: string;
  51343. };
  51344. }
  51345. declare module BABYLON {
  51346. /** @hidden */
  51347. export var pbrUboDeclaration: {
  51348. name: string;
  51349. shader: string;
  51350. };
  51351. }
  51352. declare module BABYLON {
  51353. /** @hidden */
  51354. export var pbrFragmentExtraDeclaration: {
  51355. name: string;
  51356. shader: string;
  51357. };
  51358. }
  51359. declare module BABYLON {
  51360. /** @hidden */
  51361. export var pbrFragmentSamplersDeclaration: {
  51362. name: string;
  51363. shader: string;
  51364. };
  51365. }
  51366. declare module BABYLON {
  51367. /** @hidden */
  51368. export var pbrHelperFunctions: {
  51369. name: string;
  51370. shader: string;
  51371. };
  51372. }
  51373. declare module BABYLON {
  51374. /** @hidden */
  51375. export var harmonicsFunctions: {
  51376. name: string;
  51377. shader: string;
  51378. };
  51379. }
  51380. declare module BABYLON {
  51381. /** @hidden */
  51382. export var pbrDirectLightingSetupFunctions: {
  51383. name: string;
  51384. shader: string;
  51385. };
  51386. }
  51387. declare module BABYLON {
  51388. /** @hidden */
  51389. export var pbrDirectLightingFalloffFunctions: {
  51390. name: string;
  51391. shader: string;
  51392. };
  51393. }
  51394. declare module BABYLON {
  51395. /** @hidden */
  51396. export var pbrBRDFFunctions: {
  51397. name: string;
  51398. shader: string;
  51399. };
  51400. }
  51401. declare module BABYLON {
  51402. /** @hidden */
  51403. export var pbrDirectLightingFunctions: {
  51404. name: string;
  51405. shader: string;
  51406. };
  51407. }
  51408. declare module BABYLON {
  51409. /** @hidden */
  51410. export var pbrIBLFunctions: {
  51411. name: string;
  51412. shader: string;
  51413. };
  51414. }
  51415. declare module BABYLON {
  51416. /** @hidden */
  51417. export var pbrBlockAlbedoOpacity: {
  51418. name: string;
  51419. shader: string;
  51420. };
  51421. }
  51422. declare module BABYLON {
  51423. /** @hidden */
  51424. export var pbrBlockReflectivity: {
  51425. name: string;
  51426. shader: string;
  51427. };
  51428. }
  51429. declare module BABYLON {
  51430. /** @hidden */
  51431. export var pbrBlockAmbientOcclusion: {
  51432. name: string;
  51433. shader: string;
  51434. };
  51435. }
  51436. declare module BABYLON {
  51437. /** @hidden */
  51438. export var pbrBlockAlphaFresnel: {
  51439. name: string;
  51440. shader: string;
  51441. };
  51442. }
  51443. declare module BABYLON {
  51444. /** @hidden */
  51445. export var pbrBlockAnisotropic: {
  51446. name: string;
  51447. shader: string;
  51448. };
  51449. }
  51450. declare module BABYLON {
  51451. /** @hidden */
  51452. export var pbrBlockReflection: {
  51453. name: string;
  51454. shader: string;
  51455. };
  51456. }
  51457. declare module BABYLON {
  51458. /** @hidden */
  51459. export var pbrBlockSheen: {
  51460. name: string;
  51461. shader: string;
  51462. };
  51463. }
  51464. declare module BABYLON {
  51465. /** @hidden */
  51466. export var pbrBlockClearcoat: {
  51467. name: string;
  51468. shader: string;
  51469. };
  51470. }
  51471. declare module BABYLON {
  51472. /** @hidden */
  51473. export var pbrBlockSubSurface: {
  51474. name: string;
  51475. shader: string;
  51476. };
  51477. }
  51478. declare module BABYLON {
  51479. /** @hidden */
  51480. export var pbrBlockNormalGeometric: {
  51481. name: string;
  51482. shader: string;
  51483. };
  51484. }
  51485. declare module BABYLON {
  51486. /** @hidden */
  51487. export var pbrBlockNormalFinal: {
  51488. name: string;
  51489. shader: string;
  51490. };
  51491. }
  51492. declare module BABYLON {
  51493. /** @hidden */
  51494. export var pbrBlockGeometryInfo: {
  51495. name: string;
  51496. shader: string;
  51497. };
  51498. }
  51499. declare module BABYLON {
  51500. /** @hidden */
  51501. export var pbrBlockReflectance0: {
  51502. name: string;
  51503. shader: string;
  51504. };
  51505. }
  51506. declare module BABYLON {
  51507. /** @hidden */
  51508. export var pbrBlockReflectance: {
  51509. name: string;
  51510. shader: string;
  51511. };
  51512. }
  51513. declare module BABYLON {
  51514. /** @hidden */
  51515. export var pbrBlockDirectLighting: {
  51516. name: string;
  51517. shader: string;
  51518. };
  51519. }
  51520. declare module BABYLON {
  51521. /** @hidden */
  51522. export var pbrBlockFinalLitComponents: {
  51523. name: string;
  51524. shader: string;
  51525. };
  51526. }
  51527. declare module BABYLON {
  51528. /** @hidden */
  51529. export var pbrBlockFinalUnlitComponents: {
  51530. name: string;
  51531. shader: string;
  51532. };
  51533. }
  51534. declare module BABYLON {
  51535. /** @hidden */
  51536. export var pbrBlockFinalColorComposition: {
  51537. name: string;
  51538. shader: string;
  51539. };
  51540. }
  51541. declare module BABYLON {
  51542. /** @hidden */
  51543. export var pbrBlockImageProcessing: {
  51544. name: string;
  51545. shader: string;
  51546. };
  51547. }
  51548. declare module BABYLON {
  51549. /** @hidden */
  51550. export var pbrDebug: {
  51551. name: string;
  51552. shader: string;
  51553. };
  51554. }
  51555. declare module BABYLON {
  51556. /** @hidden */
  51557. export var pbrPixelShader: {
  51558. name: string;
  51559. shader: string;
  51560. };
  51561. }
  51562. declare module BABYLON {
  51563. /** @hidden */
  51564. export var pbrVertexDeclaration: {
  51565. name: string;
  51566. shader: string;
  51567. };
  51568. }
  51569. declare module BABYLON {
  51570. /** @hidden */
  51571. export var pbrVertexShader: {
  51572. name: string;
  51573. shader: string;
  51574. };
  51575. }
  51576. declare module BABYLON {
  51577. /**
  51578. * Manages the defines for the PBR Material.
  51579. * @hidden
  51580. */
  51581. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51582. PBR: boolean;
  51583. MAINUV1: boolean;
  51584. MAINUV2: boolean;
  51585. UV1: boolean;
  51586. UV2: boolean;
  51587. ALBEDO: boolean;
  51588. GAMMAALBEDO: boolean;
  51589. ALBEDODIRECTUV: number;
  51590. VERTEXCOLOR: boolean;
  51591. AMBIENT: boolean;
  51592. AMBIENTDIRECTUV: number;
  51593. AMBIENTINGRAYSCALE: boolean;
  51594. OPACITY: boolean;
  51595. VERTEXALPHA: boolean;
  51596. OPACITYDIRECTUV: number;
  51597. OPACITYRGB: boolean;
  51598. ALPHATEST: boolean;
  51599. DEPTHPREPASS: boolean;
  51600. ALPHABLEND: boolean;
  51601. ALPHAFROMALBEDO: boolean;
  51602. ALPHATESTVALUE: string;
  51603. SPECULAROVERALPHA: boolean;
  51604. RADIANCEOVERALPHA: boolean;
  51605. ALPHAFRESNEL: boolean;
  51606. LINEARALPHAFRESNEL: boolean;
  51607. PREMULTIPLYALPHA: boolean;
  51608. EMISSIVE: boolean;
  51609. EMISSIVEDIRECTUV: number;
  51610. REFLECTIVITY: boolean;
  51611. REFLECTIVITYDIRECTUV: number;
  51612. SPECULARTERM: boolean;
  51613. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51614. MICROSURFACEAUTOMATIC: boolean;
  51615. LODBASEDMICROSFURACE: boolean;
  51616. MICROSURFACEMAP: boolean;
  51617. MICROSURFACEMAPDIRECTUV: number;
  51618. METALLICWORKFLOW: boolean;
  51619. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51620. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51621. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51622. AOSTOREINMETALMAPRED: boolean;
  51623. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51624. ENVIRONMENTBRDF: boolean;
  51625. ENVIRONMENTBRDF_RGBD: boolean;
  51626. NORMAL: boolean;
  51627. TANGENT: boolean;
  51628. BUMP: boolean;
  51629. BUMPDIRECTUV: number;
  51630. OBJECTSPACE_NORMALMAP: boolean;
  51631. PARALLAX: boolean;
  51632. PARALLAXOCCLUSION: boolean;
  51633. NORMALXYSCALE: boolean;
  51634. LIGHTMAP: boolean;
  51635. LIGHTMAPDIRECTUV: number;
  51636. USELIGHTMAPASSHADOWMAP: boolean;
  51637. GAMMALIGHTMAP: boolean;
  51638. RGBDLIGHTMAP: boolean;
  51639. REFLECTION: boolean;
  51640. REFLECTIONMAP_3D: boolean;
  51641. REFLECTIONMAP_SPHERICAL: boolean;
  51642. REFLECTIONMAP_PLANAR: boolean;
  51643. REFLECTIONMAP_CUBIC: boolean;
  51644. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51645. REFLECTIONMAP_PROJECTION: boolean;
  51646. REFLECTIONMAP_SKYBOX: boolean;
  51647. REFLECTIONMAP_EXPLICIT: boolean;
  51648. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51649. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51650. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51651. INVERTCUBICMAP: boolean;
  51652. USESPHERICALFROMREFLECTIONMAP: boolean;
  51653. USEIRRADIANCEMAP: boolean;
  51654. SPHERICAL_HARMONICS: boolean;
  51655. USESPHERICALINVERTEX: boolean;
  51656. REFLECTIONMAP_OPPOSITEZ: boolean;
  51657. LODINREFLECTIONALPHA: boolean;
  51658. GAMMAREFLECTION: boolean;
  51659. RGBDREFLECTION: boolean;
  51660. LINEARSPECULARREFLECTION: boolean;
  51661. RADIANCEOCCLUSION: boolean;
  51662. HORIZONOCCLUSION: boolean;
  51663. INSTANCES: boolean;
  51664. NUM_BONE_INFLUENCERS: number;
  51665. BonesPerMesh: number;
  51666. BONETEXTURE: boolean;
  51667. NONUNIFORMSCALING: boolean;
  51668. MORPHTARGETS: boolean;
  51669. MORPHTARGETS_NORMAL: boolean;
  51670. MORPHTARGETS_TANGENT: boolean;
  51671. MORPHTARGETS_UV: boolean;
  51672. NUM_MORPH_INFLUENCERS: number;
  51673. IMAGEPROCESSING: boolean;
  51674. VIGNETTE: boolean;
  51675. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51676. VIGNETTEBLENDMODEOPAQUE: boolean;
  51677. TONEMAPPING: boolean;
  51678. TONEMAPPING_ACES: boolean;
  51679. CONTRAST: boolean;
  51680. COLORCURVES: boolean;
  51681. COLORGRADING: boolean;
  51682. COLORGRADING3D: boolean;
  51683. SAMPLER3DGREENDEPTH: boolean;
  51684. SAMPLER3DBGRMAP: boolean;
  51685. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51686. EXPOSURE: boolean;
  51687. MULTIVIEW: boolean;
  51688. USEPHYSICALLIGHTFALLOFF: boolean;
  51689. USEGLTFLIGHTFALLOFF: boolean;
  51690. TWOSIDEDLIGHTING: boolean;
  51691. SHADOWFLOAT: boolean;
  51692. CLIPPLANE: boolean;
  51693. CLIPPLANE2: boolean;
  51694. CLIPPLANE3: boolean;
  51695. CLIPPLANE4: boolean;
  51696. CLIPPLANE5: boolean;
  51697. CLIPPLANE6: boolean;
  51698. POINTSIZE: boolean;
  51699. FOG: boolean;
  51700. LOGARITHMICDEPTH: boolean;
  51701. FORCENORMALFORWARD: boolean;
  51702. SPECULARAA: boolean;
  51703. CLEARCOAT: boolean;
  51704. CLEARCOAT_DEFAULTIOR: boolean;
  51705. CLEARCOAT_TEXTURE: boolean;
  51706. CLEARCOAT_TEXTUREDIRECTUV: number;
  51707. CLEARCOAT_BUMP: boolean;
  51708. CLEARCOAT_BUMPDIRECTUV: number;
  51709. CLEARCOAT_TINT: boolean;
  51710. CLEARCOAT_TINT_TEXTURE: boolean;
  51711. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51712. ANISOTROPIC: boolean;
  51713. ANISOTROPIC_TEXTURE: boolean;
  51714. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51715. BRDF_V_HEIGHT_CORRELATED: boolean;
  51716. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51717. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51718. SHEEN: boolean;
  51719. SHEEN_TEXTURE: boolean;
  51720. SHEEN_TEXTUREDIRECTUV: number;
  51721. SHEEN_LINKWITHALBEDO: boolean;
  51722. SHEEN_ROUGHNESS: boolean;
  51723. SHEEN_ALBEDOSCALING: boolean;
  51724. SUBSURFACE: boolean;
  51725. SS_REFRACTION: boolean;
  51726. SS_TRANSLUCENCY: boolean;
  51727. SS_SCATERRING: boolean;
  51728. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51729. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51730. SS_REFRACTIONMAP_3D: boolean;
  51731. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51732. SS_LODINREFRACTIONALPHA: boolean;
  51733. SS_GAMMAREFRACTION: boolean;
  51734. SS_RGBDREFRACTION: boolean;
  51735. SS_LINEARSPECULARREFRACTION: boolean;
  51736. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51737. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51738. UNLIT: boolean;
  51739. DEBUGMODE: number;
  51740. /**
  51741. * Initializes the PBR Material defines.
  51742. */
  51743. constructor();
  51744. /**
  51745. * Resets the PBR Material defines.
  51746. */
  51747. reset(): void;
  51748. }
  51749. /**
  51750. * The Physically based material base class of BJS.
  51751. *
  51752. * This offers the main features of a standard PBR material.
  51753. * For more information, please refer to the documentation :
  51754. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51755. */
  51756. export abstract class PBRBaseMaterial extends PushMaterial {
  51757. /**
  51758. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51759. */
  51760. static readonly PBRMATERIAL_OPAQUE: number;
  51761. /**
  51762. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51763. */
  51764. static readonly PBRMATERIAL_ALPHATEST: number;
  51765. /**
  51766. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51767. */
  51768. static readonly PBRMATERIAL_ALPHABLEND: number;
  51769. /**
  51770. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51771. * They are also discarded below the alpha cutoff threshold to improve performances.
  51772. */
  51773. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51774. /**
  51775. * Defines the default value of how much AO map is occluding the analytical lights
  51776. * (point spot...).
  51777. */
  51778. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51779. /**
  51780. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51781. */
  51782. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51783. /**
  51784. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51785. * to enhance interoperability with other engines.
  51786. */
  51787. static readonly LIGHTFALLOFF_GLTF: number;
  51788. /**
  51789. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51790. * to enhance interoperability with other materials.
  51791. */
  51792. static readonly LIGHTFALLOFF_STANDARD: number;
  51793. /**
  51794. * Intensity of the direct lights e.g. the four lights available in your scene.
  51795. * This impacts both the direct diffuse and specular highlights.
  51796. */
  51797. protected _directIntensity: number;
  51798. /**
  51799. * Intensity of the emissive part of the material.
  51800. * This helps controlling the emissive effect without modifying the emissive color.
  51801. */
  51802. protected _emissiveIntensity: number;
  51803. /**
  51804. * Intensity of the environment e.g. how much the environment will light the object
  51805. * either through harmonics for rough material or through the refelction for shiny ones.
  51806. */
  51807. protected _environmentIntensity: number;
  51808. /**
  51809. * This is a special control allowing the reduction of the specular highlights coming from the
  51810. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51811. */
  51812. protected _specularIntensity: number;
  51813. /**
  51814. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51815. */
  51816. private _lightingInfos;
  51817. /**
  51818. * Debug Control allowing disabling the bump map on this material.
  51819. */
  51820. protected _disableBumpMap: boolean;
  51821. /**
  51822. * AKA Diffuse Texture in standard nomenclature.
  51823. */
  51824. protected _albedoTexture: Nullable<BaseTexture>;
  51825. /**
  51826. * AKA Occlusion Texture in other nomenclature.
  51827. */
  51828. protected _ambientTexture: Nullable<BaseTexture>;
  51829. /**
  51830. * AKA Occlusion Texture Intensity in other nomenclature.
  51831. */
  51832. protected _ambientTextureStrength: number;
  51833. /**
  51834. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51835. * 1 means it completely occludes it
  51836. * 0 mean it has no impact
  51837. */
  51838. protected _ambientTextureImpactOnAnalyticalLights: number;
  51839. /**
  51840. * Stores the alpha values in a texture.
  51841. */
  51842. protected _opacityTexture: Nullable<BaseTexture>;
  51843. /**
  51844. * Stores the reflection values in a texture.
  51845. */
  51846. protected _reflectionTexture: Nullable<BaseTexture>;
  51847. /**
  51848. * Stores the emissive values in a texture.
  51849. */
  51850. protected _emissiveTexture: Nullable<BaseTexture>;
  51851. /**
  51852. * AKA Specular texture in other nomenclature.
  51853. */
  51854. protected _reflectivityTexture: Nullable<BaseTexture>;
  51855. /**
  51856. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51857. */
  51858. protected _metallicTexture: Nullable<BaseTexture>;
  51859. /**
  51860. * Specifies the metallic scalar of the metallic/roughness workflow.
  51861. * Can also be used to scale the metalness values of the metallic texture.
  51862. */
  51863. protected _metallic: Nullable<number>;
  51864. /**
  51865. * Specifies the roughness scalar of the metallic/roughness workflow.
  51866. * Can also be used to scale the roughness values of the metallic texture.
  51867. */
  51868. protected _roughness: Nullable<number>;
  51869. /**
  51870. * Specifies the an F0 factor to help configuring the material F0.
  51871. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51872. * to 0.5 the previously hard coded value stays the same.
  51873. * Can also be used to scale the F0 values of the metallic texture.
  51874. */
  51875. protected _metallicF0Factor: number;
  51876. /**
  51877. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51878. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51879. * your expectation as it multiplies with the texture data.
  51880. */
  51881. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51882. /**
  51883. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51884. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51885. */
  51886. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51887. /**
  51888. * Stores surface normal data used to displace a mesh in a texture.
  51889. */
  51890. protected _bumpTexture: Nullable<BaseTexture>;
  51891. /**
  51892. * Stores the pre-calculated light information of a mesh in a texture.
  51893. */
  51894. protected _lightmapTexture: Nullable<BaseTexture>;
  51895. /**
  51896. * The color of a material in ambient lighting.
  51897. */
  51898. protected _ambientColor: Color3;
  51899. /**
  51900. * AKA Diffuse Color in other nomenclature.
  51901. */
  51902. protected _albedoColor: Color3;
  51903. /**
  51904. * AKA Specular Color in other nomenclature.
  51905. */
  51906. protected _reflectivityColor: Color3;
  51907. /**
  51908. * The color applied when light is reflected from a material.
  51909. */
  51910. protected _reflectionColor: Color3;
  51911. /**
  51912. * The color applied when light is emitted from a material.
  51913. */
  51914. protected _emissiveColor: Color3;
  51915. /**
  51916. * AKA Glossiness in other nomenclature.
  51917. */
  51918. protected _microSurface: number;
  51919. /**
  51920. * Specifies that the material will use the light map as a show map.
  51921. */
  51922. protected _useLightmapAsShadowmap: boolean;
  51923. /**
  51924. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51925. * makes the reflect vector face the model (under horizon).
  51926. */
  51927. protected _useHorizonOcclusion: boolean;
  51928. /**
  51929. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51930. * too much the area relying on ambient texture to define their ambient occlusion.
  51931. */
  51932. protected _useRadianceOcclusion: boolean;
  51933. /**
  51934. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51935. */
  51936. protected _useAlphaFromAlbedoTexture: boolean;
  51937. /**
  51938. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51939. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51940. */
  51941. protected _useSpecularOverAlpha: boolean;
  51942. /**
  51943. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51944. */
  51945. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51946. /**
  51947. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51948. */
  51949. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51950. /**
  51951. * Specifies if the metallic texture contains the roughness information in its green channel.
  51952. */
  51953. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51954. /**
  51955. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51956. */
  51957. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51958. /**
  51959. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51960. */
  51961. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51962. /**
  51963. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51964. */
  51965. protected _useAmbientInGrayScale: boolean;
  51966. /**
  51967. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51968. * The material will try to infer what glossiness each pixel should be.
  51969. */
  51970. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51971. /**
  51972. * Defines the falloff type used in this material.
  51973. * It by default is Physical.
  51974. */
  51975. protected _lightFalloff: number;
  51976. /**
  51977. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51978. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51979. */
  51980. protected _useRadianceOverAlpha: boolean;
  51981. /**
  51982. * Allows using an object space normal map (instead of tangent space).
  51983. */
  51984. protected _useObjectSpaceNormalMap: boolean;
  51985. /**
  51986. * Allows using the bump map in parallax mode.
  51987. */
  51988. protected _useParallax: boolean;
  51989. /**
  51990. * Allows using the bump map in parallax occlusion mode.
  51991. */
  51992. protected _useParallaxOcclusion: boolean;
  51993. /**
  51994. * Controls the scale bias of the parallax mode.
  51995. */
  51996. protected _parallaxScaleBias: number;
  51997. /**
  51998. * If sets to true, disables all the lights affecting the material.
  51999. */
  52000. protected _disableLighting: boolean;
  52001. /**
  52002. * Number of Simultaneous lights allowed on the material.
  52003. */
  52004. protected _maxSimultaneousLights: number;
  52005. /**
  52006. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52007. */
  52008. protected _invertNormalMapX: boolean;
  52009. /**
  52010. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52011. */
  52012. protected _invertNormalMapY: boolean;
  52013. /**
  52014. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52015. */
  52016. protected _twoSidedLighting: boolean;
  52017. /**
  52018. * Defines the alpha limits in alpha test mode.
  52019. */
  52020. protected _alphaCutOff: number;
  52021. /**
  52022. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52023. */
  52024. protected _forceAlphaTest: boolean;
  52025. /**
  52026. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52027. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52028. */
  52029. protected _useAlphaFresnel: boolean;
  52030. /**
  52031. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52032. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52033. */
  52034. protected _useLinearAlphaFresnel: boolean;
  52035. /**
  52036. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52037. * from cos thetav and roughness:
  52038. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52039. */
  52040. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52041. /**
  52042. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52043. */
  52044. protected _forceIrradianceInFragment: boolean;
  52045. /**
  52046. * Force normal to face away from face.
  52047. */
  52048. protected _forceNormalForward: boolean;
  52049. /**
  52050. * Enables specular anti aliasing in the PBR shader.
  52051. * It will both interacts on the Geometry for analytical and IBL lighting.
  52052. * It also prefilter the roughness map based on the bump values.
  52053. */
  52054. protected _enableSpecularAntiAliasing: boolean;
  52055. /**
  52056. * Default configuration related to image processing available in the PBR Material.
  52057. */
  52058. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52059. /**
  52060. * Keep track of the image processing observer to allow dispose and replace.
  52061. */
  52062. private _imageProcessingObserver;
  52063. /**
  52064. * Attaches a new image processing configuration to the PBR Material.
  52065. * @param configuration
  52066. */
  52067. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52068. /**
  52069. * Stores the available render targets.
  52070. */
  52071. private _renderTargets;
  52072. /**
  52073. * Sets the global ambient color for the material used in lighting calculations.
  52074. */
  52075. private _globalAmbientColor;
  52076. /**
  52077. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52078. */
  52079. private _useLogarithmicDepth;
  52080. /**
  52081. * If set to true, no lighting calculations will be applied.
  52082. */
  52083. private _unlit;
  52084. private _debugMode;
  52085. /**
  52086. * @hidden
  52087. * This is reserved for the inspector.
  52088. * Defines the material debug mode.
  52089. * It helps seeing only some components of the material while troubleshooting.
  52090. */
  52091. debugMode: number;
  52092. /**
  52093. * @hidden
  52094. * This is reserved for the inspector.
  52095. * Specify from where on screen the debug mode should start.
  52096. * The value goes from -1 (full screen) to 1 (not visible)
  52097. * It helps with side by side comparison against the final render
  52098. * This defaults to -1
  52099. */
  52100. private debugLimit;
  52101. /**
  52102. * @hidden
  52103. * This is reserved for the inspector.
  52104. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52105. * You can use the factor to better multiply the final value.
  52106. */
  52107. private debugFactor;
  52108. /**
  52109. * Defines the clear coat layer parameters for the material.
  52110. */
  52111. readonly clearCoat: PBRClearCoatConfiguration;
  52112. /**
  52113. * Defines the anisotropic parameters for the material.
  52114. */
  52115. readonly anisotropy: PBRAnisotropicConfiguration;
  52116. /**
  52117. * Defines the BRDF parameters for the material.
  52118. */
  52119. readonly brdf: PBRBRDFConfiguration;
  52120. /**
  52121. * Defines the Sheen parameters for the material.
  52122. */
  52123. readonly sheen: PBRSheenConfiguration;
  52124. /**
  52125. * Defines the SubSurface parameters for the material.
  52126. */
  52127. readonly subSurface: PBRSubSurfaceConfiguration;
  52128. protected _rebuildInParallel: boolean;
  52129. /**
  52130. * Instantiates a new PBRMaterial instance.
  52131. *
  52132. * @param name The material name
  52133. * @param scene The scene the material will be use in.
  52134. */
  52135. constructor(name: string, scene: Scene);
  52136. /**
  52137. * Gets a boolean indicating that current material needs to register RTT
  52138. */
  52139. get hasRenderTargetTextures(): boolean;
  52140. /**
  52141. * Gets the name of the material class.
  52142. */
  52143. getClassName(): string;
  52144. /**
  52145. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52146. */
  52147. get useLogarithmicDepth(): boolean;
  52148. /**
  52149. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52150. */
  52151. set useLogarithmicDepth(value: boolean);
  52152. /**
  52153. * Returns true if alpha blending should be disabled.
  52154. */
  52155. protected get _disableAlphaBlending(): boolean;
  52156. /**
  52157. * Specifies whether or not this material should be rendered in alpha blend mode.
  52158. */
  52159. needAlphaBlending(): boolean;
  52160. /**
  52161. * Specifies whether or not this material should be rendered in alpha test mode.
  52162. */
  52163. needAlphaTesting(): boolean;
  52164. /**
  52165. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52166. */
  52167. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52168. /**
  52169. * Gets the texture used for the alpha test.
  52170. */
  52171. getAlphaTestTexture(): Nullable<BaseTexture>;
  52172. /**
  52173. * Specifies that the submesh is ready to be used.
  52174. * @param mesh - BJS mesh.
  52175. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52176. * @param useInstances - Specifies that instances should be used.
  52177. * @returns - boolean indicating that the submesh is ready or not.
  52178. */
  52179. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52180. /**
  52181. * Specifies if the material uses metallic roughness workflow.
  52182. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52183. */
  52184. isMetallicWorkflow(): boolean;
  52185. private _prepareEffect;
  52186. private _prepareDefines;
  52187. /**
  52188. * Force shader compilation
  52189. */
  52190. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52191. /**
  52192. * Initializes the uniform buffer layout for the shader.
  52193. */
  52194. buildUniformLayout(): void;
  52195. /**
  52196. * Unbinds the material from the mesh
  52197. */
  52198. unbind(): void;
  52199. /**
  52200. * Binds the submesh data.
  52201. * @param world - The world matrix.
  52202. * @param mesh - The BJS mesh.
  52203. * @param subMesh - A submesh of the BJS mesh.
  52204. */
  52205. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52206. /**
  52207. * Returns the animatable textures.
  52208. * @returns - Array of animatable textures.
  52209. */
  52210. getAnimatables(): IAnimatable[];
  52211. /**
  52212. * Returns the texture used for reflections.
  52213. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52214. */
  52215. private _getReflectionTexture;
  52216. /**
  52217. * Returns an array of the actively used textures.
  52218. * @returns - Array of BaseTextures
  52219. */
  52220. getActiveTextures(): BaseTexture[];
  52221. /**
  52222. * Checks to see if a texture is used in the material.
  52223. * @param texture - Base texture to use.
  52224. * @returns - Boolean specifying if a texture is used in the material.
  52225. */
  52226. hasTexture(texture: BaseTexture): boolean;
  52227. /**
  52228. * Disposes the resources of the material.
  52229. * @param forceDisposeEffect - Forces the disposal of effects.
  52230. * @param forceDisposeTextures - Forces the disposal of all textures.
  52231. */
  52232. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52233. }
  52234. }
  52235. declare module BABYLON {
  52236. /**
  52237. * The Physically based material of BJS.
  52238. *
  52239. * This offers the main features of a standard PBR material.
  52240. * For more information, please refer to the documentation :
  52241. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52242. */
  52243. export class PBRMaterial extends PBRBaseMaterial {
  52244. /**
  52245. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52246. */
  52247. static readonly PBRMATERIAL_OPAQUE: number;
  52248. /**
  52249. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52250. */
  52251. static readonly PBRMATERIAL_ALPHATEST: number;
  52252. /**
  52253. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52254. */
  52255. static readonly PBRMATERIAL_ALPHABLEND: number;
  52256. /**
  52257. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52258. * They are also discarded below the alpha cutoff threshold to improve performances.
  52259. */
  52260. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52261. /**
  52262. * Defines the default value of how much AO map is occluding the analytical lights
  52263. * (point spot...).
  52264. */
  52265. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52266. /**
  52267. * Intensity of the direct lights e.g. the four lights available in your scene.
  52268. * This impacts both the direct diffuse and specular highlights.
  52269. */
  52270. directIntensity: number;
  52271. /**
  52272. * Intensity of the emissive part of the material.
  52273. * This helps controlling the emissive effect without modifying the emissive color.
  52274. */
  52275. emissiveIntensity: number;
  52276. /**
  52277. * Intensity of the environment e.g. how much the environment will light the object
  52278. * either through harmonics for rough material or through the refelction for shiny ones.
  52279. */
  52280. environmentIntensity: number;
  52281. /**
  52282. * This is a special control allowing the reduction of the specular highlights coming from the
  52283. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52284. */
  52285. specularIntensity: number;
  52286. /**
  52287. * Debug Control allowing disabling the bump map on this material.
  52288. */
  52289. disableBumpMap: boolean;
  52290. /**
  52291. * AKA Diffuse Texture in standard nomenclature.
  52292. */
  52293. albedoTexture: BaseTexture;
  52294. /**
  52295. * AKA Occlusion Texture in other nomenclature.
  52296. */
  52297. ambientTexture: BaseTexture;
  52298. /**
  52299. * AKA Occlusion Texture Intensity in other nomenclature.
  52300. */
  52301. ambientTextureStrength: number;
  52302. /**
  52303. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52304. * 1 means it completely occludes it
  52305. * 0 mean it has no impact
  52306. */
  52307. ambientTextureImpactOnAnalyticalLights: number;
  52308. /**
  52309. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52310. */
  52311. opacityTexture: BaseTexture;
  52312. /**
  52313. * Stores the reflection values in a texture.
  52314. */
  52315. reflectionTexture: Nullable<BaseTexture>;
  52316. /**
  52317. * Stores the emissive values in a texture.
  52318. */
  52319. emissiveTexture: BaseTexture;
  52320. /**
  52321. * AKA Specular texture in other nomenclature.
  52322. */
  52323. reflectivityTexture: BaseTexture;
  52324. /**
  52325. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52326. */
  52327. metallicTexture: BaseTexture;
  52328. /**
  52329. * Specifies the metallic scalar of the metallic/roughness workflow.
  52330. * Can also be used to scale the metalness values of the metallic texture.
  52331. */
  52332. metallic: Nullable<number>;
  52333. /**
  52334. * Specifies the roughness scalar of the metallic/roughness workflow.
  52335. * Can also be used to scale the roughness values of the metallic texture.
  52336. */
  52337. roughness: Nullable<number>;
  52338. /**
  52339. * Specifies the an F0 factor to help configuring the material F0.
  52340. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52341. * to 0.5 the previously hard coded value stays the same.
  52342. * Can also be used to scale the F0 values of the metallic texture.
  52343. */
  52344. metallicF0Factor: number;
  52345. /**
  52346. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52347. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52348. * your expectation as it multiplies with the texture data.
  52349. */
  52350. useMetallicF0FactorFromMetallicTexture: boolean;
  52351. /**
  52352. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52353. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52354. */
  52355. microSurfaceTexture: BaseTexture;
  52356. /**
  52357. * Stores surface normal data used to displace a mesh in a texture.
  52358. */
  52359. bumpTexture: BaseTexture;
  52360. /**
  52361. * Stores the pre-calculated light information of a mesh in a texture.
  52362. */
  52363. lightmapTexture: BaseTexture;
  52364. /**
  52365. * Stores the refracted light information in a texture.
  52366. */
  52367. get refractionTexture(): Nullable<BaseTexture>;
  52368. set refractionTexture(value: Nullable<BaseTexture>);
  52369. /**
  52370. * The color of a material in ambient lighting.
  52371. */
  52372. ambientColor: Color3;
  52373. /**
  52374. * AKA Diffuse Color in other nomenclature.
  52375. */
  52376. albedoColor: Color3;
  52377. /**
  52378. * AKA Specular Color in other nomenclature.
  52379. */
  52380. reflectivityColor: Color3;
  52381. /**
  52382. * The color reflected from the material.
  52383. */
  52384. reflectionColor: Color3;
  52385. /**
  52386. * The color emitted from the material.
  52387. */
  52388. emissiveColor: Color3;
  52389. /**
  52390. * AKA Glossiness in other nomenclature.
  52391. */
  52392. microSurface: number;
  52393. /**
  52394. * source material index of refraction (IOR)' / 'destination material IOR.
  52395. */
  52396. get indexOfRefraction(): number;
  52397. set indexOfRefraction(value: number);
  52398. /**
  52399. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52400. */
  52401. get invertRefractionY(): boolean;
  52402. set invertRefractionY(value: boolean);
  52403. /**
  52404. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52405. * Materials half opaque for instance using refraction could benefit from this control.
  52406. */
  52407. get linkRefractionWithTransparency(): boolean;
  52408. set linkRefractionWithTransparency(value: boolean);
  52409. /**
  52410. * If true, the light map contains occlusion information instead of lighting info.
  52411. */
  52412. useLightmapAsShadowmap: boolean;
  52413. /**
  52414. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52415. */
  52416. useAlphaFromAlbedoTexture: boolean;
  52417. /**
  52418. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52419. */
  52420. forceAlphaTest: boolean;
  52421. /**
  52422. * Defines the alpha limits in alpha test mode.
  52423. */
  52424. alphaCutOff: number;
  52425. /**
  52426. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52427. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52428. */
  52429. useSpecularOverAlpha: boolean;
  52430. /**
  52431. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52432. */
  52433. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52434. /**
  52435. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52436. */
  52437. useRoughnessFromMetallicTextureAlpha: boolean;
  52438. /**
  52439. * Specifies if the metallic texture contains the roughness information in its green channel.
  52440. */
  52441. useRoughnessFromMetallicTextureGreen: boolean;
  52442. /**
  52443. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52444. */
  52445. useMetallnessFromMetallicTextureBlue: boolean;
  52446. /**
  52447. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52448. */
  52449. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52450. /**
  52451. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52452. */
  52453. useAmbientInGrayScale: boolean;
  52454. /**
  52455. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52456. * The material will try to infer what glossiness each pixel should be.
  52457. */
  52458. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52459. /**
  52460. * BJS is using an harcoded light falloff based on a manually sets up range.
  52461. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52462. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52463. */
  52464. get usePhysicalLightFalloff(): boolean;
  52465. /**
  52466. * BJS is using an harcoded light falloff based on a manually sets up range.
  52467. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52468. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52469. */
  52470. set usePhysicalLightFalloff(value: boolean);
  52471. /**
  52472. * In order to support the falloff compatibility with gltf, a special mode has been added
  52473. * to reproduce the gltf light falloff.
  52474. */
  52475. get useGLTFLightFalloff(): boolean;
  52476. /**
  52477. * In order to support the falloff compatibility with gltf, a special mode has been added
  52478. * to reproduce the gltf light falloff.
  52479. */
  52480. set useGLTFLightFalloff(value: boolean);
  52481. /**
  52482. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52483. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52484. */
  52485. useRadianceOverAlpha: boolean;
  52486. /**
  52487. * Allows using an object space normal map (instead of tangent space).
  52488. */
  52489. useObjectSpaceNormalMap: boolean;
  52490. /**
  52491. * Allows using the bump map in parallax mode.
  52492. */
  52493. useParallax: boolean;
  52494. /**
  52495. * Allows using the bump map in parallax occlusion mode.
  52496. */
  52497. useParallaxOcclusion: boolean;
  52498. /**
  52499. * Controls the scale bias of the parallax mode.
  52500. */
  52501. parallaxScaleBias: number;
  52502. /**
  52503. * If sets to true, disables all the lights affecting the material.
  52504. */
  52505. disableLighting: boolean;
  52506. /**
  52507. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52508. */
  52509. forceIrradianceInFragment: boolean;
  52510. /**
  52511. * Number of Simultaneous lights allowed on the material.
  52512. */
  52513. maxSimultaneousLights: number;
  52514. /**
  52515. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52516. */
  52517. invertNormalMapX: boolean;
  52518. /**
  52519. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52520. */
  52521. invertNormalMapY: boolean;
  52522. /**
  52523. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52524. */
  52525. twoSidedLighting: boolean;
  52526. /**
  52527. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52528. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52529. */
  52530. useAlphaFresnel: boolean;
  52531. /**
  52532. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52533. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52534. */
  52535. useLinearAlphaFresnel: boolean;
  52536. /**
  52537. * Let user defines the brdf lookup texture used for IBL.
  52538. * A default 8bit version is embedded but you could point at :
  52539. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52540. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52541. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52542. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52543. */
  52544. environmentBRDFTexture: Nullable<BaseTexture>;
  52545. /**
  52546. * Force normal to face away from face.
  52547. */
  52548. forceNormalForward: boolean;
  52549. /**
  52550. * Enables specular anti aliasing in the PBR shader.
  52551. * It will both interacts on the Geometry for analytical and IBL lighting.
  52552. * It also prefilter the roughness map based on the bump values.
  52553. */
  52554. enableSpecularAntiAliasing: boolean;
  52555. /**
  52556. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52557. * makes the reflect vector face the model (under horizon).
  52558. */
  52559. useHorizonOcclusion: boolean;
  52560. /**
  52561. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52562. * too much the area relying on ambient texture to define their ambient occlusion.
  52563. */
  52564. useRadianceOcclusion: boolean;
  52565. /**
  52566. * If set to true, no lighting calculations will be applied.
  52567. */
  52568. unlit: boolean;
  52569. /**
  52570. * Gets the image processing configuration used either in this material.
  52571. */
  52572. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52573. /**
  52574. * Sets the Default image processing configuration used either in the this material.
  52575. *
  52576. * If sets to null, the scene one is in use.
  52577. */
  52578. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52579. /**
  52580. * Gets wether the color curves effect is enabled.
  52581. */
  52582. get cameraColorCurvesEnabled(): boolean;
  52583. /**
  52584. * Sets wether the color curves effect is enabled.
  52585. */
  52586. set cameraColorCurvesEnabled(value: boolean);
  52587. /**
  52588. * Gets wether the color grading effect is enabled.
  52589. */
  52590. get cameraColorGradingEnabled(): boolean;
  52591. /**
  52592. * Gets wether the color grading effect is enabled.
  52593. */
  52594. set cameraColorGradingEnabled(value: boolean);
  52595. /**
  52596. * Gets wether tonemapping is enabled or not.
  52597. */
  52598. get cameraToneMappingEnabled(): boolean;
  52599. /**
  52600. * Sets wether tonemapping is enabled or not
  52601. */
  52602. set cameraToneMappingEnabled(value: boolean);
  52603. /**
  52604. * The camera exposure used on this material.
  52605. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52606. * This corresponds to a photographic exposure.
  52607. */
  52608. get cameraExposure(): number;
  52609. /**
  52610. * The camera exposure used on this material.
  52611. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52612. * This corresponds to a photographic exposure.
  52613. */
  52614. set cameraExposure(value: number);
  52615. /**
  52616. * Gets The camera contrast used on this material.
  52617. */
  52618. get cameraContrast(): number;
  52619. /**
  52620. * Sets The camera contrast used on this material.
  52621. */
  52622. set cameraContrast(value: number);
  52623. /**
  52624. * Gets the Color Grading 2D Lookup Texture.
  52625. */
  52626. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52627. /**
  52628. * Sets the Color Grading 2D Lookup Texture.
  52629. */
  52630. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52631. /**
  52632. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52633. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52634. * 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;
  52635. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52636. */
  52637. get cameraColorCurves(): Nullable<ColorCurves>;
  52638. /**
  52639. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52640. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52641. * 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;
  52642. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52643. */
  52644. set cameraColorCurves(value: Nullable<ColorCurves>);
  52645. /**
  52646. * Instantiates a new PBRMaterial instance.
  52647. *
  52648. * @param name The material name
  52649. * @param scene The scene the material will be use in.
  52650. */
  52651. constructor(name: string, scene: Scene);
  52652. /**
  52653. * Returns the name of this material class.
  52654. */
  52655. getClassName(): string;
  52656. /**
  52657. * Makes a duplicate of the current material.
  52658. * @param name - name to use for the new material.
  52659. */
  52660. clone(name: string): PBRMaterial;
  52661. /**
  52662. * Serializes this PBR Material.
  52663. * @returns - An object with the serialized material.
  52664. */
  52665. serialize(): any;
  52666. /**
  52667. * Parses a PBR Material from a serialized object.
  52668. * @param source - Serialized object.
  52669. * @param scene - BJS scene instance.
  52670. * @param rootUrl - url for the scene object
  52671. * @returns - PBRMaterial
  52672. */
  52673. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52674. }
  52675. }
  52676. declare module BABYLON {
  52677. /**
  52678. * Direct draw surface info
  52679. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52680. */
  52681. export interface DDSInfo {
  52682. /**
  52683. * Width of the texture
  52684. */
  52685. width: number;
  52686. /**
  52687. * Width of the texture
  52688. */
  52689. height: number;
  52690. /**
  52691. * Number of Mipmaps for the texture
  52692. * @see https://en.wikipedia.org/wiki/Mipmap
  52693. */
  52694. mipmapCount: number;
  52695. /**
  52696. * If the textures format is a known fourCC format
  52697. * @see https://www.fourcc.org/
  52698. */
  52699. isFourCC: boolean;
  52700. /**
  52701. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52702. */
  52703. isRGB: boolean;
  52704. /**
  52705. * If the texture is a lumincance format
  52706. */
  52707. isLuminance: boolean;
  52708. /**
  52709. * If this is a cube texture
  52710. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52711. */
  52712. isCube: boolean;
  52713. /**
  52714. * If the texture is a compressed format eg. FOURCC_DXT1
  52715. */
  52716. isCompressed: boolean;
  52717. /**
  52718. * The dxgiFormat of the texture
  52719. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52720. */
  52721. dxgiFormat: number;
  52722. /**
  52723. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52724. */
  52725. textureType: number;
  52726. /**
  52727. * Sphericle polynomial created for the dds texture
  52728. */
  52729. sphericalPolynomial?: SphericalPolynomial;
  52730. }
  52731. /**
  52732. * Class used to provide DDS decompression tools
  52733. */
  52734. export class DDSTools {
  52735. /**
  52736. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52737. */
  52738. static StoreLODInAlphaChannel: boolean;
  52739. /**
  52740. * Gets DDS information from an array buffer
  52741. * @param data defines the array buffer view to read data from
  52742. * @returns the DDS information
  52743. */
  52744. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52745. private static _FloatView;
  52746. private static _Int32View;
  52747. private static _ToHalfFloat;
  52748. private static _FromHalfFloat;
  52749. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52750. private static _GetHalfFloatRGBAArrayBuffer;
  52751. private static _GetFloatRGBAArrayBuffer;
  52752. private static _GetFloatAsUIntRGBAArrayBuffer;
  52753. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52754. private static _GetRGBAArrayBuffer;
  52755. private static _ExtractLongWordOrder;
  52756. private static _GetRGBArrayBuffer;
  52757. private static _GetLuminanceArrayBuffer;
  52758. /**
  52759. * Uploads DDS Levels to a Babylon Texture
  52760. * @hidden
  52761. */
  52762. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52763. }
  52764. interface ThinEngine {
  52765. /**
  52766. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52767. * @param rootUrl defines the url where the file to load is located
  52768. * @param scene defines the current scene
  52769. * @param lodScale defines scale to apply to the mip map selection
  52770. * @param lodOffset defines offset to apply to the mip map selection
  52771. * @param onLoad defines an optional callback raised when the texture is loaded
  52772. * @param onError defines an optional callback raised if there is an issue to load the texture
  52773. * @param format defines the format of the data
  52774. * @param forcedExtension defines the extension to use to pick the right loader
  52775. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52776. * @returns the cube texture as an InternalTexture
  52777. */
  52778. 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;
  52779. }
  52780. }
  52781. declare module BABYLON {
  52782. /**
  52783. * Implementation of the DDS Texture Loader.
  52784. * @hidden
  52785. */
  52786. export class _DDSTextureLoader implements IInternalTextureLoader {
  52787. /**
  52788. * Defines wether the loader supports cascade loading the different faces.
  52789. */
  52790. readonly supportCascades: boolean;
  52791. /**
  52792. * This returns if the loader support the current file information.
  52793. * @param extension defines the file extension of the file being loaded
  52794. * @returns true if the loader can load the specified file
  52795. */
  52796. canLoad(extension: string): boolean;
  52797. /**
  52798. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52799. * @param data contains the texture data
  52800. * @param texture defines the BabylonJS internal texture
  52801. * @param createPolynomials will be true if polynomials have been requested
  52802. * @param onLoad defines the callback to trigger once the texture is ready
  52803. * @param onError defines the callback to trigger in case of error
  52804. */
  52805. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52806. /**
  52807. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52808. * @param data contains the texture data
  52809. * @param texture defines the BabylonJS internal texture
  52810. * @param callback defines the method to call once ready to upload
  52811. */
  52812. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52813. }
  52814. }
  52815. declare module BABYLON {
  52816. /**
  52817. * Implementation of the ENV Texture Loader.
  52818. * @hidden
  52819. */
  52820. export class _ENVTextureLoader implements IInternalTextureLoader {
  52821. /**
  52822. * Defines wether the loader supports cascade loading the different faces.
  52823. */
  52824. readonly supportCascades: boolean;
  52825. /**
  52826. * This returns if the loader support the current file information.
  52827. * @param extension defines the file extension of the file being loaded
  52828. * @returns true if the loader can load the specified file
  52829. */
  52830. canLoad(extension: string): boolean;
  52831. /**
  52832. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52833. * @param data contains the texture data
  52834. * @param texture defines the BabylonJS internal texture
  52835. * @param createPolynomials will be true if polynomials have been requested
  52836. * @param onLoad defines the callback to trigger once the texture is ready
  52837. * @param onError defines the callback to trigger in case of error
  52838. */
  52839. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52840. /**
  52841. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52842. * @param data contains the texture data
  52843. * @param texture defines the BabylonJS internal texture
  52844. * @param callback defines the method to call once ready to upload
  52845. */
  52846. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52847. }
  52848. }
  52849. declare module BABYLON {
  52850. /**
  52851. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52852. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52853. */
  52854. export class KhronosTextureContainer {
  52855. /** contents of the KTX container file */
  52856. data: ArrayBufferView;
  52857. private static HEADER_LEN;
  52858. private static COMPRESSED_2D;
  52859. private static COMPRESSED_3D;
  52860. private static TEX_2D;
  52861. private static TEX_3D;
  52862. /**
  52863. * Gets the openGL type
  52864. */
  52865. glType: number;
  52866. /**
  52867. * Gets the openGL type size
  52868. */
  52869. glTypeSize: number;
  52870. /**
  52871. * Gets the openGL format
  52872. */
  52873. glFormat: number;
  52874. /**
  52875. * Gets the openGL internal format
  52876. */
  52877. glInternalFormat: number;
  52878. /**
  52879. * Gets the base internal format
  52880. */
  52881. glBaseInternalFormat: number;
  52882. /**
  52883. * Gets image width in pixel
  52884. */
  52885. pixelWidth: number;
  52886. /**
  52887. * Gets image height in pixel
  52888. */
  52889. pixelHeight: number;
  52890. /**
  52891. * Gets image depth in pixels
  52892. */
  52893. pixelDepth: number;
  52894. /**
  52895. * Gets the number of array elements
  52896. */
  52897. numberOfArrayElements: number;
  52898. /**
  52899. * Gets the number of faces
  52900. */
  52901. numberOfFaces: number;
  52902. /**
  52903. * Gets the number of mipmap levels
  52904. */
  52905. numberOfMipmapLevels: number;
  52906. /**
  52907. * Gets the bytes of key value data
  52908. */
  52909. bytesOfKeyValueData: number;
  52910. /**
  52911. * Gets the load type
  52912. */
  52913. loadType: number;
  52914. /**
  52915. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52916. */
  52917. isInvalid: boolean;
  52918. /**
  52919. * Creates a new KhronosTextureContainer
  52920. * @param data contents of the KTX container file
  52921. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52922. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52923. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52924. */
  52925. constructor(
  52926. /** contents of the KTX container file */
  52927. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52928. /**
  52929. * Uploads KTX content to a Babylon Texture.
  52930. * It is assumed that the texture has already been created & is currently bound
  52931. * @hidden
  52932. */
  52933. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52934. private _upload2DCompressedLevels;
  52935. /**
  52936. * Checks if the given data starts with a KTX file identifier.
  52937. * @param data the data to check
  52938. * @returns true if the data is a KTX file or false otherwise
  52939. */
  52940. static IsValid(data: ArrayBufferView): boolean;
  52941. }
  52942. }
  52943. declare module BABYLON {
  52944. /**
  52945. * Class for loading KTX2 files
  52946. * !!! Experimental Extension Subject to Changes !!!
  52947. * @hidden
  52948. */
  52949. export class KhronosTextureContainer2 {
  52950. private static _ModulePromise;
  52951. private static _TranscodeFormat;
  52952. constructor(engine: ThinEngine);
  52953. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52954. private _determineTranscodeFormat;
  52955. /**
  52956. * Checks if the given data starts with a KTX2 file identifier.
  52957. * @param data the data to check
  52958. * @returns true if the data is a KTX2 file or false otherwise
  52959. */
  52960. static IsValid(data: ArrayBufferView): boolean;
  52961. }
  52962. }
  52963. declare module BABYLON {
  52964. /**
  52965. * Implementation of the KTX Texture Loader.
  52966. * @hidden
  52967. */
  52968. export class _KTXTextureLoader implements IInternalTextureLoader {
  52969. /**
  52970. * Defines wether the loader supports cascade loading the different faces.
  52971. */
  52972. readonly supportCascades: boolean;
  52973. /**
  52974. * This returns if the loader support the current file information.
  52975. * @param extension defines the file extension of the file being loaded
  52976. * @returns true if the loader can load the specified file
  52977. */
  52978. canLoad(extension: string): boolean;
  52979. /**
  52980. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52981. * @param data contains the texture data
  52982. * @param texture defines the BabylonJS internal texture
  52983. * @param createPolynomials will be true if polynomials have been requested
  52984. * @param onLoad defines the callback to trigger once the texture is ready
  52985. * @param onError defines the callback to trigger in case of error
  52986. */
  52987. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52988. /**
  52989. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52990. * @param data contains the texture data
  52991. * @param texture defines the BabylonJS internal texture
  52992. * @param callback defines the method to call once ready to upload
  52993. */
  52994. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52995. }
  52996. }
  52997. declare module BABYLON {
  52998. /** @hidden */
  52999. export var _forceSceneHelpersToBundle: boolean;
  53000. interface Scene {
  53001. /**
  53002. * Creates a default light for the scene.
  53003. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53004. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53005. */
  53006. createDefaultLight(replace?: boolean): void;
  53007. /**
  53008. * Creates a default camera for the scene.
  53009. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53010. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53011. * @param replace has default false, when true replaces the active camera in the scene
  53012. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53013. */
  53014. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53015. /**
  53016. * Creates a default camera and a default light.
  53017. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53018. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53019. * @param replace has the default false, when true replaces the active camera/light in the scene
  53020. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53021. */
  53022. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53023. /**
  53024. * Creates a new sky box
  53025. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53026. * @param environmentTexture defines the texture to use as environment texture
  53027. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53028. * @param scale defines the overall scale of the skybox
  53029. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53030. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53031. * @returns a new mesh holding the sky box
  53032. */
  53033. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53034. /**
  53035. * Creates a new environment
  53036. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53037. * @param options defines the options you can use to configure the environment
  53038. * @returns the new EnvironmentHelper
  53039. */
  53040. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53041. /**
  53042. * Creates a new VREXperienceHelper
  53043. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53044. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53045. * @returns a new VREXperienceHelper
  53046. */
  53047. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53048. /**
  53049. * Creates a new WebXRDefaultExperience
  53050. * @see http://doc.babylonjs.com/how_to/webxr
  53051. * @param options experience options
  53052. * @returns a promise for a new WebXRDefaultExperience
  53053. */
  53054. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53055. }
  53056. }
  53057. declare module BABYLON {
  53058. /**
  53059. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53060. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53061. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53062. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53063. */
  53064. export class VideoDome extends TransformNode {
  53065. /**
  53066. * Define the video source as a Monoscopic panoramic 360 video.
  53067. */
  53068. static readonly MODE_MONOSCOPIC: number;
  53069. /**
  53070. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53071. */
  53072. static readonly MODE_TOPBOTTOM: number;
  53073. /**
  53074. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53075. */
  53076. static readonly MODE_SIDEBYSIDE: number;
  53077. private _halfDome;
  53078. private _useDirectMapping;
  53079. /**
  53080. * The video texture being displayed on the sphere
  53081. */
  53082. protected _videoTexture: VideoTexture;
  53083. /**
  53084. * Gets the video texture being displayed on the sphere
  53085. */
  53086. get videoTexture(): VideoTexture;
  53087. /**
  53088. * The skybox material
  53089. */
  53090. protected _material: BackgroundMaterial;
  53091. /**
  53092. * The surface used for the skybox
  53093. */
  53094. protected _mesh: Mesh;
  53095. /**
  53096. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53097. */
  53098. private _halfDomeMask;
  53099. /**
  53100. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53101. * Also see the options.resolution property.
  53102. */
  53103. get fovMultiplier(): number;
  53104. set fovMultiplier(value: number);
  53105. private _videoMode;
  53106. /**
  53107. * Gets or set the current video mode for the video. It can be:
  53108. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53109. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53110. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53111. */
  53112. get videoMode(): number;
  53113. set videoMode(value: number);
  53114. /**
  53115. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53116. *
  53117. */
  53118. get halfDome(): boolean;
  53119. /**
  53120. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53121. */
  53122. set halfDome(enabled: boolean);
  53123. /**
  53124. * Oberserver used in Stereoscopic VR Mode.
  53125. */
  53126. private _onBeforeCameraRenderObserver;
  53127. /**
  53128. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53129. * @param name Element's name, child elements will append suffixes for their own names.
  53130. * @param urlsOrVideo defines the url(s) or the video element to use
  53131. * @param options An object containing optional or exposed sub element properties
  53132. */
  53133. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53134. resolution?: number;
  53135. clickToPlay?: boolean;
  53136. autoPlay?: boolean;
  53137. loop?: boolean;
  53138. size?: number;
  53139. poster?: string;
  53140. faceForward?: boolean;
  53141. useDirectMapping?: boolean;
  53142. halfDomeMode?: boolean;
  53143. }, scene: Scene);
  53144. private _changeVideoMode;
  53145. /**
  53146. * Releases resources associated with this node.
  53147. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53148. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53149. */
  53150. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53151. }
  53152. }
  53153. declare module BABYLON {
  53154. /**
  53155. * This class can be used to get instrumentation data from a Babylon engine
  53156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53157. */
  53158. export class EngineInstrumentation implements IDisposable {
  53159. /**
  53160. * Define the instrumented engine.
  53161. */
  53162. engine: Engine;
  53163. private _captureGPUFrameTime;
  53164. private _gpuFrameTimeToken;
  53165. private _gpuFrameTime;
  53166. private _captureShaderCompilationTime;
  53167. private _shaderCompilationTime;
  53168. private _onBeginFrameObserver;
  53169. private _onEndFrameObserver;
  53170. private _onBeforeShaderCompilationObserver;
  53171. private _onAfterShaderCompilationObserver;
  53172. /**
  53173. * Gets the perf counter used for GPU frame time
  53174. */
  53175. get gpuFrameTimeCounter(): PerfCounter;
  53176. /**
  53177. * Gets the GPU frame time capture status
  53178. */
  53179. get captureGPUFrameTime(): boolean;
  53180. /**
  53181. * Enable or disable the GPU frame time capture
  53182. */
  53183. set captureGPUFrameTime(value: boolean);
  53184. /**
  53185. * Gets the perf counter used for shader compilation time
  53186. */
  53187. get shaderCompilationTimeCounter(): PerfCounter;
  53188. /**
  53189. * Gets the shader compilation time capture status
  53190. */
  53191. get captureShaderCompilationTime(): boolean;
  53192. /**
  53193. * Enable or disable the shader compilation time capture
  53194. */
  53195. set captureShaderCompilationTime(value: boolean);
  53196. /**
  53197. * Instantiates a new engine instrumentation.
  53198. * This class can be used to get instrumentation data from a Babylon engine
  53199. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53200. * @param engine Defines the engine to instrument
  53201. */
  53202. constructor(
  53203. /**
  53204. * Define the instrumented engine.
  53205. */
  53206. engine: Engine);
  53207. /**
  53208. * Dispose and release associated resources.
  53209. */
  53210. dispose(): void;
  53211. }
  53212. }
  53213. declare module BABYLON {
  53214. /**
  53215. * This class can be used to get instrumentation data from a Babylon engine
  53216. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53217. */
  53218. export class SceneInstrumentation implements IDisposable {
  53219. /**
  53220. * Defines the scene to instrument
  53221. */
  53222. scene: Scene;
  53223. private _captureActiveMeshesEvaluationTime;
  53224. private _activeMeshesEvaluationTime;
  53225. private _captureRenderTargetsRenderTime;
  53226. private _renderTargetsRenderTime;
  53227. private _captureFrameTime;
  53228. private _frameTime;
  53229. private _captureRenderTime;
  53230. private _renderTime;
  53231. private _captureInterFrameTime;
  53232. private _interFrameTime;
  53233. private _captureParticlesRenderTime;
  53234. private _particlesRenderTime;
  53235. private _captureSpritesRenderTime;
  53236. private _spritesRenderTime;
  53237. private _capturePhysicsTime;
  53238. private _physicsTime;
  53239. private _captureAnimationsTime;
  53240. private _animationsTime;
  53241. private _captureCameraRenderTime;
  53242. private _cameraRenderTime;
  53243. private _onBeforeActiveMeshesEvaluationObserver;
  53244. private _onAfterActiveMeshesEvaluationObserver;
  53245. private _onBeforeRenderTargetsRenderObserver;
  53246. private _onAfterRenderTargetsRenderObserver;
  53247. private _onAfterRenderObserver;
  53248. private _onBeforeDrawPhaseObserver;
  53249. private _onAfterDrawPhaseObserver;
  53250. private _onBeforeAnimationsObserver;
  53251. private _onBeforeParticlesRenderingObserver;
  53252. private _onAfterParticlesRenderingObserver;
  53253. private _onBeforeSpritesRenderingObserver;
  53254. private _onAfterSpritesRenderingObserver;
  53255. private _onBeforePhysicsObserver;
  53256. private _onAfterPhysicsObserver;
  53257. private _onAfterAnimationsObserver;
  53258. private _onBeforeCameraRenderObserver;
  53259. private _onAfterCameraRenderObserver;
  53260. /**
  53261. * Gets the perf counter used for active meshes evaluation time
  53262. */
  53263. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53264. /**
  53265. * Gets the active meshes evaluation time capture status
  53266. */
  53267. get captureActiveMeshesEvaluationTime(): boolean;
  53268. /**
  53269. * Enable or disable the active meshes evaluation time capture
  53270. */
  53271. set captureActiveMeshesEvaluationTime(value: boolean);
  53272. /**
  53273. * Gets the perf counter used for render targets render time
  53274. */
  53275. get renderTargetsRenderTimeCounter(): PerfCounter;
  53276. /**
  53277. * Gets the render targets render time capture status
  53278. */
  53279. get captureRenderTargetsRenderTime(): boolean;
  53280. /**
  53281. * Enable or disable the render targets render time capture
  53282. */
  53283. set captureRenderTargetsRenderTime(value: boolean);
  53284. /**
  53285. * Gets the perf counter used for particles render time
  53286. */
  53287. get particlesRenderTimeCounter(): PerfCounter;
  53288. /**
  53289. * Gets the particles render time capture status
  53290. */
  53291. get captureParticlesRenderTime(): boolean;
  53292. /**
  53293. * Enable or disable the particles render time capture
  53294. */
  53295. set captureParticlesRenderTime(value: boolean);
  53296. /**
  53297. * Gets the perf counter used for sprites render time
  53298. */
  53299. get spritesRenderTimeCounter(): PerfCounter;
  53300. /**
  53301. * Gets the sprites render time capture status
  53302. */
  53303. get captureSpritesRenderTime(): boolean;
  53304. /**
  53305. * Enable or disable the sprites render time capture
  53306. */
  53307. set captureSpritesRenderTime(value: boolean);
  53308. /**
  53309. * Gets the perf counter used for physics time
  53310. */
  53311. get physicsTimeCounter(): PerfCounter;
  53312. /**
  53313. * Gets the physics time capture status
  53314. */
  53315. get capturePhysicsTime(): boolean;
  53316. /**
  53317. * Enable or disable the physics time capture
  53318. */
  53319. set capturePhysicsTime(value: boolean);
  53320. /**
  53321. * Gets the perf counter used for animations time
  53322. */
  53323. get animationsTimeCounter(): PerfCounter;
  53324. /**
  53325. * Gets the animations time capture status
  53326. */
  53327. get captureAnimationsTime(): boolean;
  53328. /**
  53329. * Enable or disable the animations time capture
  53330. */
  53331. set captureAnimationsTime(value: boolean);
  53332. /**
  53333. * Gets the perf counter used for frame time capture
  53334. */
  53335. get frameTimeCounter(): PerfCounter;
  53336. /**
  53337. * Gets the frame time capture status
  53338. */
  53339. get captureFrameTime(): boolean;
  53340. /**
  53341. * Enable or disable the frame time capture
  53342. */
  53343. set captureFrameTime(value: boolean);
  53344. /**
  53345. * Gets the perf counter used for inter-frames time capture
  53346. */
  53347. get interFrameTimeCounter(): PerfCounter;
  53348. /**
  53349. * Gets the inter-frames time capture status
  53350. */
  53351. get captureInterFrameTime(): boolean;
  53352. /**
  53353. * Enable or disable the inter-frames time capture
  53354. */
  53355. set captureInterFrameTime(value: boolean);
  53356. /**
  53357. * Gets the perf counter used for render time capture
  53358. */
  53359. get renderTimeCounter(): PerfCounter;
  53360. /**
  53361. * Gets the render time capture status
  53362. */
  53363. get captureRenderTime(): boolean;
  53364. /**
  53365. * Enable or disable the render time capture
  53366. */
  53367. set captureRenderTime(value: boolean);
  53368. /**
  53369. * Gets the perf counter used for camera render time capture
  53370. */
  53371. get cameraRenderTimeCounter(): PerfCounter;
  53372. /**
  53373. * Gets the camera render time capture status
  53374. */
  53375. get captureCameraRenderTime(): boolean;
  53376. /**
  53377. * Enable or disable the camera render time capture
  53378. */
  53379. set captureCameraRenderTime(value: boolean);
  53380. /**
  53381. * Gets the perf counter used for draw calls
  53382. */
  53383. get drawCallsCounter(): PerfCounter;
  53384. /**
  53385. * Instantiates a new scene instrumentation.
  53386. * This class can be used to get instrumentation data from a Babylon engine
  53387. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53388. * @param scene Defines the scene to instrument
  53389. */
  53390. constructor(
  53391. /**
  53392. * Defines the scene to instrument
  53393. */
  53394. scene: Scene);
  53395. /**
  53396. * Dispose and release associated resources.
  53397. */
  53398. dispose(): void;
  53399. }
  53400. }
  53401. declare module BABYLON {
  53402. /** @hidden */
  53403. export var glowMapGenerationPixelShader: {
  53404. name: string;
  53405. shader: string;
  53406. };
  53407. }
  53408. declare module BABYLON {
  53409. /** @hidden */
  53410. export var glowMapGenerationVertexShader: {
  53411. name: string;
  53412. shader: string;
  53413. };
  53414. }
  53415. declare module BABYLON {
  53416. /**
  53417. * Effect layer options. This helps customizing the behaviour
  53418. * of the effect layer.
  53419. */
  53420. export interface IEffectLayerOptions {
  53421. /**
  53422. * Multiplication factor apply to the canvas size to compute the render target size
  53423. * used to generated the objects (the smaller the faster).
  53424. */
  53425. mainTextureRatio: number;
  53426. /**
  53427. * Enforces a fixed size texture to ensure effect stability across devices.
  53428. */
  53429. mainTextureFixedSize?: number;
  53430. /**
  53431. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53432. */
  53433. alphaBlendingMode: number;
  53434. /**
  53435. * The camera attached to the layer.
  53436. */
  53437. camera: Nullable<Camera>;
  53438. /**
  53439. * The rendering group to draw the layer in.
  53440. */
  53441. renderingGroupId: number;
  53442. }
  53443. /**
  53444. * The effect layer Helps adding post process effect blended with the main pass.
  53445. *
  53446. * This can be for instance use to generate glow or higlight effects on the scene.
  53447. *
  53448. * The effect layer class can not be used directly and is intented to inherited from to be
  53449. * customized per effects.
  53450. */
  53451. export abstract class EffectLayer {
  53452. private _vertexBuffers;
  53453. private _indexBuffer;
  53454. private _cachedDefines;
  53455. private _effectLayerMapGenerationEffect;
  53456. private _effectLayerOptions;
  53457. private _mergeEffect;
  53458. protected _scene: Scene;
  53459. protected _engine: Engine;
  53460. protected _maxSize: number;
  53461. protected _mainTextureDesiredSize: ISize;
  53462. protected _mainTexture: RenderTargetTexture;
  53463. protected _shouldRender: boolean;
  53464. protected _postProcesses: PostProcess[];
  53465. protected _textures: BaseTexture[];
  53466. protected _emissiveTextureAndColor: {
  53467. texture: Nullable<BaseTexture>;
  53468. color: Color4;
  53469. };
  53470. /**
  53471. * The name of the layer
  53472. */
  53473. name: string;
  53474. /**
  53475. * The clear color of the texture used to generate the glow map.
  53476. */
  53477. neutralColor: Color4;
  53478. /**
  53479. * Specifies whether the highlight layer is enabled or not.
  53480. */
  53481. isEnabled: boolean;
  53482. /**
  53483. * Gets the camera attached to the layer.
  53484. */
  53485. get camera(): Nullable<Camera>;
  53486. /**
  53487. * Gets the rendering group id the layer should render in.
  53488. */
  53489. get renderingGroupId(): number;
  53490. set renderingGroupId(renderingGroupId: number);
  53491. /**
  53492. * An event triggered when the effect layer has been disposed.
  53493. */
  53494. onDisposeObservable: Observable<EffectLayer>;
  53495. /**
  53496. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53497. */
  53498. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53499. /**
  53500. * An event triggered when the generated texture is being merged in the scene.
  53501. */
  53502. onBeforeComposeObservable: Observable<EffectLayer>;
  53503. /**
  53504. * An event triggered when the mesh is rendered into the effect render target.
  53505. */
  53506. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53507. /**
  53508. * An event triggered after the mesh has been rendered into the effect render target.
  53509. */
  53510. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53511. /**
  53512. * An event triggered when the generated texture has been merged in the scene.
  53513. */
  53514. onAfterComposeObservable: Observable<EffectLayer>;
  53515. /**
  53516. * An event triggered when the efffect layer changes its size.
  53517. */
  53518. onSizeChangedObservable: Observable<EffectLayer>;
  53519. /** @hidden */
  53520. static _SceneComponentInitialization: (scene: Scene) => void;
  53521. /**
  53522. * Instantiates a new effect Layer and references it in the scene.
  53523. * @param name The name of the layer
  53524. * @param scene The scene to use the layer in
  53525. */
  53526. constructor(
  53527. /** The Friendly of the effect in the scene */
  53528. name: string, scene: Scene);
  53529. /**
  53530. * Get the effect name of the layer.
  53531. * @return The effect name
  53532. */
  53533. abstract getEffectName(): string;
  53534. /**
  53535. * Checks for the readiness of the element composing the layer.
  53536. * @param subMesh the mesh to check for
  53537. * @param useInstances specify whether or not to use instances to render the mesh
  53538. * @return true if ready otherwise, false
  53539. */
  53540. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53541. /**
  53542. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53543. * @returns true if the effect requires stencil during the main canvas render pass.
  53544. */
  53545. abstract needStencil(): boolean;
  53546. /**
  53547. * Create the merge effect. This is the shader use to blit the information back
  53548. * to the main canvas at the end of the scene rendering.
  53549. * @returns The effect containing the shader used to merge the effect on the main canvas
  53550. */
  53551. protected abstract _createMergeEffect(): Effect;
  53552. /**
  53553. * Creates the render target textures and post processes used in the effect layer.
  53554. */
  53555. protected abstract _createTextureAndPostProcesses(): void;
  53556. /**
  53557. * Implementation specific of rendering the generating effect on the main canvas.
  53558. * @param effect The effect used to render through
  53559. */
  53560. protected abstract _internalRender(effect: Effect): void;
  53561. /**
  53562. * Sets the required values for both the emissive texture and and the main color.
  53563. */
  53564. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53565. /**
  53566. * Free any resources and references associated to a mesh.
  53567. * Internal use
  53568. * @param mesh The mesh to free.
  53569. */
  53570. abstract _disposeMesh(mesh: Mesh): void;
  53571. /**
  53572. * Serializes this layer (Glow or Highlight for example)
  53573. * @returns a serialized layer object
  53574. */
  53575. abstract serialize?(): any;
  53576. /**
  53577. * Initializes the effect layer with the required options.
  53578. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53579. */
  53580. protected _init(options: Partial<IEffectLayerOptions>): void;
  53581. /**
  53582. * Generates the index buffer of the full screen quad blending to the main canvas.
  53583. */
  53584. private _generateIndexBuffer;
  53585. /**
  53586. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53587. */
  53588. private _generateVertexBuffer;
  53589. /**
  53590. * Sets the main texture desired size which is the closest power of two
  53591. * of the engine canvas size.
  53592. */
  53593. private _setMainTextureSize;
  53594. /**
  53595. * Creates the main texture for the effect layer.
  53596. */
  53597. protected _createMainTexture(): void;
  53598. /**
  53599. * Adds specific effects defines.
  53600. * @param defines The defines to add specifics to.
  53601. */
  53602. protected _addCustomEffectDefines(defines: string[]): void;
  53603. /**
  53604. * Checks for the readiness of the element composing the layer.
  53605. * @param subMesh the mesh to check for
  53606. * @param useInstances specify whether or not to use instances to render the mesh
  53607. * @param emissiveTexture the associated emissive texture used to generate the glow
  53608. * @return true if ready otherwise, false
  53609. */
  53610. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53611. /**
  53612. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53613. */
  53614. render(): void;
  53615. /**
  53616. * Determine if a given mesh will be used in the current effect.
  53617. * @param mesh mesh to test
  53618. * @returns true if the mesh will be used
  53619. */
  53620. hasMesh(mesh: AbstractMesh): boolean;
  53621. /**
  53622. * Returns true if the layer contains information to display, otherwise false.
  53623. * @returns true if the glow layer should be rendered
  53624. */
  53625. shouldRender(): boolean;
  53626. /**
  53627. * Returns true if the mesh should render, otherwise false.
  53628. * @param mesh The mesh to render
  53629. * @returns true if it should render otherwise false
  53630. */
  53631. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53632. /**
  53633. * Returns true if the mesh can be rendered, otherwise false.
  53634. * @param mesh The mesh to render
  53635. * @param material The material used on the mesh
  53636. * @returns true if it can be rendered otherwise false
  53637. */
  53638. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53639. /**
  53640. * Returns true if the mesh should render, otherwise false.
  53641. * @param mesh The mesh to render
  53642. * @returns true if it should render otherwise false
  53643. */
  53644. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53645. /**
  53646. * Renders the submesh passed in parameter to the generation map.
  53647. */
  53648. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53649. /**
  53650. * Defines whether the current material of the mesh should be use to render the effect.
  53651. * @param mesh defines the current mesh to render
  53652. */
  53653. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53654. /**
  53655. * Rebuild the required buffers.
  53656. * @hidden Internal use only.
  53657. */
  53658. _rebuild(): void;
  53659. /**
  53660. * Dispose only the render target textures and post process.
  53661. */
  53662. private _disposeTextureAndPostProcesses;
  53663. /**
  53664. * Dispose the highlight layer and free resources.
  53665. */
  53666. dispose(): void;
  53667. /**
  53668. * Gets the class name of the effect layer
  53669. * @returns the string with the class name of the effect layer
  53670. */
  53671. getClassName(): string;
  53672. /**
  53673. * Creates an effect layer from parsed effect layer data
  53674. * @param parsedEffectLayer defines effect layer data
  53675. * @param scene defines the current scene
  53676. * @param rootUrl defines the root URL containing the effect layer information
  53677. * @returns a parsed effect Layer
  53678. */
  53679. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53680. }
  53681. }
  53682. declare module BABYLON {
  53683. interface AbstractScene {
  53684. /**
  53685. * The list of effect layers (highlights/glow) added to the scene
  53686. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53687. * @see http://doc.babylonjs.com/how_to/glow_layer
  53688. */
  53689. effectLayers: Array<EffectLayer>;
  53690. /**
  53691. * Removes the given effect layer from this scene.
  53692. * @param toRemove defines the effect layer to remove
  53693. * @returns the index of the removed effect layer
  53694. */
  53695. removeEffectLayer(toRemove: EffectLayer): number;
  53696. /**
  53697. * Adds the given effect layer to this scene
  53698. * @param newEffectLayer defines the effect layer to add
  53699. */
  53700. addEffectLayer(newEffectLayer: EffectLayer): void;
  53701. }
  53702. /**
  53703. * Defines the layer scene component responsible to manage any effect layers
  53704. * in a given scene.
  53705. */
  53706. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53707. /**
  53708. * The component name helpfull to identify the component in the list of scene components.
  53709. */
  53710. readonly name: string;
  53711. /**
  53712. * The scene the component belongs to.
  53713. */
  53714. scene: Scene;
  53715. private _engine;
  53716. private _renderEffects;
  53717. private _needStencil;
  53718. private _previousStencilState;
  53719. /**
  53720. * Creates a new instance of the component for the given scene
  53721. * @param scene Defines the scene to register the component in
  53722. */
  53723. constructor(scene: Scene);
  53724. /**
  53725. * Registers the component in a given scene
  53726. */
  53727. register(): void;
  53728. /**
  53729. * Rebuilds the elements related to this component in case of
  53730. * context lost for instance.
  53731. */
  53732. rebuild(): void;
  53733. /**
  53734. * Serializes the component data to the specified json object
  53735. * @param serializationObject The object to serialize to
  53736. */
  53737. serialize(serializationObject: any): void;
  53738. /**
  53739. * Adds all the elements from the container to the scene
  53740. * @param container the container holding the elements
  53741. */
  53742. addFromContainer(container: AbstractScene): void;
  53743. /**
  53744. * Removes all the elements in the container from the scene
  53745. * @param container contains the elements to remove
  53746. * @param dispose if the removed element should be disposed (default: false)
  53747. */
  53748. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53749. /**
  53750. * Disposes the component and the associated ressources.
  53751. */
  53752. dispose(): void;
  53753. private _isReadyForMesh;
  53754. private _renderMainTexture;
  53755. private _setStencil;
  53756. private _setStencilBack;
  53757. private _draw;
  53758. private _drawCamera;
  53759. private _drawRenderingGroup;
  53760. }
  53761. }
  53762. declare module BABYLON {
  53763. /** @hidden */
  53764. export var glowMapMergePixelShader: {
  53765. name: string;
  53766. shader: string;
  53767. };
  53768. }
  53769. declare module BABYLON {
  53770. /** @hidden */
  53771. export var glowMapMergeVertexShader: {
  53772. name: string;
  53773. shader: string;
  53774. };
  53775. }
  53776. declare module BABYLON {
  53777. interface AbstractScene {
  53778. /**
  53779. * Return a the first highlight layer of the scene with a given name.
  53780. * @param name The name of the highlight layer to look for.
  53781. * @return The highlight layer if found otherwise null.
  53782. */
  53783. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53784. }
  53785. /**
  53786. * Glow layer options. This helps customizing the behaviour
  53787. * of the glow layer.
  53788. */
  53789. export interface IGlowLayerOptions {
  53790. /**
  53791. * Multiplication factor apply to the canvas size to compute the render target size
  53792. * used to generated the glowing objects (the smaller the faster).
  53793. */
  53794. mainTextureRatio: number;
  53795. /**
  53796. * Enforces a fixed size texture to ensure resize independant blur.
  53797. */
  53798. mainTextureFixedSize?: number;
  53799. /**
  53800. * How big is the kernel of the blur texture.
  53801. */
  53802. blurKernelSize: number;
  53803. /**
  53804. * The camera attached to the layer.
  53805. */
  53806. camera: Nullable<Camera>;
  53807. /**
  53808. * Enable MSAA by chosing the number of samples.
  53809. */
  53810. mainTextureSamples?: number;
  53811. /**
  53812. * The rendering group to draw the layer in.
  53813. */
  53814. renderingGroupId: number;
  53815. }
  53816. /**
  53817. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53818. *
  53819. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53820. *
  53821. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53822. */
  53823. export class GlowLayer extends EffectLayer {
  53824. /**
  53825. * Effect Name of the layer.
  53826. */
  53827. static readonly EffectName: string;
  53828. /**
  53829. * The default blur kernel size used for the glow.
  53830. */
  53831. static DefaultBlurKernelSize: number;
  53832. /**
  53833. * The default texture size ratio used for the glow.
  53834. */
  53835. static DefaultTextureRatio: number;
  53836. /**
  53837. * Sets the kernel size of the blur.
  53838. */
  53839. set blurKernelSize(value: number);
  53840. /**
  53841. * Gets the kernel size of the blur.
  53842. */
  53843. get blurKernelSize(): number;
  53844. /**
  53845. * Sets the glow intensity.
  53846. */
  53847. set intensity(value: number);
  53848. /**
  53849. * Gets the glow intensity.
  53850. */
  53851. get intensity(): number;
  53852. private _options;
  53853. private _intensity;
  53854. private _horizontalBlurPostprocess1;
  53855. private _verticalBlurPostprocess1;
  53856. private _horizontalBlurPostprocess2;
  53857. private _verticalBlurPostprocess2;
  53858. private _blurTexture1;
  53859. private _blurTexture2;
  53860. private _postProcesses1;
  53861. private _postProcesses2;
  53862. private _includedOnlyMeshes;
  53863. private _excludedMeshes;
  53864. private _meshesUsingTheirOwnMaterials;
  53865. /**
  53866. * Callback used to let the user override the color selection on a per mesh basis
  53867. */
  53868. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53869. /**
  53870. * Callback used to let the user override the texture selection on a per mesh basis
  53871. */
  53872. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53873. /**
  53874. * Instantiates a new glow Layer and references it to the scene.
  53875. * @param name The name of the layer
  53876. * @param scene The scene to use the layer in
  53877. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53878. */
  53879. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53880. /**
  53881. * Get the effect name of the layer.
  53882. * @return The effect name
  53883. */
  53884. getEffectName(): string;
  53885. /**
  53886. * Create the merge effect. This is the shader use to blit the information back
  53887. * to the main canvas at the end of the scene rendering.
  53888. */
  53889. protected _createMergeEffect(): Effect;
  53890. /**
  53891. * Creates the render target textures and post processes used in the glow layer.
  53892. */
  53893. protected _createTextureAndPostProcesses(): void;
  53894. /**
  53895. * Checks for the readiness of the element composing the layer.
  53896. * @param subMesh the mesh to check for
  53897. * @param useInstances specify wether or not to use instances to render the mesh
  53898. * @param emissiveTexture the associated emissive texture used to generate the glow
  53899. * @return true if ready otherwise, false
  53900. */
  53901. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53902. /**
  53903. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53904. */
  53905. needStencil(): boolean;
  53906. /**
  53907. * Returns true if the mesh can be rendered, otherwise false.
  53908. * @param mesh The mesh to render
  53909. * @param material The material used on the mesh
  53910. * @returns true if it can be rendered otherwise false
  53911. */
  53912. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53913. /**
  53914. * Implementation specific of rendering the generating effect on the main canvas.
  53915. * @param effect The effect used to render through
  53916. */
  53917. protected _internalRender(effect: Effect): void;
  53918. /**
  53919. * Sets the required values for both the emissive texture and and the main color.
  53920. */
  53921. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53922. /**
  53923. * Returns true if the mesh should render, otherwise false.
  53924. * @param mesh The mesh to render
  53925. * @returns true if it should render otherwise false
  53926. */
  53927. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53928. /**
  53929. * Adds specific effects defines.
  53930. * @param defines The defines to add specifics to.
  53931. */
  53932. protected _addCustomEffectDefines(defines: string[]): void;
  53933. /**
  53934. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53935. * @param mesh The mesh to exclude from the glow layer
  53936. */
  53937. addExcludedMesh(mesh: Mesh): void;
  53938. /**
  53939. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53940. * @param mesh The mesh to remove
  53941. */
  53942. removeExcludedMesh(mesh: Mesh): void;
  53943. /**
  53944. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53945. * @param mesh The mesh to include in the glow layer
  53946. */
  53947. addIncludedOnlyMesh(mesh: Mesh): void;
  53948. /**
  53949. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53950. * @param mesh The mesh to remove
  53951. */
  53952. removeIncludedOnlyMesh(mesh: Mesh): void;
  53953. /**
  53954. * Determine if a given mesh will be used in the glow layer
  53955. * @param mesh The mesh to test
  53956. * @returns true if the mesh will be highlighted by the current glow layer
  53957. */
  53958. hasMesh(mesh: AbstractMesh): boolean;
  53959. /**
  53960. * Defines whether the current material of the mesh should be use to render the effect.
  53961. * @param mesh defines the current mesh to render
  53962. */
  53963. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53964. /**
  53965. * Add a mesh to be rendered through its own material and not with emissive only.
  53966. * @param mesh The mesh for which we need to use its material
  53967. */
  53968. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53969. /**
  53970. * Remove a mesh from being rendered through its own material and not with emissive only.
  53971. * @param mesh The mesh for which we need to not use its material
  53972. */
  53973. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53974. /**
  53975. * Free any resources and references associated to a mesh.
  53976. * Internal use
  53977. * @param mesh The mesh to free.
  53978. * @hidden
  53979. */
  53980. _disposeMesh(mesh: Mesh): void;
  53981. /**
  53982. * Gets the class name of the effect layer
  53983. * @returns the string with the class name of the effect layer
  53984. */
  53985. getClassName(): string;
  53986. /**
  53987. * Serializes this glow layer
  53988. * @returns a serialized glow layer object
  53989. */
  53990. serialize(): any;
  53991. /**
  53992. * Creates a Glow Layer from parsed glow layer data
  53993. * @param parsedGlowLayer defines glow layer data
  53994. * @param scene defines the current scene
  53995. * @param rootUrl defines the root URL containing the glow layer information
  53996. * @returns a parsed Glow Layer
  53997. */
  53998. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53999. }
  54000. }
  54001. declare module BABYLON {
  54002. /** @hidden */
  54003. export var glowBlurPostProcessPixelShader: {
  54004. name: string;
  54005. shader: string;
  54006. };
  54007. }
  54008. declare module BABYLON {
  54009. interface AbstractScene {
  54010. /**
  54011. * Return a the first highlight layer of the scene with a given name.
  54012. * @param name The name of the highlight layer to look for.
  54013. * @return The highlight layer if found otherwise null.
  54014. */
  54015. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54016. }
  54017. /**
  54018. * Highlight layer options. This helps customizing the behaviour
  54019. * of the highlight layer.
  54020. */
  54021. export interface IHighlightLayerOptions {
  54022. /**
  54023. * Multiplication factor apply to the canvas size to compute the render target size
  54024. * used to generated the glowing objects (the smaller the faster).
  54025. */
  54026. mainTextureRatio: number;
  54027. /**
  54028. * Enforces a fixed size texture to ensure resize independant blur.
  54029. */
  54030. mainTextureFixedSize?: number;
  54031. /**
  54032. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54033. * of the picture to blur (the smaller the faster).
  54034. */
  54035. blurTextureSizeRatio: number;
  54036. /**
  54037. * How big in texel of the blur texture is the vertical blur.
  54038. */
  54039. blurVerticalSize: number;
  54040. /**
  54041. * How big in texel of the blur texture is the horizontal blur.
  54042. */
  54043. blurHorizontalSize: number;
  54044. /**
  54045. * Alpha blending mode used to apply the blur. Default is combine.
  54046. */
  54047. alphaBlendingMode: number;
  54048. /**
  54049. * The camera attached to the layer.
  54050. */
  54051. camera: Nullable<Camera>;
  54052. /**
  54053. * Should we display highlight as a solid stroke?
  54054. */
  54055. isStroke?: boolean;
  54056. /**
  54057. * The rendering group to draw the layer in.
  54058. */
  54059. renderingGroupId: number;
  54060. }
  54061. /**
  54062. * The highlight layer Helps adding a glow effect around a mesh.
  54063. *
  54064. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54065. * glowy meshes to your scene.
  54066. *
  54067. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54068. */
  54069. export class HighlightLayer extends EffectLayer {
  54070. name: string;
  54071. /**
  54072. * Effect Name of the highlight layer.
  54073. */
  54074. static readonly EffectName: string;
  54075. /**
  54076. * The neutral color used during the preparation of the glow effect.
  54077. * This is black by default as the blend operation is a blend operation.
  54078. */
  54079. static NeutralColor: Color4;
  54080. /**
  54081. * Stencil value used for glowing meshes.
  54082. */
  54083. static GlowingMeshStencilReference: number;
  54084. /**
  54085. * Stencil value used for the other meshes in the scene.
  54086. */
  54087. static NormalMeshStencilReference: number;
  54088. /**
  54089. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54090. */
  54091. innerGlow: boolean;
  54092. /**
  54093. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54094. */
  54095. outerGlow: boolean;
  54096. /**
  54097. * Specifies the horizontal size of the blur.
  54098. */
  54099. set blurHorizontalSize(value: number);
  54100. /**
  54101. * Specifies the vertical size of the blur.
  54102. */
  54103. set blurVerticalSize(value: number);
  54104. /**
  54105. * Gets the horizontal size of the blur.
  54106. */
  54107. get blurHorizontalSize(): number;
  54108. /**
  54109. * Gets the vertical size of the blur.
  54110. */
  54111. get blurVerticalSize(): number;
  54112. /**
  54113. * An event triggered when the highlight layer is being blurred.
  54114. */
  54115. onBeforeBlurObservable: Observable<HighlightLayer>;
  54116. /**
  54117. * An event triggered when the highlight layer has been blurred.
  54118. */
  54119. onAfterBlurObservable: Observable<HighlightLayer>;
  54120. private _instanceGlowingMeshStencilReference;
  54121. private _options;
  54122. private _downSamplePostprocess;
  54123. private _horizontalBlurPostprocess;
  54124. private _verticalBlurPostprocess;
  54125. private _blurTexture;
  54126. private _meshes;
  54127. private _excludedMeshes;
  54128. /**
  54129. * Instantiates a new highlight Layer and references it to the scene..
  54130. * @param name The name of the layer
  54131. * @param scene The scene to use the layer in
  54132. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54133. */
  54134. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54135. /**
  54136. * Get the effect name of the layer.
  54137. * @return The effect name
  54138. */
  54139. getEffectName(): string;
  54140. /**
  54141. * Create the merge effect. This is the shader use to blit the information back
  54142. * to the main canvas at the end of the scene rendering.
  54143. */
  54144. protected _createMergeEffect(): Effect;
  54145. /**
  54146. * Creates the render target textures and post processes used in the highlight layer.
  54147. */
  54148. protected _createTextureAndPostProcesses(): void;
  54149. /**
  54150. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54151. */
  54152. needStencil(): boolean;
  54153. /**
  54154. * Checks for the readiness of the element composing the layer.
  54155. * @param subMesh the mesh to check for
  54156. * @param useInstances specify wether or not to use instances to render the mesh
  54157. * @param emissiveTexture the associated emissive texture used to generate the glow
  54158. * @return true if ready otherwise, false
  54159. */
  54160. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54161. /**
  54162. * Implementation specific of rendering the generating effect on the main canvas.
  54163. * @param effect The effect used to render through
  54164. */
  54165. protected _internalRender(effect: Effect): void;
  54166. /**
  54167. * Returns true if the layer contains information to display, otherwise false.
  54168. */
  54169. shouldRender(): boolean;
  54170. /**
  54171. * Returns true if the mesh should render, otherwise false.
  54172. * @param mesh The mesh to render
  54173. * @returns true if it should render otherwise false
  54174. */
  54175. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54176. /**
  54177. * Adds specific effects defines.
  54178. * @param defines The defines to add specifics to.
  54179. */
  54180. protected _addCustomEffectDefines(defines: string[]): void;
  54181. /**
  54182. * Sets the required values for both the emissive texture and and the main color.
  54183. */
  54184. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54185. /**
  54186. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54187. * @param mesh The mesh to exclude from the highlight layer
  54188. */
  54189. addExcludedMesh(mesh: Mesh): void;
  54190. /**
  54191. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54192. * @param mesh The mesh to highlight
  54193. */
  54194. removeExcludedMesh(mesh: Mesh): void;
  54195. /**
  54196. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54197. * @param mesh mesh to test
  54198. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54199. */
  54200. hasMesh(mesh: AbstractMesh): boolean;
  54201. /**
  54202. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54203. * @param mesh The mesh to highlight
  54204. * @param color The color of the highlight
  54205. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54206. */
  54207. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54208. /**
  54209. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54210. * @param mesh The mesh to highlight
  54211. */
  54212. removeMesh(mesh: Mesh): void;
  54213. /**
  54214. * Remove all the meshes currently referenced in the highlight layer
  54215. */
  54216. removeAllMeshes(): void;
  54217. /**
  54218. * Force the stencil to the normal expected value for none glowing parts
  54219. */
  54220. private _defaultStencilReference;
  54221. /**
  54222. * Free any resources and references associated to a mesh.
  54223. * Internal use
  54224. * @param mesh The mesh to free.
  54225. * @hidden
  54226. */
  54227. _disposeMesh(mesh: Mesh): void;
  54228. /**
  54229. * Dispose the highlight layer and free resources.
  54230. */
  54231. dispose(): void;
  54232. /**
  54233. * Gets the class name of the effect layer
  54234. * @returns the string with the class name of the effect layer
  54235. */
  54236. getClassName(): string;
  54237. /**
  54238. * Serializes this Highlight layer
  54239. * @returns a serialized Highlight layer object
  54240. */
  54241. serialize(): any;
  54242. /**
  54243. * Creates a Highlight layer from parsed Highlight layer data
  54244. * @param parsedHightlightLayer defines the Highlight layer data
  54245. * @param scene defines the current scene
  54246. * @param rootUrl defines the root URL containing the Highlight layer information
  54247. * @returns a parsed Highlight layer
  54248. */
  54249. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54250. }
  54251. }
  54252. declare module BABYLON {
  54253. interface AbstractScene {
  54254. /**
  54255. * The list of layers (background and foreground) of the scene
  54256. */
  54257. layers: Array<Layer>;
  54258. }
  54259. /**
  54260. * Defines the layer scene component responsible to manage any layers
  54261. * in a given scene.
  54262. */
  54263. export class LayerSceneComponent implements ISceneComponent {
  54264. /**
  54265. * The component name helpfull to identify the component in the list of scene components.
  54266. */
  54267. readonly name: string;
  54268. /**
  54269. * The scene the component belongs to.
  54270. */
  54271. scene: Scene;
  54272. private _engine;
  54273. /**
  54274. * Creates a new instance of the component for the given scene
  54275. * @param scene Defines the scene to register the component in
  54276. */
  54277. constructor(scene: Scene);
  54278. /**
  54279. * Registers the component in a given scene
  54280. */
  54281. register(): void;
  54282. /**
  54283. * Rebuilds the elements related to this component in case of
  54284. * context lost for instance.
  54285. */
  54286. rebuild(): void;
  54287. /**
  54288. * Disposes the component and the associated ressources.
  54289. */
  54290. dispose(): void;
  54291. private _draw;
  54292. private _drawCameraPredicate;
  54293. private _drawCameraBackground;
  54294. private _drawCameraForeground;
  54295. private _drawRenderTargetPredicate;
  54296. private _drawRenderTargetBackground;
  54297. private _drawRenderTargetForeground;
  54298. /**
  54299. * Adds all the elements from the container to the scene
  54300. * @param container the container holding the elements
  54301. */
  54302. addFromContainer(container: AbstractScene): void;
  54303. /**
  54304. * Removes all the elements in the container from the scene
  54305. * @param container contains the elements to remove
  54306. * @param dispose if the removed element should be disposed (default: false)
  54307. */
  54308. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54309. }
  54310. }
  54311. declare module BABYLON {
  54312. /** @hidden */
  54313. export var layerPixelShader: {
  54314. name: string;
  54315. shader: string;
  54316. };
  54317. }
  54318. declare module BABYLON {
  54319. /** @hidden */
  54320. export var layerVertexShader: {
  54321. name: string;
  54322. shader: string;
  54323. };
  54324. }
  54325. declare module BABYLON {
  54326. /**
  54327. * This represents a full screen 2d layer.
  54328. * This can be useful to display a picture in the background of your scene for instance.
  54329. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54330. */
  54331. export class Layer {
  54332. /**
  54333. * Define the name of the layer.
  54334. */
  54335. name: string;
  54336. /**
  54337. * Define the texture the layer should display.
  54338. */
  54339. texture: Nullable<Texture>;
  54340. /**
  54341. * Is the layer in background or foreground.
  54342. */
  54343. isBackground: boolean;
  54344. /**
  54345. * Define the color of the layer (instead of texture).
  54346. */
  54347. color: Color4;
  54348. /**
  54349. * Define the scale of the layer in order to zoom in out of the texture.
  54350. */
  54351. scale: Vector2;
  54352. /**
  54353. * Define an offset for the layer in order to shift the texture.
  54354. */
  54355. offset: Vector2;
  54356. /**
  54357. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54358. */
  54359. alphaBlendingMode: number;
  54360. /**
  54361. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54362. * Alpha test will not mix with the background color in case of transparency.
  54363. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54364. */
  54365. alphaTest: boolean;
  54366. /**
  54367. * Define a mask to restrict the layer to only some of the scene cameras.
  54368. */
  54369. layerMask: number;
  54370. /**
  54371. * Define the list of render target the layer is visible into.
  54372. */
  54373. renderTargetTextures: RenderTargetTexture[];
  54374. /**
  54375. * Define if the layer is only used in renderTarget or if it also
  54376. * renders in the main frame buffer of the canvas.
  54377. */
  54378. renderOnlyInRenderTargetTextures: boolean;
  54379. private _scene;
  54380. private _vertexBuffers;
  54381. private _indexBuffer;
  54382. private _effect;
  54383. private _previousDefines;
  54384. /**
  54385. * An event triggered when the layer is disposed.
  54386. */
  54387. onDisposeObservable: Observable<Layer>;
  54388. private _onDisposeObserver;
  54389. /**
  54390. * Back compatibility with callback before the onDisposeObservable existed.
  54391. * The set callback will be triggered when the layer has been disposed.
  54392. */
  54393. set onDispose(callback: () => void);
  54394. /**
  54395. * An event triggered before rendering the scene
  54396. */
  54397. onBeforeRenderObservable: Observable<Layer>;
  54398. private _onBeforeRenderObserver;
  54399. /**
  54400. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54401. * The set callback will be triggered just before rendering the layer.
  54402. */
  54403. set onBeforeRender(callback: () => void);
  54404. /**
  54405. * An event triggered after rendering the scene
  54406. */
  54407. onAfterRenderObservable: Observable<Layer>;
  54408. private _onAfterRenderObserver;
  54409. /**
  54410. * Back compatibility with callback before the onAfterRenderObservable existed.
  54411. * The set callback will be triggered just after rendering the layer.
  54412. */
  54413. set onAfterRender(callback: () => void);
  54414. /**
  54415. * Instantiates a new layer.
  54416. * This represents a full screen 2d layer.
  54417. * This can be useful to display a picture in the background of your scene for instance.
  54418. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54419. * @param name Define the name of the layer in the scene
  54420. * @param imgUrl Define the url of the texture to display in the layer
  54421. * @param scene Define the scene the layer belongs to
  54422. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54423. * @param color Defines a color for the layer
  54424. */
  54425. constructor(
  54426. /**
  54427. * Define the name of the layer.
  54428. */
  54429. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54430. private _createIndexBuffer;
  54431. /** @hidden */
  54432. _rebuild(): void;
  54433. /**
  54434. * Renders the layer in the scene.
  54435. */
  54436. render(): void;
  54437. /**
  54438. * Disposes and releases the associated ressources.
  54439. */
  54440. dispose(): void;
  54441. }
  54442. }
  54443. declare module BABYLON {
  54444. /** @hidden */
  54445. export var lensFlarePixelShader: {
  54446. name: string;
  54447. shader: string;
  54448. };
  54449. }
  54450. declare module BABYLON {
  54451. /** @hidden */
  54452. export var lensFlareVertexShader: {
  54453. name: string;
  54454. shader: string;
  54455. };
  54456. }
  54457. declare module BABYLON {
  54458. /**
  54459. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54460. * It is usually composed of several `lensFlare`.
  54461. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54462. */
  54463. export class LensFlareSystem {
  54464. /**
  54465. * Define the name of the lens flare system
  54466. */
  54467. name: string;
  54468. /**
  54469. * List of lens flares used in this system.
  54470. */
  54471. lensFlares: LensFlare[];
  54472. /**
  54473. * Define a limit from the border the lens flare can be visible.
  54474. */
  54475. borderLimit: number;
  54476. /**
  54477. * Define a viewport border we do not want to see the lens flare in.
  54478. */
  54479. viewportBorder: number;
  54480. /**
  54481. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54482. */
  54483. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54484. /**
  54485. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54486. */
  54487. layerMask: number;
  54488. /**
  54489. * Define the id of the lens flare system in the scene.
  54490. * (equal to name by default)
  54491. */
  54492. id: string;
  54493. private _scene;
  54494. private _emitter;
  54495. private _vertexBuffers;
  54496. private _indexBuffer;
  54497. private _effect;
  54498. private _positionX;
  54499. private _positionY;
  54500. private _isEnabled;
  54501. /** @hidden */
  54502. static _SceneComponentInitialization: (scene: Scene) => void;
  54503. /**
  54504. * Instantiates a lens flare system.
  54505. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54506. * It is usually composed of several `lensFlare`.
  54507. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54508. * @param name Define the name of the lens flare system in the scene
  54509. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54510. * @param scene Define the scene the lens flare system belongs to
  54511. */
  54512. constructor(
  54513. /**
  54514. * Define the name of the lens flare system
  54515. */
  54516. name: string, emitter: any, scene: Scene);
  54517. /**
  54518. * Define if the lens flare system is enabled.
  54519. */
  54520. get isEnabled(): boolean;
  54521. set isEnabled(value: boolean);
  54522. /**
  54523. * Get the scene the effects belongs to.
  54524. * @returns the scene holding the lens flare system
  54525. */
  54526. getScene(): Scene;
  54527. /**
  54528. * Get the emitter of the lens flare system.
  54529. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54530. * @returns the emitter of the lens flare system
  54531. */
  54532. getEmitter(): any;
  54533. /**
  54534. * Set the emitter of the lens flare system.
  54535. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54536. * @param newEmitter Define the new emitter of the system
  54537. */
  54538. setEmitter(newEmitter: any): void;
  54539. /**
  54540. * Get the lens flare system emitter position.
  54541. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54542. * @returns the position
  54543. */
  54544. getEmitterPosition(): Vector3;
  54545. /**
  54546. * @hidden
  54547. */
  54548. computeEffectivePosition(globalViewport: Viewport): boolean;
  54549. /** @hidden */
  54550. _isVisible(): boolean;
  54551. /**
  54552. * @hidden
  54553. */
  54554. render(): boolean;
  54555. /**
  54556. * Dispose and release the lens flare with its associated resources.
  54557. */
  54558. dispose(): void;
  54559. /**
  54560. * Parse a lens flare system from a JSON repressentation
  54561. * @param parsedLensFlareSystem Define the JSON to parse
  54562. * @param scene Define the scene the parsed system should be instantiated in
  54563. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54564. * @returns the parsed system
  54565. */
  54566. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54567. /**
  54568. * Serialize the current Lens Flare System into a JSON representation.
  54569. * @returns the serialized JSON
  54570. */
  54571. serialize(): any;
  54572. }
  54573. }
  54574. declare module BABYLON {
  54575. /**
  54576. * This represents one of the lens effect in a `lensFlareSystem`.
  54577. * It controls one of the indiviual texture used in the effect.
  54578. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54579. */
  54580. export class LensFlare {
  54581. /**
  54582. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54583. */
  54584. size: number;
  54585. /**
  54586. * 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.
  54587. */
  54588. position: number;
  54589. /**
  54590. * Define the lens color.
  54591. */
  54592. color: Color3;
  54593. /**
  54594. * Define the lens texture.
  54595. */
  54596. texture: Nullable<Texture>;
  54597. /**
  54598. * Define the alpha mode to render this particular lens.
  54599. */
  54600. alphaMode: number;
  54601. private _system;
  54602. /**
  54603. * Creates a new Lens Flare.
  54604. * This represents one of the lens effect in a `lensFlareSystem`.
  54605. * It controls one of the indiviual texture used in the effect.
  54606. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54607. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54608. * @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.
  54609. * @param color Define the lens color
  54610. * @param imgUrl Define the lens texture url
  54611. * @param system Define the `lensFlareSystem` this flare is part of
  54612. * @returns The newly created Lens Flare
  54613. */
  54614. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54615. /**
  54616. * Instantiates a new Lens Flare.
  54617. * This represents one of the lens effect in a `lensFlareSystem`.
  54618. * It controls one of the indiviual texture used in the effect.
  54619. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54620. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54621. * @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.
  54622. * @param color Define the lens color
  54623. * @param imgUrl Define the lens texture url
  54624. * @param system Define the `lensFlareSystem` this flare is part of
  54625. */
  54626. constructor(
  54627. /**
  54628. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54629. */
  54630. size: number,
  54631. /**
  54632. * 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.
  54633. */
  54634. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54635. /**
  54636. * Dispose and release the lens flare with its associated resources.
  54637. */
  54638. dispose(): void;
  54639. }
  54640. }
  54641. declare module BABYLON {
  54642. interface AbstractScene {
  54643. /**
  54644. * The list of lens flare system added to the scene
  54645. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54646. */
  54647. lensFlareSystems: Array<LensFlareSystem>;
  54648. /**
  54649. * Removes the given lens flare system from this scene.
  54650. * @param toRemove The lens flare system to remove
  54651. * @returns The index of the removed lens flare system
  54652. */
  54653. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54654. /**
  54655. * Adds the given lens flare system to this scene
  54656. * @param newLensFlareSystem The lens flare system to add
  54657. */
  54658. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54659. /**
  54660. * Gets a lens flare system using its name
  54661. * @param name defines the name to look for
  54662. * @returns the lens flare system or null if not found
  54663. */
  54664. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54665. /**
  54666. * Gets a lens flare system using its id
  54667. * @param id defines the id to look for
  54668. * @returns the lens flare system or null if not found
  54669. */
  54670. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54671. }
  54672. /**
  54673. * Defines the lens flare scene component responsible to manage any lens flares
  54674. * in a given scene.
  54675. */
  54676. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54677. /**
  54678. * The component name helpfull to identify the component in the list of scene components.
  54679. */
  54680. readonly name: string;
  54681. /**
  54682. * The scene the component belongs to.
  54683. */
  54684. scene: Scene;
  54685. /**
  54686. * Creates a new instance of the component for the given scene
  54687. * @param scene Defines the scene to register the component in
  54688. */
  54689. constructor(scene: Scene);
  54690. /**
  54691. * Registers the component in a given scene
  54692. */
  54693. register(): void;
  54694. /**
  54695. * Rebuilds the elements related to this component in case of
  54696. * context lost for instance.
  54697. */
  54698. rebuild(): void;
  54699. /**
  54700. * Adds all the elements from the container to the scene
  54701. * @param container the container holding the elements
  54702. */
  54703. addFromContainer(container: AbstractScene): void;
  54704. /**
  54705. * Removes all the elements in the container from the scene
  54706. * @param container contains the elements to remove
  54707. * @param dispose if the removed element should be disposed (default: false)
  54708. */
  54709. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54710. /**
  54711. * Serializes the component data to the specified json object
  54712. * @param serializationObject The object to serialize to
  54713. */
  54714. serialize(serializationObject: any): void;
  54715. /**
  54716. * Disposes the component and the associated ressources.
  54717. */
  54718. dispose(): void;
  54719. private _draw;
  54720. }
  54721. }
  54722. declare module BABYLON {
  54723. /** @hidden */
  54724. export var depthPixelShader: {
  54725. name: string;
  54726. shader: string;
  54727. };
  54728. }
  54729. declare module BABYLON {
  54730. /** @hidden */
  54731. export var depthVertexShader: {
  54732. name: string;
  54733. shader: string;
  54734. };
  54735. }
  54736. declare module BABYLON {
  54737. /**
  54738. * This represents a depth renderer in Babylon.
  54739. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54740. */
  54741. export class DepthRenderer {
  54742. private _scene;
  54743. private _depthMap;
  54744. private _effect;
  54745. private readonly _storeNonLinearDepth;
  54746. private readonly _clearColor;
  54747. /** Get if the depth renderer is using packed depth or not */
  54748. readonly isPacked: boolean;
  54749. private _cachedDefines;
  54750. private _camera;
  54751. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54752. enabled: boolean;
  54753. /**
  54754. * Specifiess that the depth renderer will only be used within
  54755. * the camera it is created for.
  54756. * This can help forcing its rendering during the camera processing.
  54757. */
  54758. useOnlyInActiveCamera: boolean;
  54759. /** @hidden */
  54760. static _SceneComponentInitialization: (scene: Scene) => void;
  54761. /**
  54762. * Instantiates a depth renderer
  54763. * @param scene The scene the renderer belongs to
  54764. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54765. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54766. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54767. */
  54768. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54769. /**
  54770. * Creates the depth rendering effect and checks if the effect is ready.
  54771. * @param subMesh The submesh to be used to render the depth map of
  54772. * @param useInstances If multiple world instances should be used
  54773. * @returns if the depth renderer is ready to render the depth map
  54774. */
  54775. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54776. /**
  54777. * Gets the texture which the depth map will be written to.
  54778. * @returns The depth map texture
  54779. */
  54780. getDepthMap(): RenderTargetTexture;
  54781. /**
  54782. * Disposes of the depth renderer.
  54783. */
  54784. dispose(): void;
  54785. }
  54786. }
  54787. declare module BABYLON {
  54788. /** @hidden */
  54789. export var minmaxReduxPixelShader: {
  54790. name: string;
  54791. shader: string;
  54792. };
  54793. }
  54794. declare module BABYLON {
  54795. /**
  54796. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54797. * and maximum values from all values of the texture.
  54798. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54799. * The source values are read from the red channel of the texture.
  54800. */
  54801. export class MinMaxReducer {
  54802. /**
  54803. * Observable triggered when the computation has been performed
  54804. */
  54805. onAfterReductionPerformed: Observable<{
  54806. min: number;
  54807. max: number;
  54808. }>;
  54809. protected _camera: Camera;
  54810. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54811. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54812. protected _postProcessManager: PostProcessManager;
  54813. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54814. protected _forceFullscreenViewport: boolean;
  54815. /**
  54816. * Creates a min/max reducer
  54817. * @param camera The camera to use for the post processes
  54818. */
  54819. constructor(camera: Camera);
  54820. /**
  54821. * Gets the texture used to read the values from.
  54822. */
  54823. get sourceTexture(): Nullable<RenderTargetTexture>;
  54824. /**
  54825. * Sets the source texture to read the values from.
  54826. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54827. * because in such textures '1' value must not be taken into account to compute the maximum
  54828. * as this value is used to clear the texture.
  54829. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54830. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54831. * @param depthRedux Indicates if the texture is a depth texture or not
  54832. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54833. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54834. */
  54835. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54836. /**
  54837. * Defines the refresh rate of the computation.
  54838. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54839. */
  54840. get refreshRate(): number;
  54841. set refreshRate(value: number);
  54842. protected _activated: boolean;
  54843. /**
  54844. * Gets the activation status of the reducer
  54845. */
  54846. get activated(): boolean;
  54847. /**
  54848. * Activates the reduction computation.
  54849. * When activated, the observers registered in onAfterReductionPerformed are
  54850. * called after the compuation is performed
  54851. */
  54852. activate(): void;
  54853. /**
  54854. * Deactivates the reduction computation.
  54855. */
  54856. deactivate(): void;
  54857. /**
  54858. * Disposes the min/max reducer
  54859. * @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.
  54860. */
  54861. dispose(disposeAll?: boolean): void;
  54862. }
  54863. }
  54864. declare module BABYLON {
  54865. /**
  54866. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54867. */
  54868. export class DepthReducer extends MinMaxReducer {
  54869. private _depthRenderer;
  54870. private _depthRendererId;
  54871. /**
  54872. * Gets the depth renderer used for the computation.
  54873. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54874. */
  54875. get depthRenderer(): Nullable<DepthRenderer>;
  54876. /**
  54877. * Creates a depth reducer
  54878. * @param camera The camera used to render the depth texture
  54879. */
  54880. constructor(camera: Camera);
  54881. /**
  54882. * Sets the depth renderer to use to generate the depth map
  54883. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54884. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54885. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54886. */
  54887. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54888. /** @hidden */
  54889. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54890. /**
  54891. * Activates the reduction computation.
  54892. * When activated, the observers registered in onAfterReductionPerformed are
  54893. * called after the compuation is performed
  54894. */
  54895. activate(): void;
  54896. /**
  54897. * Deactivates the reduction computation.
  54898. */
  54899. deactivate(): void;
  54900. /**
  54901. * Disposes the depth reducer
  54902. * @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.
  54903. */
  54904. dispose(disposeAll?: boolean): void;
  54905. }
  54906. }
  54907. declare module BABYLON {
  54908. /**
  54909. * A CSM implementation allowing casting shadows on large scenes.
  54910. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54911. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54912. */
  54913. export class CascadedShadowGenerator extends ShadowGenerator {
  54914. private static readonly frustumCornersNDCSpace;
  54915. /**
  54916. * Name of the CSM class
  54917. */
  54918. static CLASSNAME: string;
  54919. /**
  54920. * Defines the default number of cascades used by the CSM.
  54921. */
  54922. static readonly DEFAULT_CASCADES_COUNT: number;
  54923. /**
  54924. * Defines the minimum number of cascades used by the CSM.
  54925. */
  54926. static readonly MIN_CASCADES_COUNT: number;
  54927. /**
  54928. * Defines the maximum number of cascades used by the CSM.
  54929. */
  54930. static readonly MAX_CASCADES_COUNT: number;
  54931. protected _validateFilter(filter: number): number;
  54932. /**
  54933. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54934. */
  54935. penumbraDarkness: number;
  54936. private _numCascades;
  54937. /**
  54938. * Gets or set the number of cascades used by the CSM.
  54939. */
  54940. get numCascades(): number;
  54941. set numCascades(value: number);
  54942. /**
  54943. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54944. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54945. */
  54946. stabilizeCascades: boolean;
  54947. private _freezeShadowCastersBoundingInfo;
  54948. private _freezeShadowCastersBoundingInfoObservable;
  54949. /**
  54950. * Enables or disables the shadow casters bounding info computation.
  54951. * If your shadow casters don't move, you can disable this feature.
  54952. * If it is enabled, the bounding box computation is done every frame.
  54953. */
  54954. get freezeShadowCastersBoundingInfo(): boolean;
  54955. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54956. private _scbiMin;
  54957. private _scbiMax;
  54958. protected _computeShadowCastersBoundingInfo(): void;
  54959. protected _shadowCastersBoundingInfo: BoundingInfo;
  54960. /**
  54961. * Gets or sets the shadow casters bounding info.
  54962. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54963. * so that the system won't overwrite the bounds you provide
  54964. */
  54965. get shadowCastersBoundingInfo(): BoundingInfo;
  54966. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54967. protected _breaksAreDirty: boolean;
  54968. protected _minDistance: number;
  54969. protected _maxDistance: number;
  54970. /**
  54971. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54972. *
  54973. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54974. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54975. * @param min minimal distance for the breaks (default to 0.)
  54976. * @param max maximal distance for the breaks (default to 1.)
  54977. */
  54978. setMinMaxDistance(min: number, max: number): void;
  54979. /** Gets the minimal distance used in the cascade break computation */
  54980. get minDistance(): number;
  54981. /** Gets the maximal distance used in the cascade break computation */
  54982. get maxDistance(): number;
  54983. /**
  54984. * Gets the class name of that object
  54985. * @returns "CascadedShadowGenerator"
  54986. */
  54987. getClassName(): string;
  54988. private _cascadeMinExtents;
  54989. private _cascadeMaxExtents;
  54990. /**
  54991. * Gets a cascade minimum extents
  54992. * @param cascadeIndex index of the cascade
  54993. * @returns the minimum cascade extents
  54994. */
  54995. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54996. /**
  54997. * Gets a cascade maximum extents
  54998. * @param cascadeIndex index of the cascade
  54999. * @returns the maximum cascade extents
  55000. */
  55001. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  55002. private _cascades;
  55003. private _currentLayer;
  55004. private _viewSpaceFrustumsZ;
  55005. private _viewMatrices;
  55006. private _projectionMatrices;
  55007. private _transformMatrices;
  55008. private _transformMatricesAsArray;
  55009. private _frustumLengths;
  55010. private _lightSizeUVCorrection;
  55011. private _depthCorrection;
  55012. private _frustumCornersWorldSpace;
  55013. private _frustumCenter;
  55014. private _shadowCameraPos;
  55015. private _shadowMaxZ;
  55016. /**
  55017. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  55018. * It defaults to camera.maxZ
  55019. */
  55020. get shadowMaxZ(): number;
  55021. /**
  55022. * Sets the shadow max z distance.
  55023. */
  55024. set shadowMaxZ(value: number);
  55025. protected _debug: boolean;
  55026. /**
  55027. * Gets or sets the debug flag.
  55028. * When enabled, the cascades are materialized by different colors on the screen.
  55029. */
  55030. get debug(): boolean;
  55031. set debug(dbg: boolean);
  55032. private _depthClamp;
  55033. /**
  55034. * Gets or sets the depth clamping value.
  55035. *
  55036. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  55037. * to account for the shadow casters far away.
  55038. *
  55039. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  55040. */
  55041. get depthClamp(): boolean;
  55042. set depthClamp(value: boolean);
  55043. private _cascadeBlendPercentage;
  55044. /**
  55045. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  55046. * It defaults to 0.1 (10% blending).
  55047. */
  55048. get cascadeBlendPercentage(): number;
  55049. set cascadeBlendPercentage(value: number);
  55050. private _lambda;
  55051. /**
  55052. * Gets or set the lambda parameter.
  55053. * This parameter is used to split the camera frustum and create the cascades.
  55054. * 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.
  55055. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  55056. */
  55057. get lambda(): number;
  55058. set lambda(value: number);
  55059. /**
  55060. * Gets the view matrix corresponding to a given cascade
  55061. * @param cascadeNum cascade to retrieve the view matrix from
  55062. * @returns the cascade view matrix
  55063. */
  55064. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  55065. /**
  55066. * Gets the projection matrix corresponding to a given cascade
  55067. * @param cascadeNum cascade to retrieve the projection matrix from
  55068. * @returns the cascade projection matrix
  55069. */
  55070. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  55071. /**
  55072. * Gets the transformation matrix corresponding to a given cascade
  55073. * @param cascadeNum cascade to retrieve the transformation matrix from
  55074. * @returns the cascade transformation matrix
  55075. */
  55076. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  55077. private _depthRenderer;
  55078. /**
  55079. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  55080. *
  55081. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  55082. *
  55083. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  55084. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  55085. * @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
  55086. */
  55087. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  55088. private _depthReducer;
  55089. private _autoCalcDepthBounds;
  55090. /**
  55091. * Gets or sets the autoCalcDepthBounds property.
  55092. *
  55093. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  55094. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  55095. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  55096. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  55097. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  55098. */
  55099. get autoCalcDepthBounds(): boolean;
  55100. set autoCalcDepthBounds(value: boolean);
  55101. /**
  55102. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  55103. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55104. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  55105. * for setting the refresh rate on the renderer yourself!
  55106. */
  55107. get autoCalcDepthBoundsRefreshRate(): number;
  55108. set autoCalcDepthBoundsRefreshRate(value: number);
  55109. /**
  55110. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  55111. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  55112. * you change the camera near/far planes!
  55113. */
  55114. splitFrustum(): void;
  55115. private _splitFrustum;
  55116. private _computeMatrices;
  55117. private _computeFrustumInWorldSpace;
  55118. private _computeCascadeFrustum;
  55119. /**
  55120. * Support test.
  55121. */
  55122. static get IsSupported(): boolean;
  55123. /** @hidden */
  55124. static _SceneComponentInitialization: (scene: Scene) => void;
  55125. /**
  55126. * Creates a Cascaded Shadow Generator object.
  55127. * A ShadowGenerator is the required tool to use the shadows.
  55128. * Each directional light casting shadows needs to use its own ShadowGenerator.
  55129. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55130. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  55131. * @param light The directional light object generating the shadows.
  55132. * @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.
  55133. */
  55134. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  55135. protected _initializeGenerator(): void;
  55136. protected _createTargetRenderTexture(): void;
  55137. protected _initializeShadowMap(): void;
  55138. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  55139. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  55140. /**
  55141. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  55142. * @param defines Defines of the material we want to update
  55143. * @param lightIndex Index of the light in the enabled light list of the material
  55144. */
  55145. prepareDefines(defines: any, lightIndex: number): void;
  55146. /**
  55147. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  55148. * defined in the generator but impacting the effect).
  55149. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  55150. * @param effect The effect we are binfing the information for
  55151. */
  55152. bindShadowLight(lightIndex: string, effect: Effect): void;
  55153. /**
  55154. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  55155. * (eq to view projection * shadow projection matrices)
  55156. * @returns The transform matrix used to create the shadow map
  55157. */
  55158. getTransformMatrix(): Matrix;
  55159. /**
  55160. * Disposes the ShadowGenerator.
  55161. * Returns nothing.
  55162. */
  55163. dispose(): void;
  55164. /**
  55165. * Serializes the shadow generator setup to a json object.
  55166. * @returns The serialized JSON object
  55167. */
  55168. serialize(): any;
  55169. /**
  55170. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55171. * @param parsedShadowGenerator The JSON object to parse
  55172. * @param scene The scene to create the shadow map for
  55173. * @returns The parsed shadow generator
  55174. */
  55175. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55176. }
  55177. }
  55178. declare module BABYLON {
  55179. /**
  55180. * Defines the shadow generator component responsible to manage any shadow generators
  55181. * in a given scene.
  55182. */
  55183. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55184. /**
  55185. * The component name helpfull to identify the component in the list of scene components.
  55186. */
  55187. readonly name: string;
  55188. /**
  55189. * The scene the component belongs to.
  55190. */
  55191. scene: Scene;
  55192. /**
  55193. * Creates a new instance of the component for the given scene
  55194. * @param scene Defines the scene to register the component in
  55195. */
  55196. constructor(scene: Scene);
  55197. /**
  55198. * Registers the component in a given scene
  55199. */
  55200. register(): void;
  55201. /**
  55202. * Rebuilds the elements related to this component in case of
  55203. * context lost for instance.
  55204. */
  55205. rebuild(): void;
  55206. /**
  55207. * Serializes the component data to the specified json object
  55208. * @param serializationObject The object to serialize to
  55209. */
  55210. serialize(serializationObject: any): void;
  55211. /**
  55212. * Adds all the elements from the container to the scene
  55213. * @param container the container holding the elements
  55214. */
  55215. addFromContainer(container: AbstractScene): void;
  55216. /**
  55217. * Removes all the elements in the container from the scene
  55218. * @param container contains the elements to remove
  55219. * @param dispose if the removed element should be disposed (default: false)
  55220. */
  55221. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55222. /**
  55223. * Rebuilds the elements related to this component in case of
  55224. * context lost for instance.
  55225. */
  55226. dispose(): void;
  55227. private _gatherRenderTargets;
  55228. }
  55229. }
  55230. declare module BABYLON {
  55231. /**
  55232. * A point light is a light defined by an unique point in world space.
  55233. * The light is emitted in every direction from this point.
  55234. * A good example of a point light is a standard light bulb.
  55235. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55236. */
  55237. export class PointLight extends ShadowLight {
  55238. private _shadowAngle;
  55239. /**
  55240. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55241. * This specifies what angle the shadow will use to be created.
  55242. *
  55243. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55244. */
  55245. get shadowAngle(): number;
  55246. /**
  55247. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55248. * This specifies what angle the shadow will use to be created.
  55249. *
  55250. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55251. */
  55252. set shadowAngle(value: number);
  55253. /**
  55254. * Gets the direction if it has been set.
  55255. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55256. */
  55257. get direction(): Vector3;
  55258. /**
  55259. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55260. */
  55261. set direction(value: Vector3);
  55262. /**
  55263. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55264. * A PointLight emits the light in every direction.
  55265. * It can cast shadows.
  55266. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55267. * ```javascript
  55268. * var pointLight = new PointLight("pl", camera.position, scene);
  55269. * ```
  55270. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55271. * @param name The light friendly name
  55272. * @param position The position of the point light in the scene
  55273. * @param scene The scene the lights belongs to
  55274. */
  55275. constructor(name: string, position: Vector3, scene: Scene);
  55276. /**
  55277. * Returns the string "PointLight"
  55278. * @returns the class name
  55279. */
  55280. getClassName(): string;
  55281. /**
  55282. * Returns the integer 0.
  55283. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55284. */
  55285. getTypeID(): number;
  55286. /**
  55287. * Specifies wether or not the shadowmap should be a cube texture.
  55288. * @returns true if the shadowmap needs to be a cube texture.
  55289. */
  55290. needCube(): boolean;
  55291. /**
  55292. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55293. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55294. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55295. */
  55296. getShadowDirection(faceIndex?: number): Vector3;
  55297. /**
  55298. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55299. * - fov = PI / 2
  55300. * - aspect ratio : 1.0
  55301. * - z-near and far equal to the active camera minZ and maxZ.
  55302. * Returns the PointLight.
  55303. */
  55304. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55305. protected _buildUniformLayout(): void;
  55306. /**
  55307. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55308. * @param effect The effect to update
  55309. * @param lightIndex The index of the light in the effect to update
  55310. * @returns The point light
  55311. */
  55312. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55313. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55314. /**
  55315. * Prepares the list of defines specific to the light type.
  55316. * @param defines the list of defines
  55317. * @param lightIndex defines the index of the light for the effect
  55318. */
  55319. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55320. }
  55321. }
  55322. declare module BABYLON {
  55323. /**
  55324. * Header information of HDR texture files.
  55325. */
  55326. export interface HDRInfo {
  55327. /**
  55328. * The height of the texture in pixels.
  55329. */
  55330. height: number;
  55331. /**
  55332. * The width of the texture in pixels.
  55333. */
  55334. width: number;
  55335. /**
  55336. * The index of the beginning of the data in the binary file.
  55337. */
  55338. dataPosition: number;
  55339. }
  55340. /**
  55341. * This groups tools to convert HDR texture to native colors array.
  55342. */
  55343. export class HDRTools {
  55344. private static Ldexp;
  55345. private static Rgbe2float;
  55346. private static readStringLine;
  55347. /**
  55348. * Reads header information from an RGBE texture stored in a native array.
  55349. * More information on this format are available here:
  55350. * https://en.wikipedia.org/wiki/RGBE_image_format
  55351. *
  55352. * @param uint8array The binary file stored in native array.
  55353. * @return The header information.
  55354. */
  55355. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55356. /**
  55357. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55358. * This RGBE texture needs to store the information as a panorama.
  55359. *
  55360. * More information on this format are available here:
  55361. * https://en.wikipedia.org/wiki/RGBE_image_format
  55362. *
  55363. * @param buffer The binary file stored in an array buffer.
  55364. * @param size The expected size of the extracted cubemap.
  55365. * @return The Cube Map information.
  55366. */
  55367. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55368. /**
  55369. * Returns the pixels data extracted from an RGBE texture.
  55370. * This pixels will be stored left to right up to down in the R G B order in one array.
  55371. *
  55372. * More information on this format are available here:
  55373. * https://en.wikipedia.org/wiki/RGBE_image_format
  55374. *
  55375. * @param uint8array The binary file stored in an array buffer.
  55376. * @param hdrInfo The header information of the file.
  55377. * @return The pixels data in RGB right to left up to down order.
  55378. */
  55379. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55380. private static RGBE_ReadPixels_RLE;
  55381. }
  55382. }
  55383. declare module BABYLON {
  55384. /**
  55385. * This represents a texture coming from an HDR input.
  55386. *
  55387. * The only supported format is currently panorama picture stored in RGBE format.
  55388. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55389. */
  55390. export class HDRCubeTexture extends BaseTexture {
  55391. private static _facesMapping;
  55392. private _generateHarmonics;
  55393. private _noMipmap;
  55394. private _textureMatrix;
  55395. private _size;
  55396. private _onLoad;
  55397. private _onError;
  55398. /**
  55399. * The texture URL.
  55400. */
  55401. url: string;
  55402. /**
  55403. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55404. */
  55405. coordinatesMode: number;
  55406. protected _isBlocking: boolean;
  55407. /**
  55408. * Sets wether or not the texture is blocking during loading.
  55409. */
  55410. set isBlocking(value: boolean);
  55411. /**
  55412. * Gets wether or not the texture is blocking during loading.
  55413. */
  55414. get isBlocking(): boolean;
  55415. protected _rotationY: number;
  55416. /**
  55417. * Sets texture matrix rotation angle around Y axis in radians.
  55418. */
  55419. set rotationY(value: number);
  55420. /**
  55421. * Gets texture matrix rotation angle around Y axis radians.
  55422. */
  55423. get rotationY(): number;
  55424. /**
  55425. * Gets or sets the center of the bounding box associated with the cube texture
  55426. * It must define where the camera used to render the texture was set
  55427. */
  55428. boundingBoxPosition: Vector3;
  55429. private _boundingBoxSize;
  55430. /**
  55431. * Gets or sets the size of the bounding box associated with the cube texture
  55432. * When defined, the cubemap will switch to local mode
  55433. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55434. * @example https://www.babylonjs-playground.com/#RNASML
  55435. */
  55436. set boundingBoxSize(value: Vector3);
  55437. get boundingBoxSize(): Vector3;
  55438. /**
  55439. * Instantiates an HDRTexture from the following parameters.
  55440. *
  55441. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55442. * @param scene The scene the texture will be used in
  55443. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55444. * @param noMipmap Forces to not generate the mipmap if true
  55445. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55446. * @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)
  55447. * @param reserved Reserved flag for internal use.
  55448. */
  55449. 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>);
  55450. /**
  55451. * Get the current class name of the texture useful for serialization or dynamic coding.
  55452. * @returns "HDRCubeTexture"
  55453. */
  55454. getClassName(): string;
  55455. /**
  55456. * Occurs when the file is raw .hdr file.
  55457. */
  55458. private loadTexture;
  55459. clone(): HDRCubeTexture;
  55460. delayLoad(): void;
  55461. /**
  55462. * Get the texture reflection matrix used to rotate/transform the reflection.
  55463. * @returns the reflection matrix
  55464. */
  55465. getReflectionTextureMatrix(): Matrix;
  55466. /**
  55467. * Set the texture reflection matrix used to rotate/transform the reflection.
  55468. * @param value Define the reflection matrix to set
  55469. */
  55470. setReflectionTextureMatrix(value: Matrix): void;
  55471. /**
  55472. * Parses a JSON representation of an HDR Texture in order to create the texture
  55473. * @param parsedTexture Define the JSON representation
  55474. * @param scene Define the scene the texture should be created in
  55475. * @param rootUrl Define the root url in case we need to load relative dependencies
  55476. * @returns the newly created texture after parsing
  55477. */
  55478. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55479. serialize(): any;
  55480. }
  55481. }
  55482. declare module BABYLON {
  55483. /**
  55484. * Class used to control physics engine
  55485. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55486. */
  55487. export class PhysicsEngine implements IPhysicsEngine {
  55488. private _physicsPlugin;
  55489. /**
  55490. * Global value used to control the smallest number supported by the simulation
  55491. */
  55492. static Epsilon: number;
  55493. private _impostors;
  55494. private _joints;
  55495. private _subTimeStep;
  55496. /**
  55497. * Gets the gravity vector used by the simulation
  55498. */
  55499. gravity: Vector3;
  55500. /**
  55501. * Factory used to create the default physics plugin.
  55502. * @returns The default physics plugin
  55503. */
  55504. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55505. /**
  55506. * Creates a new Physics Engine
  55507. * @param gravity defines the gravity vector used by the simulation
  55508. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55509. */
  55510. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55511. /**
  55512. * Sets the gravity vector used by the simulation
  55513. * @param gravity defines the gravity vector to use
  55514. */
  55515. setGravity(gravity: Vector3): void;
  55516. /**
  55517. * Set the time step of the physics engine.
  55518. * Default is 1/60.
  55519. * To slow it down, enter 1/600 for example.
  55520. * To speed it up, 1/30
  55521. * @param newTimeStep defines the new timestep to apply to this world.
  55522. */
  55523. setTimeStep(newTimeStep?: number): void;
  55524. /**
  55525. * Get the time step of the physics engine.
  55526. * @returns the current time step
  55527. */
  55528. getTimeStep(): number;
  55529. /**
  55530. * Set the sub time step of the physics engine.
  55531. * Default is 0 meaning there is no sub steps
  55532. * To increase physics resolution precision, set a small value (like 1 ms)
  55533. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55534. */
  55535. setSubTimeStep(subTimeStep?: number): void;
  55536. /**
  55537. * Get the sub time step of the physics engine.
  55538. * @returns the current sub time step
  55539. */
  55540. getSubTimeStep(): number;
  55541. /**
  55542. * Release all resources
  55543. */
  55544. dispose(): void;
  55545. /**
  55546. * Gets the name of the current physics plugin
  55547. * @returns the name of the plugin
  55548. */
  55549. getPhysicsPluginName(): string;
  55550. /**
  55551. * Adding a new impostor for the impostor tracking.
  55552. * This will be done by the impostor itself.
  55553. * @param impostor the impostor to add
  55554. */
  55555. addImpostor(impostor: PhysicsImpostor): void;
  55556. /**
  55557. * Remove an impostor from the engine.
  55558. * This impostor and its mesh will not longer be updated by the physics engine.
  55559. * @param impostor the impostor to remove
  55560. */
  55561. removeImpostor(impostor: PhysicsImpostor): void;
  55562. /**
  55563. * Add a joint to the physics engine
  55564. * @param mainImpostor defines the main impostor to which the joint is added.
  55565. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55566. * @param joint defines the joint that will connect both impostors.
  55567. */
  55568. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55569. /**
  55570. * Removes a joint from the simulation
  55571. * @param mainImpostor defines the impostor used with the joint
  55572. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55573. * @param joint defines the joint to remove
  55574. */
  55575. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55576. /**
  55577. * Called by the scene. No need to call it.
  55578. * @param delta defines the timespam between frames
  55579. */
  55580. _step(delta: number): void;
  55581. /**
  55582. * Gets the current plugin used to run the simulation
  55583. * @returns current plugin
  55584. */
  55585. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55586. /**
  55587. * Gets the list of physic impostors
  55588. * @returns an array of PhysicsImpostor
  55589. */
  55590. getImpostors(): Array<PhysicsImpostor>;
  55591. /**
  55592. * Gets the impostor for a physics enabled object
  55593. * @param object defines the object impersonated by the impostor
  55594. * @returns the PhysicsImpostor or null if not found
  55595. */
  55596. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55597. /**
  55598. * Gets the impostor for a physics body object
  55599. * @param body defines physics body used by the impostor
  55600. * @returns the PhysicsImpostor or null if not found
  55601. */
  55602. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55603. /**
  55604. * Does a raycast in the physics world
  55605. * @param from when should the ray start?
  55606. * @param to when should the ray end?
  55607. * @returns PhysicsRaycastResult
  55608. */
  55609. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55610. }
  55611. }
  55612. declare module BABYLON {
  55613. /** @hidden */
  55614. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55615. private _useDeltaForWorldStep;
  55616. world: any;
  55617. name: string;
  55618. private _physicsMaterials;
  55619. private _fixedTimeStep;
  55620. private _cannonRaycastResult;
  55621. private _raycastResult;
  55622. private _physicsBodysToRemoveAfterStep;
  55623. BJSCANNON: any;
  55624. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55625. setGravity(gravity: Vector3): void;
  55626. setTimeStep(timeStep: number): void;
  55627. getTimeStep(): number;
  55628. executeStep(delta: number): void;
  55629. private _removeMarkedPhysicsBodiesFromWorld;
  55630. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55631. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55632. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55633. private _processChildMeshes;
  55634. removePhysicsBody(impostor: PhysicsImpostor): void;
  55635. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55636. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55637. private _addMaterial;
  55638. private _checkWithEpsilon;
  55639. private _createShape;
  55640. private _createHeightmap;
  55641. private _minus90X;
  55642. private _plus90X;
  55643. private _tmpPosition;
  55644. private _tmpDeltaPosition;
  55645. private _tmpUnityRotation;
  55646. private _updatePhysicsBodyTransformation;
  55647. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55648. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55649. isSupported(): boolean;
  55650. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55651. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55652. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55653. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55654. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55655. getBodyMass(impostor: PhysicsImpostor): number;
  55656. getBodyFriction(impostor: PhysicsImpostor): number;
  55657. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55658. getBodyRestitution(impostor: PhysicsImpostor): number;
  55659. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55660. sleepBody(impostor: PhysicsImpostor): void;
  55661. wakeUpBody(impostor: PhysicsImpostor): void;
  55662. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55663. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55664. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55665. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55666. getRadius(impostor: PhysicsImpostor): number;
  55667. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55668. dispose(): void;
  55669. private _extendNamespace;
  55670. /**
  55671. * Does a raycast in the physics world
  55672. * @param from when should the ray start?
  55673. * @param to when should the ray end?
  55674. * @returns PhysicsRaycastResult
  55675. */
  55676. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55677. }
  55678. }
  55679. declare module BABYLON {
  55680. /** @hidden */
  55681. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55682. private _useDeltaForWorldStep;
  55683. world: any;
  55684. name: string;
  55685. BJSOIMO: any;
  55686. private _raycastResult;
  55687. private _fixedTimeStep;
  55688. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  55689. setGravity(gravity: Vector3): void;
  55690. setTimeStep(timeStep: number): void;
  55691. getTimeStep(): number;
  55692. private _tmpImpostorsArray;
  55693. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55694. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55695. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55696. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55697. private _tmpPositionVector;
  55698. removePhysicsBody(impostor: PhysicsImpostor): void;
  55699. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55700. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55701. isSupported(): boolean;
  55702. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55703. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55704. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55705. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55706. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55707. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55708. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55709. getBodyMass(impostor: PhysicsImpostor): number;
  55710. getBodyFriction(impostor: PhysicsImpostor): number;
  55711. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55712. getBodyRestitution(impostor: PhysicsImpostor): number;
  55713. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55714. sleepBody(impostor: PhysicsImpostor): void;
  55715. wakeUpBody(impostor: PhysicsImpostor): void;
  55716. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55717. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55718. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55719. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55720. getRadius(impostor: PhysicsImpostor): number;
  55721. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55722. dispose(): void;
  55723. /**
  55724. * Does a raycast in the physics world
  55725. * @param from when should the ray start?
  55726. * @param to when should the ray end?
  55727. * @returns PhysicsRaycastResult
  55728. */
  55729. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55730. }
  55731. }
  55732. declare module BABYLON {
  55733. /**
  55734. * Class containing static functions to help procedurally build meshes
  55735. */
  55736. export class RibbonBuilder {
  55737. /**
  55738. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55739. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55740. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55741. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55742. * * 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
  55743. * * 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
  55744. * * 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
  55745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55746. * * 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
  55747. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55748. * * 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
  55749. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55750. * * 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
  55751. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55753. * @param name defines the name of the mesh
  55754. * @param options defines the options used to create the mesh
  55755. * @param scene defines the hosting scene
  55756. * @returns the ribbon mesh
  55757. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55758. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55759. */
  55760. static CreateRibbon(name: string, options: {
  55761. pathArray: Vector3[][];
  55762. closeArray?: boolean;
  55763. closePath?: boolean;
  55764. offset?: number;
  55765. updatable?: boolean;
  55766. sideOrientation?: number;
  55767. frontUVs?: Vector4;
  55768. backUVs?: Vector4;
  55769. instance?: Mesh;
  55770. invertUV?: boolean;
  55771. uvs?: Vector2[];
  55772. colors?: Color4[];
  55773. }, scene?: Nullable<Scene>): Mesh;
  55774. }
  55775. }
  55776. declare module BABYLON {
  55777. /**
  55778. * Class containing static functions to help procedurally build meshes
  55779. */
  55780. export class ShapeBuilder {
  55781. /**
  55782. * 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.
  55783. * * 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.
  55784. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55785. * * 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.
  55786. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55787. * * 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
  55788. * * 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
  55789. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55791. * * 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
  55792. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55794. * @param name defines the name of the mesh
  55795. * @param options defines the options used to create the mesh
  55796. * @param scene defines the hosting scene
  55797. * @returns the extruded shape mesh
  55798. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55799. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55800. */
  55801. static ExtrudeShape(name: string, options: {
  55802. shape: Vector3[];
  55803. path: Vector3[];
  55804. scale?: number;
  55805. rotation?: number;
  55806. cap?: number;
  55807. updatable?: boolean;
  55808. sideOrientation?: number;
  55809. frontUVs?: Vector4;
  55810. backUVs?: Vector4;
  55811. instance?: Mesh;
  55812. invertUV?: boolean;
  55813. }, scene?: Nullable<Scene>): Mesh;
  55814. /**
  55815. * Creates an custom extruded shape mesh.
  55816. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55817. * * 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.
  55818. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55819. * * 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
  55820. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55821. * * 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
  55822. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55823. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55824. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55825. * * 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
  55826. * * 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
  55827. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55829. * * 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
  55830. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55832. * @param name defines the name of the mesh
  55833. * @param options defines the options used to create the mesh
  55834. * @param scene defines the hosting scene
  55835. * @returns the custom extruded shape mesh
  55836. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55837. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55838. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55839. */
  55840. static ExtrudeShapeCustom(name: string, options: {
  55841. shape: Vector3[];
  55842. path: Vector3[];
  55843. scaleFunction?: any;
  55844. rotationFunction?: any;
  55845. ribbonCloseArray?: boolean;
  55846. ribbonClosePath?: boolean;
  55847. cap?: number;
  55848. updatable?: boolean;
  55849. sideOrientation?: number;
  55850. frontUVs?: Vector4;
  55851. backUVs?: Vector4;
  55852. instance?: Mesh;
  55853. invertUV?: boolean;
  55854. }, scene?: Nullable<Scene>): Mesh;
  55855. private static _ExtrudeShapeGeneric;
  55856. }
  55857. }
  55858. declare module BABYLON {
  55859. /**
  55860. * AmmoJS Physics plugin
  55861. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55862. * @see https://github.com/kripken/ammo.js/
  55863. */
  55864. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55865. private _useDeltaForWorldStep;
  55866. /**
  55867. * Reference to the Ammo library
  55868. */
  55869. bjsAMMO: any;
  55870. /**
  55871. * Created ammoJS world which physics bodies are added to
  55872. */
  55873. world: any;
  55874. /**
  55875. * Name of the plugin
  55876. */
  55877. name: string;
  55878. private _timeStep;
  55879. private _fixedTimeStep;
  55880. private _maxSteps;
  55881. private _tmpQuaternion;
  55882. private _tmpAmmoTransform;
  55883. private _tmpAmmoQuaternion;
  55884. private _tmpAmmoConcreteContactResultCallback;
  55885. private _collisionConfiguration;
  55886. private _dispatcher;
  55887. private _overlappingPairCache;
  55888. private _solver;
  55889. private _softBodySolver;
  55890. private _tmpAmmoVectorA;
  55891. private _tmpAmmoVectorB;
  55892. private _tmpAmmoVectorC;
  55893. private _tmpAmmoVectorD;
  55894. private _tmpContactCallbackResult;
  55895. private _tmpAmmoVectorRCA;
  55896. private _tmpAmmoVectorRCB;
  55897. private _raycastResult;
  55898. private static readonly DISABLE_COLLISION_FLAG;
  55899. private static readonly KINEMATIC_FLAG;
  55900. private static readonly DISABLE_DEACTIVATION_FLAG;
  55901. /**
  55902. * Initializes the ammoJS plugin
  55903. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55904. * @param ammoInjection can be used to inject your own ammo reference
  55905. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55906. */
  55907. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55908. /**
  55909. * Sets the gravity of the physics world (m/(s^2))
  55910. * @param gravity Gravity to set
  55911. */
  55912. setGravity(gravity: Vector3): void;
  55913. /**
  55914. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55915. * @param timeStep timestep to use in seconds
  55916. */
  55917. setTimeStep(timeStep: number): void;
  55918. /**
  55919. * 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)
  55920. * @param fixedTimeStep fixedTimeStep to use in seconds
  55921. */
  55922. setFixedTimeStep(fixedTimeStep: number): void;
  55923. /**
  55924. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55925. * @param maxSteps the maximum number of steps by the physics engine per frame
  55926. */
  55927. setMaxSteps(maxSteps: number): void;
  55928. /**
  55929. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55930. * @returns the current timestep in seconds
  55931. */
  55932. getTimeStep(): number;
  55933. /**
  55934. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55935. */
  55936. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55937. private _isImpostorInContact;
  55938. private _isImpostorPairInContact;
  55939. private _stepSimulation;
  55940. /**
  55941. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55942. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55943. * After the step the babylon meshes are set to the position of the physics imposters
  55944. * @param delta amount of time to step forward
  55945. * @param impostors array of imposters to update before/after the step
  55946. */
  55947. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55948. /**
  55949. * Update babylon mesh to match physics world object
  55950. * @param impostor imposter to match
  55951. */
  55952. private _afterSoftStep;
  55953. /**
  55954. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55955. * @param impostor imposter to match
  55956. */
  55957. private _ropeStep;
  55958. /**
  55959. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55960. * @param impostor imposter to match
  55961. */
  55962. private _softbodyOrClothStep;
  55963. private _tmpMatrix;
  55964. /**
  55965. * Applies an impulse on the imposter
  55966. * @param impostor imposter to apply impulse to
  55967. * @param force amount of force to be applied to the imposter
  55968. * @param contactPoint the location to apply the impulse on the imposter
  55969. */
  55970. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55971. /**
  55972. * Applies a force on the imposter
  55973. * @param impostor imposter to apply force
  55974. * @param force amount of force to be applied to the imposter
  55975. * @param contactPoint the location to apply the force on the imposter
  55976. */
  55977. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55978. /**
  55979. * Creates a physics body using the plugin
  55980. * @param impostor the imposter to create the physics body on
  55981. */
  55982. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55983. /**
  55984. * Removes the physics body from the imposter and disposes of the body's memory
  55985. * @param impostor imposter to remove the physics body from
  55986. */
  55987. removePhysicsBody(impostor: PhysicsImpostor): void;
  55988. /**
  55989. * Generates a joint
  55990. * @param impostorJoint the imposter joint to create the joint with
  55991. */
  55992. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55993. /**
  55994. * Removes a joint
  55995. * @param impostorJoint the imposter joint to remove the joint from
  55996. */
  55997. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55998. private _addMeshVerts;
  55999. /**
  56000. * Initialise the soft body vertices to match its object's (mesh) vertices
  56001. * Softbody vertices (nodes) are in world space and to match this
  56002. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56003. * @param impostor to create the softbody for
  56004. */
  56005. private _softVertexData;
  56006. /**
  56007. * Create an impostor's soft body
  56008. * @param impostor to create the softbody for
  56009. */
  56010. private _createSoftbody;
  56011. /**
  56012. * Create cloth for an impostor
  56013. * @param impostor to create the softbody for
  56014. */
  56015. private _createCloth;
  56016. /**
  56017. * Create rope for an impostor
  56018. * @param impostor to create the softbody for
  56019. */
  56020. private _createRope;
  56021. /**
  56022. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56023. * @param impostor to create the custom physics shape for
  56024. */
  56025. private _createCustom;
  56026. private _addHullVerts;
  56027. private _createShape;
  56028. /**
  56029. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56030. * @param impostor imposter containing the physics body and babylon object
  56031. */
  56032. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56033. /**
  56034. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56035. * @param impostor imposter containing the physics body and babylon object
  56036. * @param newPosition new position
  56037. * @param newRotation new rotation
  56038. */
  56039. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56040. /**
  56041. * If this plugin is supported
  56042. * @returns true if its supported
  56043. */
  56044. isSupported(): boolean;
  56045. /**
  56046. * Sets the linear velocity of the physics body
  56047. * @param impostor imposter to set the velocity on
  56048. * @param velocity velocity to set
  56049. */
  56050. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56051. /**
  56052. * Sets the angular velocity of the physics body
  56053. * @param impostor imposter to set the velocity on
  56054. * @param velocity velocity to set
  56055. */
  56056. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56057. /**
  56058. * gets the linear velocity
  56059. * @param impostor imposter to get linear velocity from
  56060. * @returns linear velocity
  56061. */
  56062. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56063. /**
  56064. * gets the angular velocity
  56065. * @param impostor imposter to get angular velocity from
  56066. * @returns angular velocity
  56067. */
  56068. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56069. /**
  56070. * Sets the mass of physics body
  56071. * @param impostor imposter to set the mass on
  56072. * @param mass mass to set
  56073. */
  56074. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56075. /**
  56076. * Gets the mass of the physics body
  56077. * @param impostor imposter to get the mass from
  56078. * @returns mass
  56079. */
  56080. getBodyMass(impostor: PhysicsImpostor): number;
  56081. /**
  56082. * Gets friction of the impostor
  56083. * @param impostor impostor to get friction from
  56084. * @returns friction value
  56085. */
  56086. getBodyFriction(impostor: PhysicsImpostor): number;
  56087. /**
  56088. * Sets friction of the impostor
  56089. * @param impostor impostor to set friction on
  56090. * @param friction friction value
  56091. */
  56092. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56093. /**
  56094. * Gets restitution of the impostor
  56095. * @param impostor impostor to get restitution from
  56096. * @returns restitution value
  56097. */
  56098. getBodyRestitution(impostor: PhysicsImpostor): number;
  56099. /**
  56100. * Sets resitution of the impostor
  56101. * @param impostor impostor to set resitution on
  56102. * @param restitution resitution value
  56103. */
  56104. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56105. /**
  56106. * Gets pressure inside the impostor
  56107. * @param impostor impostor to get pressure from
  56108. * @returns pressure value
  56109. */
  56110. getBodyPressure(impostor: PhysicsImpostor): number;
  56111. /**
  56112. * Sets pressure inside a soft body impostor
  56113. * Cloth and rope must remain 0 pressure
  56114. * @param impostor impostor to set pressure on
  56115. * @param pressure pressure value
  56116. */
  56117. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56118. /**
  56119. * Gets stiffness of the impostor
  56120. * @param impostor impostor to get stiffness from
  56121. * @returns pressure value
  56122. */
  56123. getBodyStiffness(impostor: PhysicsImpostor): number;
  56124. /**
  56125. * Sets stiffness of the impostor
  56126. * @param impostor impostor to set stiffness on
  56127. * @param stiffness stiffness value from 0 to 1
  56128. */
  56129. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56130. /**
  56131. * Gets velocityIterations of the impostor
  56132. * @param impostor impostor to get velocity iterations from
  56133. * @returns velocityIterations value
  56134. */
  56135. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56136. /**
  56137. * Sets velocityIterations of the impostor
  56138. * @param impostor impostor to set velocity iterations on
  56139. * @param velocityIterations velocityIterations value
  56140. */
  56141. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56142. /**
  56143. * Gets positionIterations of the impostor
  56144. * @param impostor impostor to get position iterations from
  56145. * @returns positionIterations value
  56146. */
  56147. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56148. /**
  56149. * Sets positionIterations of the impostor
  56150. * @param impostor impostor to set position on
  56151. * @param positionIterations positionIterations value
  56152. */
  56153. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56154. /**
  56155. * Append an anchor to a cloth object
  56156. * @param impostor is the cloth impostor to add anchor to
  56157. * @param otherImpostor is the rigid impostor to anchor to
  56158. * @param width ratio across width from 0 to 1
  56159. * @param height ratio up height from 0 to 1
  56160. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56161. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56162. */
  56163. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56164. /**
  56165. * Append an hook to a rope object
  56166. * @param impostor is the rope impostor to add hook to
  56167. * @param otherImpostor is the rigid impostor to hook to
  56168. * @param length ratio along the rope from 0 to 1
  56169. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56170. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56171. */
  56172. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56173. /**
  56174. * Sleeps the physics body and stops it from being active
  56175. * @param impostor impostor to sleep
  56176. */
  56177. sleepBody(impostor: PhysicsImpostor): void;
  56178. /**
  56179. * Activates the physics body
  56180. * @param impostor impostor to activate
  56181. */
  56182. wakeUpBody(impostor: PhysicsImpostor): void;
  56183. /**
  56184. * Updates the distance parameters of the joint
  56185. * @param joint joint to update
  56186. * @param maxDistance maximum distance of the joint
  56187. * @param minDistance minimum distance of the joint
  56188. */
  56189. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56190. /**
  56191. * Sets a motor on the joint
  56192. * @param joint joint to set motor on
  56193. * @param speed speed of the motor
  56194. * @param maxForce maximum force of the motor
  56195. * @param motorIndex index of the motor
  56196. */
  56197. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56198. /**
  56199. * Sets the motors limit
  56200. * @param joint joint to set limit on
  56201. * @param upperLimit upper limit
  56202. * @param lowerLimit lower limit
  56203. */
  56204. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56205. /**
  56206. * Syncs the position and rotation of a mesh with the impostor
  56207. * @param mesh mesh to sync
  56208. * @param impostor impostor to update the mesh with
  56209. */
  56210. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56211. /**
  56212. * Gets the radius of the impostor
  56213. * @param impostor impostor to get radius from
  56214. * @returns the radius
  56215. */
  56216. getRadius(impostor: PhysicsImpostor): number;
  56217. /**
  56218. * Gets the box size of the impostor
  56219. * @param impostor impostor to get box size from
  56220. * @param result the resulting box size
  56221. */
  56222. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56223. /**
  56224. * Disposes of the impostor
  56225. */
  56226. dispose(): void;
  56227. /**
  56228. * Does a raycast in the physics world
  56229. * @param from when should the ray start?
  56230. * @param to when should the ray end?
  56231. * @returns PhysicsRaycastResult
  56232. */
  56233. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56234. }
  56235. }
  56236. declare module BABYLON {
  56237. interface AbstractScene {
  56238. /**
  56239. * The list of reflection probes added to the scene
  56240. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56241. */
  56242. reflectionProbes: Array<ReflectionProbe>;
  56243. /**
  56244. * Removes the given reflection probe from this scene.
  56245. * @param toRemove The reflection probe to remove
  56246. * @returns The index of the removed reflection probe
  56247. */
  56248. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56249. /**
  56250. * Adds the given reflection probe to this scene.
  56251. * @param newReflectionProbe The reflection probe to add
  56252. */
  56253. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56254. }
  56255. /**
  56256. * Class used to generate realtime reflection / refraction cube textures
  56257. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56258. */
  56259. export class ReflectionProbe {
  56260. /** defines the name of the probe */
  56261. name: string;
  56262. private _scene;
  56263. private _renderTargetTexture;
  56264. private _projectionMatrix;
  56265. private _viewMatrix;
  56266. private _target;
  56267. private _add;
  56268. private _attachedMesh;
  56269. private _invertYAxis;
  56270. /** Gets or sets probe position (center of the cube map) */
  56271. position: Vector3;
  56272. /**
  56273. * Creates a new reflection probe
  56274. * @param name defines the name of the probe
  56275. * @param size defines the texture resolution (for each face)
  56276. * @param scene defines the hosting scene
  56277. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56278. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56279. */
  56280. constructor(
  56281. /** defines the name of the probe */
  56282. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56283. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56284. get samples(): number;
  56285. set samples(value: number);
  56286. /** Gets or sets the refresh rate to use (on every frame by default) */
  56287. get refreshRate(): number;
  56288. set refreshRate(value: number);
  56289. /**
  56290. * Gets the hosting scene
  56291. * @returns a Scene
  56292. */
  56293. getScene(): Scene;
  56294. /** Gets the internal CubeTexture used to render to */
  56295. get cubeTexture(): RenderTargetTexture;
  56296. /** Gets the list of meshes to render */
  56297. get renderList(): Nullable<AbstractMesh[]>;
  56298. /**
  56299. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56300. * @param mesh defines the mesh to attach to
  56301. */
  56302. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56303. /**
  56304. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56305. * @param renderingGroupId The rendering group id corresponding to its index
  56306. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56307. */
  56308. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56309. /**
  56310. * Clean all associated resources
  56311. */
  56312. dispose(): void;
  56313. /**
  56314. * Converts the reflection probe information to a readable string for debug purpose.
  56315. * @param fullDetails Supports for multiple levels of logging within scene loading
  56316. * @returns the human readable reflection probe info
  56317. */
  56318. toString(fullDetails?: boolean): string;
  56319. /**
  56320. * Get the class name of the relfection probe.
  56321. * @returns "ReflectionProbe"
  56322. */
  56323. getClassName(): string;
  56324. /**
  56325. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56326. * @returns The JSON representation of the texture
  56327. */
  56328. serialize(): any;
  56329. /**
  56330. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56331. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56332. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56333. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56334. * @returns The parsed reflection probe if successful
  56335. */
  56336. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56337. }
  56338. }
  56339. declare module BABYLON {
  56340. /** @hidden */
  56341. export var _BabylonLoaderRegistered: boolean;
  56342. /**
  56343. * Helps setting up some configuration for the babylon file loader.
  56344. */
  56345. export class BabylonFileLoaderConfiguration {
  56346. /**
  56347. * The loader does not allow injecting custom physix engine into the plugins.
  56348. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56349. * So you could set this variable to your engine import to make it work.
  56350. */
  56351. static LoaderInjectedPhysicsEngine: any;
  56352. }
  56353. }
  56354. declare module BABYLON {
  56355. /**
  56356. * The Physically based simple base material of BJS.
  56357. *
  56358. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56359. * It is used as the base class for both the specGloss and metalRough conventions.
  56360. */
  56361. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56362. /**
  56363. * Number of Simultaneous lights allowed on the material.
  56364. */
  56365. maxSimultaneousLights: number;
  56366. /**
  56367. * If sets to true, disables all the lights affecting the material.
  56368. */
  56369. disableLighting: boolean;
  56370. /**
  56371. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56372. */
  56373. environmentTexture: BaseTexture;
  56374. /**
  56375. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56376. */
  56377. invertNormalMapX: boolean;
  56378. /**
  56379. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56380. */
  56381. invertNormalMapY: boolean;
  56382. /**
  56383. * Normal map used in the model.
  56384. */
  56385. normalTexture: BaseTexture;
  56386. /**
  56387. * Emissivie color used to self-illuminate the model.
  56388. */
  56389. emissiveColor: Color3;
  56390. /**
  56391. * Emissivie texture used to self-illuminate the model.
  56392. */
  56393. emissiveTexture: BaseTexture;
  56394. /**
  56395. * Occlusion Channel Strenght.
  56396. */
  56397. occlusionStrength: number;
  56398. /**
  56399. * Occlusion Texture of the material (adding extra occlusion effects).
  56400. */
  56401. occlusionTexture: BaseTexture;
  56402. /**
  56403. * Defines the alpha limits in alpha test mode.
  56404. */
  56405. alphaCutOff: number;
  56406. /**
  56407. * Gets the current double sided mode.
  56408. */
  56409. get doubleSided(): boolean;
  56410. /**
  56411. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56412. */
  56413. set doubleSided(value: boolean);
  56414. /**
  56415. * Stores the pre-calculated light information of a mesh in a texture.
  56416. */
  56417. lightmapTexture: BaseTexture;
  56418. /**
  56419. * If true, the light map contains occlusion information instead of lighting info.
  56420. */
  56421. useLightmapAsShadowmap: boolean;
  56422. /**
  56423. * Instantiates a new PBRMaterial instance.
  56424. *
  56425. * @param name The material name
  56426. * @param scene The scene the material will be use in.
  56427. */
  56428. constructor(name: string, scene: Scene);
  56429. getClassName(): string;
  56430. }
  56431. }
  56432. declare module BABYLON {
  56433. /**
  56434. * The PBR material of BJS following the metal roughness convention.
  56435. *
  56436. * This fits to the PBR convention in the GLTF definition:
  56437. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56438. */
  56439. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56440. /**
  56441. * The base color has two different interpretations depending on the value of metalness.
  56442. * When the material is a metal, the base color is the specific measured reflectance value
  56443. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56444. * of the material.
  56445. */
  56446. baseColor: Color3;
  56447. /**
  56448. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56449. * well as opacity information in the alpha channel.
  56450. */
  56451. baseTexture: BaseTexture;
  56452. /**
  56453. * Specifies the metallic scalar value of the material.
  56454. * Can also be used to scale the metalness values of the metallic texture.
  56455. */
  56456. metallic: number;
  56457. /**
  56458. * Specifies the roughness scalar value of the material.
  56459. * Can also be used to scale the roughness values of the metallic texture.
  56460. */
  56461. roughness: number;
  56462. /**
  56463. * Texture containing both the metallic value in the B channel and the
  56464. * roughness value in the G channel to keep better precision.
  56465. */
  56466. metallicRoughnessTexture: BaseTexture;
  56467. /**
  56468. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56469. *
  56470. * @param name The material name
  56471. * @param scene The scene the material will be use in.
  56472. */
  56473. constructor(name: string, scene: Scene);
  56474. /**
  56475. * Return the currrent class name of the material.
  56476. */
  56477. getClassName(): string;
  56478. /**
  56479. * Makes a duplicate of the current material.
  56480. * @param name - name to use for the new material.
  56481. */
  56482. clone(name: string): PBRMetallicRoughnessMaterial;
  56483. /**
  56484. * Serialize the material to a parsable JSON object.
  56485. */
  56486. serialize(): any;
  56487. /**
  56488. * Parses a JSON object correponding to the serialize function.
  56489. */
  56490. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56491. }
  56492. }
  56493. declare module BABYLON {
  56494. /**
  56495. * The PBR material of BJS following the specular glossiness convention.
  56496. *
  56497. * This fits to the PBR convention in the GLTF definition:
  56498. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56499. */
  56500. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56501. /**
  56502. * Specifies the diffuse color of the material.
  56503. */
  56504. diffuseColor: Color3;
  56505. /**
  56506. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56507. * channel.
  56508. */
  56509. diffuseTexture: BaseTexture;
  56510. /**
  56511. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56512. */
  56513. specularColor: Color3;
  56514. /**
  56515. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56516. */
  56517. glossiness: number;
  56518. /**
  56519. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56520. */
  56521. specularGlossinessTexture: BaseTexture;
  56522. /**
  56523. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56524. *
  56525. * @param name The material name
  56526. * @param scene The scene the material will be use in.
  56527. */
  56528. constructor(name: string, scene: Scene);
  56529. /**
  56530. * Return the currrent class name of the material.
  56531. */
  56532. getClassName(): string;
  56533. /**
  56534. * Makes a duplicate of the current material.
  56535. * @param name - name to use for the new material.
  56536. */
  56537. clone(name: string): PBRSpecularGlossinessMaterial;
  56538. /**
  56539. * Serialize the material to a parsable JSON object.
  56540. */
  56541. serialize(): any;
  56542. /**
  56543. * Parses a JSON object correponding to the serialize function.
  56544. */
  56545. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56546. }
  56547. }
  56548. declare module BABYLON {
  56549. /**
  56550. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56551. * It can help converting any input color in a desired output one. This can then be used to create effects
  56552. * from sepia, black and white to sixties or futuristic rendering...
  56553. *
  56554. * The only supported format is currently 3dl.
  56555. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56556. */
  56557. export class ColorGradingTexture extends BaseTexture {
  56558. /**
  56559. * The texture URL.
  56560. */
  56561. url: string;
  56562. /**
  56563. * Empty line regex stored for GC.
  56564. */
  56565. private static _noneEmptyLineRegex;
  56566. private _textureMatrix;
  56567. private _engine;
  56568. private _onLoad;
  56569. /**
  56570. * Instantiates a ColorGradingTexture from the following parameters.
  56571. *
  56572. * @param url The location of the color gradind data (currently only supporting 3dl)
  56573. * @param sceneOrEngine The scene or engine the texture will be used in
  56574. * @param onLoad defines a callback triggered when the texture has been loaded
  56575. */
  56576. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  56577. /**
  56578. * Fires the onload event from the constructor if requested.
  56579. */
  56580. private _triggerOnLoad;
  56581. /**
  56582. * Returns the texture matrix used in most of the material.
  56583. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56584. */
  56585. getTextureMatrix(): Matrix;
  56586. /**
  56587. * Occurs when the file being loaded is a .3dl LUT file.
  56588. */
  56589. private load3dlTexture;
  56590. /**
  56591. * Starts the loading process of the texture.
  56592. */
  56593. private loadTexture;
  56594. /**
  56595. * Clones the color gradind texture.
  56596. */
  56597. clone(): ColorGradingTexture;
  56598. /**
  56599. * Called during delayed load for textures.
  56600. */
  56601. delayLoad(): void;
  56602. /**
  56603. * Parses a color grading texture serialized by Babylon.
  56604. * @param parsedTexture The texture information being parsedTexture
  56605. * @param scene The scene to load the texture in
  56606. * @param rootUrl The root url of the data assets to load
  56607. * @return A color gradind texture
  56608. */
  56609. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56610. /**
  56611. * Serializes the LUT texture to json format.
  56612. */
  56613. serialize(): any;
  56614. /**
  56615. * Returns true if the passed parameter is a scene object (can be use for typings)
  56616. * @param sceneOrEngine The object to test.
  56617. */
  56618. private static _isScene;
  56619. }
  56620. }
  56621. declare module BABYLON {
  56622. /**
  56623. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56624. */
  56625. export class EquiRectangularCubeTexture extends BaseTexture {
  56626. /** The six faces of the cube. */
  56627. private static _FacesMapping;
  56628. private _noMipmap;
  56629. private _onLoad;
  56630. private _onError;
  56631. /** The size of the cubemap. */
  56632. private _size;
  56633. /** The buffer of the image. */
  56634. private _buffer;
  56635. /** The width of the input image. */
  56636. private _width;
  56637. /** The height of the input image. */
  56638. private _height;
  56639. /** The URL to the image. */
  56640. url: string;
  56641. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56642. coordinatesMode: number;
  56643. /**
  56644. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56645. * @param url The location of the image
  56646. * @param scene The scene the texture will be used in
  56647. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56648. * @param noMipmap Forces to not generate the mipmap if true
  56649. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56650. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56651. * @param onLoad — defines a callback called when texture is loaded
  56652. * @param onError — defines a callback called if there is an error
  56653. */
  56654. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56655. /**
  56656. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56657. */
  56658. private loadImage;
  56659. /**
  56660. * Convert the image buffer into a cubemap and create a CubeTexture.
  56661. */
  56662. private loadTexture;
  56663. /**
  56664. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56665. * @param buffer The ArrayBuffer that should be converted.
  56666. * @returns The buffer as Float32Array.
  56667. */
  56668. private getFloat32ArrayFromArrayBuffer;
  56669. /**
  56670. * Get the current class name of the texture useful for serialization or dynamic coding.
  56671. * @returns "EquiRectangularCubeTexture"
  56672. */
  56673. getClassName(): string;
  56674. /**
  56675. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56676. * @returns A clone of the current EquiRectangularCubeTexture.
  56677. */
  56678. clone(): EquiRectangularCubeTexture;
  56679. }
  56680. }
  56681. declare module BABYLON {
  56682. /**
  56683. * Based on jsTGALoader - Javascript loader for TGA file
  56684. * By Vincent Thibault
  56685. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56686. */
  56687. export class TGATools {
  56688. private static _TYPE_INDEXED;
  56689. private static _TYPE_RGB;
  56690. private static _TYPE_GREY;
  56691. private static _TYPE_RLE_INDEXED;
  56692. private static _TYPE_RLE_RGB;
  56693. private static _TYPE_RLE_GREY;
  56694. private static _ORIGIN_MASK;
  56695. private static _ORIGIN_SHIFT;
  56696. private static _ORIGIN_BL;
  56697. private static _ORIGIN_BR;
  56698. private static _ORIGIN_UL;
  56699. private static _ORIGIN_UR;
  56700. /**
  56701. * Gets the header of a TGA file
  56702. * @param data defines the TGA data
  56703. * @returns the header
  56704. */
  56705. static GetTGAHeader(data: Uint8Array): any;
  56706. /**
  56707. * Uploads TGA content to a Babylon Texture
  56708. * @hidden
  56709. */
  56710. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56711. /** @hidden */
  56712. 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;
  56713. /** @hidden */
  56714. 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;
  56715. /** @hidden */
  56716. 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;
  56717. /** @hidden */
  56718. 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;
  56719. /** @hidden */
  56720. 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;
  56721. /** @hidden */
  56722. 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;
  56723. }
  56724. }
  56725. declare module BABYLON {
  56726. /**
  56727. * Implementation of the TGA Texture Loader.
  56728. * @hidden
  56729. */
  56730. export class _TGATextureLoader implements IInternalTextureLoader {
  56731. /**
  56732. * Defines wether the loader supports cascade loading the different faces.
  56733. */
  56734. readonly supportCascades: boolean;
  56735. /**
  56736. * This returns if the loader support the current file information.
  56737. * @param extension defines the file extension of the file being loaded
  56738. * @returns true if the loader can load the specified file
  56739. */
  56740. canLoad(extension: string): boolean;
  56741. /**
  56742. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56743. * @param data contains the texture data
  56744. * @param texture defines the BabylonJS internal texture
  56745. * @param createPolynomials will be true if polynomials have been requested
  56746. * @param onLoad defines the callback to trigger once the texture is ready
  56747. * @param onError defines the callback to trigger in case of error
  56748. */
  56749. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56750. /**
  56751. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56752. * @param data contains the texture data
  56753. * @param texture defines the BabylonJS internal texture
  56754. * @param callback defines the method to call once ready to upload
  56755. */
  56756. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56757. }
  56758. }
  56759. declare module BABYLON {
  56760. /**
  56761. * Info about the .basis files
  56762. */
  56763. class BasisFileInfo {
  56764. /**
  56765. * If the file has alpha
  56766. */
  56767. hasAlpha: boolean;
  56768. /**
  56769. * Info about each image of the basis file
  56770. */
  56771. images: Array<{
  56772. levels: Array<{
  56773. width: number;
  56774. height: number;
  56775. transcodedPixels: ArrayBufferView;
  56776. }>;
  56777. }>;
  56778. }
  56779. /**
  56780. * Result of transcoding a basis file
  56781. */
  56782. class TranscodeResult {
  56783. /**
  56784. * Info about the .basis file
  56785. */
  56786. fileInfo: BasisFileInfo;
  56787. /**
  56788. * Format to use when loading the file
  56789. */
  56790. format: number;
  56791. }
  56792. /**
  56793. * Configuration options for the Basis transcoder
  56794. */
  56795. export class BasisTranscodeConfiguration {
  56796. /**
  56797. * Supported compression formats used to determine the supported output format of the transcoder
  56798. */
  56799. supportedCompressionFormats?: {
  56800. /**
  56801. * etc1 compression format
  56802. */
  56803. etc1?: boolean;
  56804. /**
  56805. * s3tc compression format
  56806. */
  56807. s3tc?: boolean;
  56808. /**
  56809. * pvrtc compression format
  56810. */
  56811. pvrtc?: boolean;
  56812. /**
  56813. * etc2 compression format
  56814. */
  56815. etc2?: boolean;
  56816. };
  56817. /**
  56818. * If mipmap levels should be loaded for transcoded images (Default: true)
  56819. */
  56820. loadMipmapLevels?: boolean;
  56821. /**
  56822. * Index of a single image to load (Default: all images)
  56823. */
  56824. loadSingleImage?: number;
  56825. }
  56826. /**
  56827. * Used to load .Basis files
  56828. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56829. */
  56830. export class BasisTools {
  56831. private static _IgnoreSupportedFormats;
  56832. /**
  56833. * URL to use when loading the basis transcoder
  56834. */
  56835. static JSModuleURL: string;
  56836. /**
  56837. * URL to use when loading the wasm module for the transcoder
  56838. */
  56839. static WasmModuleURL: string;
  56840. /**
  56841. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56842. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56843. * @returns internal format corresponding to the Basis format
  56844. */
  56845. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56846. private static _WorkerPromise;
  56847. private static _Worker;
  56848. private static _actionId;
  56849. private static _CreateWorkerAsync;
  56850. /**
  56851. * Transcodes a loaded image file to compressed pixel data
  56852. * @param data image data to transcode
  56853. * @param config configuration options for the transcoding
  56854. * @returns a promise resulting in the transcoded image
  56855. */
  56856. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56857. /**
  56858. * Loads a texture from the transcode result
  56859. * @param texture texture load to
  56860. * @param transcodeResult the result of transcoding the basis file to load from
  56861. */
  56862. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56863. }
  56864. }
  56865. declare module BABYLON {
  56866. /**
  56867. * Loader for .basis file format
  56868. */
  56869. export class _BasisTextureLoader implements IInternalTextureLoader {
  56870. /**
  56871. * Defines whether the loader supports cascade loading the different faces.
  56872. */
  56873. readonly supportCascades: boolean;
  56874. /**
  56875. * This returns if the loader support the current file information.
  56876. * @param extension defines the file extension of the file being loaded
  56877. * @returns true if the loader can load the specified file
  56878. */
  56879. canLoad(extension: string): boolean;
  56880. /**
  56881. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56882. * @param data contains the texture data
  56883. * @param texture defines the BabylonJS internal texture
  56884. * @param createPolynomials will be true if polynomials have been requested
  56885. * @param onLoad defines the callback to trigger once the texture is ready
  56886. * @param onError defines the callback to trigger in case of error
  56887. */
  56888. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56889. /**
  56890. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56891. * @param data contains the texture data
  56892. * @param texture defines the BabylonJS internal texture
  56893. * @param callback defines the method to call once ready to upload
  56894. */
  56895. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56896. }
  56897. }
  56898. declare module BABYLON {
  56899. /**
  56900. * 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.
  56901. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56902. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56903. */
  56904. export class CustomProceduralTexture extends ProceduralTexture {
  56905. private _animate;
  56906. private _time;
  56907. private _config;
  56908. private _texturePath;
  56909. /**
  56910. * Instantiates a new Custom Procedural Texture.
  56911. * 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.
  56912. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56913. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56914. * @param name Define the name of the texture
  56915. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56916. * @param size Define the size of the texture to create
  56917. * @param scene Define the scene the texture belongs to
  56918. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56919. * @param generateMipMaps Define if the texture should creates mip maps or not
  56920. */
  56921. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56922. private _loadJson;
  56923. /**
  56924. * Is the texture ready to be used ? (rendered at least once)
  56925. * @returns true if ready, otherwise, false.
  56926. */
  56927. isReady(): boolean;
  56928. /**
  56929. * Render the texture to its associated render target.
  56930. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56931. */
  56932. render(useCameraPostProcess?: boolean): void;
  56933. /**
  56934. * Update the list of dependant textures samplers in the shader.
  56935. */
  56936. updateTextures(): void;
  56937. /**
  56938. * Update the uniform values of the procedural texture in the shader.
  56939. */
  56940. updateShaderUniforms(): void;
  56941. /**
  56942. * Define if the texture animates or not.
  56943. */
  56944. get animate(): boolean;
  56945. set animate(value: boolean);
  56946. }
  56947. }
  56948. declare module BABYLON {
  56949. /** @hidden */
  56950. export var noisePixelShader: {
  56951. name: string;
  56952. shader: string;
  56953. };
  56954. }
  56955. declare module BABYLON {
  56956. /**
  56957. * Class used to generate noise procedural textures
  56958. */
  56959. export class NoiseProceduralTexture extends ProceduralTexture {
  56960. private _time;
  56961. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56962. brightness: number;
  56963. /** Defines the number of octaves to process */
  56964. octaves: number;
  56965. /** Defines the level of persistence (0.8 by default) */
  56966. persistence: number;
  56967. /** Gets or sets animation speed factor (default is 1) */
  56968. animationSpeedFactor: number;
  56969. /**
  56970. * Creates a new NoiseProceduralTexture
  56971. * @param name defines the name fo the texture
  56972. * @param size defines the size of the texture (default is 256)
  56973. * @param scene defines the hosting scene
  56974. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56975. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56976. */
  56977. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56978. private _updateShaderUniforms;
  56979. protected _getDefines(): string;
  56980. /** Generate the current state of the procedural texture */
  56981. render(useCameraPostProcess?: boolean): void;
  56982. /**
  56983. * Serializes this noise procedural texture
  56984. * @returns a serialized noise procedural texture object
  56985. */
  56986. serialize(): any;
  56987. /**
  56988. * Clone the texture.
  56989. * @returns the cloned texture
  56990. */
  56991. clone(): NoiseProceduralTexture;
  56992. /**
  56993. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56994. * @param parsedTexture defines parsed texture data
  56995. * @param scene defines the current scene
  56996. * @param rootUrl defines the root URL containing noise procedural texture information
  56997. * @returns a parsed NoiseProceduralTexture
  56998. */
  56999. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57000. }
  57001. }
  57002. declare module BABYLON {
  57003. /**
  57004. * Raw cube texture where the raw buffers are passed in
  57005. */
  57006. export class RawCubeTexture extends CubeTexture {
  57007. /**
  57008. * Creates a cube texture where the raw buffers are passed in.
  57009. * @param scene defines the scene the texture is attached to
  57010. * @param data defines the array of data to use to create each face
  57011. * @param size defines the size of the textures
  57012. * @param format defines the format of the data
  57013. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57014. * @param generateMipMaps defines if the engine should generate the mip levels
  57015. * @param invertY defines if data must be stored with Y axis inverted
  57016. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57017. * @param compression defines the compression used (null by default)
  57018. */
  57019. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57020. /**
  57021. * Updates the raw cube texture.
  57022. * @param data defines the data to store
  57023. * @param format defines the data format
  57024. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57025. * @param invertY defines if data must be stored with Y axis inverted
  57026. * @param compression defines the compression used (null by default)
  57027. * @param level defines which level of the texture to update
  57028. */
  57029. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57030. /**
  57031. * Updates a raw cube texture with RGBD encoded data.
  57032. * @param data defines the array of data [mipmap][face] to use to create each face
  57033. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57034. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57035. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57036. * @returns a promsie that resolves when the operation is complete
  57037. */
  57038. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57039. /**
  57040. * Clones the raw cube texture.
  57041. * @return a new cube texture
  57042. */
  57043. clone(): CubeTexture;
  57044. /** @hidden */
  57045. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57046. }
  57047. }
  57048. declare module BABYLON {
  57049. /**
  57050. * Class used to store 3D textures containing user data
  57051. */
  57052. export class RawTexture3D extends Texture {
  57053. /** Gets or sets the texture format to use */
  57054. format: number;
  57055. private _engine;
  57056. /**
  57057. * Create a new RawTexture3D
  57058. * @param data defines the data of the texture
  57059. * @param width defines the width of the texture
  57060. * @param height defines the height of the texture
  57061. * @param depth defines the depth of the texture
  57062. * @param format defines the texture format to use
  57063. * @param scene defines the hosting scene
  57064. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57065. * @param invertY defines if texture must be stored with Y axis inverted
  57066. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57067. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57068. */
  57069. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57070. /** Gets or sets the texture format to use */
  57071. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57072. /**
  57073. * Update the texture with new data
  57074. * @param data defines the data to store in the texture
  57075. */
  57076. update(data: ArrayBufferView): void;
  57077. }
  57078. }
  57079. declare module BABYLON {
  57080. /**
  57081. * Class used to store 2D array textures containing user data
  57082. */
  57083. export class RawTexture2DArray extends Texture {
  57084. /** Gets or sets the texture format to use */
  57085. format: number;
  57086. private _engine;
  57087. /**
  57088. * Create a new RawTexture2DArray
  57089. * @param data defines the data of the texture
  57090. * @param width defines the width of the texture
  57091. * @param height defines the height of the texture
  57092. * @param depth defines the number of layers of the texture
  57093. * @param format defines the texture format to use
  57094. * @param scene defines the hosting scene
  57095. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57096. * @param invertY defines if texture must be stored with Y axis inverted
  57097. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57098. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57099. */
  57100. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57101. /** Gets or sets the texture format to use */
  57102. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57103. /**
  57104. * Update the texture with new data
  57105. * @param data defines the data to store in the texture
  57106. */
  57107. update(data: ArrayBufferView): void;
  57108. }
  57109. }
  57110. declare module BABYLON {
  57111. /**
  57112. * Creates a refraction texture used by refraction channel of the standard material.
  57113. * It is like a mirror but to see through a material.
  57114. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57115. */
  57116. export class RefractionTexture extends RenderTargetTexture {
  57117. /**
  57118. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57119. * 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.
  57120. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57121. */
  57122. refractionPlane: Plane;
  57123. /**
  57124. * Define how deep under the surface we should see.
  57125. */
  57126. depth: number;
  57127. /**
  57128. * Creates a refraction texture used by refraction channel of the standard material.
  57129. * It is like a mirror but to see through a material.
  57130. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57131. * @param name Define the texture name
  57132. * @param size Define the size of the underlying texture
  57133. * @param scene Define the scene the refraction belongs to
  57134. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57135. */
  57136. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57137. /**
  57138. * Clone the refraction texture.
  57139. * @returns the cloned texture
  57140. */
  57141. clone(): RefractionTexture;
  57142. /**
  57143. * Serialize the texture to a JSON representation you could use in Parse later on
  57144. * @returns the serialized JSON representation
  57145. */
  57146. serialize(): any;
  57147. }
  57148. }
  57149. declare module BABYLON {
  57150. /**
  57151. * Defines the options related to the creation of an HtmlElementTexture
  57152. */
  57153. export interface IHtmlElementTextureOptions {
  57154. /**
  57155. * Defines wether mip maps should be created or not.
  57156. */
  57157. generateMipMaps?: boolean;
  57158. /**
  57159. * Defines the sampling mode of the texture.
  57160. */
  57161. samplingMode?: number;
  57162. /**
  57163. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57164. */
  57165. engine: Nullable<ThinEngine>;
  57166. /**
  57167. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57168. */
  57169. scene: Nullable<Scene>;
  57170. }
  57171. /**
  57172. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57173. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57174. * is automatically managed.
  57175. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57176. * in your application.
  57177. *
  57178. * As the update is not automatic, you need to call them manually.
  57179. */
  57180. export class HtmlElementTexture extends BaseTexture {
  57181. /**
  57182. * The texture URL.
  57183. */
  57184. element: HTMLVideoElement | HTMLCanvasElement;
  57185. private static readonly DefaultOptions;
  57186. private _textureMatrix;
  57187. private _engine;
  57188. private _isVideo;
  57189. private _generateMipMaps;
  57190. private _samplingMode;
  57191. /**
  57192. * Instantiates a HtmlElementTexture from the following parameters.
  57193. *
  57194. * @param name Defines the name of the texture
  57195. * @param element Defines the video or canvas the texture is filled with
  57196. * @param options Defines the other none mandatory texture creation options
  57197. */
  57198. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57199. private _createInternalTexture;
  57200. /**
  57201. * Returns the texture matrix used in most of the material.
  57202. */
  57203. getTextureMatrix(): Matrix;
  57204. /**
  57205. * Updates the content of the texture.
  57206. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57207. */
  57208. update(invertY?: Nullable<boolean>): void;
  57209. }
  57210. }
  57211. declare module BABYLON {
  57212. /**
  57213. * Defines the basic options interface of a TexturePacker Frame
  57214. */
  57215. export interface ITexturePackerFrame {
  57216. /**
  57217. * The frame ID
  57218. */
  57219. id: number;
  57220. /**
  57221. * The frames Scale
  57222. */
  57223. scale: Vector2;
  57224. /**
  57225. * The Frames offset
  57226. */
  57227. offset: Vector2;
  57228. }
  57229. /**
  57230. * This is a support class for frame Data on texture packer sets.
  57231. */
  57232. export class TexturePackerFrame implements ITexturePackerFrame {
  57233. /**
  57234. * The frame ID
  57235. */
  57236. id: number;
  57237. /**
  57238. * The frames Scale
  57239. */
  57240. scale: Vector2;
  57241. /**
  57242. * The Frames offset
  57243. */
  57244. offset: Vector2;
  57245. /**
  57246. * Initializes a texture package frame.
  57247. * @param id The numerical frame identifier
  57248. * @param scale Scalar Vector2 for UV frame
  57249. * @param offset Vector2 for the frame position in UV units.
  57250. * @returns TexturePackerFrame
  57251. */
  57252. constructor(id: number, scale: Vector2, offset: Vector2);
  57253. }
  57254. }
  57255. declare module BABYLON {
  57256. /**
  57257. * Defines the basic options interface of a TexturePacker
  57258. */
  57259. export interface ITexturePackerOptions {
  57260. /**
  57261. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57262. */
  57263. map?: string[];
  57264. /**
  57265. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57266. */
  57267. uvsIn?: string;
  57268. /**
  57269. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57270. */
  57271. uvsOut?: string;
  57272. /**
  57273. * number representing the layout style. Defaults to LAYOUT_STRIP
  57274. */
  57275. layout?: number;
  57276. /**
  57277. * number of columns if using custom column count layout(2). This defaults to 4.
  57278. */
  57279. colnum?: number;
  57280. /**
  57281. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57282. */
  57283. updateInputMeshes?: boolean;
  57284. /**
  57285. * boolean flag to dispose all the source textures. Defaults to true.
  57286. */
  57287. disposeSources?: boolean;
  57288. /**
  57289. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57290. */
  57291. fillBlanks?: boolean;
  57292. /**
  57293. * string value representing the context fill style color. Defaults to 'black'.
  57294. */
  57295. customFillColor?: string;
  57296. /**
  57297. * Width and Height Value of each Frame in the TexturePacker Sets
  57298. */
  57299. frameSize?: number;
  57300. /**
  57301. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57302. */
  57303. paddingRatio?: number;
  57304. /**
  57305. * Number that declares the fill method for the padding gutter.
  57306. */
  57307. paddingMode?: number;
  57308. /**
  57309. * If in SUBUV_COLOR padding mode what color to use.
  57310. */
  57311. paddingColor?: Color3 | Color4;
  57312. }
  57313. /**
  57314. * Defines the basic interface of a TexturePacker JSON File
  57315. */
  57316. export interface ITexturePackerJSON {
  57317. /**
  57318. * The frame ID
  57319. */
  57320. name: string;
  57321. /**
  57322. * The base64 channel data
  57323. */
  57324. sets: any;
  57325. /**
  57326. * The options of the Packer
  57327. */
  57328. options: ITexturePackerOptions;
  57329. /**
  57330. * The frame data of the Packer
  57331. */
  57332. frames: Array<number>;
  57333. }
  57334. /**
  57335. * This is a support class that generates a series of packed texture sets.
  57336. * @see https://doc.babylonjs.com/babylon101/materials
  57337. */
  57338. export class TexturePacker {
  57339. /** Packer Layout Constant 0 */
  57340. static readonly LAYOUT_STRIP: number;
  57341. /** Packer Layout Constant 1 */
  57342. static readonly LAYOUT_POWER2: number;
  57343. /** Packer Layout Constant 2 */
  57344. static readonly LAYOUT_COLNUM: number;
  57345. /** Packer Layout Constant 0 */
  57346. static readonly SUBUV_WRAP: number;
  57347. /** Packer Layout Constant 1 */
  57348. static readonly SUBUV_EXTEND: number;
  57349. /** Packer Layout Constant 2 */
  57350. static readonly SUBUV_COLOR: number;
  57351. /** The Name of the Texture Package */
  57352. name: string;
  57353. /** The scene scope of the TexturePacker */
  57354. scene: Scene;
  57355. /** The Meshes to target */
  57356. meshes: AbstractMesh[];
  57357. /** Arguments passed with the Constructor */
  57358. options: ITexturePackerOptions;
  57359. /** The promise that is started upon initialization */
  57360. promise: Nullable<Promise<TexturePacker | string>>;
  57361. /** The Container object for the channel sets that are generated */
  57362. sets: object;
  57363. /** The Container array for the frames that are generated */
  57364. frames: TexturePackerFrame[];
  57365. /** The expected number of textures the system is parsing. */
  57366. private _expecting;
  57367. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57368. private _paddingValue;
  57369. /**
  57370. * Initializes a texture package series from an array of meshes or a single mesh.
  57371. * @param name The name of the package
  57372. * @param meshes The target meshes to compose the package from
  57373. * @param options The arguments that texture packer should follow while building.
  57374. * @param scene The scene which the textures are scoped to.
  57375. * @returns TexturePacker
  57376. */
  57377. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57378. /**
  57379. * Starts the package process
  57380. * @param resolve The promises resolution function
  57381. * @returns TexturePacker
  57382. */
  57383. private _createFrames;
  57384. /**
  57385. * Calculates the Size of the Channel Sets
  57386. * @returns Vector2
  57387. */
  57388. private _calculateSize;
  57389. /**
  57390. * Calculates the UV data for the frames.
  57391. * @param baseSize the base frameSize
  57392. * @param padding the base frame padding
  57393. * @param dtSize size of the Dynamic Texture for that channel
  57394. * @param dtUnits is 1/dtSize
  57395. * @param update flag to update the input meshes
  57396. */
  57397. private _calculateMeshUVFrames;
  57398. /**
  57399. * Calculates the frames Offset.
  57400. * @param index of the frame
  57401. * @returns Vector2
  57402. */
  57403. private _getFrameOffset;
  57404. /**
  57405. * Updates a Mesh to the frame data
  57406. * @param mesh that is the target
  57407. * @param frameID or the frame index
  57408. */
  57409. private _updateMeshUV;
  57410. /**
  57411. * Updates a Meshes materials to use the texture packer channels
  57412. * @param m is the mesh to target
  57413. * @param force all channels on the packer to be set.
  57414. */
  57415. private _updateTextureReferences;
  57416. /**
  57417. * Public method to set a Mesh to a frame
  57418. * @param m that is the target
  57419. * @param frameID or the frame index
  57420. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57421. */
  57422. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57423. /**
  57424. * Starts the async promise to compile the texture packer.
  57425. * @returns Promise<void>
  57426. */
  57427. processAsync(): Promise<void>;
  57428. /**
  57429. * Disposes all textures associated with this packer
  57430. */
  57431. dispose(): void;
  57432. /**
  57433. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57434. * @param imageType is the image type to use.
  57435. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57436. */
  57437. download(imageType?: string, quality?: number): void;
  57438. /**
  57439. * Public method to load a texturePacker JSON file.
  57440. * @param data of the JSON file in string format.
  57441. */
  57442. updateFromJSON(data: string): void;
  57443. }
  57444. }
  57445. declare module BABYLON {
  57446. /**
  57447. * Enum used to define the target of a block
  57448. */
  57449. export enum NodeMaterialBlockTargets {
  57450. /** Vertex shader */
  57451. Vertex = 1,
  57452. /** Fragment shader */
  57453. Fragment = 2,
  57454. /** Neutral */
  57455. Neutral = 4,
  57456. /** Vertex and Fragment */
  57457. VertexAndFragment = 3
  57458. }
  57459. }
  57460. declare module BABYLON {
  57461. /**
  57462. * Defines the kind of connection point for node based material
  57463. */
  57464. export enum NodeMaterialBlockConnectionPointTypes {
  57465. /** Float */
  57466. Float = 1,
  57467. /** Int */
  57468. Int = 2,
  57469. /** Vector2 */
  57470. Vector2 = 4,
  57471. /** Vector3 */
  57472. Vector3 = 8,
  57473. /** Vector4 */
  57474. Vector4 = 16,
  57475. /** Color3 */
  57476. Color3 = 32,
  57477. /** Color4 */
  57478. Color4 = 64,
  57479. /** Matrix */
  57480. Matrix = 128,
  57481. /** Detect type based on connection */
  57482. AutoDetect = 1024,
  57483. /** Output type that will be defined by input type */
  57484. BasedOnInput = 2048
  57485. }
  57486. }
  57487. declare module BABYLON {
  57488. /**
  57489. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57490. */
  57491. export enum NodeMaterialBlockConnectionPointMode {
  57492. /** Value is an uniform */
  57493. Uniform = 0,
  57494. /** Value is a mesh attribute */
  57495. Attribute = 1,
  57496. /** Value is a varying between vertex and fragment shaders */
  57497. Varying = 2,
  57498. /** Mode is undefined */
  57499. Undefined = 3
  57500. }
  57501. }
  57502. declare module BABYLON {
  57503. /**
  57504. * Enum used to define system values e.g. values automatically provided by the system
  57505. */
  57506. export enum NodeMaterialSystemValues {
  57507. /** World */
  57508. World = 1,
  57509. /** View */
  57510. View = 2,
  57511. /** Projection */
  57512. Projection = 3,
  57513. /** ViewProjection */
  57514. ViewProjection = 4,
  57515. /** WorldView */
  57516. WorldView = 5,
  57517. /** WorldViewProjection */
  57518. WorldViewProjection = 6,
  57519. /** CameraPosition */
  57520. CameraPosition = 7,
  57521. /** Fog Color */
  57522. FogColor = 8,
  57523. /** Delta time */
  57524. DeltaTime = 9
  57525. }
  57526. }
  57527. declare module BABYLON {
  57528. /**
  57529. * Root class for all node material optimizers
  57530. */
  57531. export class NodeMaterialOptimizer {
  57532. /**
  57533. * Function used to optimize a NodeMaterial graph
  57534. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57535. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57536. */
  57537. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57538. }
  57539. }
  57540. declare module BABYLON {
  57541. /**
  57542. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57543. */
  57544. export class TransformBlock extends NodeMaterialBlock {
  57545. /**
  57546. * Defines the value to use to complement W value to transform it to a Vector4
  57547. */
  57548. complementW: number;
  57549. /**
  57550. * Defines the value to use to complement z value to transform it to a Vector4
  57551. */
  57552. complementZ: number;
  57553. /**
  57554. * Creates a new TransformBlock
  57555. * @param name defines the block name
  57556. */
  57557. constructor(name: string);
  57558. /**
  57559. * Gets the current class name
  57560. * @returns the class name
  57561. */
  57562. getClassName(): string;
  57563. /**
  57564. * Gets the vector input
  57565. */
  57566. get vector(): NodeMaterialConnectionPoint;
  57567. /**
  57568. * Gets the output component
  57569. */
  57570. get output(): NodeMaterialConnectionPoint;
  57571. /**
  57572. * Gets the xyz output component
  57573. */
  57574. get xyz(): NodeMaterialConnectionPoint;
  57575. /**
  57576. * Gets the matrix transform input
  57577. */
  57578. get transform(): NodeMaterialConnectionPoint;
  57579. protected _buildBlock(state: NodeMaterialBuildState): this;
  57580. serialize(): any;
  57581. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57582. protected _dumpPropertiesCode(): string;
  57583. }
  57584. }
  57585. declare module BABYLON {
  57586. /**
  57587. * Block used to output the vertex position
  57588. */
  57589. export class VertexOutputBlock extends NodeMaterialBlock {
  57590. /**
  57591. * Creates a new VertexOutputBlock
  57592. * @param name defines the block name
  57593. */
  57594. constructor(name: string);
  57595. /**
  57596. * Gets the current class name
  57597. * @returns the class name
  57598. */
  57599. getClassName(): string;
  57600. /**
  57601. * Gets the vector input component
  57602. */
  57603. get vector(): NodeMaterialConnectionPoint;
  57604. protected _buildBlock(state: NodeMaterialBuildState): this;
  57605. }
  57606. }
  57607. declare module BABYLON {
  57608. /**
  57609. * Block used to output the final color
  57610. */
  57611. export class FragmentOutputBlock extends NodeMaterialBlock {
  57612. /**
  57613. * Create a new FragmentOutputBlock
  57614. * @param name defines the block name
  57615. */
  57616. constructor(name: string);
  57617. /**
  57618. * Gets the current class name
  57619. * @returns the class name
  57620. */
  57621. getClassName(): string;
  57622. /**
  57623. * Gets the rgba input component
  57624. */
  57625. get rgba(): NodeMaterialConnectionPoint;
  57626. /**
  57627. * Gets the rgb input component
  57628. */
  57629. get rgb(): NodeMaterialConnectionPoint;
  57630. /**
  57631. * Gets the a input component
  57632. */
  57633. get a(): NodeMaterialConnectionPoint;
  57634. protected _buildBlock(state: NodeMaterialBuildState): this;
  57635. }
  57636. }
  57637. declare module BABYLON {
  57638. /**
  57639. * Block used to read a reflection texture from a sampler
  57640. */
  57641. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57642. private _define3DName;
  57643. private _defineCubicName;
  57644. private _defineExplicitName;
  57645. private _defineProjectionName;
  57646. private _defineLocalCubicName;
  57647. private _defineSphericalName;
  57648. private _definePlanarName;
  57649. private _defineEquirectangularName;
  57650. private _defineMirroredEquirectangularFixedName;
  57651. private _defineEquirectangularFixedName;
  57652. private _defineSkyboxName;
  57653. private _cubeSamplerName;
  57654. private _2DSamplerName;
  57655. private _positionUVWName;
  57656. private _directionWName;
  57657. private _reflectionCoordsName;
  57658. private _reflection2DCoordsName;
  57659. private _reflectionColorName;
  57660. private _reflectionMatrixName;
  57661. /**
  57662. * Gets or sets the texture associated with the node
  57663. */
  57664. texture: Nullable<BaseTexture>;
  57665. /**
  57666. * Create a new TextureBlock
  57667. * @param name defines the block name
  57668. */
  57669. constructor(name: string);
  57670. /**
  57671. * Gets the current class name
  57672. * @returns the class name
  57673. */
  57674. getClassName(): string;
  57675. /**
  57676. * Gets the world position input component
  57677. */
  57678. get position(): NodeMaterialConnectionPoint;
  57679. /**
  57680. * Gets the world position input component
  57681. */
  57682. get worldPosition(): NodeMaterialConnectionPoint;
  57683. /**
  57684. * Gets the world normal input component
  57685. */
  57686. get worldNormal(): NodeMaterialConnectionPoint;
  57687. /**
  57688. * Gets the world input component
  57689. */
  57690. get world(): NodeMaterialConnectionPoint;
  57691. /**
  57692. * Gets the camera (or eye) position component
  57693. */
  57694. get cameraPosition(): NodeMaterialConnectionPoint;
  57695. /**
  57696. * Gets the view input component
  57697. */
  57698. get view(): NodeMaterialConnectionPoint;
  57699. /**
  57700. * Gets the rgb output component
  57701. */
  57702. get rgb(): NodeMaterialConnectionPoint;
  57703. /**
  57704. * Gets the r output component
  57705. */
  57706. get r(): NodeMaterialConnectionPoint;
  57707. /**
  57708. * Gets the g output component
  57709. */
  57710. get g(): NodeMaterialConnectionPoint;
  57711. /**
  57712. * Gets the b output component
  57713. */
  57714. get b(): NodeMaterialConnectionPoint;
  57715. autoConfigure(material: NodeMaterial): void;
  57716. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57717. isReady(): boolean;
  57718. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57719. private _injectVertexCode;
  57720. private _writeOutput;
  57721. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57722. protected _dumpPropertiesCode(): string;
  57723. serialize(): any;
  57724. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57725. }
  57726. }
  57727. declare module BABYLON {
  57728. /**
  57729. * Interface used to configure the node material editor
  57730. */
  57731. export interface INodeMaterialEditorOptions {
  57732. /** Define the URl to load node editor script */
  57733. editorURL?: string;
  57734. }
  57735. /** @hidden */
  57736. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57737. NORMAL: boolean;
  57738. TANGENT: boolean;
  57739. UV1: boolean;
  57740. /** BONES */
  57741. NUM_BONE_INFLUENCERS: number;
  57742. BonesPerMesh: number;
  57743. BONETEXTURE: boolean;
  57744. /** MORPH TARGETS */
  57745. MORPHTARGETS: boolean;
  57746. MORPHTARGETS_NORMAL: boolean;
  57747. MORPHTARGETS_TANGENT: boolean;
  57748. MORPHTARGETS_UV: boolean;
  57749. NUM_MORPH_INFLUENCERS: number;
  57750. /** IMAGE PROCESSING */
  57751. IMAGEPROCESSING: boolean;
  57752. VIGNETTE: boolean;
  57753. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57754. VIGNETTEBLENDMODEOPAQUE: boolean;
  57755. TONEMAPPING: boolean;
  57756. TONEMAPPING_ACES: boolean;
  57757. CONTRAST: boolean;
  57758. EXPOSURE: boolean;
  57759. COLORCURVES: boolean;
  57760. COLORGRADING: boolean;
  57761. COLORGRADING3D: boolean;
  57762. SAMPLER3DGREENDEPTH: boolean;
  57763. SAMPLER3DBGRMAP: boolean;
  57764. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57765. /** MISC. */
  57766. BUMPDIRECTUV: number;
  57767. constructor();
  57768. setValue(name: string, value: boolean): void;
  57769. }
  57770. /**
  57771. * Class used to configure NodeMaterial
  57772. */
  57773. export interface INodeMaterialOptions {
  57774. /**
  57775. * Defines if blocks should emit comments
  57776. */
  57777. emitComments: boolean;
  57778. }
  57779. /**
  57780. * Class used to create a node based material built by assembling shader blocks
  57781. */
  57782. export class NodeMaterial extends PushMaterial {
  57783. private static _BuildIdGenerator;
  57784. private _options;
  57785. private _vertexCompilationState;
  57786. private _fragmentCompilationState;
  57787. private _sharedData;
  57788. private _buildId;
  57789. private _buildWasSuccessful;
  57790. private _cachedWorldViewMatrix;
  57791. private _cachedWorldViewProjectionMatrix;
  57792. private _optimizers;
  57793. private _animationFrame;
  57794. /** Define the Url to load node editor script */
  57795. static EditorURL: string;
  57796. /** Define the Url to load snippets */
  57797. static SnippetUrl: string;
  57798. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  57799. static IgnoreTexturesAtLoadTime: boolean;
  57800. private BJSNODEMATERIALEDITOR;
  57801. /** Get the inspector from bundle or global */
  57802. private _getGlobalNodeMaterialEditor;
  57803. /**
  57804. * Snippet ID if the material was created from the snippet server
  57805. */
  57806. snippetId: string;
  57807. /**
  57808. * Gets or sets data used by visual editor
  57809. * @see https://nme.babylonjs.com
  57810. */
  57811. editorData: any;
  57812. /**
  57813. * 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)
  57814. */
  57815. ignoreAlpha: boolean;
  57816. /**
  57817. * Defines the maximum number of lights that can be used in the material
  57818. */
  57819. maxSimultaneousLights: number;
  57820. /**
  57821. * Observable raised when the material is built
  57822. */
  57823. onBuildObservable: Observable<NodeMaterial>;
  57824. /**
  57825. * Gets or sets the root nodes of the material vertex shader
  57826. */
  57827. _vertexOutputNodes: NodeMaterialBlock[];
  57828. /**
  57829. * Gets or sets the root nodes of the material fragment (pixel) shader
  57830. */
  57831. _fragmentOutputNodes: NodeMaterialBlock[];
  57832. /** Gets or sets options to control the node material overall behavior */
  57833. get options(): INodeMaterialOptions;
  57834. set options(options: INodeMaterialOptions);
  57835. /**
  57836. * Default configuration related to image processing available in the standard Material.
  57837. */
  57838. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57839. /**
  57840. * Gets the image processing configuration used either in this material.
  57841. */
  57842. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57843. /**
  57844. * Sets the Default image processing configuration used either in the this material.
  57845. *
  57846. * If sets to null, the scene one is in use.
  57847. */
  57848. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57849. /**
  57850. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57851. */
  57852. attachedBlocks: NodeMaterialBlock[];
  57853. /**
  57854. * Create a new node based material
  57855. * @param name defines the material name
  57856. * @param scene defines the hosting scene
  57857. * @param options defines creation option
  57858. */
  57859. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57860. /**
  57861. * Gets the current class name of the material e.g. "NodeMaterial"
  57862. * @returns the class name
  57863. */
  57864. getClassName(): string;
  57865. /**
  57866. * Keep track of the image processing observer to allow dispose and replace.
  57867. */
  57868. private _imageProcessingObserver;
  57869. /**
  57870. * Attaches a new image processing configuration to the Standard Material.
  57871. * @param configuration
  57872. */
  57873. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57874. /**
  57875. * Get a block by its name
  57876. * @param name defines the name of the block to retrieve
  57877. * @returns the required block or null if not found
  57878. */
  57879. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57880. /**
  57881. * Get a block by its name
  57882. * @param predicate defines the predicate used to find the good candidate
  57883. * @returns the required block or null if not found
  57884. */
  57885. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57886. /**
  57887. * Get an input block by its name
  57888. * @param predicate defines the predicate used to find the good candidate
  57889. * @returns the required input block or null if not found
  57890. */
  57891. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57892. /**
  57893. * Gets the list of input blocks attached to this material
  57894. * @returns an array of InputBlocks
  57895. */
  57896. getInputBlocks(): InputBlock[];
  57897. /**
  57898. * Adds a new optimizer to the list of optimizers
  57899. * @param optimizer defines the optimizers to add
  57900. * @returns the current material
  57901. */
  57902. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57903. /**
  57904. * Remove an optimizer from the list of optimizers
  57905. * @param optimizer defines the optimizers to remove
  57906. * @returns the current material
  57907. */
  57908. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57909. /**
  57910. * Add a new block to the list of output nodes
  57911. * @param node defines the node to add
  57912. * @returns the current material
  57913. */
  57914. addOutputNode(node: NodeMaterialBlock): this;
  57915. /**
  57916. * Remove a block from the list of root nodes
  57917. * @param node defines the node to remove
  57918. * @returns the current material
  57919. */
  57920. removeOutputNode(node: NodeMaterialBlock): this;
  57921. private _addVertexOutputNode;
  57922. private _removeVertexOutputNode;
  57923. private _addFragmentOutputNode;
  57924. private _removeFragmentOutputNode;
  57925. /**
  57926. * Specifies if the material will require alpha blending
  57927. * @returns a boolean specifying if alpha blending is needed
  57928. */
  57929. needAlphaBlending(): boolean;
  57930. /**
  57931. * Specifies if this material should be rendered in alpha test mode
  57932. * @returns a boolean specifying if an alpha test is needed.
  57933. */
  57934. needAlphaTesting(): boolean;
  57935. private _initializeBlock;
  57936. private _resetDualBlocks;
  57937. /**
  57938. * Remove a block from the current node material
  57939. * @param block defines the block to remove
  57940. */
  57941. removeBlock(block: NodeMaterialBlock): void;
  57942. /**
  57943. * Build the material and generates the inner effect
  57944. * @param verbose defines if the build should log activity
  57945. */
  57946. build(verbose?: boolean): void;
  57947. /**
  57948. * Runs an otpimization phase to try to improve the shader code
  57949. */
  57950. optimize(): void;
  57951. private _prepareDefinesForAttributes;
  57952. /**
  57953. * Get if the submesh is ready to be used and all its information available.
  57954. * Child classes can use it to update shaders
  57955. * @param mesh defines the mesh to check
  57956. * @param subMesh defines which submesh to check
  57957. * @param useInstances specifies that instances should be used
  57958. * @returns a boolean indicating that the submesh is ready or not
  57959. */
  57960. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57961. /**
  57962. * Get a string representing the shaders built by the current node graph
  57963. */
  57964. get compiledShaders(): string;
  57965. /**
  57966. * Binds the world matrix to the material
  57967. * @param world defines the world transformation matrix
  57968. */
  57969. bindOnlyWorldMatrix(world: Matrix): void;
  57970. /**
  57971. * Binds the submesh to this material by preparing the effect and shader to draw
  57972. * @param world defines the world transformation matrix
  57973. * @param mesh defines the mesh containing the submesh
  57974. * @param subMesh defines the submesh to bind the material to
  57975. */
  57976. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57977. /**
  57978. * Gets the active textures from the material
  57979. * @returns an array of textures
  57980. */
  57981. getActiveTextures(): BaseTexture[];
  57982. /**
  57983. * Gets the list of texture blocks
  57984. * @returns an array of texture blocks
  57985. */
  57986. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57987. /**
  57988. * Specifies if the material uses a texture
  57989. * @param texture defines the texture to check against the material
  57990. * @returns a boolean specifying if the material uses the texture
  57991. */
  57992. hasTexture(texture: BaseTexture): boolean;
  57993. /**
  57994. * Disposes the material
  57995. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57996. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57997. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57998. */
  57999. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58000. /** Creates the node editor window. */
  58001. private _createNodeEditor;
  58002. /**
  58003. * Launch the node material editor
  58004. * @param config Define the configuration of the editor
  58005. * @return a promise fulfilled when the node editor is visible
  58006. */
  58007. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58008. /**
  58009. * Clear the current material
  58010. */
  58011. clear(): void;
  58012. /**
  58013. * Clear the current material and set it to a default state
  58014. */
  58015. setToDefault(): void;
  58016. /**
  58017. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58018. * @param url defines the url to load from
  58019. * @returns a promise that will fullfil when the material is fully loaded
  58020. */
  58021. loadAsync(url: string): Promise<void>;
  58022. private _gatherBlocks;
  58023. /**
  58024. * Generate a string containing the code declaration required to create an equivalent of this material
  58025. * @returns a string
  58026. */
  58027. generateCode(): string;
  58028. /**
  58029. * Serializes this material in a JSON representation
  58030. * @returns the serialized material object
  58031. */
  58032. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58033. private _restoreConnections;
  58034. /**
  58035. * Clear the current graph and load a new one from a serialization object
  58036. * @param source defines the JSON representation of the material
  58037. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58038. */
  58039. loadFromSerialization(source: any, rootUrl?: string): void;
  58040. /**
  58041. * Makes a duplicate of the current material.
  58042. * @param name - name to use for the new material.
  58043. */
  58044. clone(name: string): NodeMaterial;
  58045. /**
  58046. * Creates a node material from parsed material data
  58047. * @param source defines the JSON representation of the material
  58048. * @param scene defines the hosting scene
  58049. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58050. * @returns a new node material
  58051. */
  58052. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58053. /**
  58054. * Creates a node material from a snippet saved in a remote file
  58055. * @param name defines the name of the material to create
  58056. * @param url defines the url to load from
  58057. * @param scene defines the hosting scene
  58058. * @returns a promise that will resolve to the new node material
  58059. */
  58060. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  58061. /**
  58062. * Creates a node material from a snippet saved by the node material editor
  58063. * @param snippetId defines the snippet to load
  58064. * @param scene defines the hosting scene
  58065. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58066. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  58067. * @returns a promise that will resolve to the new node material
  58068. */
  58069. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  58070. /**
  58071. * Creates a new node material set to default basic configuration
  58072. * @param name defines the name of the material
  58073. * @param scene defines the hosting scene
  58074. * @returns a new NodeMaterial
  58075. */
  58076. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58077. }
  58078. }
  58079. declare module BABYLON {
  58080. /**
  58081. * Block used to read a texture from a sampler
  58082. */
  58083. export class TextureBlock extends NodeMaterialBlock {
  58084. private _defineName;
  58085. private _linearDefineName;
  58086. private _tempTextureRead;
  58087. private _samplerName;
  58088. private _transformedUVName;
  58089. private _textureTransformName;
  58090. private _textureInfoName;
  58091. private _mainUVName;
  58092. private _mainUVDefineName;
  58093. /**
  58094. * Gets or sets the texture associated with the node
  58095. */
  58096. texture: Nullable<Texture>;
  58097. /**
  58098. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58099. */
  58100. convertToGammaSpace: boolean;
  58101. /**
  58102. * Create a new TextureBlock
  58103. * @param name defines the block name
  58104. */
  58105. constructor(name: string);
  58106. /**
  58107. * Gets the current class name
  58108. * @returns the class name
  58109. */
  58110. getClassName(): string;
  58111. /**
  58112. * Gets the uv input component
  58113. */
  58114. get uv(): NodeMaterialConnectionPoint;
  58115. /**
  58116. * Gets the rgba output component
  58117. */
  58118. get rgba(): NodeMaterialConnectionPoint;
  58119. /**
  58120. * Gets the rgb output component
  58121. */
  58122. get rgb(): NodeMaterialConnectionPoint;
  58123. /**
  58124. * Gets the r output component
  58125. */
  58126. get r(): NodeMaterialConnectionPoint;
  58127. /**
  58128. * Gets the g output component
  58129. */
  58130. get g(): NodeMaterialConnectionPoint;
  58131. /**
  58132. * Gets the b output component
  58133. */
  58134. get b(): NodeMaterialConnectionPoint;
  58135. /**
  58136. * Gets the a output component
  58137. */
  58138. get a(): NodeMaterialConnectionPoint;
  58139. get target(): NodeMaterialBlockTargets;
  58140. autoConfigure(material: NodeMaterial): void;
  58141. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58142. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58143. isReady(): boolean;
  58144. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58145. private get _isMixed();
  58146. private _injectVertexCode;
  58147. private _writeTextureRead;
  58148. private _writeOutput;
  58149. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58150. protected _dumpPropertiesCode(): string;
  58151. serialize(): any;
  58152. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58153. }
  58154. }
  58155. declare module BABYLON {
  58156. /**
  58157. * Class used to store shared data between 2 NodeMaterialBuildState
  58158. */
  58159. export class NodeMaterialBuildStateSharedData {
  58160. /**
  58161. * Gets the list of emitted varyings
  58162. */
  58163. temps: string[];
  58164. /**
  58165. * Gets the list of emitted varyings
  58166. */
  58167. varyings: string[];
  58168. /**
  58169. * Gets the varying declaration string
  58170. */
  58171. varyingDeclaration: string;
  58172. /**
  58173. * Input blocks
  58174. */
  58175. inputBlocks: InputBlock[];
  58176. /**
  58177. * Input blocks
  58178. */
  58179. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58180. /**
  58181. * Bindable blocks (Blocks that need to set data to the effect)
  58182. */
  58183. bindableBlocks: NodeMaterialBlock[];
  58184. /**
  58185. * List of blocks that can provide a compilation fallback
  58186. */
  58187. blocksWithFallbacks: NodeMaterialBlock[];
  58188. /**
  58189. * List of blocks that can provide a define update
  58190. */
  58191. blocksWithDefines: NodeMaterialBlock[];
  58192. /**
  58193. * List of blocks that can provide a repeatable content
  58194. */
  58195. repeatableContentBlocks: NodeMaterialBlock[];
  58196. /**
  58197. * List of blocks that can provide a dynamic list of uniforms
  58198. */
  58199. dynamicUniformBlocks: NodeMaterialBlock[];
  58200. /**
  58201. * List of blocks that can block the isReady function for the material
  58202. */
  58203. blockingBlocks: NodeMaterialBlock[];
  58204. /**
  58205. * Gets the list of animated inputs
  58206. */
  58207. animatedInputs: InputBlock[];
  58208. /**
  58209. * Build Id used to avoid multiple recompilations
  58210. */
  58211. buildId: number;
  58212. /** List of emitted variables */
  58213. variableNames: {
  58214. [key: string]: number;
  58215. };
  58216. /** List of emitted defines */
  58217. defineNames: {
  58218. [key: string]: number;
  58219. };
  58220. /** Should emit comments? */
  58221. emitComments: boolean;
  58222. /** Emit build activity */
  58223. verbose: boolean;
  58224. /** Gets or sets the hosting scene */
  58225. scene: Scene;
  58226. /**
  58227. * Gets the compilation hints emitted at compilation time
  58228. */
  58229. hints: {
  58230. needWorldViewMatrix: boolean;
  58231. needWorldViewProjectionMatrix: boolean;
  58232. needAlphaBlending: boolean;
  58233. needAlphaTesting: boolean;
  58234. };
  58235. /**
  58236. * List of compilation checks
  58237. */
  58238. checks: {
  58239. emitVertex: boolean;
  58240. emitFragment: boolean;
  58241. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58242. };
  58243. /** Creates a new shared data */
  58244. constructor();
  58245. /**
  58246. * Emits console errors and exceptions if there is a failing check
  58247. */
  58248. emitErrors(): void;
  58249. }
  58250. }
  58251. declare module BABYLON {
  58252. /**
  58253. * Class used to store node based material build state
  58254. */
  58255. export class NodeMaterialBuildState {
  58256. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58257. supportUniformBuffers: boolean;
  58258. /**
  58259. * Gets the list of emitted attributes
  58260. */
  58261. attributes: string[];
  58262. /**
  58263. * Gets the list of emitted uniforms
  58264. */
  58265. uniforms: string[];
  58266. /**
  58267. * Gets the list of emitted constants
  58268. */
  58269. constants: string[];
  58270. /**
  58271. * Gets the list of emitted samplers
  58272. */
  58273. samplers: string[];
  58274. /**
  58275. * Gets the list of emitted functions
  58276. */
  58277. functions: {
  58278. [key: string]: string;
  58279. };
  58280. /**
  58281. * Gets the list of emitted extensions
  58282. */
  58283. extensions: {
  58284. [key: string]: string;
  58285. };
  58286. /**
  58287. * Gets the target of the compilation state
  58288. */
  58289. target: NodeMaterialBlockTargets;
  58290. /**
  58291. * Gets the list of emitted counters
  58292. */
  58293. counters: {
  58294. [key: string]: number;
  58295. };
  58296. /**
  58297. * Shared data between multiple NodeMaterialBuildState instances
  58298. */
  58299. sharedData: NodeMaterialBuildStateSharedData;
  58300. /** @hidden */
  58301. _vertexState: NodeMaterialBuildState;
  58302. /** @hidden */
  58303. _attributeDeclaration: string;
  58304. /** @hidden */
  58305. _uniformDeclaration: string;
  58306. /** @hidden */
  58307. _constantDeclaration: string;
  58308. /** @hidden */
  58309. _samplerDeclaration: string;
  58310. /** @hidden */
  58311. _varyingTransfer: string;
  58312. private _repeatableContentAnchorIndex;
  58313. /** @hidden */
  58314. _builtCompilationString: string;
  58315. /**
  58316. * Gets the emitted compilation strings
  58317. */
  58318. compilationString: string;
  58319. /**
  58320. * Finalize the compilation strings
  58321. * @param state defines the current compilation state
  58322. */
  58323. finalize(state: NodeMaterialBuildState): void;
  58324. /** @hidden */
  58325. get _repeatableContentAnchor(): string;
  58326. /** @hidden */
  58327. _getFreeVariableName(prefix: string): string;
  58328. /** @hidden */
  58329. _getFreeDefineName(prefix: string): string;
  58330. /** @hidden */
  58331. _excludeVariableName(name: string): void;
  58332. /** @hidden */
  58333. _emit2DSampler(name: string): void;
  58334. /** @hidden */
  58335. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58336. /** @hidden */
  58337. _emitExtension(name: string, extension: string): void;
  58338. /** @hidden */
  58339. _emitFunction(name: string, code: string, comments: string): void;
  58340. /** @hidden */
  58341. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58342. replaceStrings?: {
  58343. search: RegExp;
  58344. replace: string;
  58345. }[];
  58346. repeatKey?: string;
  58347. }): string;
  58348. /** @hidden */
  58349. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58350. repeatKey?: string;
  58351. removeAttributes?: boolean;
  58352. removeUniforms?: boolean;
  58353. removeVaryings?: boolean;
  58354. removeIfDef?: boolean;
  58355. replaceStrings?: {
  58356. search: RegExp;
  58357. replace: string;
  58358. }[];
  58359. }, storeKey?: string): void;
  58360. /** @hidden */
  58361. _registerTempVariable(name: string): boolean;
  58362. /** @hidden */
  58363. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58364. /** @hidden */
  58365. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58366. /** @hidden */
  58367. _emitFloat(value: number): string;
  58368. }
  58369. }
  58370. declare module BABYLON {
  58371. /**
  58372. * Defines a block that can be used inside a node based material
  58373. */
  58374. export class NodeMaterialBlock {
  58375. private _buildId;
  58376. private _buildTarget;
  58377. private _target;
  58378. private _isFinalMerger;
  58379. private _isInput;
  58380. protected _isUnique: boolean;
  58381. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58382. inputsAreExclusive: boolean;
  58383. /** @hidden */
  58384. _codeVariableName: string;
  58385. /** @hidden */
  58386. _inputs: NodeMaterialConnectionPoint[];
  58387. /** @hidden */
  58388. _outputs: NodeMaterialConnectionPoint[];
  58389. /** @hidden */
  58390. _preparationId: number;
  58391. /**
  58392. * Gets or sets the name of the block
  58393. */
  58394. name: string;
  58395. /**
  58396. * Gets or sets the unique id of the node
  58397. */
  58398. uniqueId: number;
  58399. /**
  58400. * Gets or sets the comments associated with this block
  58401. */
  58402. comments: string;
  58403. /**
  58404. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58405. */
  58406. get isUnique(): boolean;
  58407. /**
  58408. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58409. */
  58410. get isFinalMerger(): boolean;
  58411. /**
  58412. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58413. */
  58414. get isInput(): boolean;
  58415. /**
  58416. * Gets or sets the build Id
  58417. */
  58418. get buildId(): number;
  58419. set buildId(value: number);
  58420. /**
  58421. * Gets or sets the target of the block
  58422. */
  58423. get target(): NodeMaterialBlockTargets;
  58424. set target(value: NodeMaterialBlockTargets);
  58425. /**
  58426. * Gets the list of input points
  58427. */
  58428. get inputs(): NodeMaterialConnectionPoint[];
  58429. /** Gets the list of output points */
  58430. get outputs(): NodeMaterialConnectionPoint[];
  58431. /**
  58432. * Find an input by its name
  58433. * @param name defines the name of the input to look for
  58434. * @returns the input or null if not found
  58435. */
  58436. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58437. /**
  58438. * Find an output by its name
  58439. * @param name defines the name of the outputto look for
  58440. * @returns the output or null if not found
  58441. */
  58442. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58443. /**
  58444. * Creates a new NodeMaterialBlock
  58445. * @param name defines the block name
  58446. * @param target defines the target of that block (Vertex by default)
  58447. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58448. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58449. */
  58450. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58451. /**
  58452. * Initialize the block and prepare the context for build
  58453. * @param state defines the state that will be used for the build
  58454. */
  58455. initialize(state: NodeMaterialBuildState): void;
  58456. /**
  58457. * Bind data to effect. Will only be called for blocks with isBindable === true
  58458. * @param effect defines the effect to bind data to
  58459. * @param nodeMaterial defines the hosting NodeMaterial
  58460. * @param mesh defines the mesh that will be rendered
  58461. */
  58462. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58463. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58464. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58465. protected _writeFloat(value: number): string;
  58466. /**
  58467. * Gets the current class name e.g. "NodeMaterialBlock"
  58468. * @returns the class name
  58469. */
  58470. getClassName(): string;
  58471. /**
  58472. * Register a new input. Must be called inside a block constructor
  58473. * @param name defines the connection point name
  58474. * @param type defines the connection point type
  58475. * @param isOptional defines a boolean indicating that this input can be omitted
  58476. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58477. * @returns the current block
  58478. */
  58479. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58480. /**
  58481. * Register a new output. Must be called inside a block constructor
  58482. * @param name defines the connection point name
  58483. * @param type defines the connection point type
  58484. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58485. * @returns the current block
  58486. */
  58487. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58488. /**
  58489. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58490. * @param forOutput defines an optional connection point to check compatibility with
  58491. * @returns the first available input or null
  58492. */
  58493. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58494. /**
  58495. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58496. * @param forBlock defines an optional block to check compatibility with
  58497. * @returns the first available input or null
  58498. */
  58499. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58500. /**
  58501. * Gets the sibling of the given output
  58502. * @param current defines the current output
  58503. * @returns the next output in the list or null
  58504. */
  58505. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58506. /**
  58507. * Connect current block with another block
  58508. * @param other defines the block to connect with
  58509. * @param options define the various options to help pick the right connections
  58510. * @returns the current block
  58511. */
  58512. connectTo(other: NodeMaterialBlock, options?: {
  58513. input?: string;
  58514. output?: string;
  58515. outputSwizzle?: string;
  58516. }): this | undefined;
  58517. protected _buildBlock(state: NodeMaterialBuildState): void;
  58518. /**
  58519. * Add uniforms, samplers and uniform buffers at compilation time
  58520. * @param state defines the state to update
  58521. * @param nodeMaterial defines the node material requesting the update
  58522. * @param defines defines the material defines to update
  58523. * @param uniformBuffers defines the list of uniform buffer names
  58524. */
  58525. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58526. /**
  58527. * Add potential fallbacks if shader compilation fails
  58528. * @param mesh defines the mesh to be rendered
  58529. * @param fallbacks defines the current prioritized list of fallbacks
  58530. */
  58531. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58532. /**
  58533. * Initialize defines for shader compilation
  58534. * @param mesh defines the mesh to be rendered
  58535. * @param nodeMaterial defines the node material requesting the update
  58536. * @param defines defines the material defines to update
  58537. * @param useInstances specifies that instances should be used
  58538. */
  58539. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58540. /**
  58541. * Update defines for shader compilation
  58542. * @param mesh defines the mesh to be rendered
  58543. * @param nodeMaterial defines the node material requesting the update
  58544. * @param defines defines the material defines to update
  58545. * @param useInstances specifies that instances should be used
  58546. */
  58547. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58548. /**
  58549. * Lets the block try to connect some inputs automatically
  58550. * @param material defines the hosting NodeMaterial
  58551. */
  58552. autoConfigure(material: NodeMaterial): void;
  58553. /**
  58554. * Function called when a block is declared as repeatable content generator
  58555. * @param vertexShaderState defines the current compilation state for the vertex shader
  58556. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58557. * @param mesh defines the mesh to be rendered
  58558. * @param defines defines the material defines to update
  58559. */
  58560. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58561. /**
  58562. * Checks if the block is ready
  58563. * @param mesh defines the mesh to be rendered
  58564. * @param nodeMaterial defines the node material requesting the update
  58565. * @param defines defines the material defines to update
  58566. * @param useInstances specifies that instances should be used
  58567. * @returns true if the block is ready
  58568. */
  58569. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58570. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58571. private _processBuild;
  58572. /**
  58573. * Compile the current node and generate the shader code
  58574. * @param state defines the current compilation state (uniforms, samplers, current string)
  58575. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58576. * @returns true if already built
  58577. */
  58578. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58579. protected _inputRename(name: string): string;
  58580. protected _outputRename(name: string): string;
  58581. protected _dumpPropertiesCode(): string;
  58582. /** @hidden */
  58583. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58584. /** @hidden */
  58585. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58586. /**
  58587. * Clone the current block to a new identical block
  58588. * @param scene defines the hosting scene
  58589. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58590. * @returns a copy of the current block
  58591. */
  58592. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58593. /**
  58594. * Serializes this block in a JSON representation
  58595. * @returns the serialized block object
  58596. */
  58597. serialize(): any;
  58598. /** @hidden */
  58599. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58600. private _deserializePortDisplayNames;
  58601. /**
  58602. * Release resources
  58603. */
  58604. dispose(): void;
  58605. }
  58606. }
  58607. declare module BABYLON {
  58608. /**
  58609. * Enum defining the type of animations supported by InputBlock
  58610. */
  58611. export enum AnimatedInputBlockTypes {
  58612. /** No animation */
  58613. None = 0,
  58614. /** Time based animation. Will only work for floats */
  58615. Time = 1
  58616. }
  58617. }
  58618. declare module BABYLON {
  58619. /**
  58620. * Block used to expose an input value
  58621. */
  58622. export class InputBlock extends NodeMaterialBlock {
  58623. private _mode;
  58624. private _associatedVariableName;
  58625. private _storedValue;
  58626. private _valueCallback;
  58627. private _type;
  58628. private _animationType;
  58629. /** Gets or set a value used to limit the range of float values */
  58630. min: number;
  58631. /** Gets or set a value used to limit the range of float values */
  58632. max: number;
  58633. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58634. isBoolean: boolean;
  58635. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58636. matrixMode: number;
  58637. /** @hidden */
  58638. _systemValue: Nullable<NodeMaterialSystemValues>;
  58639. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58640. visibleInInspector: boolean;
  58641. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58642. isConstant: boolean;
  58643. /** Gets or sets the group to use to display this block in the Inspector */
  58644. groupInInspector: string;
  58645. /** Gets an observable raised when the value is changed */
  58646. onValueChangedObservable: Observable<InputBlock>;
  58647. /**
  58648. * Gets or sets the connection point type (default is float)
  58649. */
  58650. get type(): NodeMaterialBlockConnectionPointTypes;
  58651. /**
  58652. * Creates a new InputBlock
  58653. * @param name defines the block name
  58654. * @param target defines the target of that block (Vertex by default)
  58655. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58656. */
  58657. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58658. /**
  58659. * Gets the output component
  58660. */
  58661. get output(): NodeMaterialConnectionPoint;
  58662. /**
  58663. * Set the source of this connection point to a vertex attribute
  58664. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58665. * @returns the current connection point
  58666. */
  58667. setAsAttribute(attributeName?: string): InputBlock;
  58668. /**
  58669. * Set the source of this connection point to a system value
  58670. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58671. * @returns the current connection point
  58672. */
  58673. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58674. /**
  58675. * Gets or sets the value of that point.
  58676. * Please note that this value will be ignored if valueCallback is defined
  58677. */
  58678. get value(): any;
  58679. set value(value: any);
  58680. /**
  58681. * Gets or sets a callback used to get the value of that point.
  58682. * Please note that setting this value will force the connection point to ignore the value property
  58683. */
  58684. get valueCallback(): () => any;
  58685. set valueCallback(value: () => any);
  58686. /**
  58687. * Gets or sets the associated variable name in the shader
  58688. */
  58689. get associatedVariableName(): string;
  58690. set associatedVariableName(value: string);
  58691. /** Gets or sets the type of animation applied to the input */
  58692. get animationType(): AnimatedInputBlockTypes;
  58693. set animationType(value: AnimatedInputBlockTypes);
  58694. /**
  58695. * Gets a boolean indicating that this connection point not defined yet
  58696. */
  58697. get isUndefined(): boolean;
  58698. /**
  58699. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58700. * In this case the connection point name must be the name of the uniform to use.
  58701. * Can only be set on inputs
  58702. */
  58703. get isUniform(): boolean;
  58704. set isUniform(value: boolean);
  58705. /**
  58706. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58707. * In this case the connection point name must be the name of the attribute to use
  58708. * Can only be set on inputs
  58709. */
  58710. get isAttribute(): boolean;
  58711. set isAttribute(value: boolean);
  58712. /**
  58713. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58714. * Can only be set on exit points
  58715. */
  58716. get isVarying(): boolean;
  58717. set isVarying(value: boolean);
  58718. /**
  58719. * Gets a boolean indicating that the current connection point is a system value
  58720. */
  58721. get isSystemValue(): boolean;
  58722. /**
  58723. * Gets or sets the current well known value or null if not defined as a system value
  58724. */
  58725. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58726. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58727. /**
  58728. * Gets the current class name
  58729. * @returns the class name
  58730. */
  58731. getClassName(): string;
  58732. /**
  58733. * Animate the input if animationType !== None
  58734. * @param scene defines the rendering scene
  58735. */
  58736. animate(scene: Scene): void;
  58737. private _emitDefine;
  58738. initialize(state: NodeMaterialBuildState): void;
  58739. /**
  58740. * Set the input block to its default value (based on its type)
  58741. */
  58742. setDefaultValue(): void;
  58743. private _emitConstant;
  58744. private _emit;
  58745. /** @hidden */
  58746. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58747. /** @hidden */
  58748. _transmit(effect: Effect, scene: Scene): void;
  58749. protected _buildBlock(state: NodeMaterialBuildState): void;
  58750. protected _dumpPropertiesCode(): string;
  58751. dispose(): void;
  58752. serialize(): any;
  58753. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58754. }
  58755. }
  58756. declare module BABYLON {
  58757. /**
  58758. * Enum used to define the compatibility state between two connection points
  58759. */
  58760. export enum NodeMaterialConnectionPointCompatibilityStates {
  58761. /** Points are compatibles */
  58762. Compatible = 0,
  58763. /** Points are incompatible because of their types */
  58764. TypeIncompatible = 1,
  58765. /** Points are incompatible because of their targets (vertex vs fragment) */
  58766. TargetIncompatible = 2
  58767. }
  58768. /**
  58769. * Defines the direction of a connection point
  58770. */
  58771. export enum NodeMaterialConnectionPointDirection {
  58772. /** Input */
  58773. Input = 0,
  58774. /** Output */
  58775. Output = 1
  58776. }
  58777. /**
  58778. * Defines a connection point for a block
  58779. */
  58780. export class NodeMaterialConnectionPoint {
  58781. /** @hidden */
  58782. _ownerBlock: NodeMaterialBlock;
  58783. /** @hidden */
  58784. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58785. private _endpoints;
  58786. private _associatedVariableName;
  58787. private _direction;
  58788. /** @hidden */
  58789. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58790. /** @hidden */
  58791. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58792. private _type;
  58793. /** @hidden */
  58794. _enforceAssociatedVariableName: boolean;
  58795. /** Gets the direction of the point */
  58796. get direction(): NodeMaterialConnectionPointDirection;
  58797. /**
  58798. * Gets or sets the additional types supported by this connection point
  58799. */
  58800. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58801. /**
  58802. * Gets or sets the additional types excluded by this connection point
  58803. */
  58804. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58805. /**
  58806. * Observable triggered when this point is connected
  58807. */
  58808. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58809. /**
  58810. * Gets or sets the associated variable name in the shader
  58811. */
  58812. get associatedVariableName(): string;
  58813. set associatedVariableName(value: string);
  58814. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58815. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58816. /**
  58817. * Gets or sets the connection point type (default is float)
  58818. */
  58819. get type(): NodeMaterialBlockConnectionPointTypes;
  58820. set type(value: NodeMaterialBlockConnectionPointTypes);
  58821. /**
  58822. * Gets or sets the connection point name
  58823. */
  58824. name: string;
  58825. /**
  58826. * Gets or sets the connection point name
  58827. */
  58828. displayName: string;
  58829. /**
  58830. * Gets or sets a boolean indicating that this connection point can be omitted
  58831. */
  58832. isOptional: boolean;
  58833. /**
  58834. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58835. */
  58836. define: string;
  58837. /** @hidden */
  58838. _prioritizeVertex: boolean;
  58839. private _target;
  58840. /** Gets or sets the target of that connection point */
  58841. get target(): NodeMaterialBlockTargets;
  58842. set target(value: NodeMaterialBlockTargets);
  58843. /**
  58844. * Gets a boolean indicating that the current point is connected
  58845. */
  58846. get isConnected(): boolean;
  58847. /**
  58848. * Gets a boolean indicating that the current point is connected to an input block
  58849. */
  58850. get isConnectedToInputBlock(): boolean;
  58851. /**
  58852. * Gets a the connected input block (if any)
  58853. */
  58854. get connectInputBlock(): Nullable<InputBlock>;
  58855. /** Get the other side of the connection (if any) */
  58856. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58857. /** Get the block that owns this connection point */
  58858. get ownerBlock(): NodeMaterialBlock;
  58859. /** Get the block connected on the other side of this connection (if any) */
  58860. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58861. /** Get the block connected on the endpoints of this connection (if any) */
  58862. get connectedBlocks(): Array<NodeMaterialBlock>;
  58863. /** Gets the list of connected endpoints */
  58864. get endpoints(): NodeMaterialConnectionPoint[];
  58865. /** Gets a boolean indicating if that output point is connected to at least one input */
  58866. get hasEndpoints(): boolean;
  58867. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58868. get isConnectedInVertexShader(): boolean;
  58869. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58870. get isConnectedInFragmentShader(): boolean;
  58871. /**
  58872. * Creates a new connection point
  58873. * @param name defines the connection point name
  58874. * @param ownerBlock defines the block hosting this connection point
  58875. * @param direction defines the direction of the connection point
  58876. */
  58877. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58878. /**
  58879. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58880. * @returns the class name
  58881. */
  58882. getClassName(): string;
  58883. /**
  58884. * Gets a boolean indicating if the current point can be connected to another point
  58885. * @param connectionPoint defines the other connection point
  58886. * @returns a boolean
  58887. */
  58888. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58889. /**
  58890. * Gets a number indicating if the current point can be connected to another point
  58891. * @param connectionPoint defines the other connection point
  58892. * @returns a number defining the compatibility state
  58893. */
  58894. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58895. /**
  58896. * Connect this point to another connection point
  58897. * @param connectionPoint defines the other connection point
  58898. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58899. * @returns the current connection point
  58900. */
  58901. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58902. /**
  58903. * Disconnect this point from one of his endpoint
  58904. * @param endpoint defines the other connection point
  58905. * @returns the current connection point
  58906. */
  58907. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58908. /**
  58909. * Serializes this point in a JSON representation
  58910. * @param isInput defines if the connection point is an input (default is true)
  58911. * @returns the serialized point object
  58912. */
  58913. serialize(isInput?: boolean): any;
  58914. /**
  58915. * Release resources
  58916. */
  58917. dispose(): void;
  58918. }
  58919. }
  58920. declare module BABYLON {
  58921. /**
  58922. * Block used to add support for vertex skinning (bones)
  58923. */
  58924. export class BonesBlock extends NodeMaterialBlock {
  58925. /**
  58926. * Creates a new BonesBlock
  58927. * @param name defines the block name
  58928. */
  58929. constructor(name: string);
  58930. /**
  58931. * Initialize the block and prepare the context for build
  58932. * @param state defines the state that will be used for the build
  58933. */
  58934. initialize(state: NodeMaterialBuildState): void;
  58935. /**
  58936. * Gets the current class name
  58937. * @returns the class name
  58938. */
  58939. getClassName(): string;
  58940. /**
  58941. * Gets the matrix indices input component
  58942. */
  58943. get matricesIndices(): NodeMaterialConnectionPoint;
  58944. /**
  58945. * Gets the matrix weights input component
  58946. */
  58947. get matricesWeights(): NodeMaterialConnectionPoint;
  58948. /**
  58949. * Gets the extra matrix indices input component
  58950. */
  58951. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58952. /**
  58953. * Gets the extra matrix weights input component
  58954. */
  58955. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58956. /**
  58957. * Gets the world input component
  58958. */
  58959. get world(): NodeMaterialConnectionPoint;
  58960. /**
  58961. * Gets the output component
  58962. */
  58963. get output(): NodeMaterialConnectionPoint;
  58964. autoConfigure(material: NodeMaterial): void;
  58965. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58966. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58967. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58968. protected _buildBlock(state: NodeMaterialBuildState): this;
  58969. }
  58970. }
  58971. declare module BABYLON {
  58972. /**
  58973. * Block used to add support for instances
  58974. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58975. */
  58976. export class InstancesBlock extends NodeMaterialBlock {
  58977. /**
  58978. * Creates a new InstancesBlock
  58979. * @param name defines the block name
  58980. */
  58981. constructor(name: string);
  58982. /**
  58983. * Gets the current class name
  58984. * @returns the class name
  58985. */
  58986. getClassName(): string;
  58987. /**
  58988. * Gets the first world row input component
  58989. */
  58990. get world0(): NodeMaterialConnectionPoint;
  58991. /**
  58992. * Gets the second world row input component
  58993. */
  58994. get world1(): NodeMaterialConnectionPoint;
  58995. /**
  58996. * Gets the third world row input component
  58997. */
  58998. get world2(): NodeMaterialConnectionPoint;
  58999. /**
  59000. * Gets the forth world row input component
  59001. */
  59002. get world3(): NodeMaterialConnectionPoint;
  59003. /**
  59004. * Gets the world input component
  59005. */
  59006. get world(): NodeMaterialConnectionPoint;
  59007. /**
  59008. * Gets the output component
  59009. */
  59010. get output(): NodeMaterialConnectionPoint;
  59011. /**
  59012. * Gets the isntanceID component
  59013. */
  59014. get instanceID(): NodeMaterialConnectionPoint;
  59015. autoConfigure(material: NodeMaterial): void;
  59016. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59017. protected _buildBlock(state: NodeMaterialBuildState): this;
  59018. }
  59019. }
  59020. declare module BABYLON {
  59021. /**
  59022. * Block used to add morph targets support to vertex shader
  59023. */
  59024. export class MorphTargetsBlock extends NodeMaterialBlock {
  59025. private _repeatableContentAnchor;
  59026. /**
  59027. * Create a new MorphTargetsBlock
  59028. * @param name defines the block name
  59029. */
  59030. constructor(name: string);
  59031. /**
  59032. * Gets the current class name
  59033. * @returns the class name
  59034. */
  59035. getClassName(): string;
  59036. /**
  59037. * Gets the position input component
  59038. */
  59039. get position(): NodeMaterialConnectionPoint;
  59040. /**
  59041. * Gets the normal input component
  59042. */
  59043. get normal(): NodeMaterialConnectionPoint;
  59044. /**
  59045. * Gets the tangent input component
  59046. */
  59047. get tangent(): NodeMaterialConnectionPoint;
  59048. /**
  59049. * Gets the tangent input component
  59050. */
  59051. get uv(): NodeMaterialConnectionPoint;
  59052. /**
  59053. * Gets the position output component
  59054. */
  59055. get positionOutput(): NodeMaterialConnectionPoint;
  59056. /**
  59057. * Gets the normal output component
  59058. */
  59059. get normalOutput(): NodeMaterialConnectionPoint;
  59060. /**
  59061. * Gets the tangent output component
  59062. */
  59063. get tangentOutput(): NodeMaterialConnectionPoint;
  59064. /**
  59065. * Gets the tangent output component
  59066. */
  59067. get uvOutput(): NodeMaterialConnectionPoint;
  59068. initialize(state: NodeMaterialBuildState): void;
  59069. autoConfigure(material: NodeMaterial): void;
  59070. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59071. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59072. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59073. protected _buildBlock(state: NodeMaterialBuildState): this;
  59074. }
  59075. }
  59076. declare module BABYLON {
  59077. /**
  59078. * Block used to get data information from a light
  59079. */
  59080. export class LightInformationBlock extends NodeMaterialBlock {
  59081. private _lightDataUniformName;
  59082. private _lightColorUniformName;
  59083. private _lightTypeDefineName;
  59084. /**
  59085. * Gets or sets the light associated with this block
  59086. */
  59087. light: Nullable<Light>;
  59088. /**
  59089. * Creates a new LightInformationBlock
  59090. * @param name defines the block name
  59091. */
  59092. constructor(name: string);
  59093. /**
  59094. * Gets the current class name
  59095. * @returns the class name
  59096. */
  59097. getClassName(): string;
  59098. /**
  59099. * Gets the world position input component
  59100. */
  59101. get worldPosition(): NodeMaterialConnectionPoint;
  59102. /**
  59103. * Gets the direction output component
  59104. */
  59105. get direction(): NodeMaterialConnectionPoint;
  59106. /**
  59107. * Gets the direction output component
  59108. */
  59109. get color(): NodeMaterialConnectionPoint;
  59110. /**
  59111. * Gets the direction output component
  59112. */
  59113. get intensity(): NodeMaterialConnectionPoint;
  59114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59116. protected _buildBlock(state: NodeMaterialBuildState): this;
  59117. serialize(): any;
  59118. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59119. }
  59120. }
  59121. declare module BABYLON {
  59122. /**
  59123. * Block used to add image processing support to fragment shader
  59124. */
  59125. export class ImageProcessingBlock extends NodeMaterialBlock {
  59126. /**
  59127. * Create a new ImageProcessingBlock
  59128. * @param name defines the block name
  59129. */
  59130. constructor(name: string);
  59131. /**
  59132. * Gets the current class name
  59133. * @returns the class name
  59134. */
  59135. getClassName(): string;
  59136. /**
  59137. * Gets the color input component
  59138. */
  59139. get color(): NodeMaterialConnectionPoint;
  59140. /**
  59141. * Gets the output component
  59142. */
  59143. get output(): NodeMaterialConnectionPoint;
  59144. /**
  59145. * Initialize the block and prepare the context for build
  59146. * @param state defines the state that will be used for the build
  59147. */
  59148. initialize(state: NodeMaterialBuildState): void;
  59149. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59150. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59151. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59152. protected _buildBlock(state: NodeMaterialBuildState): this;
  59153. }
  59154. }
  59155. declare module BABYLON {
  59156. /**
  59157. * Block used to pertub normals based on a normal map
  59158. */
  59159. export class PerturbNormalBlock extends NodeMaterialBlock {
  59160. private _tangentSpaceParameterName;
  59161. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59162. invertX: boolean;
  59163. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59164. invertY: boolean;
  59165. /**
  59166. * Create a new PerturbNormalBlock
  59167. * @param name defines the block name
  59168. */
  59169. constructor(name: string);
  59170. /**
  59171. * Gets the current class name
  59172. * @returns the class name
  59173. */
  59174. getClassName(): string;
  59175. /**
  59176. * Gets the world position input component
  59177. */
  59178. get worldPosition(): NodeMaterialConnectionPoint;
  59179. /**
  59180. * Gets the world normal input component
  59181. */
  59182. get worldNormal(): NodeMaterialConnectionPoint;
  59183. /**
  59184. * Gets the world tangent input component
  59185. */
  59186. get worldTangent(): NodeMaterialConnectionPoint;
  59187. /**
  59188. * Gets the uv input component
  59189. */
  59190. get uv(): NodeMaterialConnectionPoint;
  59191. /**
  59192. * Gets the normal map color input component
  59193. */
  59194. get normalMapColor(): NodeMaterialConnectionPoint;
  59195. /**
  59196. * Gets the strength input component
  59197. */
  59198. get strength(): NodeMaterialConnectionPoint;
  59199. /**
  59200. * Gets the output component
  59201. */
  59202. get output(): NodeMaterialConnectionPoint;
  59203. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59204. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59205. autoConfigure(material: NodeMaterial): void;
  59206. protected _buildBlock(state: NodeMaterialBuildState): this;
  59207. protected _dumpPropertiesCode(): string;
  59208. serialize(): any;
  59209. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59210. }
  59211. }
  59212. declare module BABYLON {
  59213. /**
  59214. * Block used to discard a pixel if a value is smaller than a cutoff
  59215. */
  59216. export class DiscardBlock extends NodeMaterialBlock {
  59217. /**
  59218. * Create a new DiscardBlock
  59219. * @param name defines the block name
  59220. */
  59221. constructor(name: string);
  59222. /**
  59223. * Gets the current class name
  59224. * @returns the class name
  59225. */
  59226. getClassName(): string;
  59227. /**
  59228. * Gets the color input component
  59229. */
  59230. get value(): NodeMaterialConnectionPoint;
  59231. /**
  59232. * Gets the cutoff input component
  59233. */
  59234. get cutoff(): NodeMaterialConnectionPoint;
  59235. protected _buildBlock(state: NodeMaterialBuildState): this;
  59236. }
  59237. }
  59238. declare module BABYLON {
  59239. /**
  59240. * Block used to test if the fragment shader is front facing
  59241. */
  59242. export class FrontFacingBlock extends NodeMaterialBlock {
  59243. /**
  59244. * Creates a new FrontFacingBlock
  59245. * @param name defines the block name
  59246. */
  59247. constructor(name: string);
  59248. /**
  59249. * Gets the current class name
  59250. * @returns the class name
  59251. */
  59252. getClassName(): string;
  59253. /**
  59254. * Gets the output component
  59255. */
  59256. get output(): NodeMaterialConnectionPoint;
  59257. protected _buildBlock(state: NodeMaterialBuildState): this;
  59258. }
  59259. }
  59260. declare module BABYLON {
  59261. /**
  59262. * Block used to get the derivative value on x and y of a given input
  59263. */
  59264. export class DerivativeBlock extends NodeMaterialBlock {
  59265. /**
  59266. * Create a new DerivativeBlock
  59267. * @param name defines the block name
  59268. */
  59269. constructor(name: string);
  59270. /**
  59271. * Gets the current class name
  59272. * @returns the class name
  59273. */
  59274. getClassName(): string;
  59275. /**
  59276. * Gets the input component
  59277. */
  59278. get input(): NodeMaterialConnectionPoint;
  59279. /**
  59280. * Gets the derivative output on x
  59281. */
  59282. get dx(): NodeMaterialConnectionPoint;
  59283. /**
  59284. * Gets the derivative output on y
  59285. */
  59286. get dy(): NodeMaterialConnectionPoint;
  59287. protected _buildBlock(state: NodeMaterialBuildState): this;
  59288. }
  59289. }
  59290. declare module BABYLON {
  59291. /**
  59292. * Block used to add support for scene fog
  59293. */
  59294. export class FogBlock extends NodeMaterialBlock {
  59295. private _fogDistanceName;
  59296. private _fogParameters;
  59297. /**
  59298. * Create a new FogBlock
  59299. * @param name defines the block name
  59300. */
  59301. constructor(name: string);
  59302. /**
  59303. * Gets the current class name
  59304. * @returns the class name
  59305. */
  59306. getClassName(): string;
  59307. /**
  59308. * Gets the world position input component
  59309. */
  59310. get worldPosition(): NodeMaterialConnectionPoint;
  59311. /**
  59312. * Gets the view input component
  59313. */
  59314. get view(): NodeMaterialConnectionPoint;
  59315. /**
  59316. * Gets the color input component
  59317. */
  59318. get input(): NodeMaterialConnectionPoint;
  59319. /**
  59320. * Gets the fog color input component
  59321. */
  59322. get fogColor(): NodeMaterialConnectionPoint;
  59323. /**
  59324. * Gets the output component
  59325. */
  59326. get output(): NodeMaterialConnectionPoint;
  59327. autoConfigure(material: NodeMaterial): void;
  59328. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59329. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59330. protected _buildBlock(state: NodeMaterialBuildState): this;
  59331. }
  59332. }
  59333. declare module BABYLON {
  59334. /**
  59335. * Block used to add light in the fragment shader
  59336. */
  59337. export class LightBlock extends NodeMaterialBlock {
  59338. private _lightId;
  59339. /**
  59340. * Gets or sets the light associated with this block
  59341. */
  59342. light: Nullable<Light>;
  59343. /**
  59344. * Create a new LightBlock
  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 input component
  59355. */
  59356. get worldPosition(): NodeMaterialConnectionPoint;
  59357. /**
  59358. * Gets the world normal input component
  59359. */
  59360. get worldNormal(): NodeMaterialConnectionPoint;
  59361. /**
  59362. * Gets the camera (or eye) position component
  59363. */
  59364. get cameraPosition(): NodeMaterialConnectionPoint;
  59365. /**
  59366. * Gets the glossiness component
  59367. */
  59368. get glossiness(): NodeMaterialConnectionPoint;
  59369. /**
  59370. * Gets the glossinness power component
  59371. */
  59372. get glossPower(): NodeMaterialConnectionPoint;
  59373. /**
  59374. * Gets the diffuse color component
  59375. */
  59376. get diffuseColor(): NodeMaterialConnectionPoint;
  59377. /**
  59378. * Gets the specular color component
  59379. */
  59380. get specularColor(): NodeMaterialConnectionPoint;
  59381. /**
  59382. * Gets the diffuse output component
  59383. */
  59384. get diffuseOutput(): NodeMaterialConnectionPoint;
  59385. /**
  59386. * Gets the specular output component
  59387. */
  59388. get specularOutput(): NodeMaterialConnectionPoint;
  59389. /**
  59390. * Gets the shadow output component
  59391. */
  59392. get shadow(): NodeMaterialConnectionPoint;
  59393. autoConfigure(material: NodeMaterial): void;
  59394. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59395. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59396. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59397. private _injectVertexCode;
  59398. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59399. serialize(): any;
  59400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59401. }
  59402. }
  59403. declare module BABYLON {
  59404. /**
  59405. * Block used to multiply 2 values
  59406. */
  59407. export class MultiplyBlock extends NodeMaterialBlock {
  59408. /**
  59409. * Creates a new MultiplyBlock
  59410. * @param name defines the block name
  59411. */
  59412. constructor(name: string);
  59413. /**
  59414. * Gets the current class name
  59415. * @returns the class name
  59416. */
  59417. getClassName(): string;
  59418. /**
  59419. * Gets the left operand input component
  59420. */
  59421. get left(): NodeMaterialConnectionPoint;
  59422. /**
  59423. * Gets the right operand input component
  59424. */
  59425. get right(): NodeMaterialConnectionPoint;
  59426. /**
  59427. * Gets the output component
  59428. */
  59429. get output(): NodeMaterialConnectionPoint;
  59430. protected _buildBlock(state: NodeMaterialBuildState): this;
  59431. }
  59432. }
  59433. declare module BABYLON {
  59434. /**
  59435. * Block used to add 2 vectors
  59436. */
  59437. export class AddBlock extends NodeMaterialBlock {
  59438. /**
  59439. * Creates a new AddBlock
  59440. * @param name defines the block name
  59441. */
  59442. constructor(name: string);
  59443. /**
  59444. * Gets the current class name
  59445. * @returns the class name
  59446. */
  59447. getClassName(): string;
  59448. /**
  59449. * Gets the left operand input component
  59450. */
  59451. get left(): NodeMaterialConnectionPoint;
  59452. /**
  59453. * Gets the right operand input component
  59454. */
  59455. get right(): NodeMaterialConnectionPoint;
  59456. /**
  59457. * Gets the output component
  59458. */
  59459. get output(): NodeMaterialConnectionPoint;
  59460. protected _buildBlock(state: NodeMaterialBuildState): this;
  59461. }
  59462. }
  59463. declare module BABYLON {
  59464. /**
  59465. * Block used to scale a vector by a float
  59466. */
  59467. export class ScaleBlock extends NodeMaterialBlock {
  59468. /**
  59469. * Creates a new ScaleBlock
  59470. * @param name defines the block name
  59471. */
  59472. constructor(name: string);
  59473. /**
  59474. * Gets the current class name
  59475. * @returns the class name
  59476. */
  59477. getClassName(): string;
  59478. /**
  59479. * Gets the input component
  59480. */
  59481. get input(): NodeMaterialConnectionPoint;
  59482. /**
  59483. * Gets the factor input component
  59484. */
  59485. get factor(): NodeMaterialConnectionPoint;
  59486. /**
  59487. * Gets the output component
  59488. */
  59489. get output(): NodeMaterialConnectionPoint;
  59490. protected _buildBlock(state: NodeMaterialBuildState): this;
  59491. }
  59492. }
  59493. declare module BABYLON {
  59494. /**
  59495. * Block used to clamp a float
  59496. */
  59497. export class ClampBlock extends NodeMaterialBlock {
  59498. /** Gets or sets the minimum range */
  59499. minimum: number;
  59500. /** Gets or sets the maximum range */
  59501. maximum: number;
  59502. /**
  59503. * Creates a new ClampBlock
  59504. * @param name defines the block name
  59505. */
  59506. constructor(name: string);
  59507. /**
  59508. * Gets the current class name
  59509. * @returns the class name
  59510. */
  59511. getClassName(): string;
  59512. /**
  59513. * Gets the value input component
  59514. */
  59515. get value(): NodeMaterialConnectionPoint;
  59516. /**
  59517. * Gets the output component
  59518. */
  59519. get output(): NodeMaterialConnectionPoint;
  59520. protected _buildBlock(state: NodeMaterialBuildState): this;
  59521. protected _dumpPropertiesCode(): string;
  59522. serialize(): any;
  59523. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59524. }
  59525. }
  59526. declare module BABYLON {
  59527. /**
  59528. * Block used to apply a cross product between 2 vectors
  59529. */
  59530. export class CrossBlock extends NodeMaterialBlock {
  59531. /**
  59532. * Creates a new CrossBlock
  59533. * @param name defines the block name
  59534. */
  59535. constructor(name: string);
  59536. /**
  59537. * Gets the current class name
  59538. * @returns the class name
  59539. */
  59540. getClassName(): string;
  59541. /**
  59542. * Gets the left operand input component
  59543. */
  59544. get left(): NodeMaterialConnectionPoint;
  59545. /**
  59546. * Gets the right operand input component
  59547. */
  59548. get right(): NodeMaterialConnectionPoint;
  59549. /**
  59550. * Gets the output component
  59551. */
  59552. get output(): NodeMaterialConnectionPoint;
  59553. protected _buildBlock(state: NodeMaterialBuildState): this;
  59554. }
  59555. }
  59556. declare module BABYLON {
  59557. /**
  59558. * Block used to apply a dot product between 2 vectors
  59559. */
  59560. export class DotBlock extends NodeMaterialBlock {
  59561. /**
  59562. * Creates a new DotBlock
  59563. * @param name defines the block name
  59564. */
  59565. constructor(name: string);
  59566. /**
  59567. * Gets the current class name
  59568. * @returns the class name
  59569. */
  59570. getClassName(): string;
  59571. /**
  59572. * Gets the left operand input component
  59573. */
  59574. get left(): NodeMaterialConnectionPoint;
  59575. /**
  59576. * Gets the right operand input component
  59577. */
  59578. get right(): NodeMaterialConnectionPoint;
  59579. /**
  59580. * Gets the output component
  59581. */
  59582. get output(): NodeMaterialConnectionPoint;
  59583. protected _buildBlock(state: NodeMaterialBuildState): this;
  59584. }
  59585. }
  59586. declare module BABYLON {
  59587. /**
  59588. * Block used to remap a float from a range to a new one
  59589. */
  59590. export class RemapBlock extends NodeMaterialBlock {
  59591. /**
  59592. * Gets or sets the source range
  59593. */
  59594. sourceRange: Vector2;
  59595. /**
  59596. * Gets or sets the target range
  59597. */
  59598. targetRange: Vector2;
  59599. /**
  59600. * Creates a new RemapBlock
  59601. * @param name defines the block name
  59602. */
  59603. constructor(name: string);
  59604. /**
  59605. * Gets the current class name
  59606. * @returns the class name
  59607. */
  59608. getClassName(): string;
  59609. /**
  59610. * Gets the input component
  59611. */
  59612. get input(): NodeMaterialConnectionPoint;
  59613. /**
  59614. * Gets the source min input component
  59615. */
  59616. get sourceMin(): NodeMaterialConnectionPoint;
  59617. /**
  59618. * Gets the source max input component
  59619. */
  59620. get sourceMax(): NodeMaterialConnectionPoint;
  59621. /**
  59622. * Gets the target min input component
  59623. */
  59624. get targetMin(): NodeMaterialConnectionPoint;
  59625. /**
  59626. * Gets the target max input component
  59627. */
  59628. get targetMax(): NodeMaterialConnectionPoint;
  59629. /**
  59630. * Gets the output component
  59631. */
  59632. get output(): NodeMaterialConnectionPoint;
  59633. protected _buildBlock(state: NodeMaterialBuildState): this;
  59634. protected _dumpPropertiesCode(): string;
  59635. serialize(): any;
  59636. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59637. }
  59638. }
  59639. declare module BABYLON {
  59640. /**
  59641. * Block used to normalize a vector
  59642. */
  59643. export class NormalizeBlock extends NodeMaterialBlock {
  59644. /**
  59645. * Creates a new NormalizeBlock
  59646. * @param name defines the block name
  59647. */
  59648. constructor(name: string);
  59649. /**
  59650. * Gets the current class name
  59651. * @returns the class name
  59652. */
  59653. getClassName(): string;
  59654. /**
  59655. * Gets the input component
  59656. */
  59657. get input(): NodeMaterialConnectionPoint;
  59658. /**
  59659. * Gets the output component
  59660. */
  59661. get output(): NodeMaterialConnectionPoint;
  59662. protected _buildBlock(state: NodeMaterialBuildState): this;
  59663. }
  59664. }
  59665. declare module BABYLON {
  59666. /**
  59667. * Operations supported by the Trigonometry block
  59668. */
  59669. export enum TrigonometryBlockOperations {
  59670. /** Cos */
  59671. Cos = 0,
  59672. /** Sin */
  59673. Sin = 1,
  59674. /** Abs */
  59675. Abs = 2,
  59676. /** Exp */
  59677. Exp = 3,
  59678. /** Exp2 */
  59679. Exp2 = 4,
  59680. /** Round */
  59681. Round = 5,
  59682. /** Floor */
  59683. Floor = 6,
  59684. /** Ceiling */
  59685. Ceiling = 7,
  59686. /** Square root */
  59687. Sqrt = 8,
  59688. /** Log */
  59689. Log = 9,
  59690. /** Tangent */
  59691. Tan = 10,
  59692. /** Arc tangent */
  59693. ArcTan = 11,
  59694. /** Arc cosinus */
  59695. ArcCos = 12,
  59696. /** Arc sinus */
  59697. ArcSin = 13,
  59698. /** Fraction */
  59699. Fract = 14,
  59700. /** Sign */
  59701. Sign = 15,
  59702. /** To radians (from degrees) */
  59703. Radians = 16,
  59704. /** To degrees (from radians) */
  59705. Degrees = 17
  59706. }
  59707. /**
  59708. * Block used to apply trigonometry operation to floats
  59709. */
  59710. export class TrigonometryBlock extends NodeMaterialBlock {
  59711. /**
  59712. * Gets or sets the operation applied by the block
  59713. */
  59714. operation: TrigonometryBlockOperations;
  59715. /**
  59716. * Creates a new TrigonometryBlock
  59717. * @param name defines the block name
  59718. */
  59719. constructor(name: string);
  59720. /**
  59721. * Gets the current class name
  59722. * @returns the class name
  59723. */
  59724. getClassName(): string;
  59725. /**
  59726. * Gets the input component
  59727. */
  59728. get input(): NodeMaterialConnectionPoint;
  59729. /**
  59730. * Gets the output component
  59731. */
  59732. get output(): NodeMaterialConnectionPoint;
  59733. protected _buildBlock(state: NodeMaterialBuildState): this;
  59734. serialize(): any;
  59735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59736. protected _dumpPropertiesCode(): string;
  59737. }
  59738. }
  59739. declare module BABYLON {
  59740. /**
  59741. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59742. */
  59743. export class ColorMergerBlock extends NodeMaterialBlock {
  59744. /**
  59745. * Create a new ColorMergerBlock
  59746. * @param name defines the block name
  59747. */
  59748. constructor(name: string);
  59749. /**
  59750. * Gets the current class name
  59751. * @returns the class name
  59752. */
  59753. getClassName(): string;
  59754. /**
  59755. * Gets the rgb component (input)
  59756. */
  59757. get rgbIn(): NodeMaterialConnectionPoint;
  59758. /**
  59759. * Gets the r component (input)
  59760. */
  59761. get r(): NodeMaterialConnectionPoint;
  59762. /**
  59763. * Gets the g component (input)
  59764. */
  59765. get g(): NodeMaterialConnectionPoint;
  59766. /**
  59767. * Gets the b component (input)
  59768. */
  59769. get b(): NodeMaterialConnectionPoint;
  59770. /**
  59771. * Gets the a component (input)
  59772. */
  59773. get a(): NodeMaterialConnectionPoint;
  59774. /**
  59775. * Gets the rgba component (output)
  59776. */
  59777. get rgba(): NodeMaterialConnectionPoint;
  59778. /**
  59779. * Gets the rgb component (output)
  59780. */
  59781. get rgbOut(): NodeMaterialConnectionPoint;
  59782. /**
  59783. * Gets the rgb component (output)
  59784. * @deprecated Please use rgbOut instead.
  59785. */
  59786. get rgb(): NodeMaterialConnectionPoint;
  59787. protected _buildBlock(state: NodeMaterialBuildState): this;
  59788. }
  59789. }
  59790. declare module BABYLON {
  59791. /**
  59792. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59793. */
  59794. export class VectorMergerBlock extends NodeMaterialBlock {
  59795. /**
  59796. * Create a new VectorMergerBlock
  59797. * @param name defines the block name
  59798. */
  59799. constructor(name: string);
  59800. /**
  59801. * Gets the current class name
  59802. * @returns the class name
  59803. */
  59804. getClassName(): string;
  59805. /**
  59806. * Gets the xyz component (input)
  59807. */
  59808. get xyzIn(): NodeMaterialConnectionPoint;
  59809. /**
  59810. * Gets the xy component (input)
  59811. */
  59812. get xyIn(): NodeMaterialConnectionPoint;
  59813. /**
  59814. * Gets the x component (input)
  59815. */
  59816. get x(): NodeMaterialConnectionPoint;
  59817. /**
  59818. * Gets the y component (input)
  59819. */
  59820. get y(): NodeMaterialConnectionPoint;
  59821. /**
  59822. * Gets the z component (input)
  59823. */
  59824. get z(): NodeMaterialConnectionPoint;
  59825. /**
  59826. * Gets the w component (input)
  59827. */
  59828. get w(): NodeMaterialConnectionPoint;
  59829. /**
  59830. * Gets the xyzw component (output)
  59831. */
  59832. get xyzw(): NodeMaterialConnectionPoint;
  59833. /**
  59834. * Gets the xyz component (output)
  59835. */
  59836. get xyzOut(): NodeMaterialConnectionPoint;
  59837. /**
  59838. * Gets the xy component (output)
  59839. */
  59840. get xyOut(): NodeMaterialConnectionPoint;
  59841. /**
  59842. * Gets the xy component (output)
  59843. * @deprecated Please use xyOut instead.
  59844. */
  59845. get xy(): NodeMaterialConnectionPoint;
  59846. /**
  59847. * Gets the xyz component (output)
  59848. * @deprecated Please use xyzOut instead.
  59849. */
  59850. get xyz(): NodeMaterialConnectionPoint;
  59851. protected _buildBlock(state: NodeMaterialBuildState): this;
  59852. }
  59853. }
  59854. declare module BABYLON {
  59855. /**
  59856. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59857. */
  59858. export class ColorSplitterBlock extends NodeMaterialBlock {
  59859. /**
  59860. * Create a new ColorSplitterBlock
  59861. * @param name defines the block name
  59862. */
  59863. constructor(name: string);
  59864. /**
  59865. * Gets the current class name
  59866. * @returns the class name
  59867. */
  59868. getClassName(): string;
  59869. /**
  59870. * Gets the rgba component (input)
  59871. */
  59872. get rgba(): NodeMaterialConnectionPoint;
  59873. /**
  59874. * Gets the rgb component (input)
  59875. */
  59876. get rgbIn(): NodeMaterialConnectionPoint;
  59877. /**
  59878. * Gets the rgb component (output)
  59879. */
  59880. get rgbOut(): NodeMaterialConnectionPoint;
  59881. /**
  59882. * Gets the r component (output)
  59883. */
  59884. get r(): NodeMaterialConnectionPoint;
  59885. /**
  59886. * Gets the g component (output)
  59887. */
  59888. get g(): NodeMaterialConnectionPoint;
  59889. /**
  59890. * Gets the b component (output)
  59891. */
  59892. get b(): NodeMaterialConnectionPoint;
  59893. /**
  59894. * Gets the a component (output)
  59895. */
  59896. get a(): NodeMaterialConnectionPoint;
  59897. protected _inputRename(name: string): string;
  59898. protected _outputRename(name: string): string;
  59899. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59900. }
  59901. }
  59902. declare module BABYLON {
  59903. /**
  59904. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59905. */
  59906. export class VectorSplitterBlock extends NodeMaterialBlock {
  59907. /**
  59908. * Create a new VectorSplitterBlock
  59909. * @param name defines the block name
  59910. */
  59911. constructor(name: string);
  59912. /**
  59913. * Gets the current class name
  59914. * @returns the class name
  59915. */
  59916. getClassName(): string;
  59917. /**
  59918. * Gets the xyzw component (input)
  59919. */
  59920. get xyzw(): NodeMaterialConnectionPoint;
  59921. /**
  59922. * Gets the xyz component (input)
  59923. */
  59924. get xyzIn(): NodeMaterialConnectionPoint;
  59925. /**
  59926. * Gets the xy component (input)
  59927. */
  59928. get xyIn(): NodeMaterialConnectionPoint;
  59929. /**
  59930. * Gets the xyz component (output)
  59931. */
  59932. get xyzOut(): NodeMaterialConnectionPoint;
  59933. /**
  59934. * Gets the xy component (output)
  59935. */
  59936. get xyOut(): NodeMaterialConnectionPoint;
  59937. /**
  59938. * Gets the x component (output)
  59939. */
  59940. get x(): NodeMaterialConnectionPoint;
  59941. /**
  59942. * Gets the y component (output)
  59943. */
  59944. get y(): NodeMaterialConnectionPoint;
  59945. /**
  59946. * Gets the z component (output)
  59947. */
  59948. get z(): NodeMaterialConnectionPoint;
  59949. /**
  59950. * Gets the w component (output)
  59951. */
  59952. get w(): NodeMaterialConnectionPoint;
  59953. protected _inputRename(name: string): string;
  59954. protected _outputRename(name: string): string;
  59955. protected _buildBlock(state: NodeMaterialBuildState): this;
  59956. }
  59957. }
  59958. declare module BABYLON {
  59959. /**
  59960. * Block used to lerp between 2 values
  59961. */
  59962. export class LerpBlock extends NodeMaterialBlock {
  59963. /**
  59964. * Creates a new LerpBlock
  59965. * @param name defines the block name
  59966. */
  59967. constructor(name: string);
  59968. /**
  59969. * Gets the current class name
  59970. * @returns the class name
  59971. */
  59972. getClassName(): string;
  59973. /**
  59974. * Gets the left operand input component
  59975. */
  59976. get left(): NodeMaterialConnectionPoint;
  59977. /**
  59978. * Gets the right operand input component
  59979. */
  59980. get right(): NodeMaterialConnectionPoint;
  59981. /**
  59982. * Gets the gradient operand input component
  59983. */
  59984. get gradient(): NodeMaterialConnectionPoint;
  59985. /**
  59986. * Gets the output component
  59987. */
  59988. get output(): NodeMaterialConnectionPoint;
  59989. protected _buildBlock(state: NodeMaterialBuildState): this;
  59990. }
  59991. }
  59992. declare module BABYLON {
  59993. /**
  59994. * Block used to divide 2 vectors
  59995. */
  59996. export class DivideBlock extends NodeMaterialBlock {
  59997. /**
  59998. * Creates a new DivideBlock
  59999. * @param name defines the block name
  60000. */
  60001. constructor(name: string);
  60002. /**
  60003. * Gets the current class name
  60004. * @returns the class name
  60005. */
  60006. getClassName(): string;
  60007. /**
  60008. * Gets the left operand input component
  60009. */
  60010. get left(): NodeMaterialConnectionPoint;
  60011. /**
  60012. * Gets the right operand input component
  60013. */
  60014. get right(): NodeMaterialConnectionPoint;
  60015. /**
  60016. * Gets the output component
  60017. */
  60018. get output(): NodeMaterialConnectionPoint;
  60019. protected _buildBlock(state: NodeMaterialBuildState): this;
  60020. }
  60021. }
  60022. declare module BABYLON {
  60023. /**
  60024. * Block used to subtract 2 vectors
  60025. */
  60026. export class SubtractBlock extends NodeMaterialBlock {
  60027. /**
  60028. * Creates a new SubtractBlock
  60029. * @param name defines the block name
  60030. */
  60031. constructor(name: string);
  60032. /**
  60033. * Gets the current class name
  60034. * @returns the class name
  60035. */
  60036. getClassName(): string;
  60037. /**
  60038. * Gets the left operand input component
  60039. */
  60040. get left(): NodeMaterialConnectionPoint;
  60041. /**
  60042. * Gets the right operand input component
  60043. */
  60044. get right(): NodeMaterialConnectionPoint;
  60045. /**
  60046. * Gets the output component
  60047. */
  60048. get output(): NodeMaterialConnectionPoint;
  60049. protected _buildBlock(state: NodeMaterialBuildState): this;
  60050. }
  60051. }
  60052. declare module BABYLON {
  60053. /**
  60054. * Block used to step a value
  60055. */
  60056. export class StepBlock extends NodeMaterialBlock {
  60057. /**
  60058. * Creates a new StepBlock
  60059. * @param name defines the block name
  60060. */
  60061. constructor(name: string);
  60062. /**
  60063. * Gets the current class name
  60064. * @returns the class name
  60065. */
  60066. getClassName(): string;
  60067. /**
  60068. * Gets the value operand input component
  60069. */
  60070. get value(): NodeMaterialConnectionPoint;
  60071. /**
  60072. * Gets the edge operand input component
  60073. */
  60074. get edge(): NodeMaterialConnectionPoint;
  60075. /**
  60076. * Gets the output component
  60077. */
  60078. get output(): NodeMaterialConnectionPoint;
  60079. protected _buildBlock(state: NodeMaterialBuildState): this;
  60080. }
  60081. }
  60082. declare module BABYLON {
  60083. /**
  60084. * Block used to get the opposite (1 - x) of a value
  60085. */
  60086. export class OneMinusBlock extends NodeMaterialBlock {
  60087. /**
  60088. * Creates a new OneMinusBlock
  60089. * @param name defines the block name
  60090. */
  60091. constructor(name: string);
  60092. /**
  60093. * Gets the current class name
  60094. * @returns the class name
  60095. */
  60096. getClassName(): string;
  60097. /**
  60098. * Gets the input component
  60099. */
  60100. get input(): NodeMaterialConnectionPoint;
  60101. /**
  60102. * Gets the output component
  60103. */
  60104. get output(): NodeMaterialConnectionPoint;
  60105. protected _buildBlock(state: NodeMaterialBuildState): this;
  60106. }
  60107. }
  60108. declare module BABYLON {
  60109. /**
  60110. * Block used to get the view direction
  60111. */
  60112. export class ViewDirectionBlock extends NodeMaterialBlock {
  60113. /**
  60114. * Creates a new ViewDirectionBlock
  60115. * @param name defines the block name
  60116. */
  60117. constructor(name: string);
  60118. /**
  60119. * Gets the current class name
  60120. * @returns the class name
  60121. */
  60122. getClassName(): string;
  60123. /**
  60124. * Gets the world position component
  60125. */
  60126. get worldPosition(): NodeMaterialConnectionPoint;
  60127. /**
  60128. * Gets the camera position component
  60129. */
  60130. get cameraPosition(): NodeMaterialConnectionPoint;
  60131. /**
  60132. * Gets the output component
  60133. */
  60134. get output(): NodeMaterialConnectionPoint;
  60135. autoConfigure(material: NodeMaterial): void;
  60136. protected _buildBlock(state: NodeMaterialBuildState): this;
  60137. }
  60138. }
  60139. declare module BABYLON {
  60140. /**
  60141. * Block used to compute fresnel value
  60142. */
  60143. export class FresnelBlock extends NodeMaterialBlock {
  60144. /**
  60145. * Create a new FresnelBlock
  60146. * @param name defines the block name
  60147. */
  60148. constructor(name: string);
  60149. /**
  60150. * Gets the current class name
  60151. * @returns the class name
  60152. */
  60153. getClassName(): string;
  60154. /**
  60155. * Gets the world normal input component
  60156. */
  60157. get worldNormal(): NodeMaterialConnectionPoint;
  60158. /**
  60159. * Gets the view direction input component
  60160. */
  60161. get viewDirection(): NodeMaterialConnectionPoint;
  60162. /**
  60163. * Gets the bias input component
  60164. */
  60165. get bias(): NodeMaterialConnectionPoint;
  60166. /**
  60167. * Gets the camera (or eye) position component
  60168. */
  60169. get power(): NodeMaterialConnectionPoint;
  60170. /**
  60171. * Gets the fresnel output component
  60172. */
  60173. get fresnel(): NodeMaterialConnectionPoint;
  60174. autoConfigure(material: NodeMaterial): void;
  60175. protected _buildBlock(state: NodeMaterialBuildState): this;
  60176. }
  60177. }
  60178. declare module BABYLON {
  60179. /**
  60180. * Block used to get the max of 2 values
  60181. */
  60182. export class MaxBlock extends NodeMaterialBlock {
  60183. /**
  60184. * Creates a new MaxBlock
  60185. * @param name defines the block name
  60186. */
  60187. constructor(name: string);
  60188. /**
  60189. * Gets the current class name
  60190. * @returns the class name
  60191. */
  60192. getClassName(): string;
  60193. /**
  60194. * Gets the left operand input component
  60195. */
  60196. get left(): NodeMaterialConnectionPoint;
  60197. /**
  60198. * Gets the right operand input component
  60199. */
  60200. get right(): NodeMaterialConnectionPoint;
  60201. /**
  60202. * Gets the output component
  60203. */
  60204. get output(): NodeMaterialConnectionPoint;
  60205. protected _buildBlock(state: NodeMaterialBuildState): this;
  60206. }
  60207. }
  60208. declare module BABYLON {
  60209. /**
  60210. * Block used to get the min of 2 values
  60211. */
  60212. export class MinBlock extends NodeMaterialBlock {
  60213. /**
  60214. * Creates a new MinBlock
  60215. * @param name defines the block name
  60216. */
  60217. constructor(name: string);
  60218. /**
  60219. * Gets the current class name
  60220. * @returns the class name
  60221. */
  60222. getClassName(): string;
  60223. /**
  60224. * Gets the left operand input component
  60225. */
  60226. get left(): NodeMaterialConnectionPoint;
  60227. /**
  60228. * Gets the right operand input component
  60229. */
  60230. get right(): NodeMaterialConnectionPoint;
  60231. /**
  60232. * Gets the output component
  60233. */
  60234. get output(): NodeMaterialConnectionPoint;
  60235. protected _buildBlock(state: NodeMaterialBuildState): this;
  60236. }
  60237. }
  60238. declare module BABYLON {
  60239. /**
  60240. * Block used to get the distance between 2 values
  60241. */
  60242. export class DistanceBlock extends NodeMaterialBlock {
  60243. /**
  60244. * Creates a new DistanceBlock
  60245. * @param name defines the block name
  60246. */
  60247. constructor(name: string);
  60248. /**
  60249. * Gets the current class name
  60250. * @returns the class name
  60251. */
  60252. getClassName(): string;
  60253. /**
  60254. * Gets the left operand input component
  60255. */
  60256. get left(): NodeMaterialConnectionPoint;
  60257. /**
  60258. * Gets the right operand input component
  60259. */
  60260. get right(): NodeMaterialConnectionPoint;
  60261. /**
  60262. * Gets the output component
  60263. */
  60264. get output(): NodeMaterialConnectionPoint;
  60265. protected _buildBlock(state: NodeMaterialBuildState): this;
  60266. }
  60267. }
  60268. declare module BABYLON {
  60269. /**
  60270. * Block used to get the length of a vector
  60271. */
  60272. export class LengthBlock extends NodeMaterialBlock {
  60273. /**
  60274. * Creates a new LengthBlock
  60275. * @param name defines the block name
  60276. */
  60277. constructor(name: string);
  60278. /**
  60279. * Gets the current class name
  60280. * @returns the class name
  60281. */
  60282. getClassName(): string;
  60283. /**
  60284. * Gets the value input component
  60285. */
  60286. get value(): NodeMaterialConnectionPoint;
  60287. /**
  60288. * Gets the output component
  60289. */
  60290. get output(): NodeMaterialConnectionPoint;
  60291. protected _buildBlock(state: NodeMaterialBuildState): this;
  60292. }
  60293. }
  60294. declare module BABYLON {
  60295. /**
  60296. * Block used to get negative version of a value (i.e. x * -1)
  60297. */
  60298. export class NegateBlock extends NodeMaterialBlock {
  60299. /**
  60300. * Creates a new NegateBlock
  60301. * @param name defines the block name
  60302. */
  60303. constructor(name: string);
  60304. /**
  60305. * Gets the current class name
  60306. * @returns the class name
  60307. */
  60308. getClassName(): string;
  60309. /**
  60310. * Gets the value input component
  60311. */
  60312. get value(): NodeMaterialConnectionPoint;
  60313. /**
  60314. * Gets the output component
  60315. */
  60316. get output(): NodeMaterialConnectionPoint;
  60317. protected _buildBlock(state: NodeMaterialBuildState): this;
  60318. }
  60319. }
  60320. declare module BABYLON {
  60321. /**
  60322. * Block used to get the value of the first parameter raised to the power of the second
  60323. */
  60324. export class PowBlock extends NodeMaterialBlock {
  60325. /**
  60326. * Creates a new PowBlock
  60327. * @param name defines the block name
  60328. */
  60329. constructor(name: string);
  60330. /**
  60331. * Gets the current class name
  60332. * @returns the class name
  60333. */
  60334. getClassName(): string;
  60335. /**
  60336. * Gets the value operand input component
  60337. */
  60338. get value(): NodeMaterialConnectionPoint;
  60339. /**
  60340. * Gets the power operand input component
  60341. */
  60342. get power(): NodeMaterialConnectionPoint;
  60343. /**
  60344. * Gets the output component
  60345. */
  60346. get output(): NodeMaterialConnectionPoint;
  60347. protected _buildBlock(state: NodeMaterialBuildState): this;
  60348. }
  60349. }
  60350. declare module BABYLON {
  60351. /**
  60352. * Block used to get a random number
  60353. */
  60354. export class RandomNumberBlock extends NodeMaterialBlock {
  60355. /**
  60356. * Creates a new RandomNumberBlock
  60357. * @param name defines the block name
  60358. */
  60359. constructor(name: string);
  60360. /**
  60361. * Gets the current class name
  60362. * @returns the class name
  60363. */
  60364. getClassName(): string;
  60365. /**
  60366. * Gets the seed input component
  60367. */
  60368. get seed(): NodeMaterialConnectionPoint;
  60369. /**
  60370. * Gets the output component
  60371. */
  60372. get output(): NodeMaterialConnectionPoint;
  60373. protected _buildBlock(state: NodeMaterialBuildState): this;
  60374. }
  60375. }
  60376. declare module BABYLON {
  60377. /**
  60378. * Block used to compute arc tangent of 2 values
  60379. */
  60380. export class ArcTan2Block extends NodeMaterialBlock {
  60381. /**
  60382. * Creates a new ArcTan2Block
  60383. * @param name defines the block name
  60384. */
  60385. constructor(name: string);
  60386. /**
  60387. * Gets the current class name
  60388. * @returns the class name
  60389. */
  60390. getClassName(): string;
  60391. /**
  60392. * Gets the x operand input component
  60393. */
  60394. get x(): NodeMaterialConnectionPoint;
  60395. /**
  60396. * Gets the y operand input component
  60397. */
  60398. get y(): NodeMaterialConnectionPoint;
  60399. /**
  60400. * Gets the output component
  60401. */
  60402. get output(): NodeMaterialConnectionPoint;
  60403. protected _buildBlock(state: NodeMaterialBuildState): this;
  60404. }
  60405. }
  60406. declare module BABYLON {
  60407. /**
  60408. * Block used to smooth step a value
  60409. */
  60410. export class SmoothStepBlock extends NodeMaterialBlock {
  60411. /**
  60412. * Creates a new SmoothStepBlock
  60413. * @param name defines the block name
  60414. */
  60415. constructor(name: string);
  60416. /**
  60417. * Gets the current class name
  60418. * @returns the class name
  60419. */
  60420. getClassName(): string;
  60421. /**
  60422. * Gets the value operand input component
  60423. */
  60424. get value(): NodeMaterialConnectionPoint;
  60425. /**
  60426. * Gets the first edge operand input component
  60427. */
  60428. get edge0(): NodeMaterialConnectionPoint;
  60429. /**
  60430. * Gets the second edge operand input component
  60431. */
  60432. get edge1(): NodeMaterialConnectionPoint;
  60433. /**
  60434. * Gets the output component
  60435. */
  60436. get output(): NodeMaterialConnectionPoint;
  60437. protected _buildBlock(state: NodeMaterialBuildState): this;
  60438. }
  60439. }
  60440. declare module BABYLON {
  60441. /**
  60442. * Block used to get the reciprocal (1 / x) of a value
  60443. */
  60444. export class ReciprocalBlock extends NodeMaterialBlock {
  60445. /**
  60446. * Creates a new ReciprocalBlock
  60447. * @param name defines the block name
  60448. */
  60449. constructor(name: string);
  60450. /**
  60451. * Gets the current class name
  60452. * @returns the class name
  60453. */
  60454. getClassName(): string;
  60455. /**
  60456. * Gets the input component
  60457. */
  60458. get input(): NodeMaterialConnectionPoint;
  60459. /**
  60460. * Gets the output component
  60461. */
  60462. get output(): NodeMaterialConnectionPoint;
  60463. protected _buildBlock(state: NodeMaterialBuildState): this;
  60464. }
  60465. }
  60466. declare module BABYLON {
  60467. /**
  60468. * Block used to replace a color by another one
  60469. */
  60470. export class ReplaceColorBlock extends NodeMaterialBlock {
  60471. /**
  60472. * Creates a new ReplaceColorBlock
  60473. * @param name defines the block name
  60474. */
  60475. constructor(name: string);
  60476. /**
  60477. * Gets the current class name
  60478. * @returns the class name
  60479. */
  60480. getClassName(): string;
  60481. /**
  60482. * Gets the value input component
  60483. */
  60484. get value(): NodeMaterialConnectionPoint;
  60485. /**
  60486. * Gets the reference input component
  60487. */
  60488. get reference(): NodeMaterialConnectionPoint;
  60489. /**
  60490. * Gets the distance input component
  60491. */
  60492. get distance(): NodeMaterialConnectionPoint;
  60493. /**
  60494. * Gets the replacement input component
  60495. */
  60496. get replacement(): NodeMaterialConnectionPoint;
  60497. /**
  60498. * Gets the output component
  60499. */
  60500. get output(): NodeMaterialConnectionPoint;
  60501. protected _buildBlock(state: NodeMaterialBuildState): this;
  60502. }
  60503. }
  60504. declare module BABYLON {
  60505. /**
  60506. * Block used to posterize a value
  60507. * @see https://en.wikipedia.org/wiki/Posterization
  60508. */
  60509. export class PosterizeBlock extends NodeMaterialBlock {
  60510. /**
  60511. * Creates a new PosterizeBlock
  60512. * @param name defines the block name
  60513. */
  60514. constructor(name: string);
  60515. /**
  60516. * Gets the current class name
  60517. * @returns the class name
  60518. */
  60519. getClassName(): string;
  60520. /**
  60521. * Gets the value input component
  60522. */
  60523. get value(): NodeMaterialConnectionPoint;
  60524. /**
  60525. * Gets the steps input component
  60526. */
  60527. get steps(): NodeMaterialConnectionPoint;
  60528. /**
  60529. * Gets the output component
  60530. */
  60531. get output(): NodeMaterialConnectionPoint;
  60532. protected _buildBlock(state: NodeMaterialBuildState): this;
  60533. }
  60534. }
  60535. declare module BABYLON {
  60536. /**
  60537. * Operations supported by the Wave block
  60538. */
  60539. export enum WaveBlockKind {
  60540. /** SawTooth */
  60541. SawTooth = 0,
  60542. /** Square */
  60543. Square = 1,
  60544. /** Triangle */
  60545. Triangle = 2
  60546. }
  60547. /**
  60548. * Block used to apply wave operation to floats
  60549. */
  60550. export class WaveBlock extends NodeMaterialBlock {
  60551. /**
  60552. * Gets or sets the kibnd of wave to be applied by the block
  60553. */
  60554. kind: WaveBlockKind;
  60555. /**
  60556. * Creates a new WaveBlock
  60557. * @param name defines the block name
  60558. */
  60559. constructor(name: string);
  60560. /**
  60561. * Gets the current class name
  60562. * @returns the class name
  60563. */
  60564. getClassName(): string;
  60565. /**
  60566. * Gets the input component
  60567. */
  60568. get input(): NodeMaterialConnectionPoint;
  60569. /**
  60570. * Gets the output component
  60571. */
  60572. get output(): NodeMaterialConnectionPoint;
  60573. protected _buildBlock(state: NodeMaterialBuildState): this;
  60574. serialize(): any;
  60575. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60576. }
  60577. }
  60578. declare module BABYLON {
  60579. /**
  60580. * Class used to store a color step for the GradientBlock
  60581. */
  60582. export class GradientBlockColorStep {
  60583. /**
  60584. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60585. */
  60586. step: number;
  60587. /**
  60588. * Gets or sets the color associated with this step
  60589. */
  60590. color: Color3;
  60591. /**
  60592. * Creates a new GradientBlockColorStep
  60593. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60594. * @param color defines the color associated with this step
  60595. */
  60596. constructor(
  60597. /**
  60598. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60599. */
  60600. step: number,
  60601. /**
  60602. * Gets or sets the color associated with this step
  60603. */
  60604. color: Color3);
  60605. }
  60606. /**
  60607. * Block used to return a color from a gradient based on an input value between 0 and 1
  60608. */
  60609. export class GradientBlock extends NodeMaterialBlock {
  60610. /**
  60611. * Gets or sets the list of color steps
  60612. */
  60613. colorSteps: GradientBlockColorStep[];
  60614. /**
  60615. * Creates a new GradientBlock
  60616. * @param name defines the block name
  60617. */
  60618. constructor(name: string);
  60619. /**
  60620. * Gets the current class name
  60621. * @returns the class name
  60622. */
  60623. getClassName(): string;
  60624. /**
  60625. * Gets the gradient input component
  60626. */
  60627. get gradient(): NodeMaterialConnectionPoint;
  60628. /**
  60629. * Gets the output component
  60630. */
  60631. get output(): NodeMaterialConnectionPoint;
  60632. private _writeColorConstant;
  60633. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60634. serialize(): any;
  60635. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60636. protected _dumpPropertiesCode(): string;
  60637. }
  60638. }
  60639. declare module BABYLON {
  60640. /**
  60641. * Block used to normalize lerp between 2 values
  60642. */
  60643. export class NLerpBlock extends NodeMaterialBlock {
  60644. /**
  60645. * Creates a new NLerpBlock
  60646. * @param name defines the block name
  60647. */
  60648. constructor(name: string);
  60649. /**
  60650. * Gets the current class name
  60651. * @returns the class name
  60652. */
  60653. getClassName(): string;
  60654. /**
  60655. * Gets the left operand input component
  60656. */
  60657. get left(): NodeMaterialConnectionPoint;
  60658. /**
  60659. * Gets the right operand input component
  60660. */
  60661. get right(): NodeMaterialConnectionPoint;
  60662. /**
  60663. * Gets the gradient operand input component
  60664. */
  60665. get gradient(): NodeMaterialConnectionPoint;
  60666. /**
  60667. * Gets the output component
  60668. */
  60669. get output(): NodeMaterialConnectionPoint;
  60670. protected _buildBlock(state: NodeMaterialBuildState): this;
  60671. }
  60672. }
  60673. declare module BABYLON {
  60674. /**
  60675. * block used to Generate a Worley Noise 3D Noise Pattern
  60676. */
  60677. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60678. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60679. manhattanDistance: boolean;
  60680. /**
  60681. * Creates a new WorleyNoise3DBlock
  60682. * @param name defines the block name
  60683. */
  60684. constructor(name: string);
  60685. /**
  60686. * Gets the current class name
  60687. * @returns the class name
  60688. */
  60689. getClassName(): string;
  60690. /**
  60691. * Gets the seed input component
  60692. */
  60693. get seed(): NodeMaterialConnectionPoint;
  60694. /**
  60695. * Gets the jitter input component
  60696. */
  60697. get jitter(): NodeMaterialConnectionPoint;
  60698. /**
  60699. * Gets the output component
  60700. */
  60701. get output(): NodeMaterialConnectionPoint;
  60702. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60703. /**
  60704. * Exposes the properties to the UI?
  60705. */
  60706. protected _dumpPropertiesCode(): string;
  60707. /**
  60708. * Exposes the properties to the Seralize?
  60709. */
  60710. serialize(): any;
  60711. /**
  60712. * Exposes the properties to the deseralize?
  60713. */
  60714. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60715. }
  60716. }
  60717. declare module BABYLON {
  60718. /**
  60719. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60720. */
  60721. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60722. /**
  60723. * Creates a new SimplexPerlin3DBlock
  60724. * @param name defines the block name
  60725. */
  60726. constructor(name: string);
  60727. /**
  60728. * Gets the current class name
  60729. * @returns the class name
  60730. */
  60731. getClassName(): string;
  60732. /**
  60733. * Gets the seed operand input component
  60734. */
  60735. get seed(): NodeMaterialConnectionPoint;
  60736. /**
  60737. * Gets the output component
  60738. */
  60739. get output(): NodeMaterialConnectionPoint;
  60740. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60741. }
  60742. }
  60743. declare module BABYLON {
  60744. /**
  60745. * Block used to blend normals
  60746. */
  60747. export class NormalBlendBlock extends NodeMaterialBlock {
  60748. /**
  60749. * Creates a new NormalBlendBlock
  60750. * @param name defines the block name
  60751. */
  60752. constructor(name: string);
  60753. /**
  60754. * Gets the current class name
  60755. * @returns the class name
  60756. */
  60757. getClassName(): string;
  60758. /**
  60759. * Gets the first input component
  60760. */
  60761. get normalMap0(): NodeMaterialConnectionPoint;
  60762. /**
  60763. * Gets the second input component
  60764. */
  60765. get normalMap1(): NodeMaterialConnectionPoint;
  60766. /**
  60767. * Gets the output component
  60768. */
  60769. get output(): NodeMaterialConnectionPoint;
  60770. protected _buildBlock(state: NodeMaterialBuildState): this;
  60771. }
  60772. }
  60773. declare module BABYLON {
  60774. /**
  60775. * Block used to rotate a 2d vector by a given angle
  60776. */
  60777. export class Rotate2dBlock extends NodeMaterialBlock {
  60778. /**
  60779. * Creates a new Rotate2dBlock
  60780. * @param name defines the block name
  60781. */
  60782. constructor(name: string);
  60783. /**
  60784. * Gets the current class name
  60785. * @returns the class name
  60786. */
  60787. getClassName(): string;
  60788. /**
  60789. * Gets the input vector
  60790. */
  60791. get input(): NodeMaterialConnectionPoint;
  60792. /**
  60793. * Gets the input angle
  60794. */
  60795. get angle(): NodeMaterialConnectionPoint;
  60796. /**
  60797. * Gets the output component
  60798. */
  60799. get output(): NodeMaterialConnectionPoint;
  60800. autoConfigure(material: NodeMaterial): void;
  60801. protected _buildBlock(state: NodeMaterialBuildState): this;
  60802. }
  60803. }
  60804. declare module BABYLON {
  60805. /**
  60806. * Block used to get the reflected vector from a direction and a normal
  60807. */
  60808. export class ReflectBlock extends NodeMaterialBlock {
  60809. /**
  60810. * Creates a new ReflectBlock
  60811. * @param name defines the block name
  60812. */
  60813. constructor(name: string);
  60814. /**
  60815. * Gets the current class name
  60816. * @returns the class name
  60817. */
  60818. getClassName(): string;
  60819. /**
  60820. * Gets the incident component
  60821. */
  60822. get incident(): NodeMaterialConnectionPoint;
  60823. /**
  60824. * Gets the normal component
  60825. */
  60826. get normal(): NodeMaterialConnectionPoint;
  60827. /**
  60828. * Gets the output component
  60829. */
  60830. get output(): NodeMaterialConnectionPoint;
  60831. protected _buildBlock(state: NodeMaterialBuildState): this;
  60832. }
  60833. }
  60834. declare module BABYLON {
  60835. /**
  60836. * Block used to get the refracted vector from a direction and a normal
  60837. */
  60838. export class RefractBlock extends NodeMaterialBlock {
  60839. /**
  60840. * Creates a new RefractBlock
  60841. * @param name defines the block name
  60842. */
  60843. constructor(name: string);
  60844. /**
  60845. * Gets the current class name
  60846. * @returns the class name
  60847. */
  60848. getClassName(): string;
  60849. /**
  60850. * Gets the incident component
  60851. */
  60852. get incident(): NodeMaterialConnectionPoint;
  60853. /**
  60854. * Gets the normal component
  60855. */
  60856. get normal(): NodeMaterialConnectionPoint;
  60857. /**
  60858. * Gets the index of refraction component
  60859. */
  60860. get ior(): NodeMaterialConnectionPoint;
  60861. /**
  60862. * Gets the output component
  60863. */
  60864. get output(): NodeMaterialConnectionPoint;
  60865. protected _buildBlock(state: NodeMaterialBuildState): this;
  60866. }
  60867. }
  60868. declare module BABYLON {
  60869. /**
  60870. * Block used to desaturate a color
  60871. */
  60872. export class DesaturateBlock extends NodeMaterialBlock {
  60873. /**
  60874. * Creates a new DesaturateBlock
  60875. * @param name defines the block name
  60876. */
  60877. constructor(name: string);
  60878. /**
  60879. * Gets the current class name
  60880. * @returns the class name
  60881. */
  60882. getClassName(): string;
  60883. /**
  60884. * Gets the color operand input component
  60885. */
  60886. get color(): NodeMaterialConnectionPoint;
  60887. /**
  60888. * Gets the level operand input component
  60889. */
  60890. get level(): NodeMaterialConnectionPoint;
  60891. /**
  60892. * Gets the output component
  60893. */
  60894. get output(): NodeMaterialConnectionPoint;
  60895. protected _buildBlock(state: NodeMaterialBuildState): this;
  60896. }
  60897. }
  60898. declare module BABYLON {
  60899. /**
  60900. * Effect Render Options
  60901. */
  60902. export interface IEffectRendererOptions {
  60903. /**
  60904. * Defines the vertices positions.
  60905. */
  60906. positions?: number[];
  60907. /**
  60908. * Defines the indices.
  60909. */
  60910. indices?: number[];
  60911. }
  60912. /**
  60913. * Helper class to render one or more effects.
  60914. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60915. */
  60916. export class EffectRenderer {
  60917. private engine;
  60918. private static _DefaultOptions;
  60919. private _vertexBuffers;
  60920. private _indexBuffer;
  60921. private _fullscreenViewport;
  60922. /**
  60923. * Creates an effect renderer
  60924. * @param engine the engine to use for rendering
  60925. * @param options defines the options of the effect renderer
  60926. */
  60927. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60928. /**
  60929. * Sets the current viewport in normalized coordinates 0-1
  60930. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60931. */
  60932. setViewport(viewport?: Viewport): void;
  60933. /**
  60934. * Binds the embedded attributes buffer to the effect.
  60935. * @param effect Defines the effect to bind the attributes for
  60936. */
  60937. bindBuffers(effect: Effect): void;
  60938. /**
  60939. * Sets the current effect wrapper to use during draw.
  60940. * The effect needs to be ready before calling this api.
  60941. * This also sets the default full screen position attribute.
  60942. * @param effectWrapper Defines the effect to draw with
  60943. */
  60944. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60945. /**
  60946. * Draws a full screen quad.
  60947. */
  60948. draw(): void;
  60949. private isRenderTargetTexture;
  60950. /**
  60951. * renders one or more effects to a specified texture
  60952. * @param effectWrapper the effect to renderer
  60953. * @param outputTexture texture to draw to, if null it will render to the screen.
  60954. */
  60955. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60956. /**
  60957. * Disposes of the effect renderer
  60958. */
  60959. dispose(): void;
  60960. }
  60961. /**
  60962. * Options to create an EffectWrapper
  60963. */
  60964. interface EffectWrapperCreationOptions {
  60965. /**
  60966. * Engine to use to create the effect
  60967. */
  60968. engine: ThinEngine;
  60969. /**
  60970. * Fragment shader for the effect
  60971. */
  60972. fragmentShader: string;
  60973. /**
  60974. * Vertex shader for the effect
  60975. */
  60976. vertexShader?: string;
  60977. /**
  60978. * Attributes to use in the shader
  60979. */
  60980. attributeNames?: Array<string>;
  60981. /**
  60982. * Uniforms to use in the shader
  60983. */
  60984. uniformNames?: Array<string>;
  60985. /**
  60986. * Texture sampler names to use in the shader
  60987. */
  60988. samplerNames?: Array<string>;
  60989. /**
  60990. * The friendly name of the effect displayed in Spector.
  60991. */
  60992. name?: string;
  60993. }
  60994. /**
  60995. * Wraps an effect to be used for rendering
  60996. */
  60997. export class EffectWrapper {
  60998. /**
  60999. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61000. */
  61001. onApplyObservable: Observable<{}>;
  61002. /**
  61003. * The underlying effect
  61004. */
  61005. effect: Effect;
  61006. /**
  61007. * Creates an effect to be renderer
  61008. * @param creationOptions options to create the effect
  61009. */
  61010. constructor(creationOptions: EffectWrapperCreationOptions);
  61011. /**
  61012. * Disposes of the effect wrapper
  61013. */
  61014. dispose(): void;
  61015. }
  61016. }
  61017. declare module BABYLON {
  61018. /**
  61019. * Helper class to push actions to a pool of workers.
  61020. */
  61021. export class WorkerPool implements IDisposable {
  61022. private _workerInfos;
  61023. private _pendingActions;
  61024. /**
  61025. * Constructor
  61026. * @param workers Array of workers to use for actions
  61027. */
  61028. constructor(workers: Array<Worker>);
  61029. /**
  61030. * Terminates all workers and clears any pending actions.
  61031. */
  61032. dispose(): void;
  61033. /**
  61034. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61035. * pended until a worker has completed its action.
  61036. * @param action The action to perform. Call onComplete when the action is complete.
  61037. */
  61038. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61039. private _execute;
  61040. }
  61041. }
  61042. declare module BABYLON {
  61043. /**
  61044. * Configuration for Draco compression
  61045. */
  61046. export interface IDracoCompressionConfiguration {
  61047. /**
  61048. * Configuration for the decoder.
  61049. */
  61050. decoder: {
  61051. /**
  61052. * The url to the WebAssembly module.
  61053. */
  61054. wasmUrl?: string;
  61055. /**
  61056. * The url to the WebAssembly binary.
  61057. */
  61058. wasmBinaryUrl?: string;
  61059. /**
  61060. * The url to the fallback JavaScript module.
  61061. */
  61062. fallbackUrl?: string;
  61063. };
  61064. }
  61065. /**
  61066. * Draco compression (https://google.github.io/draco/)
  61067. *
  61068. * This class wraps the Draco module.
  61069. *
  61070. * **Encoder**
  61071. *
  61072. * The encoder is not currently implemented.
  61073. *
  61074. * **Decoder**
  61075. *
  61076. * 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.
  61077. *
  61078. * To update the configuration, use the following code:
  61079. * ```javascript
  61080. * DracoCompression.Configuration = {
  61081. * decoder: {
  61082. * wasmUrl: "<url to the WebAssembly library>",
  61083. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61084. * fallbackUrl: "<url to the fallback JavaScript library>",
  61085. * }
  61086. * };
  61087. * ```
  61088. *
  61089. * 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.
  61090. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61091. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61092. *
  61093. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61094. * ```javascript
  61095. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61096. * ```
  61097. *
  61098. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61099. */
  61100. export class DracoCompression implements IDisposable {
  61101. private _workerPoolPromise?;
  61102. private _decoderModulePromise?;
  61103. /**
  61104. * The configuration. Defaults to the following urls:
  61105. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61106. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61107. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61108. */
  61109. static Configuration: IDracoCompressionConfiguration;
  61110. /**
  61111. * Returns true if the decoder configuration is available.
  61112. */
  61113. static get DecoderAvailable(): boolean;
  61114. /**
  61115. * Default number of workers to create when creating the draco compression object.
  61116. */
  61117. static DefaultNumWorkers: number;
  61118. private static GetDefaultNumWorkers;
  61119. private static _Default;
  61120. /**
  61121. * Default instance for the draco compression object.
  61122. */
  61123. static get Default(): DracoCompression;
  61124. /**
  61125. * Constructor
  61126. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61127. */
  61128. constructor(numWorkers?: number);
  61129. /**
  61130. * Stop all async operations and release resources.
  61131. */
  61132. dispose(): void;
  61133. /**
  61134. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61135. * @returns a promise that resolves when ready
  61136. */
  61137. whenReadyAsync(): Promise<void>;
  61138. /**
  61139. * Decode Draco compressed mesh data to vertex data.
  61140. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61141. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61142. * @returns A promise that resolves with the decoded vertex data
  61143. */
  61144. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61145. [kind: string]: number;
  61146. }): Promise<VertexData>;
  61147. }
  61148. }
  61149. declare module BABYLON {
  61150. /**
  61151. * Class for building Constructive Solid Geometry
  61152. */
  61153. export class CSG {
  61154. private polygons;
  61155. /**
  61156. * The world matrix
  61157. */
  61158. matrix: Matrix;
  61159. /**
  61160. * Stores the position
  61161. */
  61162. position: Vector3;
  61163. /**
  61164. * Stores the rotation
  61165. */
  61166. rotation: Vector3;
  61167. /**
  61168. * Stores the rotation quaternion
  61169. */
  61170. rotationQuaternion: Nullable<Quaternion>;
  61171. /**
  61172. * Stores the scaling vector
  61173. */
  61174. scaling: Vector3;
  61175. /**
  61176. * Convert the Mesh to CSG
  61177. * @param mesh The Mesh to convert to CSG
  61178. * @returns A new CSG from the Mesh
  61179. */
  61180. static FromMesh(mesh: Mesh): CSG;
  61181. /**
  61182. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61183. * @param polygons Polygons used to construct a CSG solid
  61184. */
  61185. private static FromPolygons;
  61186. /**
  61187. * Clones, or makes a deep copy, of the CSG
  61188. * @returns A new CSG
  61189. */
  61190. clone(): CSG;
  61191. /**
  61192. * Unions this CSG with another CSG
  61193. * @param csg The CSG to union against this CSG
  61194. * @returns The unioned CSG
  61195. */
  61196. union(csg: CSG): CSG;
  61197. /**
  61198. * Unions this CSG with another CSG in place
  61199. * @param csg The CSG to union against this CSG
  61200. */
  61201. unionInPlace(csg: CSG): void;
  61202. /**
  61203. * Subtracts this CSG with another CSG
  61204. * @param csg The CSG to subtract against this CSG
  61205. * @returns A new CSG
  61206. */
  61207. subtract(csg: CSG): CSG;
  61208. /**
  61209. * Subtracts this CSG with another CSG in place
  61210. * @param csg The CSG to subtact against this CSG
  61211. */
  61212. subtractInPlace(csg: CSG): void;
  61213. /**
  61214. * Intersect this CSG with another CSG
  61215. * @param csg The CSG to intersect against this CSG
  61216. * @returns A new CSG
  61217. */
  61218. intersect(csg: CSG): CSG;
  61219. /**
  61220. * Intersects this CSG with another CSG in place
  61221. * @param csg The CSG to intersect against this CSG
  61222. */
  61223. intersectInPlace(csg: CSG): void;
  61224. /**
  61225. * Return a new CSG solid with solid and empty space switched. This solid is
  61226. * not modified.
  61227. * @returns A new CSG solid with solid and empty space switched
  61228. */
  61229. inverse(): CSG;
  61230. /**
  61231. * Inverses the CSG in place
  61232. */
  61233. inverseInPlace(): void;
  61234. /**
  61235. * This is used to keep meshes transformations so they can be restored
  61236. * when we build back a Babylon Mesh
  61237. * NB : All CSG operations are performed in world coordinates
  61238. * @param csg The CSG to copy the transform attributes from
  61239. * @returns This CSG
  61240. */
  61241. copyTransformAttributes(csg: CSG): CSG;
  61242. /**
  61243. * Build Raw mesh from CSG
  61244. * Coordinates here are in world space
  61245. * @param name The name of the mesh geometry
  61246. * @param scene The Scene
  61247. * @param keepSubMeshes Specifies if the submeshes should be kept
  61248. * @returns A new Mesh
  61249. */
  61250. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61251. /**
  61252. * Build Mesh from CSG taking material and transforms into account
  61253. * @param name The name of the Mesh
  61254. * @param material The material of the Mesh
  61255. * @param scene The Scene
  61256. * @param keepSubMeshes Specifies if submeshes should be kept
  61257. * @returns The new Mesh
  61258. */
  61259. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61260. }
  61261. }
  61262. declare module BABYLON {
  61263. /**
  61264. * Class used to create a trail following a mesh
  61265. */
  61266. export class TrailMesh extends Mesh {
  61267. private _generator;
  61268. private _autoStart;
  61269. private _running;
  61270. private _diameter;
  61271. private _length;
  61272. private _sectionPolygonPointsCount;
  61273. private _sectionVectors;
  61274. private _sectionNormalVectors;
  61275. private _beforeRenderObserver;
  61276. /**
  61277. * @constructor
  61278. * @param name The value used by scene.getMeshByName() to do a lookup.
  61279. * @param generator The mesh or transform node to generate a trail.
  61280. * @param scene The scene to add this mesh to.
  61281. * @param diameter Diameter of trailing mesh. Default is 1.
  61282. * @param length Length of trailing mesh. Default is 60.
  61283. * @param autoStart Automatically start trailing mesh. Default true.
  61284. */
  61285. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61286. /**
  61287. * "TrailMesh"
  61288. * @returns "TrailMesh"
  61289. */
  61290. getClassName(): string;
  61291. private _createMesh;
  61292. /**
  61293. * Start trailing mesh.
  61294. */
  61295. start(): void;
  61296. /**
  61297. * Stop trailing mesh.
  61298. */
  61299. stop(): void;
  61300. /**
  61301. * Update trailing mesh geometry.
  61302. */
  61303. update(): void;
  61304. /**
  61305. * Returns a new TrailMesh object.
  61306. * @param name is a string, the name given to the new mesh
  61307. * @param newGenerator use new generator object for cloned trail mesh
  61308. * @returns a new mesh
  61309. */
  61310. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61311. /**
  61312. * Serializes this trail mesh
  61313. * @param serializationObject object to write serialization to
  61314. */
  61315. serialize(serializationObject: any): void;
  61316. /**
  61317. * Parses a serialized trail mesh
  61318. * @param parsedMesh the serialized mesh
  61319. * @param scene the scene to create the trail mesh in
  61320. * @returns the created trail mesh
  61321. */
  61322. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61323. }
  61324. }
  61325. declare module BABYLON {
  61326. /**
  61327. * Class containing static functions to help procedurally build meshes
  61328. */
  61329. export class TiledBoxBuilder {
  61330. /**
  61331. * Creates a box mesh
  61332. * 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)
  61333. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61335. * * 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
  61336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61337. * @param name defines the name of the mesh
  61338. * @param options defines the options used to create the mesh
  61339. * @param scene defines the hosting scene
  61340. * @returns the box mesh
  61341. */
  61342. static CreateTiledBox(name: string, options: {
  61343. pattern?: number;
  61344. width?: number;
  61345. height?: number;
  61346. depth?: number;
  61347. tileSize?: number;
  61348. tileWidth?: number;
  61349. tileHeight?: number;
  61350. alignHorizontal?: number;
  61351. alignVertical?: number;
  61352. faceUV?: Vector4[];
  61353. faceColors?: Color4[];
  61354. sideOrientation?: number;
  61355. updatable?: boolean;
  61356. }, scene?: Nullable<Scene>): Mesh;
  61357. }
  61358. }
  61359. declare module BABYLON {
  61360. /**
  61361. * Class containing static functions to help procedurally build meshes
  61362. */
  61363. export class TorusKnotBuilder {
  61364. /**
  61365. * Creates a torus knot mesh
  61366. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61367. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61368. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61369. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61371. * * 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
  61372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61373. * @param name defines the name of the mesh
  61374. * @param options defines the options used to create the mesh
  61375. * @param scene defines the hosting scene
  61376. * @returns the torus knot mesh
  61377. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61378. */
  61379. static CreateTorusKnot(name: string, options: {
  61380. radius?: number;
  61381. tube?: number;
  61382. radialSegments?: number;
  61383. tubularSegments?: number;
  61384. p?: number;
  61385. q?: number;
  61386. updatable?: boolean;
  61387. sideOrientation?: number;
  61388. frontUVs?: Vector4;
  61389. backUVs?: Vector4;
  61390. }, scene: any): Mesh;
  61391. }
  61392. }
  61393. declare module BABYLON {
  61394. /**
  61395. * Polygon
  61396. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61397. */
  61398. export class Polygon {
  61399. /**
  61400. * Creates a rectangle
  61401. * @param xmin bottom X coord
  61402. * @param ymin bottom Y coord
  61403. * @param xmax top X coord
  61404. * @param ymax top Y coord
  61405. * @returns points that make the resulting rectation
  61406. */
  61407. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61408. /**
  61409. * Creates a circle
  61410. * @param radius radius of circle
  61411. * @param cx scale in x
  61412. * @param cy scale in y
  61413. * @param numberOfSides number of sides that make up the circle
  61414. * @returns points that make the resulting circle
  61415. */
  61416. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61417. /**
  61418. * Creates a polygon from input string
  61419. * @param input Input polygon data
  61420. * @returns the parsed points
  61421. */
  61422. static Parse(input: string): Vector2[];
  61423. /**
  61424. * Starts building a polygon from x and y coordinates
  61425. * @param x x coordinate
  61426. * @param y y coordinate
  61427. * @returns the started path2
  61428. */
  61429. static StartingAt(x: number, y: number): Path2;
  61430. }
  61431. /**
  61432. * Builds a polygon
  61433. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61434. */
  61435. export class PolygonMeshBuilder {
  61436. private _points;
  61437. private _outlinepoints;
  61438. private _holes;
  61439. private _name;
  61440. private _scene;
  61441. private _epoints;
  61442. private _eholes;
  61443. private _addToepoint;
  61444. /**
  61445. * Babylon reference to the earcut plugin.
  61446. */
  61447. bjsEarcut: any;
  61448. /**
  61449. * Creates a PolygonMeshBuilder
  61450. * @param name name of the builder
  61451. * @param contours Path of the polygon
  61452. * @param scene scene to add to when creating the mesh
  61453. * @param earcutInjection can be used to inject your own earcut reference
  61454. */
  61455. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61456. /**
  61457. * Adds a whole within the polygon
  61458. * @param hole Array of points defining the hole
  61459. * @returns this
  61460. */
  61461. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61462. /**
  61463. * Creates the polygon
  61464. * @param updatable If the mesh should be updatable
  61465. * @param depth The depth of the mesh created
  61466. * @returns the created mesh
  61467. */
  61468. build(updatable?: boolean, depth?: number): Mesh;
  61469. /**
  61470. * Creates the polygon
  61471. * @param depth The depth of the mesh created
  61472. * @returns the created VertexData
  61473. */
  61474. buildVertexData(depth?: number): VertexData;
  61475. /**
  61476. * Adds a side to the polygon
  61477. * @param positions points that make the polygon
  61478. * @param normals normals of the polygon
  61479. * @param uvs uvs of the polygon
  61480. * @param indices indices of the polygon
  61481. * @param bounds bounds of the polygon
  61482. * @param points points of the polygon
  61483. * @param depth depth of the polygon
  61484. * @param flip flip of the polygon
  61485. */
  61486. private addSide;
  61487. }
  61488. }
  61489. declare module BABYLON {
  61490. /**
  61491. * Class containing static functions to help procedurally build meshes
  61492. */
  61493. export class PolygonBuilder {
  61494. /**
  61495. * Creates a polygon mesh
  61496. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61497. * * 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
  61498. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61500. * * 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)
  61501. * * Remember you can only change the shape positions, not their number when updating a polygon
  61502. * @param name defines the name of the mesh
  61503. * @param options defines the options used to create the mesh
  61504. * @param scene defines the hosting scene
  61505. * @param earcutInjection can be used to inject your own earcut reference
  61506. * @returns the polygon mesh
  61507. */
  61508. static CreatePolygon(name: string, options: {
  61509. shape: Vector3[];
  61510. holes?: Vector3[][];
  61511. depth?: number;
  61512. faceUV?: Vector4[];
  61513. faceColors?: Color4[];
  61514. updatable?: boolean;
  61515. sideOrientation?: number;
  61516. frontUVs?: Vector4;
  61517. backUVs?: Vector4;
  61518. wrap?: boolean;
  61519. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61520. /**
  61521. * Creates an extruded polygon mesh, with depth in the Y direction.
  61522. * * 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)
  61523. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61524. * @param name defines the name of the mesh
  61525. * @param options defines the options used to create the mesh
  61526. * @param scene defines the hosting scene
  61527. * @param earcutInjection can be used to inject your own earcut reference
  61528. * @returns the polygon mesh
  61529. */
  61530. static ExtrudePolygon(name: string, options: {
  61531. shape: Vector3[];
  61532. holes?: Vector3[][];
  61533. depth?: number;
  61534. faceUV?: Vector4[];
  61535. faceColors?: Color4[];
  61536. updatable?: boolean;
  61537. sideOrientation?: number;
  61538. frontUVs?: Vector4;
  61539. backUVs?: Vector4;
  61540. wrap?: boolean;
  61541. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61542. }
  61543. }
  61544. declare module BABYLON {
  61545. /**
  61546. * Class containing static functions to help procedurally build meshes
  61547. */
  61548. export class LatheBuilder {
  61549. /**
  61550. * Creates lathe mesh.
  61551. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61552. * * 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
  61553. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61554. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61555. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61556. * * 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
  61557. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61558. * * 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
  61559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61560. * * 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
  61561. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61563. * @param name defines the name of the mesh
  61564. * @param options defines the options used to create the mesh
  61565. * @param scene defines the hosting scene
  61566. * @returns the lathe mesh
  61567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61568. */
  61569. static CreateLathe(name: string, options: {
  61570. shape: Vector3[];
  61571. radius?: number;
  61572. tessellation?: number;
  61573. clip?: number;
  61574. arc?: number;
  61575. closed?: boolean;
  61576. updatable?: boolean;
  61577. sideOrientation?: number;
  61578. frontUVs?: Vector4;
  61579. backUVs?: Vector4;
  61580. cap?: number;
  61581. invertUV?: boolean;
  61582. }, scene?: Nullable<Scene>): Mesh;
  61583. }
  61584. }
  61585. declare module BABYLON {
  61586. /**
  61587. * Class containing static functions to help procedurally build meshes
  61588. */
  61589. export class TiledPlaneBuilder {
  61590. /**
  61591. * Creates a tiled plane mesh
  61592. * * The parameter `pattern` will, depending on value, do nothing or
  61593. * * * flip (reflect about central vertical) alternate tiles across and up
  61594. * * * flip every tile on alternate rows
  61595. * * * rotate (180 degs) alternate tiles across and up
  61596. * * * rotate every tile on alternate rows
  61597. * * * flip and rotate alternate tiles across and up
  61598. * * * flip and rotate every tile on alternate rows
  61599. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61600. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61601. * * 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
  61602. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61603. * * 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)
  61604. * * 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)
  61605. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61606. * @param name defines the name of the mesh
  61607. * @param options defines the options used to create the mesh
  61608. * @param scene defines the hosting scene
  61609. * @returns the box mesh
  61610. */
  61611. static CreateTiledPlane(name: string, options: {
  61612. pattern?: number;
  61613. tileSize?: number;
  61614. tileWidth?: number;
  61615. tileHeight?: number;
  61616. size?: number;
  61617. width?: number;
  61618. height?: number;
  61619. alignHorizontal?: number;
  61620. alignVertical?: number;
  61621. sideOrientation?: number;
  61622. frontUVs?: Vector4;
  61623. backUVs?: Vector4;
  61624. updatable?: boolean;
  61625. }, scene?: Nullable<Scene>): Mesh;
  61626. }
  61627. }
  61628. declare module BABYLON {
  61629. /**
  61630. * Class containing static functions to help procedurally build meshes
  61631. */
  61632. export class TubeBuilder {
  61633. /**
  61634. * Creates a tube mesh.
  61635. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61636. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61637. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61638. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61639. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61640. * * 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)
  61641. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61642. * * 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
  61643. * * 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
  61644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61645. * * 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
  61646. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61648. * @param name defines the name of the mesh
  61649. * @param options defines the options used to create the mesh
  61650. * @param scene defines the hosting scene
  61651. * @returns the tube mesh
  61652. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61653. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61654. */
  61655. static CreateTube(name: string, options: {
  61656. path: Vector3[];
  61657. radius?: number;
  61658. tessellation?: number;
  61659. radiusFunction?: {
  61660. (i: number, distance: number): number;
  61661. };
  61662. cap?: number;
  61663. arc?: number;
  61664. updatable?: boolean;
  61665. sideOrientation?: number;
  61666. frontUVs?: Vector4;
  61667. backUVs?: Vector4;
  61668. instance?: Mesh;
  61669. invertUV?: boolean;
  61670. }, scene?: Nullable<Scene>): Mesh;
  61671. }
  61672. }
  61673. declare module BABYLON {
  61674. /**
  61675. * Class containing static functions to help procedurally build meshes
  61676. */
  61677. export class IcoSphereBuilder {
  61678. /**
  61679. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61680. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61681. * * 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`)
  61682. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61683. * * 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
  61684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61685. * * 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
  61686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61687. * @param name defines the name of the mesh
  61688. * @param options defines the options used to create the mesh
  61689. * @param scene defines the hosting scene
  61690. * @returns the icosahedron mesh
  61691. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61692. */
  61693. static CreateIcoSphere(name: string, options: {
  61694. radius?: number;
  61695. radiusX?: number;
  61696. radiusY?: number;
  61697. radiusZ?: number;
  61698. flat?: boolean;
  61699. subdivisions?: number;
  61700. sideOrientation?: number;
  61701. frontUVs?: Vector4;
  61702. backUVs?: Vector4;
  61703. updatable?: boolean;
  61704. }, scene?: Nullable<Scene>): Mesh;
  61705. }
  61706. }
  61707. declare module BABYLON {
  61708. /**
  61709. * Class containing static functions to help procedurally build meshes
  61710. */
  61711. export class DecalBuilder {
  61712. /**
  61713. * Creates a decal mesh.
  61714. * 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
  61715. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61716. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61717. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61718. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61719. * @param name defines the name of the mesh
  61720. * @param sourceMesh defines the mesh where the decal must be applied
  61721. * @param options defines the options used to create the mesh
  61722. * @param scene defines the hosting scene
  61723. * @returns the decal mesh
  61724. * @see https://doc.babylonjs.com/how_to/decals
  61725. */
  61726. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61727. position?: Vector3;
  61728. normal?: Vector3;
  61729. size?: Vector3;
  61730. angle?: number;
  61731. }): Mesh;
  61732. }
  61733. }
  61734. declare module BABYLON {
  61735. /**
  61736. * Class containing static functions to help procedurally build meshes
  61737. */
  61738. export class MeshBuilder {
  61739. /**
  61740. * Creates a box mesh
  61741. * * The parameter `size` sets the size (float) of each box side (default 1)
  61742. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61743. * * 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)
  61744. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61746. * * 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
  61747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61748. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61749. * @param name defines the name of the mesh
  61750. * @param options defines the options used to create the mesh
  61751. * @param scene defines the hosting scene
  61752. * @returns the box mesh
  61753. */
  61754. static CreateBox(name: string, options: {
  61755. size?: number;
  61756. width?: number;
  61757. height?: number;
  61758. depth?: number;
  61759. faceUV?: Vector4[];
  61760. faceColors?: Color4[];
  61761. sideOrientation?: number;
  61762. frontUVs?: Vector4;
  61763. backUVs?: Vector4;
  61764. wrap?: boolean;
  61765. topBaseAt?: number;
  61766. bottomBaseAt?: number;
  61767. updatable?: boolean;
  61768. }, scene?: Nullable<Scene>): Mesh;
  61769. /**
  61770. * Creates a tiled box mesh
  61771. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61773. * @param name defines the name of the mesh
  61774. * @param options defines the options used to create the mesh
  61775. * @param scene defines the hosting scene
  61776. * @returns the tiled box mesh
  61777. */
  61778. static CreateTiledBox(name: string, options: {
  61779. pattern?: number;
  61780. size?: number;
  61781. width?: number;
  61782. height?: number;
  61783. depth: number;
  61784. tileSize?: number;
  61785. tileWidth?: number;
  61786. tileHeight?: number;
  61787. faceUV?: Vector4[];
  61788. faceColors?: Color4[];
  61789. alignHorizontal?: number;
  61790. alignVertical?: number;
  61791. sideOrientation?: number;
  61792. updatable?: boolean;
  61793. }, scene?: Nullable<Scene>): Mesh;
  61794. /**
  61795. * Creates a sphere mesh
  61796. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61797. * * 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`)
  61798. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61799. * * 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
  61800. * * 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)
  61801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61802. * * 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
  61803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61804. * @param name defines the name of the mesh
  61805. * @param options defines the options used to create the mesh
  61806. * @param scene defines the hosting scene
  61807. * @returns the sphere mesh
  61808. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61809. */
  61810. static CreateSphere(name: string, options: {
  61811. segments?: number;
  61812. diameter?: number;
  61813. diameterX?: number;
  61814. diameterY?: number;
  61815. diameterZ?: number;
  61816. arc?: number;
  61817. slice?: number;
  61818. sideOrientation?: number;
  61819. frontUVs?: Vector4;
  61820. backUVs?: Vector4;
  61821. updatable?: boolean;
  61822. }, scene?: Nullable<Scene>): Mesh;
  61823. /**
  61824. * Creates a plane polygonal mesh. By default, this is a disc
  61825. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61826. * * 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
  61827. * * 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
  61828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61829. * * 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
  61830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61831. * @param name defines the name of the mesh
  61832. * @param options defines the options used to create the mesh
  61833. * @param scene defines the hosting scene
  61834. * @returns the plane polygonal mesh
  61835. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61836. */
  61837. static CreateDisc(name: string, options: {
  61838. radius?: number;
  61839. tessellation?: number;
  61840. arc?: number;
  61841. updatable?: boolean;
  61842. sideOrientation?: number;
  61843. frontUVs?: Vector4;
  61844. backUVs?: Vector4;
  61845. }, scene?: Nullable<Scene>): Mesh;
  61846. /**
  61847. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61848. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61849. * * 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`)
  61850. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61851. * * 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
  61852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61853. * * 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
  61854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61855. * @param name defines the name of the mesh
  61856. * @param options defines the options used to create the mesh
  61857. * @param scene defines the hosting scene
  61858. * @returns the icosahedron mesh
  61859. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61860. */
  61861. static CreateIcoSphere(name: string, options: {
  61862. radius?: number;
  61863. radiusX?: number;
  61864. radiusY?: number;
  61865. radiusZ?: number;
  61866. flat?: boolean;
  61867. subdivisions?: number;
  61868. sideOrientation?: number;
  61869. frontUVs?: Vector4;
  61870. backUVs?: Vector4;
  61871. updatable?: boolean;
  61872. }, scene?: Nullable<Scene>): Mesh;
  61873. /**
  61874. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61875. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61876. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61877. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61878. * * 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
  61879. * * 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
  61880. * * 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
  61881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61882. * * 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
  61883. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61884. * * 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
  61885. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61886. * * 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
  61887. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61889. * @param name defines the name of the mesh
  61890. * @param options defines the options used to create the mesh
  61891. * @param scene defines the hosting scene
  61892. * @returns the ribbon mesh
  61893. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61894. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61895. */
  61896. static CreateRibbon(name: string, options: {
  61897. pathArray: Vector3[][];
  61898. closeArray?: boolean;
  61899. closePath?: boolean;
  61900. offset?: number;
  61901. updatable?: boolean;
  61902. sideOrientation?: number;
  61903. frontUVs?: Vector4;
  61904. backUVs?: Vector4;
  61905. instance?: Mesh;
  61906. invertUV?: boolean;
  61907. uvs?: Vector2[];
  61908. colors?: Color4[];
  61909. }, scene?: Nullable<Scene>): Mesh;
  61910. /**
  61911. * Creates a cylinder or a cone mesh
  61912. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61913. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61914. * * 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.
  61915. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61916. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61917. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61918. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61919. * * 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).
  61920. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61921. * * 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).
  61922. * * 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
  61923. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61924. * * 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
  61925. * * 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.
  61926. * * If `enclose` is false, a ring surface is one element.
  61927. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61928. * * 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
  61929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61930. * * 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
  61931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61932. * @param name defines the name of the mesh
  61933. * @param options defines the options used to create the mesh
  61934. * @param scene defines the hosting scene
  61935. * @returns the cylinder mesh
  61936. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61937. */
  61938. static CreateCylinder(name: string, options: {
  61939. height?: number;
  61940. diameterTop?: number;
  61941. diameterBottom?: number;
  61942. diameter?: number;
  61943. tessellation?: number;
  61944. subdivisions?: number;
  61945. arc?: number;
  61946. faceColors?: Color4[];
  61947. faceUV?: Vector4[];
  61948. updatable?: boolean;
  61949. hasRings?: boolean;
  61950. enclose?: boolean;
  61951. cap?: number;
  61952. sideOrientation?: number;
  61953. frontUVs?: Vector4;
  61954. backUVs?: Vector4;
  61955. }, scene?: Nullable<Scene>): Mesh;
  61956. /**
  61957. * Creates a torus mesh
  61958. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61959. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61960. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61962. * * 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
  61963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61964. * @param name defines the name of the mesh
  61965. * @param options defines the options used to create the mesh
  61966. * @param scene defines the hosting scene
  61967. * @returns the torus mesh
  61968. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61969. */
  61970. static CreateTorus(name: string, options: {
  61971. diameter?: number;
  61972. thickness?: number;
  61973. tessellation?: number;
  61974. updatable?: boolean;
  61975. sideOrientation?: number;
  61976. frontUVs?: Vector4;
  61977. backUVs?: Vector4;
  61978. }, scene?: Nullable<Scene>): Mesh;
  61979. /**
  61980. * Creates a torus knot mesh
  61981. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61982. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61983. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61984. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61986. * * 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
  61987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61988. * @param name defines the name of the mesh
  61989. * @param options defines the options used to create the mesh
  61990. * @param scene defines the hosting scene
  61991. * @returns the torus knot mesh
  61992. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61993. */
  61994. static CreateTorusKnot(name: string, options: {
  61995. radius?: number;
  61996. tube?: number;
  61997. radialSegments?: number;
  61998. tubularSegments?: number;
  61999. p?: number;
  62000. q?: number;
  62001. updatable?: boolean;
  62002. sideOrientation?: number;
  62003. frontUVs?: Vector4;
  62004. backUVs?: Vector4;
  62005. }, scene?: Nullable<Scene>): Mesh;
  62006. /**
  62007. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  62008. * * 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
  62009. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  62010. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  62011. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  62012. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  62013. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  62014. * * 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
  62015. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  62016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62017. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  62018. * @param name defines the name of the new line system
  62019. * @param options defines the options used to create the line system
  62020. * @param scene defines the hosting scene
  62021. * @returns a new line system mesh
  62022. */
  62023. static CreateLineSystem(name: string, options: {
  62024. lines: Vector3[][];
  62025. updatable?: boolean;
  62026. instance?: Nullable<LinesMesh>;
  62027. colors?: Nullable<Color4[][]>;
  62028. useVertexAlpha?: boolean;
  62029. }, scene: Nullable<Scene>): LinesMesh;
  62030. /**
  62031. * Creates a line mesh
  62032. * 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
  62033. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62034. * * The parameter `points` is an array successive Vector3
  62035. * * 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
  62036. * * The optional parameter `colors` is an array of successive Color4, one per line point
  62037. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  62038. * * When updating an instance, remember that only point positions can change, not the number of points
  62039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62040. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  62041. * @param name defines the name of the new line system
  62042. * @param options defines the options used to create the line system
  62043. * @param scene defines the hosting scene
  62044. * @returns a new line mesh
  62045. */
  62046. static CreateLines(name: string, options: {
  62047. points: Vector3[];
  62048. updatable?: boolean;
  62049. instance?: Nullable<LinesMesh>;
  62050. colors?: Color4[];
  62051. useVertexAlpha?: boolean;
  62052. }, scene?: Nullable<Scene>): LinesMesh;
  62053. /**
  62054. * Creates a dashed line mesh
  62055. * * 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
  62056. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62057. * * The parameter `points` is an array successive Vector3
  62058. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  62059. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  62060. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  62061. * * 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
  62062. * * When updating an instance, remember that only point positions can change, not the number of points
  62063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62064. * @param name defines the name of the mesh
  62065. * @param options defines the options used to create the mesh
  62066. * @param scene defines the hosting scene
  62067. * @returns the dashed line mesh
  62068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62069. */
  62070. static CreateDashedLines(name: string, options: {
  62071. points: Vector3[];
  62072. dashSize?: number;
  62073. gapSize?: number;
  62074. dashNb?: number;
  62075. updatable?: boolean;
  62076. instance?: LinesMesh;
  62077. }, scene?: Nullable<Scene>): LinesMesh;
  62078. /**
  62079. * 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.
  62080. * * 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.
  62081. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62082. * * 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.
  62083. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62084. * * 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
  62085. * * 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
  62086. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62088. * * 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
  62089. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62091. * @param name defines the name of the mesh
  62092. * @param options defines the options used to create the mesh
  62093. * @param scene defines the hosting scene
  62094. * @returns the extruded shape mesh
  62095. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62097. */
  62098. static ExtrudeShape(name: string, options: {
  62099. shape: Vector3[];
  62100. path: Vector3[];
  62101. scale?: number;
  62102. rotation?: number;
  62103. cap?: number;
  62104. updatable?: boolean;
  62105. sideOrientation?: number;
  62106. frontUVs?: Vector4;
  62107. backUVs?: Vector4;
  62108. instance?: Mesh;
  62109. invertUV?: boolean;
  62110. }, scene?: Nullable<Scene>): Mesh;
  62111. /**
  62112. * Creates an custom extruded shape mesh.
  62113. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62114. * * 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.
  62115. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62116. * * 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
  62117. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62118. * * 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
  62119. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62120. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62121. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62122. * * 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
  62123. * * 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
  62124. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62126. * * 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
  62127. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62129. * @param name defines the name of the mesh
  62130. * @param options defines the options used to create the mesh
  62131. * @param scene defines the hosting scene
  62132. * @returns the custom extruded shape mesh
  62133. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62134. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62135. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62136. */
  62137. static ExtrudeShapeCustom(name: string, options: {
  62138. shape: Vector3[];
  62139. path: Vector3[];
  62140. scaleFunction?: any;
  62141. rotationFunction?: any;
  62142. ribbonCloseArray?: boolean;
  62143. ribbonClosePath?: boolean;
  62144. cap?: number;
  62145. updatable?: boolean;
  62146. sideOrientation?: number;
  62147. frontUVs?: Vector4;
  62148. backUVs?: Vector4;
  62149. instance?: Mesh;
  62150. invertUV?: boolean;
  62151. }, scene?: Nullable<Scene>): Mesh;
  62152. /**
  62153. * Creates lathe mesh.
  62154. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62155. * * 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
  62156. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62157. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62158. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62159. * * 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
  62160. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62161. * * 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
  62162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62163. * * 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
  62164. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62166. * @param name defines the name of the mesh
  62167. * @param options defines the options used to create the mesh
  62168. * @param scene defines the hosting scene
  62169. * @returns the lathe mesh
  62170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62171. */
  62172. static CreateLathe(name: string, options: {
  62173. shape: Vector3[];
  62174. radius?: number;
  62175. tessellation?: number;
  62176. clip?: number;
  62177. arc?: number;
  62178. closed?: boolean;
  62179. updatable?: boolean;
  62180. sideOrientation?: number;
  62181. frontUVs?: Vector4;
  62182. backUVs?: Vector4;
  62183. cap?: number;
  62184. invertUV?: boolean;
  62185. }, scene?: Nullable<Scene>): Mesh;
  62186. /**
  62187. * Creates a tiled plane mesh
  62188. * * You can set a limited pattern arrangement with the tiles
  62189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62190. * * 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
  62191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62192. * @param name defines the name of the mesh
  62193. * @param options defines the options used to create the mesh
  62194. * @param scene defines the hosting scene
  62195. * @returns the plane mesh
  62196. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62197. */
  62198. static CreateTiledPlane(name: string, options: {
  62199. pattern?: number;
  62200. tileSize?: number;
  62201. tileWidth?: number;
  62202. tileHeight?: number;
  62203. size?: number;
  62204. width?: number;
  62205. height?: number;
  62206. alignHorizontal?: number;
  62207. alignVertical?: number;
  62208. sideOrientation?: number;
  62209. frontUVs?: Vector4;
  62210. backUVs?: Vector4;
  62211. updatable?: boolean;
  62212. }, scene?: Nullable<Scene>): Mesh;
  62213. /**
  62214. * Creates a plane mesh
  62215. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62216. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62217. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62219. * * 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
  62220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62221. * @param name defines the name of the mesh
  62222. * @param options defines the options used to create the mesh
  62223. * @param scene defines the hosting scene
  62224. * @returns the plane mesh
  62225. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62226. */
  62227. static CreatePlane(name: string, options: {
  62228. size?: number;
  62229. width?: number;
  62230. height?: number;
  62231. sideOrientation?: number;
  62232. frontUVs?: Vector4;
  62233. backUVs?: Vector4;
  62234. updatable?: boolean;
  62235. sourcePlane?: Plane;
  62236. }, scene?: Nullable<Scene>): Mesh;
  62237. /**
  62238. * Creates a ground mesh
  62239. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62240. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62242. * @param name defines the name of the mesh
  62243. * @param options defines the options used to create the mesh
  62244. * @param scene defines the hosting scene
  62245. * @returns the ground mesh
  62246. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62247. */
  62248. static CreateGround(name: string, options: {
  62249. width?: number;
  62250. height?: number;
  62251. subdivisions?: number;
  62252. subdivisionsX?: number;
  62253. subdivisionsY?: number;
  62254. updatable?: boolean;
  62255. }, scene?: Nullable<Scene>): Mesh;
  62256. /**
  62257. * Creates a tiled ground mesh
  62258. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62259. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62260. * * 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
  62261. * * 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
  62262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62263. * @param name defines the name of the mesh
  62264. * @param options defines the options used to create the mesh
  62265. * @param scene defines the hosting scene
  62266. * @returns the tiled ground mesh
  62267. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62268. */
  62269. static CreateTiledGround(name: string, options: {
  62270. xmin: number;
  62271. zmin: number;
  62272. xmax: number;
  62273. zmax: number;
  62274. subdivisions?: {
  62275. w: number;
  62276. h: number;
  62277. };
  62278. precision?: {
  62279. w: number;
  62280. h: number;
  62281. };
  62282. updatable?: boolean;
  62283. }, scene?: Nullable<Scene>): Mesh;
  62284. /**
  62285. * Creates a ground mesh from a height map
  62286. * * The parameter `url` sets the URL of the height map image resource.
  62287. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62288. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62289. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62290. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62291. * * 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.
  62292. * * 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).
  62293. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62295. * @param name defines the name of the mesh
  62296. * @param url defines the url to the height map
  62297. * @param options defines the options used to create the mesh
  62298. * @param scene defines the hosting scene
  62299. * @returns the ground mesh
  62300. * @see https://doc.babylonjs.com/babylon101/height_map
  62301. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62302. */
  62303. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62304. width?: number;
  62305. height?: number;
  62306. subdivisions?: number;
  62307. minHeight?: number;
  62308. maxHeight?: number;
  62309. colorFilter?: Color3;
  62310. alphaFilter?: number;
  62311. updatable?: boolean;
  62312. onReady?: (mesh: GroundMesh) => void;
  62313. }, scene?: Nullable<Scene>): GroundMesh;
  62314. /**
  62315. * Creates a polygon mesh
  62316. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62317. * * 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
  62318. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62320. * * 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)
  62321. * * Remember you can only change the shape positions, not their number when updating a polygon
  62322. * @param name defines the name of the mesh
  62323. * @param options defines the options used to create the mesh
  62324. * @param scene defines the hosting scene
  62325. * @param earcutInjection can be used to inject your own earcut reference
  62326. * @returns the polygon mesh
  62327. */
  62328. static CreatePolygon(name: string, options: {
  62329. shape: Vector3[];
  62330. holes?: Vector3[][];
  62331. depth?: number;
  62332. faceUV?: Vector4[];
  62333. faceColors?: Color4[];
  62334. updatable?: boolean;
  62335. sideOrientation?: number;
  62336. frontUVs?: Vector4;
  62337. backUVs?: Vector4;
  62338. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62339. /**
  62340. * Creates an extruded polygon mesh, with depth in the Y direction.
  62341. * * 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)
  62342. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62343. * @param name defines the name of the mesh
  62344. * @param options defines the options used to create the mesh
  62345. * @param scene defines the hosting scene
  62346. * @param earcutInjection can be used to inject your own earcut reference
  62347. * @returns the polygon mesh
  62348. */
  62349. static ExtrudePolygon(name: string, options: {
  62350. shape: Vector3[];
  62351. holes?: Vector3[][];
  62352. depth?: number;
  62353. faceUV?: Vector4[];
  62354. faceColors?: Color4[];
  62355. updatable?: boolean;
  62356. sideOrientation?: number;
  62357. frontUVs?: Vector4;
  62358. backUVs?: Vector4;
  62359. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62360. /**
  62361. * Creates a tube mesh.
  62362. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62363. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62364. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62365. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62366. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62367. * * 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)
  62368. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62369. * * 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
  62370. * * 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
  62371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62372. * * 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
  62373. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62375. * @param name defines the name of the mesh
  62376. * @param options defines the options used to create the mesh
  62377. * @param scene defines the hosting scene
  62378. * @returns the tube mesh
  62379. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62380. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62381. */
  62382. static CreateTube(name: string, options: {
  62383. path: Vector3[];
  62384. radius?: number;
  62385. tessellation?: number;
  62386. radiusFunction?: {
  62387. (i: number, distance: number): number;
  62388. };
  62389. cap?: number;
  62390. arc?: number;
  62391. updatable?: boolean;
  62392. sideOrientation?: number;
  62393. frontUVs?: Vector4;
  62394. backUVs?: Vector4;
  62395. instance?: Mesh;
  62396. invertUV?: boolean;
  62397. }, scene?: Nullable<Scene>): Mesh;
  62398. /**
  62399. * Creates a polyhedron mesh
  62400. * * 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
  62401. * * The parameter `size` (positive float, default 1) sets the polygon size
  62402. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62403. * * 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`
  62404. * * 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
  62405. * * 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)`)
  62406. * * 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
  62407. * * 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
  62408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62409. * * 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
  62410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62411. * @param name defines the name of the mesh
  62412. * @param options defines the options used to create the mesh
  62413. * @param scene defines the hosting scene
  62414. * @returns the polyhedron mesh
  62415. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62416. */
  62417. static CreatePolyhedron(name: string, options: {
  62418. type?: number;
  62419. size?: number;
  62420. sizeX?: number;
  62421. sizeY?: number;
  62422. sizeZ?: number;
  62423. custom?: any;
  62424. faceUV?: Vector4[];
  62425. faceColors?: Color4[];
  62426. flat?: boolean;
  62427. updatable?: boolean;
  62428. sideOrientation?: number;
  62429. frontUVs?: Vector4;
  62430. backUVs?: Vector4;
  62431. }, scene?: Nullable<Scene>): Mesh;
  62432. /**
  62433. * Creates a decal mesh.
  62434. * 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
  62435. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62436. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62437. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62438. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62439. * @param name defines the name of the mesh
  62440. * @param sourceMesh defines the mesh where the decal must be applied
  62441. * @param options defines the options used to create the mesh
  62442. * @param scene defines the hosting scene
  62443. * @returns the decal mesh
  62444. * @see https://doc.babylonjs.com/how_to/decals
  62445. */
  62446. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62447. position?: Vector3;
  62448. normal?: Vector3;
  62449. size?: Vector3;
  62450. angle?: number;
  62451. }): Mesh;
  62452. }
  62453. }
  62454. declare module BABYLON {
  62455. /**
  62456. * A simplifier interface for future simplification implementations
  62457. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62458. */
  62459. export interface ISimplifier {
  62460. /**
  62461. * Simplification of a given mesh according to the given settings.
  62462. * Since this requires computation, it is assumed that the function runs async.
  62463. * @param settings The settings of the simplification, including quality and distance
  62464. * @param successCallback A callback that will be called after the mesh was simplified.
  62465. * @param errorCallback in case of an error, this callback will be called. optional.
  62466. */
  62467. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62468. }
  62469. /**
  62470. * Expected simplification settings.
  62471. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62472. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62473. */
  62474. export interface ISimplificationSettings {
  62475. /**
  62476. * Gets or sets the expected quality
  62477. */
  62478. quality: number;
  62479. /**
  62480. * Gets or sets the distance when this optimized version should be used
  62481. */
  62482. distance: number;
  62483. /**
  62484. * Gets an already optimized mesh
  62485. */
  62486. optimizeMesh?: boolean;
  62487. }
  62488. /**
  62489. * Class used to specify simplification options
  62490. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62491. */
  62492. export class SimplificationSettings implements ISimplificationSettings {
  62493. /** expected quality */
  62494. quality: number;
  62495. /** distance when this optimized version should be used */
  62496. distance: number;
  62497. /** already optimized mesh */
  62498. optimizeMesh?: boolean | undefined;
  62499. /**
  62500. * Creates a SimplificationSettings
  62501. * @param quality expected quality
  62502. * @param distance distance when this optimized version should be used
  62503. * @param optimizeMesh already optimized mesh
  62504. */
  62505. constructor(
  62506. /** expected quality */
  62507. quality: number,
  62508. /** distance when this optimized version should be used */
  62509. distance: number,
  62510. /** already optimized mesh */
  62511. optimizeMesh?: boolean | undefined);
  62512. }
  62513. /**
  62514. * Interface used to define a simplification task
  62515. */
  62516. export interface ISimplificationTask {
  62517. /**
  62518. * Array of settings
  62519. */
  62520. settings: Array<ISimplificationSettings>;
  62521. /**
  62522. * Simplification type
  62523. */
  62524. simplificationType: SimplificationType;
  62525. /**
  62526. * Mesh to simplify
  62527. */
  62528. mesh: Mesh;
  62529. /**
  62530. * Callback called on success
  62531. */
  62532. successCallback?: () => void;
  62533. /**
  62534. * Defines if parallel processing can be used
  62535. */
  62536. parallelProcessing: boolean;
  62537. }
  62538. /**
  62539. * Queue used to order the simplification tasks
  62540. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62541. */
  62542. export class SimplificationQueue {
  62543. private _simplificationArray;
  62544. /**
  62545. * Gets a boolean indicating that the process is still running
  62546. */
  62547. running: boolean;
  62548. /**
  62549. * Creates a new queue
  62550. */
  62551. constructor();
  62552. /**
  62553. * Adds a new simplification task
  62554. * @param task defines a task to add
  62555. */
  62556. addTask(task: ISimplificationTask): void;
  62557. /**
  62558. * Execute next task
  62559. */
  62560. executeNext(): void;
  62561. /**
  62562. * Execute a simplification task
  62563. * @param task defines the task to run
  62564. */
  62565. runSimplification(task: ISimplificationTask): void;
  62566. private getSimplifier;
  62567. }
  62568. /**
  62569. * The implemented types of simplification
  62570. * At the moment only Quadratic Error Decimation is implemented
  62571. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62572. */
  62573. export enum SimplificationType {
  62574. /** Quadratic error decimation */
  62575. QUADRATIC = 0
  62576. }
  62577. /**
  62578. * An implementation of the Quadratic Error simplification algorithm.
  62579. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62580. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62581. * @author RaananW
  62582. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62583. */
  62584. export class QuadraticErrorSimplification implements ISimplifier {
  62585. private _mesh;
  62586. private triangles;
  62587. private vertices;
  62588. private references;
  62589. private _reconstructedMesh;
  62590. /** Gets or sets the number pf sync interations */
  62591. syncIterations: number;
  62592. /** Gets or sets the aggressiveness of the simplifier */
  62593. aggressiveness: number;
  62594. /** Gets or sets the number of allowed iterations for decimation */
  62595. decimationIterations: number;
  62596. /** Gets or sets the espilon to use for bounding box computation */
  62597. boundingBoxEpsilon: number;
  62598. /**
  62599. * Creates a new QuadraticErrorSimplification
  62600. * @param _mesh defines the target mesh
  62601. */
  62602. constructor(_mesh: Mesh);
  62603. /**
  62604. * Simplification of a given mesh according to the given settings.
  62605. * Since this requires computation, it is assumed that the function runs async.
  62606. * @param settings The settings of the simplification, including quality and distance
  62607. * @param successCallback A callback that will be called after the mesh was simplified.
  62608. */
  62609. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62610. private runDecimation;
  62611. private initWithMesh;
  62612. private init;
  62613. private reconstructMesh;
  62614. private initDecimatedMesh;
  62615. private isFlipped;
  62616. private updateTriangles;
  62617. private identifyBorder;
  62618. private updateMesh;
  62619. private vertexError;
  62620. private calculateError;
  62621. }
  62622. }
  62623. declare module BABYLON {
  62624. interface Scene {
  62625. /** @hidden (Backing field) */
  62626. _simplificationQueue: SimplificationQueue;
  62627. /**
  62628. * Gets or sets the simplification queue attached to the scene
  62629. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62630. */
  62631. simplificationQueue: SimplificationQueue;
  62632. }
  62633. interface Mesh {
  62634. /**
  62635. * Simplify the mesh according to the given array of settings.
  62636. * Function will return immediately and will simplify async
  62637. * @param settings a collection of simplification settings
  62638. * @param parallelProcessing should all levels calculate parallel or one after the other
  62639. * @param simplificationType the type of simplification to run
  62640. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62641. * @returns the current mesh
  62642. */
  62643. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62644. }
  62645. /**
  62646. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62647. * created in a scene
  62648. */
  62649. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62650. /**
  62651. * The component name helpfull to identify the component in the list of scene components.
  62652. */
  62653. readonly name: string;
  62654. /**
  62655. * The scene the component belongs to.
  62656. */
  62657. scene: Scene;
  62658. /**
  62659. * Creates a new instance of the component for the given scene
  62660. * @param scene Defines the scene to register the component in
  62661. */
  62662. constructor(scene: Scene);
  62663. /**
  62664. * Registers the component in a given scene
  62665. */
  62666. register(): void;
  62667. /**
  62668. * Rebuilds the elements related to this component in case of
  62669. * context lost for instance.
  62670. */
  62671. rebuild(): void;
  62672. /**
  62673. * Disposes the component and the associated ressources
  62674. */
  62675. dispose(): void;
  62676. private _beforeCameraUpdate;
  62677. }
  62678. }
  62679. declare module BABYLON {
  62680. /**
  62681. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62682. */
  62683. export interface INavigationEnginePlugin {
  62684. /**
  62685. * plugin name
  62686. */
  62687. name: string;
  62688. /**
  62689. * Creates a navigation mesh
  62690. * @param meshes array of all the geometry used to compute the navigatio mesh
  62691. * @param parameters bunch of parameters used to filter geometry
  62692. */
  62693. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62694. /**
  62695. * Create a navigation mesh debug mesh
  62696. * @param scene is where the mesh will be added
  62697. * @returns debug display mesh
  62698. */
  62699. createDebugNavMesh(scene: Scene): Mesh;
  62700. /**
  62701. * Get a navigation mesh constrained position, closest to the parameter position
  62702. * @param position world position
  62703. * @returns the closest point to position constrained by the navigation mesh
  62704. */
  62705. getClosestPoint(position: Vector3): Vector3;
  62706. /**
  62707. * Get a navigation mesh constrained position, closest to the parameter position
  62708. * @param position world position
  62709. * @param result output the closest point to position constrained by the navigation mesh
  62710. */
  62711. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62712. /**
  62713. * Get a navigation mesh constrained position, within a particular radius
  62714. * @param position world position
  62715. * @param maxRadius the maximum distance to the constrained world position
  62716. * @returns the closest point to position constrained by the navigation mesh
  62717. */
  62718. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62719. /**
  62720. * Get a navigation mesh constrained position, within a particular radius
  62721. * @param position world position
  62722. * @param maxRadius the maximum distance to the constrained world position
  62723. * @param result output the closest point to position constrained by the navigation mesh
  62724. */
  62725. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62726. /**
  62727. * Compute the final position from a segment made of destination-position
  62728. * @param position world position
  62729. * @param destination world position
  62730. * @returns the resulting point along the navmesh
  62731. */
  62732. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62733. /**
  62734. * Compute the final position from a segment made of destination-position
  62735. * @param position world position
  62736. * @param destination world position
  62737. * @param result output the resulting point along the navmesh
  62738. */
  62739. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62740. /**
  62741. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62742. * @param start world position
  62743. * @param end world position
  62744. * @returns array containing world position composing the path
  62745. */
  62746. computePath(start: Vector3, end: Vector3): Vector3[];
  62747. /**
  62748. * If this plugin is supported
  62749. * @returns true if plugin is supported
  62750. */
  62751. isSupported(): boolean;
  62752. /**
  62753. * Create a new Crowd so you can add agents
  62754. * @param maxAgents the maximum agent count in the crowd
  62755. * @param maxAgentRadius the maximum radius an agent can have
  62756. * @param scene to attach the crowd to
  62757. * @returns the crowd you can add agents to
  62758. */
  62759. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62760. /**
  62761. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62762. * The queries will try to find a solution within those bounds
  62763. * default is (1,1,1)
  62764. * @param extent x,y,z value that define the extent around the queries point of reference
  62765. */
  62766. setDefaultQueryExtent(extent: Vector3): void;
  62767. /**
  62768. * Get the Bounding box extent specified by setDefaultQueryExtent
  62769. * @returns the box extent values
  62770. */
  62771. getDefaultQueryExtent(): Vector3;
  62772. /**
  62773. * build the navmesh from a previously saved state using getNavmeshData
  62774. * @param data the Uint8Array returned by getNavmeshData
  62775. */
  62776. buildFromNavmeshData(data: Uint8Array): void;
  62777. /**
  62778. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62779. * @returns data the Uint8Array that can be saved and reused
  62780. */
  62781. getNavmeshData(): Uint8Array;
  62782. /**
  62783. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62784. * @param result output the box extent values
  62785. */
  62786. getDefaultQueryExtentToRef(result: Vector3): void;
  62787. /**
  62788. * Release all resources
  62789. */
  62790. dispose(): void;
  62791. }
  62792. /**
  62793. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62794. */
  62795. export interface ICrowd {
  62796. /**
  62797. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62798. * You can attach anything to that node. The node position is updated in the scene update tick.
  62799. * @param pos world position that will be constrained by the navigation mesh
  62800. * @param parameters agent parameters
  62801. * @param transform hooked to the agent that will be update by the scene
  62802. * @returns agent index
  62803. */
  62804. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62805. /**
  62806. * Returns the agent position in world space
  62807. * @param index agent index returned by addAgent
  62808. * @returns world space position
  62809. */
  62810. getAgentPosition(index: number): Vector3;
  62811. /**
  62812. * Gets the agent position result in world space
  62813. * @param index agent index returned by addAgent
  62814. * @param result output world space position
  62815. */
  62816. getAgentPositionToRef(index: number, result: Vector3): void;
  62817. /**
  62818. * Gets the agent velocity in world space
  62819. * @param index agent index returned by addAgent
  62820. * @returns world space velocity
  62821. */
  62822. getAgentVelocity(index: number): Vector3;
  62823. /**
  62824. * Gets the agent velocity result in world space
  62825. * @param index agent index returned by addAgent
  62826. * @param result output world space velocity
  62827. */
  62828. getAgentVelocityToRef(index: number, result: Vector3): void;
  62829. /**
  62830. * remove a particular agent previously created
  62831. * @param index agent index returned by addAgent
  62832. */
  62833. removeAgent(index: number): void;
  62834. /**
  62835. * get the list of all agents attached to this crowd
  62836. * @returns list of agent indices
  62837. */
  62838. getAgents(): number[];
  62839. /**
  62840. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62841. * @param deltaTime in seconds
  62842. */
  62843. update(deltaTime: number): void;
  62844. /**
  62845. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62846. * @param index agent index returned by addAgent
  62847. * @param destination targeted world position
  62848. */
  62849. agentGoto(index: number, destination: Vector3): void;
  62850. /**
  62851. * Teleport the agent to a new position
  62852. * @param index agent index returned by addAgent
  62853. * @param destination targeted world position
  62854. */
  62855. agentTeleport(index: number, destination: Vector3): void;
  62856. /**
  62857. * Update agent parameters
  62858. * @param index agent index returned by addAgent
  62859. * @param parameters agent parameters
  62860. */
  62861. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62862. /**
  62863. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62864. * The queries will try to find a solution within those bounds
  62865. * default is (1,1,1)
  62866. * @param extent x,y,z value that define the extent around the queries point of reference
  62867. */
  62868. setDefaultQueryExtent(extent: Vector3): void;
  62869. /**
  62870. * Get the Bounding box extent specified by setDefaultQueryExtent
  62871. * @returns the box extent values
  62872. */
  62873. getDefaultQueryExtent(): Vector3;
  62874. /**
  62875. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62876. * @param result output the box extent values
  62877. */
  62878. getDefaultQueryExtentToRef(result: Vector3): void;
  62879. /**
  62880. * Release all resources
  62881. */
  62882. dispose(): void;
  62883. }
  62884. /**
  62885. * Configures an agent
  62886. */
  62887. export interface IAgentParameters {
  62888. /**
  62889. * Agent radius. [Limit: >= 0]
  62890. */
  62891. radius: number;
  62892. /**
  62893. * Agent height. [Limit: > 0]
  62894. */
  62895. height: number;
  62896. /**
  62897. * Maximum allowed acceleration. [Limit: >= 0]
  62898. */
  62899. maxAcceleration: number;
  62900. /**
  62901. * Maximum allowed speed. [Limit: >= 0]
  62902. */
  62903. maxSpeed: number;
  62904. /**
  62905. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62906. */
  62907. collisionQueryRange: number;
  62908. /**
  62909. * The path visibility optimization range. [Limit: > 0]
  62910. */
  62911. pathOptimizationRange: number;
  62912. /**
  62913. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62914. */
  62915. separationWeight: number;
  62916. }
  62917. /**
  62918. * Configures the navigation mesh creation
  62919. */
  62920. export interface INavMeshParameters {
  62921. /**
  62922. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62923. */
  62924. cs: number;
  62925. /**
  62926. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62927. */
  62928. ch: number;
  62929. /**
  62930. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62931. */
  62932. walkableSlopeAngle: number;
  62933. /**
  62934. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62935. * be considered walkable. [Limit: >= 3] [Units: vx]
  62936. */
  62937. walkableHeight: number;
  62938. /**
  62939. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62940. */
  62941. walkableClimb: number;
  62942. /**
  62943. * The distance to erode/shrink the walkable area of the heightfield away from
  62944. * obstructions. [Limit: >=0] [Units: vx]
  62945. */
  62946. walkableRadius: number;
  62947. /**
  62948. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62949. */
  62950. maxEdgeLen: number;
  62951. /**
  62952. * The maximum distance a simplfied contour's border edges should deviate
  62953. * the original raw contour. [Limit: >=0] [Units: vx]
  62954. */
  62955. maxSimplificationError: number;
  62956. /**
  62957. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62958. */
  62959. minRegionArea: number;
  62960. /**
  62961. * Any regions with a span count smaller than this value will, if possible,
  62962. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62963. */
  62964. mergeRegionArea: number;
  62965. /**
  62966. * The maximum number of vertices allowed for polygons generated during the
  62967. * contour to polygon conversion process. [Limit: >= 3]
  62968. */
  62969. maxVertsPerPoly: number;
  62970. /**
  62971. * Sets the sampling distance to use when generating the detail mesh.
  62972. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62973. */
  62974. detailSampleDist: number;
  62975. /**
  62976. * The maximum distance the detail mesh surface should deviate from heightfield
  62977. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62978. */
  62979. detailSampleMaxError: number;
  62980. }
  62981. }
  62982. declare module BABYLON {
  62983. /**
  62984. * RecastJS navigation plugin
  62985. */
  62986. export class RecastJSPlugin implements INavigationEnginePlugin {
  62987. /**
  62988. * Reference to the Recast library
  62989. */
  62990. bjsRECAST: any;
  62991. /**
  62992. * plugin name
  62993. */
  62994. name: string;
  62995. /**
  62996. * the first navmesh created. We might extend this to support multiple navmeshes
  62997. */
  62998. navMesh: any;
  62999. /**
  63000. * Initializes the recastJS plugin
  63001. * @param recastInjection can be used to inject your own recast reference
  63002. */
  63003. constructor(recastInjection?: any);
  63004. /**
  63005. * Creates a navigation mesh
  63006. * @param meshes array of all the geometry used to compute the navigatio mesh
  63007. * @param parameters bunch of parameters used to filter geometry
  63008. */
  63009. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63010. /**
  63011. * Create a navigation mesh debug mesh
  63012. * @param scene is where the mesh will be added
  63013. * @returns debug display mesh
  63014. */
  63015. createDebugNavMesh(scene: Scene): Mesh;
  63016. /**
  63017. * Get a navigation mesh constrained position, closest to the parameter position
  63018. * @param position world position
  63019. * @returns the closest point to position constrained by the navigation mesh
  63020. */
  63021. getClosestPoint(position: Vector3): Vector3;
  63022. /**
  63023. * Get a navigation mesh constrained position, closest to the parameter position
  63024. * @param position world position
  63025. * @param result output the closest point to position constrained by the navigation mesh
  63026. */
  63027. getClosestPointToRef(position: Vector3, result: Vector3): void;
  63028. /**
  63029. * Get a navigation mesh constrained position, within a particular radius
  63030. * @param position world position
  63031. * @param maxRadius the maximum distance to the constrained world position
  63032. * @returns the closest point to position constrained by the navigation mesh
  63033. */
  63034. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63035. /**
  63036. * Get a navigation mesh constrained position, within a particular radius
  63037. * @param position world position
  63038. * @param maxRadius the maximum distance to the constrained world position
  63039. * @param result output the closest point to position constrained by the navigation mesh
  63040. */
  63041. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  63042. /**
  63043. * Compute the final position from a segment made of destination-position
  63044. * @param position world position
  63045. * @param destination world position
  63046. * @returns the resulting point along the navmesh
  63047. */
  63048. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63049. /**
  63050. * Compute the final position from a segment made of destination-position
  63051. * @param position world position
  63052. * @param destination world position
  63053. * @param result output the resulting point along the navmesh
  63054. */
  63055. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  63056. /**
  63057. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63058. * @param start world position
  63059. * @param end world position
  63060. * @returns array containing world position composing the path
  63061. */
  63062. computePath(start: Vector3, end: Vector3): Vector3[];
  63063. /**
  63064. * Create a new Crowd so you can add agents
  63065. * @param maxAgents the maximum agent count in the crowd
  63066. * @param maxAgentRadius the maximum radius an agent can have
  63067. * @param scene to attach the crowd to
  63068. * @returns the crowd you can add agents to
  63069. */
  63070. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63071. /**
  63072. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63073. * The queries will try to find a solution within those bounds
  63074. * default is (1,1,1)
  63075. * @param extent x,y,z value that define the extent around the queries point of reference
  63076. */
  63077. setDefaultQueryExtent(extent: Vector3): void;
  63078. /**
  63079. * Get the Bounding box extent specified by setDefaultQueryExtent
  63080. * @returns the box extent values
  63081. */
  63082. getDefaultQueryExtent(): Vector3;
  63083. /**
  63084. * build the navmesh from a previously saved state using getNavmeshData
  63085. * @param data the Uint8Array returned by getNavmeshData
  63086. */
  63087. buildFromNavmeshData(data: Uint8Array): void;
  63088. /**
  63089. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  63090. * @returns data the Uint8Array that can be saved and reused
  63091. */
  63092. getNavmeshData(): Uint8Array;
  63093. /**
  63094. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63095. * @param result output the box extent values
  63096. */
  63097. getDefaultQueryExtentToRef(result: Vector3): void;
  63098. /**
  63099. * Disposes
  63100. */
  63101. dispose(): void;
  63102. /**
  63103. * If this plugin is supported
  63104. * @returns true if plugin is supported
  63105. */
  63106. isSupported(): boolean;
  63107. }
  63108. /**
  63109. * Recast detour crowd implementation
  63110. */
  63111. export class RecastJSCrowd implements ICrowd {
  63112. /**
  63113. * Recast/detour plugin
  63114. */
  63115. bjsRECASTPlugin: RecastJSPlugin;
  63116. /**
  63117. * Link to the detour crowd
  63118. */
  63119. recastCrowd: any;
  63120. /**
  63121. * One transform per agent
  63122. */
  63123. transforms: TransformNode[];
  63124. /**
  63125. * All agents created
  63126. */
  63127. agents: number[];
  63128. /**
  63129. * Link to the scene is kept to unregister the crowd from the scene
  63130. */
  63131. private _scene;
  63132. /**
  63133. * Observer for crowd updates
  63134. */
  63135. private _onBeforeAnimationsObserver;
  63136. /**
  63137. * Constructor
  63138. * @param plugin recastJS plugin
  63139. * @param maxAgents the maximum agent count in the crowd
  63140. * @param maxAgentRadius the maximum radius an agent can have
  63141. * @param scene to attach the crowd to
  63142. * @returns the crowd you can add agents to
  63143. */
  63144. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63145. /**
  63146. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63147. * You can attach anything to that node. The node position is updated in the scene update tick.
  63148. * @param pos world position that will be constrained by the navigation mesh
  63149. * @param parameters agent parameters
  63150. * @param transform hooked to the agent that will be update by the scene
  63151. * @returns agent index
  63152. */
  63153. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63154. /**
  63155. * Returns the agent position in world space
  63156. * @param index agent index returned by addAgent
  63157. * @returns world space position
  63158. */
  63159. getAgentPosition(index: number): Vector3;
  63160. /**
  63161. * Returns the agent position result in world space
  63162. * @param index agent index returned by addAgent
  63163. * @param result output world space position
  63164. */
  63165. getAgentPositionToRef(index: number, result: Vector3): void;
  63166. /**
  63167. * Returns the agent velocity in world space
  63168. * @param index agent index returned by addAgent
  63169. * @returns world space velocity
  63170. */
  63171. getAgentVelocity(index: number): Vector3;
  63172. /**
  63173. * Returns the agent velocity result in world space
  63174. * @param index agent index returned by addAgent
  63175. * @param result output world space velocity
  63176. */
  63177. getAgentVelocityToRef(index: number, result: Vector3): void;
  63178. /**
  63179. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63180. * @param index agent index returned by addAgent
  63181. * @param destination targeted world position
  63182. */
  63183. agentGoto(index: number, destination: Vector3): void;
  63184. /**
  63185. * Teleport the agent to a new position
  63186. * @param index agent index returned by addAgent
  63187. * @param destination targeted world position
  63188. */
  63189. agentTeleport(index: number, destination: Vector3): void;
  63190. /**
  63191. * Update agent parameters
  63192. * @param index agent index returned by addAgent
  63193. * @param parameters agent parameters
  63194. */
  63195. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  63196. /**
  63197. * remove a particular agent previously created
  63198. * @param index agent index returned by addAgent
  63199. */
  63200. removeAgent(index: number): void;
  63201. /**
  63202. * get the list of all agents attached to this crowd
  63203. * @returns list of agent indices
  63204. */
  63205. getAgents(): number[];
  63206. /**
  63207. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63208. * @param deltaTime in seconds
  63209. */
  63210. update(deltaTime: number): void;
  63211. /**
  63212. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63213. * The queries will try to find a solution within those bounds
  63214. * default is (1,1,1)
  63215. * @param extent x,y,z value that define the extent around the queries point of reference
  63216. */
  63217. setDefaultQueryExtent(extent: Vector3): void;
  63218. /**
  63219. * Get the Bounding box extent specified by setDefaultQueryExtent
  63220. * @returns the box extent values
  63221. */
  63222. getDefaultQueryExtent(): Vector3;
  63223. /**
  63224. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63225. * @param result output the box extent values
  63226. */
  63227. getDefaultQueryExtentToRef(result: Vector3): void;
  63228. /**
  63229. * Release all resources
  63230. */
  63231. dispose(): void;
  63232. }
  63233. }
  63234. declare module BABYLON {
  63235. /**
  63236. * Class used to enable access to IndexedDB
  63237. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63238. */
  63239. export class Database implements IOfflineProvider {
  63240. private _callbackManifestChecked;
  63241. private _currentSceneUrl;
  63242. private _db;
  63243. private _enableSceneOffline;
  63244. private _enableTexturesOffline;
  63245. private _manifestVersionFound;
  63246. private _mustUpdateRessources;
  63247. private _hasReachedQuota;
  63248. private _isSupported;
  63249. private _idbFactory;
  63250. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63251. private static IsUASupportingBlobStorage;
  63252. /**
  63253. * Gets a boolean indicating if Database storate is enabled (off by default)
  63254. */
  63255. static IDBStorageEnabled: boolean;
  63256. /**
  63257. * Gets a boolean indicating if scene must be saved in the database
  63258. */
  63259. get enableSceneOffline(): boolean;
  63260. /**
  63261. * Gets a boolean indicating if textures must be saved in the database
  63262. */
  63263. get enableTexturesOffline(): boolean;
  63264. /**
  63265. * Creates a new Database
  63266. * @param urlToScene defines the url to load the scene
  63267. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63268. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63269. */
  63270. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63271. private static _ParseURL;
  63272. private static _ReturnFullUrlLocation;
  63273. private _checkManifestFile;
  63274. /**
  63275. * Open the database and make it available
  63276. * @param successCallback defines the callback to call on success
  63277. * @param errorCallback defines the callback to call on error
  63278. */
  63279. open(successCallback: () => void, errorCallback: () => void): void;
  63280. /**
  63281. * Loads an image from the database
  63282. * @param url defines the url to load from
  63283. * @param image defines the target DOM image
  63284. */
  63285. loadImage(url: string, image: HTMLImageElement): void;
  63286. private _loadImageFromDBAsync;
  63287. private _saveImageIntoDBAsync;
  63288. private _checkVersionFromDB;
  63289. private _loadVersionFromDBAsync;
  63290. private _saveVersionIntoDBAsync;
  63291. /**
  63292. * Loads a file from database
  63293. * @param url defines the URL to load from
  63294. * @param sceneLoaded defines a callback to call on success
  63295. * @param progressCallBack defines a callback to call when progress changed
  63296. * @param errorCallback defines a callback to call on error
  63297. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63298. */
  63299. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63300. private _loadFileAsync;
  63301. private _saveFileAsync;
  63302. /**
  63303. * Validates if xhr data is correct
  63304. * @param xhr defines the request to validate
  63305. * @param dataType defines the expected data type
  63306. * @returns true if data is correct
  63307. */
  63308. private static _ValidateXHRData;
  63309. }
  63310. }
  63311. declare module BABYLON {
  63312. /** @hidden */
  63313. export var gpuUpdateParticlesPixelShader: {
  63314. name: string;
  63315. shader: string;
  63316. };
  63317. }
  63318. declare module BABYLON {
  63319. /** @hidden */
  63320. export var gpuUpdateParticlesVertexShader: {
  63321. name: string;
  63322. shader: string;
  63323. };
  63324. }
  63325. declare module BABYLON {
  63326. /** @hidden */
  63327. export var clipPlaneFragmentDeclaration2: {
  63328. name: string;
  63329. shader: string;
  63330. };
  63331. }
  63332. declare module BABYLON {
  63333. /** @hidden */
  63334. export var gpuRenderParticlesPixelShader: {
  63335. name: string;
  63336. shader: string;
  63337. };
  63338. }
  63339. declare module BABYLON {
  63340. /** @hidden */
  63341. export var clipPlaneVertexDeclaration2: {
  63342. name: string;
  63343. shader: string;
  63344. };
  63345. }
  63346. declare module BABYLON {
  63347. /** @hidden */
  63348. export var gpuRenderParticlesVertexShader: {
  63349. name: string;
  63350. shader: string;
  63351. };
  63352. }
  63353. declare module BABYLON {
  63354. /**
  63355. * This represents a GPU particle system in Babylon
  63356. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63357. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63358. */
  63359. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63360. /**
  63361. * The layer mask we are rendering the particles through.
  63362. */
  63363. layerMask: number;
  63364. private _capacity;
  63365. private _activeCount;
  63366. private _currentActiveCount;
  63367. private _accumulatedCount;
  63368. private _renderEffect;
  63369. private _updateEffect;
  63370. private _buffer0;
  63371. private _buffer1;
  63372. private _spriteBuffer;
  63373. private _updateVAO;
  63374. private _renderVAO;
  63375. private _targetIndex;
  63376. private _sourceBuffer;
  63377. private _targetBuffer;
  63378. private _engine;
  63379. private _currentRenderId;
  63380. private _started;
  63381. private _stopped;
  63382. private _timeDelta;
  63383. private _randomTexture;
  63384. private _randomTexture2;
  63385. private _attributesStrideSize;
  63386. private _updateEffectOptions;
  63387. private _randomTextureSize;
  63388. private _actualFrame;
  63389. private readonly _rawTextureWidth;
  63390. /**
  63391. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63392. */
  63393. static get IsSupported(): boolean;
  63394. /**
  63395. * An event triggered when the system is disposed.
  63396. */
  63397. onDisposeObservable: Observable<GPUParticleSystem>;
  63398. /**
  63399. * Gets the maximum number of particles active at the same time.
  63400. * @returns The max number of active particles.
  63401. */
  63402. getCapacity(): number;
  63403. /**
  63404. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63405. * to override the particles.
  63406. */
  63407. forceDepthWrite: boolean;
  63408. /**
  63409. * Gets or set the number of active particles
  63410. */
  63411. get activeParticleCount(): number;
  63412. set activeParticleCount(value: number);
  63413. private _preWarmDone;
  63414. /**
  63415. * Specifies if the particles are updated in emitter local space or world space.
  63416. */
  63417. isLocal: boolean;
  63418. /**
  63419. * Is this system ready to be used/rendered
  63420. * @return true if the system is ready
  63421. */
  63422. isReady(): boolean;
  63423. /**
  63424. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63425. * @returns True if it has been started, otherwise false.
  63426. */
  63427. isStarted(): boolean;
  63428. /**
  63429. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63430. * @returns True if it has been stopped, otherwise false.
  63431. */
  63432. isStopped(): boolean;
  63433. /**
  63434. * Gets a boolean indicating that the system is stopping
  63435. * @returns true if the system is currently stopping
  63436. */
  63437. isStopping(): boolean;
  63438. /**
  63439. * Gets the number of particles active at the same time.
  63440. * @returns The number of active particles.
  63441. */
  63442. getActiveCount(): number;
  63443. /**
  63444. * Starts the particle system and begins to emit
  63445. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63446. */
  63447. start(delay?: number): void;
  63448. /**
  63449. * Stops the particle system.
  63450. */
  63451. stop(): void;
  63452. /**
  63453. * Remove all active particles
  63454. */
  63455. reset(): void;
  63456. /**
  63457. * Returns the string "GPUParticleSystem"
  63458. * @returns a string containing the class name
  63459. */
  63460. getClassName(): string;
  63461. private _colorGradientsTexture;
  63462. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63463. /**
  63464. * Adds a new color gradient
  63465. * @param gradient defines the gradient to use (between 0 and 1)
  63466. * @param color1 defines the color to affect to the specified gradient
  63467. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63468. * @returns the current particle system
  63469. */
  63470. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63471. private _refreshColorGradient;
  63472. /** Force the system to rebuild all gradients that need to be resync */
  63473. forceRefreshGradients(): void;
  63474. /**
  63475. * Remove a specific color gradient
  63476. * @param gradient defines the gradient to remove
  63477. * @returns the current particle system
  63478. */
  63479. removeColorGradient(gradient: number): GPUParticleSystem;
  63480. private _angularSpeedGradientsTexture;
  63481. private _sizeGradientsTexture;
  63482. private _velocityGradientsTexture;
  63483. private _limitVelocityGradientsTexture;
  63484. private _dragGradientsTexture;
  63485. private _addFactorGradient;
  63486. /**
  63487. * Adds a new size gradient
  63488. * @param gradient defines the gradient to use (between 0 and 1)
  63489. * @param factor defines the size factor to affect to the specified gradient
  63490. * @returns the current particle system
  63491. */
  63492. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63493. /**
  63494. * Remove a specific size gradient
  63495. * @param gradient defines the gradient to remove
  63496. * @returns the current particle system
  63497. */
  63498. removeSizeGradient(gradient: number): GPUParticleSystem;
  63499. private _refreshFactorGradient;
  63500. /**
  63501. * Adds a new angular speed gradient
  63502. * @param gradient defines the gradient to use (between 0 and 1)
  63503. * @param factor defines the angular speed to affect to the specified gradient
  63504. * @returns the current particle system
  63505. */
  63506. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63507. /**
  63508. * Remove a specific angular speed gradient
  63509. * @param gradient defines the gradient to remove
  63510. * @returns the current particle system
  63511. */
  63512. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63513. /**
  63514. * Adds a new velocity gradient
  63515. * @param gradient defines the gradient to use (between 0 and 1)
  63516. * @param factor defines the velocity to affect to the specified gradient
  63517. * @returns the current particle system
  63518. */
  63519. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63520. /**
  63521. * Remove a specific velocity gradient
  63522. * @param gradient defines the gradient to remove
  63523. * @returns the current particle system
  63524. */
  63525. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63526. /**
  63527. * Adds a new limit velocity gradient
  63528. * @param gradient defines the gradient to use (between 0 and 1)
  63529. * @param factor defines the limit velocity value to affect to the specified gradient
  63530. * @returns the current particle system
  63531. */
  63532. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63533. /**
  63534. * Remove a specific limit velocity gradient
  63535. * @param gradient defines the gradient to remove
  63536. * @returns the current particle system
  63537. */
  63538. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63539. /**
  63540. * Adds a new drag gradient
  63541. * @param gradient defines the gradient to use (between 0 and 1)
  63542. * @param factor defines the drag value to affect to the specified gradient
  63543. * @returns the current particle system
  63544. */
  63545. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63546. /**
  63547. * Remove a specific drag gradient
  63548. * @param gradient defines the gradient to remove
  63549. * @returns the current particle system
  63550. */
  63551. removeDragGradient(gradient: number): GPUParticleSystem;
  63552. /**
  63553. * Not supported by GPUParticleSystem
  63554. * @param gradient defines the gradient to use (between 0 and 1)
  63555. * @param factor defines the emit rate value to affect to the specified gradient
  63556. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63557. * @returns the current particle system
  63558. */
  63559. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63560. /**
  63561. * Not supported by GPUParticleSystem
  63562. * @param gradient defines the gradient to remove
  63563. * @returns the current particle system
  63564. */
  63565. removeEmitRateGradient(gradient: number): IParticleSystem;
  63566. /**
  63567. * Not supported by GPUParticleSystem
  63568. * @param gradient defines the gradient to use (between 0 and 1)
  63569. * @param factor defines the start size value to affect to the specified gradient
  63570. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63571. * @returns the current particle system
  63572. */
  63573. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63574. /**
  63575. * Not supported by GPUParticleSystem
  63576. * @param gradient defines the gradient to remove
  63577. * @returns the current particle system
  63578. */
  63579. removeStartSizeGradient(gradient: number): IParticleSystem;
  63580. /**
  63581. * Not supported by GPUParticleSystem
  63582. * @param gradient defines the gradient to use (between 0 and 1)
  63583. * @param min defines the color remap minimal range
  63584. * @param max defines the color remap maximal range
  63585. * @returns the current particle system
  63586. */
  63587. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63588. /**
  63589. * Not supported by GPUParticleSystem
  63590. * @param gradient defines the gradient to remove
  63591. * @returns the current particle system
  63592. */
  63593. removeColorRemapGradient(): IParticleSystem;
  63594. /**
  63595. * Not supported by GPUParticleSystem
  63596. * @param gradient defines the gradient to use (between 0 and 1)
  63597. * @param min defines the alpha remap minimal range
  63598. * @param max defines the alpha remap maximal range
  63599. * @returns the current particle system
  63600. */
  63601. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63602. /**
  63603. * Not supported by GPUParticleSystem
  63604. * @param gradient defines the gradient to remove
  63605. * @returns the current particle system
  63606. */
  63607. removeAlphaRemapGradient(): IParticleSystem;
  63608. /**
  63609. * Not supported by GPUParticleSystem
  63610. * @param gradient defines the gradient to use (between 0 and 1)
  63611. * @param color defines the color to affect to the specified gradient
  63612. * @returns the current particle system
  63613. */
  63614. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63615. /**
  63616. * Not supported by GPUParticleSystem
  63617. * @param gradient defines the gradient to remove
  63618. * @returns the current particle system
  63619. */
  63620. removeRampGradient(): IParticleSystem;
  63621. /**
  63622. * Not supported by GPUParticleSystem
  63623. * @returns the list of ramp gradients
  63624. */
  63625. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63626. /**
  63627. * Not supported by GPUParticleSystem
  63628. * Gets or sets a boolean indicating that ramp gradients must be used
  63629. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63630. */
  63631. get useRampGradients(): boolean;
  63632. set useRampGradients(value: boolean);
  63633. /**
  63634. * Not supported by GPUParticleSystem
  63635. * @param gradient defines the gradient to use (between 0 and 1)
  63636. * @param factor defines the life time factor to affect to the specified gradient
  63637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63638. * @returns the current particle system
  63639. */
  63640. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63641. /**
  63642. * Not supported by GPUParticleSystem
  63643. * @param gradient defines the gradient to remove
  63644. * @returns the current particle system
  63645. */
  63646. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63647. /**
  63648. * Instantiates a GPU particle system.
  63649. * 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.
  63650. * @param name The name of the particle system
  63651. * @param options The options used to create the system
  63652. * @param scene The scene the particle system belongs to
  63653. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63654. */
  63655. constructor(name: string, options: Partial<{
  63656. capacity: number;
  63657. randomTextureSize: number;
  63658. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63659. protected _reset(): void;
  63660. private _createUpdateVAO;
  63661. private _createRenderVAO;
  63662. private _initialize;
  63663. /** @hidden */
  63664. _recreateUpdateEffect(): void;
  63665. /** @hidden */
  63666. _recreateRenderEffect(): void;
  63667. /**
  63668. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63669. * @param preWarm defines if we are in the pre-warmimg phase
  63670. */
  63671. animate(preWarm?: boolean): void;
  63672. private _createFactorGradientTexture;
  63673. private _createSizeGradientTexture;
  63674. private _createAngularSpeedGradientTexture;
  63675. private _createVelocityGradientTexture;
  63676. private _createLimitVelocityGradientTexture;
  63677. private _createDragGradientTexture;
  63678. private _createColorGradientTexture;
  63679. /**
  63680. * Renders the particle system in its current state
  63681. * @param preWarm defines if the system should only update the particles but not render them
  63682. * @returns the current number of particles
  63683. */
  63684. render(preWarm?: boolean): number;
  63685. /**
  63686. * Rebuilds the particle system
  63687. */
  63688. rebuild(): void;
  63689. private _releaseBuffers;
  63690. private _releaseVAOs;
  63691. /**
  63692. * Disposes the particle system and free the associated resources
  63693. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63694. */
  63695. dispose(disposeTexture?: boolean): void;
  63696. /**
  63697. * Clones the particle system.
  63698. * @param name The name of the cloned object
  63699. * @param newEmitter The new emitter to use
  63700. * @returns the cloned particle system
  63701. */
  63702. clone(name: string, newEmitter: any): GPUParticleSystem;
  63703. /**
  63704. * Serializes the particle system to a JSON object
  63705. * @param serializeTexture defines if the texture must be serialized as well
  63706. * @returns the JSON object
  63707. */
  63708. serialize(serializeTexture?: boolean): any;
  63709. /**
  63710. * Parses a JSON object to create a GPU particle system.
  63711. * @param parsedParticleSystem The JSON object to parse
  63712. * @param scene The scene to create the particle system in
  63713. * @param rootUrl The root url to use to load external dependencies like texture
  63714. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63715. * @returns the parsed GPU particle system
  63716. */
  63717. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63718. }
  63719. }
  63720. declare module BABYLON {
  63721. /**
  63722. * Represents a set of particle systems working together to create a specific effect
  63723. */
  63724. export class ParticleSystemSet implements IDisposable {
  63725. /**
  63726. * Gets or sets base Assets URL
  63727. */
  63728. static BaseAssetsUrl: string;
  63729. private _emitterCreationOptions;
  63730. private _emitterNode;
  63731. /**
  63732. * Gets the particle system list
  63733. */
  63734. systems: IParticleSystem[];
  63735. /**
  63736. * Gets the emitter node used with this set
  63737. */
  63738. get emitterNode(): Nullable<TransformNode>;
  63739. /**
  63740. * Creates a new emitter mesh as a sphere
  63741. * @param options defines the options used to create the sphere
  63742. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63743. * @param scene defines the hosting scene
  63744. */
  63745. setEmitterAsSphere(options: {
  63746. diameter: number;
  63747. segments: number;
  63748. color: Color3;
  63749. }, renderingGroupId: number, scene: Scene): void;
  63750. /**
  63751. * Starts all particle systems of the set
  63752. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63753. */
  63754. start(emitter?: AbstractMesh): void;
  63755. /**
  63756. * Release all associated resources
  63757. */
  63758. dispose(): void;
  63759. /**
  63760. * Serialize the set into a JSON compatible object
  63761. * @param serializeTexture defines if the texture must be serialized as well
  63762. * @returns a JSON compatible representation of the set
  63763. */
  63764. serialize(serializeTexture?: boolean): any;
  63765. /**
  63766. * Parse a new ParticleSystemSet from a serialized source
  63767. * @param data defines a JSON compatible representation of the set
  63768. * @param scene defines the hosting scene
  63769. * @param gpu defines if we want GPU particles or CPU particles
  63770. * @returns a new ParticleSystemSet
  63771. */
  63772. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63773. }
  63774. }
  63775. declare module BABYLON {
  63776. /**
  63777. * This class is made for on one-liner static method to help creating particle system set.
  63778. */
  63779. export class ParticleHelper {
  63780. /**
  63781. * Gets or sets base Assets URL
  63782. */
  63783. static BaseAssetsUrl: string;
  63784. /** Define the Url to load snippets */
  63785. static SnippetUrl: string;
  63786. /**
  63787. * Create a default particle system that you can tweak
  63788. * @param emitter defines the emitter to use
  63789. * @param capacity defines the system capacity (default is 500 particles)
  63790. * @param scene defines the hosting scene
  63791. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63792. * @returns the new Particle system
  63793. */
  63794. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63795. /**
  63796. * This is the main static method (one-liner) of this helper to create different particle systems
  63797. * @param type This string represents the type to the particle system to create
  63798. * @param scene The scene where the particle system should live
  63799. * @param gpu If the system will use gpu
  63800. * @returns the ParticleSystemSet created
  63801. */
  63802. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63803. /**
  63804. * Static function used to export a particle system to a ParticleSystemSet variable.
  63805. * Please note that the emitter shape is not exported
  63806. * @param systems defines the particle systems to export
  63807. * @returns the created particle system set
  63808. */
  63809. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63810. /**
  63811. * Creates a particle system from a snippet saved in a remote file
  63812. * @param name defines the name of the particle system to create
  63813. * @param url defines the url to load from
  63814. * @param scene defines the hosting scene
  63815. * @param gpu If the system will use gpu
  63816. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63817. * @returns a promise that will resolve to the new particle system
  63818. */
  63819. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63820. /**
  63821. * Creates a particle system from a snippet saved by the particle system editor
  63822. * @param snippetId defines the snippet to load
  63823. * @param scene defines the hosting scene
  63824. * @param gpu If the system will use gpu
  63825. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63826. * @returns a promise that will resolve to the new particle system
  63827. */
  63828. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63829. }
  63830. }
  63831. declare module BABYLON {
  63832. interface Engine {
  63833. /**
  63834. * Create an effect to use with particle systems.
  63835. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63836. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63837. * @param uniformsNames defines a list of attribute names
  63838. * @param samplers defines an array of string used to represent textures
  63839. * @param defines defines the string containing the defines to use to compile the shaders
  63840. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63841. * @param onCompiled defines a function to call when the effect creation is successful
  63842. * @param onError defines a function to call when the effect creation has failed
  63843. * @returns the new Effect
  63844. */
  63845. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63846. }
  63847. interface Mesh {
  63848. /**
  63849. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63850. * @returns an array of IParticleSystem
  63851. */
  63852. getEmittedParticleSystems(): IParticleSystem[];
  63853. /**
  63854. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63855. * @returns an array of IParticleSystem
  63856. */
  63857. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63858. }
  63859. /**
  63860. * @hidden
  63861. */
  63862. export var _IDoNeedToBeInTheBuild: number;
  63863. }
  63864. declare module BABYLON {
  63865. /** Defines the 4 color options */
  63866. export enum PointColor {
  63867. /** color value */
  63868. Color = 2,
  63869. /** uv value */
  63870. UV = 1,
  63871. /** random value */
  63872. Random = 0,
  63873. /** stated value */
  63874. Stated = 3
  63875. }
  63876. /**
  63877. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63878. * 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.
  63879. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63880. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63881. *
  63882. * Full documentation here : TO BE ENTERED
  63883. */
  63884. export class PointsCloudSystem implements IDisposable {
  63885. /**
  63886. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63887. * Example : var p = SPS.particles[i];
  63888. */
  63889. particles: CloudPoint[];
  63890. /**
  63891. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63892. */
  63893. nbParticles: number;
  63894. /**
  63895. * This a counter for your own usage. It's not set by any SPS functions.
  63896. */
  63897. counter: number;
  63898. /**
  63899. * The PCS name. This name is also given to the underlying mesh.
  63900. */
  63901. name: string;
  63902. /**
  63903. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63904. */
  63905. mesh: Mesh;
  63906. /**
  63907. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63908. * Please read :
  63909. */
  63910. vars: any;
  63911. /**
  63912. * @hidden
  63913. */
  63914. _size: number;
  63915. private _scene;
  63916. private _promises;
  63917. private _positions;
  63918. private _indices;
  63919. private _normals;
  63920. private _colors;
  63921. private _uvs;
  63922. private _indices32;
  63923. private _positions32;
  63924. private _colors32;
  63925. private _uvs32;
  63926. private _updatable;
  63927. private _isVisibilityBoxLocked;
  63928. private _alwaysVisible;
  63929. private _groups;
  63930. private _groupCounter;
  63931. private _computeParticleColor;
  63932. private _computeParticleTexture;
  63933. private _computeParticleRotation;
  63934. private _computeBoundingBox;
  63935. private _isReady;
  63936. /**
  63937. * Creates a PCS (Points Cloud System) object
  63938. * @param name (String) is the PCS name, this will be the underlying mesh name
  63939. * @param pointSize (number) is the size for each point
  63940. * @param scene (Scene) is the scene in which the PCS is added
  63941. * @param options defines the options of the PCS e.g.
  63942. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63943. */
  63944. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63945. updatable?: boolean;
  63946. });
  63947. /**
  63948. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63949. * If no points were added to the PCS, the returned mesh is just a single point.
  63950. * @returns a promise for the created mesh
  63951. */
  63952. buildMeshAsync(): Promise<Mesh>;
  63953. /**
  63954. * @hidden
  63955. */
  63956. private _buildMesh;
  63957. private _addParticle;
  63958. private _randomUnitVector;
  63959. private _getColorIndicesForCoord;
  63960. private _setPointsColorOrUV;
  63961. private _colorFromTexture;
  63962. private _calculateDensity;
  63963. /**
  63964. * Adds points to the PCS in random positions within a unit sphere
  63965. * @param nb (positive integer) the number of particles to be created from this model
  63966. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63967. * @returns the number of groups in the system
  63968. */
  63969. addPoints(nb: number, pointFunction?: any): number;
  63970. /**
  63971. * Adds points to the PCS from the surface of the model shape
  63972. * @param mesh is any Mesh object that will be used as a surface model for the points
  63973. * @param nb (positive integer) the number of particles to be created from this model
  63974. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63975. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63976. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63977. * @returns the number of groups in the system
  63978. */
  63979. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63980. /**
  63981. * Adds points to the PCS inside the model shape
  63982. * @param mesh is any Mesh object that will be used as a surface model for the points
  63983. * @param nb (positive integer) the number of particles to be created from this model
  63984. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63985. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63986. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63987. * @returns the number of groups in the system
  63988. */
  63989. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63990. /**
  63991. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63992. * This method calls `updateParticle()` for each particle of the SPS.
  63993. * For an animated SPS, it is usually called within the render loop.
  63994. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63995. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63996. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63997. * @returns the PCS.
  63998. */
  63999. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  64000. /**
  64001. * Disposes the PCS.
  64002. */
  64003. dispose(): void;
  64004. /**
  64005. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  64006. * doc :
  64007. * @returns the PCS.
  64008. */
  64009. refreshVisibleSize(): PointsCloudSystem;
  64010. /**
  64011. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  64012. * @param size the size (float) of the visibility box
  64013. * note : this doesn't lock the PCS mesh bounding box.
  64014. * doc :
  64015. */
  64016. setVisibilityBox(size: number): void;
  64017. /**
  64018. * Gets whether the PCS is always visible or not
  64019. * doc :
  64020. */
  64021. get isAlwaysVisible(): boolean;
  64022. /**
  64023. * Sets the PCS as always visible or not
  64024. * doc :
  64025. */
  64026. set isAlwaysVisible(val: boolean);
  64027. /**
  64028. * Tells to `setParticles()` to compute the particle rotations or not
  64029. * Default value : false. The PCS is faster when it's set to false
  64030. * Note : particle rotations are only applied to parent particles
  64031. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  64032. */
  64033. set computeParticleRotation(val: boolean);
  64034. /**
  64035. * Tells to `setParticles()` to compute the particle colors or not.
  64036. * Default value : true. The PCS is faster when it's set to false.
  64037. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64038. */
  64039. set computeParticleColor(val: boolean);
  64040. set computeParticleTexture(val: boolean);
  64041. /**
  64042. * Gets if `setParticles()` computes the particle colors or not.
  64043. * Default value : false. The PCS is faster when it's set to false.
  64044. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64045. */
  64046. get computeParticleColor(): boolean;
  64047. /**
  64048. * Gets if `setParticles()` computes the particle textures or not.
  64049. * Default value : false. The PCS is faster when it's set to false.
  64050. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  64051. */
  64052. get computeParticleTexture(): boolean;
  64053. /**
  64054. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  64055. */
  64056. set computeBoundingBox(val: boolean);
  64057. /**
  64058. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  64059. */
  64060. get computeBoundingBox(): boolean;
  64061. /**
  64062. * This function does nothing. It may be overwritten to set all the particle first values.
  64063. * The PCS doesn't call this function, you may have to call it by your own.
  64064. * doc :
  64065. */
  64066. initParticles(): void;
  64067. /**
  64068. * This function does nothing. It may be overwritten to recycle a particle
  64069. * The PCS doesn't call this function, you can to call it
  64070. * doc :
  64071. * @param particle The particle to recycle
  64072. * @returns the recycled particle
  64073. */
  64074. recycleParticle(particle: CloudPoint): CloudPoint;
  64075. /**
  64076. * Updates a particle : this function should be overwritten by the user.
  64077. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  64078. * doc :
  64079. * @example : just set a particle position or velocity and recycle conditions
  64080. * @param particle The particle to update
  64081. * @returns the updated particle
  64082. */
  64083. updateParticle(particle: CloudPoint): CloudPoint;
  64084. /**
  64085. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64086. * This does nothing and may be overwritten by the user.
  64087. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64088. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64089. * @param update the boolean update value actually passed to setParticles()
  64090. */
  64091. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64092. /**
  64093. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64094. * This will be passed three parameters.
  64095. * This does nothing and may be overwritten by the user.
  64096. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64097. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64098. * @param update the boolean update value actually passed to setParticles()
  64099. */
  64100. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64101. }
  64102. }
  64103. declare module BABYLON {
  64104. /**
  64105. * Represents one particle of a points cloud system.
  64106. */
  64107. export class CloudPoint {
  64108. /**
  64109. * particle global index
  64110. */
  64111. idx: number;
  64112. /**
  64113. * The color of the particle
  64114. */
  64115. color: Nullable<Color4>;
  64116. /**
  64117. * The world space position of the particle.
  64118. */
  64119. position: Vector3;
  64120. /**
  64121. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64122. */
  64123. rotation: Vector3;
  64124. /**
  64125. * The world space rotation quaternion of the particle.
  64126. */
  64127. rotationQuaternion: Nullable<Quaternion>;
  64128. /**
  64129. * The uv of the particle.
  64130. */
  64131. uv: Nullable<Vector2>;
  64132. /**
  64133. * The current speed of the particle.
  64134. */
  64135. velocity: Vector3;
  64136. /**
  64137. * The pivot point in the particle local space.
  64138. */
  64139. pivot: Vector3;
  64140. /**
  64141. * Must the particle be translated from its pivot point in its local space ?
  64142. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64143. * Default : false
  64144. */
  64145. translateFromPivot: boolean;
  64146. /**
  64147. * Index of this particle in the global "positions" array (Internal use)
  64148. * @hidden
  64149. */
  64150. _pos: number;
  64151. /**
  64152. * @hidden Index of this particle in the global "indices" array (Internal use)
  64153. */
  64154. _ind: number;
  64155. /**
  64156. * Group this particle belongs to
  64157. */
  64158. _group: PointsGroup;
  64159. /**
  64160. * Group id of this particle
  64161. */
  64162. groupId: number;
  64163. /**
  64164. * Index of the particle in its group id (Internal use)
  64165. */
  64166. idxInGroup: number;
  64167. /**
  64168. * @hidden Particle BoundingInfo object (Internal use)
  64169. */
  64170. _boundingInfo: BoundingInfo;
  64171. /**
  64172. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64173. */
  64174. _pcs: PointsCloudSystem;
  64175. /**
  64176. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64177. */
  64178. _stillInvisible: boolean;
  64179. /**
  64180. * @hidden Last computed particle rotation matrix
  64181. */
  64182. _rotationMatrix: number[];
  64183. /**
  64184. * Parent particle Id, if any.
  64185. * Default null.
  64186. */
  64187. parentId: Nullable<number>;
  64188. /**
  64189. * @hidden Internal global position in the PCS.
  64190. */
  64191. _globalPosition: Vector3;
  64192. /**
  64193. * Creates a Point Cloud object.
  64194. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64195. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64196. * @param group (PointsGroup) is the group the particle belongs to
  64197. * @param groupId (integer) is the group identifier in the PCS.
  64198. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64199. * @param pcs defines the PCS it is associated to
  64200. */
  64201. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64202. /**
  64203. * get point size
  64204. */
  64205. get size(): Vector3;
  64206. /**
  64207. * Set point size
  64208. */
  64209. set size(scale: Vector3);
  64210. /**
  64211. * Legacy support, changed quaternion to rotationQuaternion
  64212. */
  64213. get quaternion(): Nullable<Quaternion>;
  64214. /**
  64215. * Legacy support, changed quaternion to rotationQuaternion
  64216. */
  64217. set quaternion(q: Nullable<Quaternion>);
  64218. /**
  64219. * Returns a boolean. True if the particle intersects a mesh, else false
  64220. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64221. * @param target is the object (point or mesh) what the intersection is computed against
  64222. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64223. * @returns true if it intersects
  64224. */
  64225. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64226. /**
  64227. * get the rotation matrix of the particle
  64228. * @hidden
  64229. */
  64230. getRotationMatrix(m: Matrix): void;
  64231. }
  64232. /**
  64233. * Represents a group of points in a points cloud system
  64234. * * PCS internal tool, don't use it manually.
  64235. */
  64236. export class PointsGroup {
  64237. /**
  64238. * The group id
  64239. * @hidden
  64240. */
  64241. groupID: number;
  64242. /**
  64243. * image data for group (internal use)
  64244. * @hidden
  64245. */
  64246. _groupImageData: Nullable<ArrayBufferView>;
  64247. /**
  64248. * Image Width (internal use)
  64249. * @hidden
  64250. */
  64251. _groupImgWidth: number;
  64252. /**
  64253. * Image Height (internal use)
  64254. * @hidden
  64255. */
  64256. _groupImgHeight: number;
  64257. /**
  64258. * Custom position function (internal use)
  64259. * @hidden
  64260. */
  64261. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64262. /**
  64263. * density per facet for surface points
  64264. * @hidden
  64265. */
  64266. _groupDensity: number[];
  64267. /**
  64268. * Only when points are colored by texture carries pointer to texture list array
  64269. * @hidden
  64270. */
  64271. _textureNb: number;
  64272. /**
  64273. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64274. * PCS internal tool, don't use it manually.
  64275. * @hidden
  64276. */
  64277. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64278. }
  64279. }
  64280. declare module BABYLON {
  64281. interface Scene {
  64282. /** @hidden (Backing field) */
  64283. _physicsEngine: Nullable<IPhysicsEngine>;
  64284. /** @hidden */
  64285. _physicsTimeAccumulator: number;
  64286. /**
  64287. * Gets the current physics engine
  64288. * @returns a IPhysicsEngine or null if none attached
  64289. */
  64290. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64291. /**
  64292. * Enables physics to the current scene
  64293. * @param gravity defines the scene's gravity for the physics engine
  64294. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64295. * @return a boolean indicating if the physics engine was initialized
  64296. */
  64297. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64298. /**
  64299. * Disables and disposes the physics engine associated with the scene
  64300. */
  64301. disablePhysicsEngine(): void;
  64302. /**
  64303. * Gets a boolean indicating if there is an active physics engine
  64304. * @returns a boolean indicating if there is an active physics engine
  64305. */
  64306. isPhysicsEnabled(): boolean;
  64307. /**
  64308. * Deletes a physics compound impostor
  64309. * @param compound defines the compound to delete
  64310. */
  64311. deleteCompoundImpostor(compound: any): void;
  64312. /**
  64313. * An event triggered when physic simulation is about to be run
  64314. */
  64315. onBeforePhysicsObservable: Observable<Scene>;
  64316. /**
  64317. * An event triggered when physic simulation has been done
  64318. */
  64319. onAfterPhysicsObservable: Observable<Scene>;
  64320. }
  64321. interface AbstractMesh {
  64322. /** @hidden */
  64323. _physicsImpostor: Nullable<PhysicsImpostor>;
  64324. /**
  64325. * Gets or sets impostor used for physic simulation
  64326. * @see http://doc.babylonjs.com/features/physics_engine
  64327. */
  64328. physicsImpostor: Nullable<PhysicsImpostor>;
  64329. /**
  64330. * Gets the current physics impostor
  64331. * @see http://doc.babylonjs.com/features/physics_engine
  64332. * @returns a physics impostor or null
  64333. */
  64334. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64335. /** Apply a physic impulse to the mesh
  64336. * @param force defines the force to apply
  64337. * @param contactPoint defines where to apply the force
  64338. * @returns the current mesh
  64339. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64340. */
  64341. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64342. /**
  64343. * Creates a physic joint between two meshes
  64344. * @param otherMesh defines the other mesh to use
  64345. * @param pivot1 defines the pivot to use on this mesh
  64346. * @param pivot2 defines the pivot to use on the other mesh
  64347. * @param options defines additional options (can be plugin dependent)
  64348. * @returns the current mesh
  64349. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64350. */
  64351. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64352. /** @hidden */
  64353. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64354. }
  64355. /**
  64356. * Defines the physics engine scene component responsible to manage a physics engine
  64357. */
  64358. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64359. /**
  64360. * The component name helpful to identify the component in the list of scene components.
  64361. */
  64362. readonly name: string;
  64363. /**
  64364. * The scene the component belongs to.
  64365. */
  64366. scene: Scene;
  64367. /**
  64368. * Creates a new instance of the component for the given scene
  64369. * @param scene Defines the scene to register the component in
  64370. */
  64371. constructor(scene: Scene);
  64372. /**
  64373. * Registers the component in a given scene
  64374. */
  64375. register(): void;
  64376. /**
  64377. * Rebuilds the elements related to this component in case of
  64378. * context lost for instance.
  64379. */
  64380. rebuild(): void;
  64381. /**
  64382. * Disposes the component and the associated ressources
  64383. */
  64384. dispose(): void;
  64385. }
  64386. }
  64387. declare module BABYLON {
  64388. /**
  64389. * A helper for physics simulations
  64390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64391. */
  64392. export class PhysicsHelper {
  64393. private _scene;
  64394. private _physicsEngine;
  64395. /**
  64396. * Initializes the Physics helper
  64397. * @param scene Babylon.js scene
  64398. */
  64399. constructor(scene: Scene);
  64400. /**
  64401. * Applies a radial explosion impulse
  64402. * @param origin the origin of the explosion
  64403. * @param radiusOrEventOptions the radius or the options of radial explosion
  64404. * @param strength the explosion strength
  64405. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64406. * @returns A physics radial explosion event, or null
  64407. */
  64408. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64409. /**
  64410. * Applies a radial explosion force
  64411. * @param origin the origin of the explosion
  64412. * @param radiusOrEventOptions the radius or the options of radial explosion
  64413. * @param strength the explosion strength
  64414. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64415. * @returns A physics radial explosion event, or null
  64416. */
  64417. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64418. /**
  64419. * Creates a gravitational field
  64420. * @param origin the origin of the explosion
  64421. * @param radiusOrEventOptions the radius or the options of radial explosion
  64422. * @param strength the explosion strength
  64423. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64424. * @returns A physics gravitational field event, or null
  64425. */
  64426. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64427. /**
  64428. * Creates a physics updraft event
  64429. * @param origin the origin of the updraft
  64430. * @param radiusOrEventOptions the radius or the options of the updraft
  64431. * @param strength the strength of the updraft
  64432. * @param height the height of the updraft
  64433. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64434. * @returns A physics updraft event, or null
  64435. */
  64436. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64437. /**
  64438. * Creates a physics vortex event
  64439. * @param origin the of the vortex
  64440. * @param radiusOrEventOptions the radius or the options of the vortex
  64441. * @param strength the strength of the vortex
  64442. * @param height the height of the vortex
  64443. * @returns a Physics vortex event, or null
  64444. * A physics vortex event or null
  64445. */
  64446. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64447. }
  64448. /**
  64449. * Represents a physics radial explosion event
  64450. */
  64451. class PhysicsRadialExplosionEvent {
  64452. private _scene;
  64453. private _options;
  64454. private _sphere;
  64455. private _dataFetched;
  64456. /**
  64457. * Initializes a radial explosioin event
  64458. * @param _scene BabylonJS scene
  64459. * @param _options The options for the vortex event
  64460. */
  64461. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64462. /**
  64463. * Returns the data related to the radial explosion event (sphere).
  64464. * @returns The radial explosion event data
  64465. */
  64466. getData(): PhysicsRadialExplosionEventData;
  64467. /**
  64468. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64469. * @param impostor A physics imposter
  64470. * @param origin the origin of the explosion
  64471. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64472. */
  64473. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64474. /**
  64475. * Triggers affecterd impostors callbacks
  64476. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64477. */
  64478. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64479. /**
  64480. * Disposes the sphere.
  64481. * @param force Specifies if the sphere should be disposed by force
  64482. */
  64483. dispose(force?: boolean): void;
  64484. /*** Helpers ***/
  64485. private _prepareSphere;
  64486. private _intersectsWithSphere;
  64487. }
  64488. /**
  64489. * Represents a gravitational field event
  64490. */
  64491. class PhysicsGravitationalFieldEvent {
  64492. private _physicsHelper;
  64493. private _scene;
  64494. private _origin;
  64495. private _options;
  64496. private _tickCallback;
  64497. private _sphere;
  64498. private _dataFetched;
  64499. /**
  64500. * Initializes the physics gravitational field event
  64501. * @param _physicsHelper A physics helper
  64502. * @param _scene BabylonJS scene
  64503. * @param _origin The origin position of the gravitational field event
  64504. * @param _options The options for the vortex event
  64505. */
  64506. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64507. /**
  64508. * Returns the data related to the gravitational field event (sphere).
  64509. * @returns A gravitational field event
  64510. */
  64511. getData(): PhysicsGravitationalFieldEventData;
  64512. /**
  64513. * Enables the gravitational field.
  64514. */
  64515. enable(): void;
  64516. /**
  64517. * Disables the gravitational field.
  64518. */
  64519. disable(): void;
  64520. /**
  64521. * Disposes the sphere.
  64522. * @param force The force to dispose from the gravitational field event
  64523. */
  64524. dispose(force?: boolean): void;
  64525. private _tick;
  64526. }
  64527. /**
  64528. * Represents a physics updraft event
  64529. */
  64530. class PhysicsUpdraftEvent {
  64531. private _scene;
  64532. private _origin;
  64533. private _options;
  64534. private _physicsEngine;
  64535. private _originTop;
  64536. private _originDirection;
  64537. private _tickCallback;
  64538. private _cylinder;
  64539. private _cylinderPosition;
  64540. private _dataFetched;
  64541. /**
  64542. * Initializes the physics updraft event
  64543. * @param _scene BabylonJS scene
  64544. * @param _origin The origin position of the updraft
  64545. * @param _options The options for the updraft event
  64546. */
  64547. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64548. /**
  64549. * Returns the data related to the updraft event (cylinder).
  64550. * @returns A physics updraft event
  64551. */
  64552. getData(): PhysicsUpdraftEventData;
  64553. /**
  64554. * Enables the updraft.
  64555. */
  64556. enable(): void;
  64557. /**
  64558. * Disables the updraft.
  64559. */
  64560. disable(): void;
  64561. /**
  64562. * Disposes the cylinder.
  64563. * @param force Specifies if the updraft should be disposed by force
  64564. */
  64565. dispose(force?: boolean): void;
  64566. private getImpostorHitData;
  64567. private _tick;
  64568. /*** Helpers ***/
  64569. private _prepareCylinder;
  64570. private _intersectsWithCylinder;
  64571. }
  64572. /**
  64573. * Represents a physics vortex event
  64574. */
  64575. class PhysicsVortexEvent {
  64576. private _scene;
  64577. private _origin;
  64578. private _options;
  64579. private _physicsEngine;
  64580. private _originTop;
  64581. private _tickCallback;
  64582. private _cylinder;
  64583. private _cylinderPosition;
  64584. private _dataFetched;
  64585. /**
  64586. * Initializes the physics vortex event
  64587. * @param _scene The BabylonJS scene
  64588. * @param _origin The origin position of the vortex
  64589. * @param _options The options for the vortex event
  64590. */
  64591. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64592. /**
  64593. * Returns the data related to the vortex event (cylinder).
  64594. * @returns The physics vortex event data
  64595. */
  64596. getData(): PhysicsVortexEventData;
  64597. /**
  64598. * Enables the vortex.
  64599. */
  64600. enable(): void;
  64601. /**
  64602. * Disables the cortex.
  64603. */
  64604. disable(): void;
  64605. /**
  64606. * Disposes the sphere.
  64607. * @param force
  64608. */
  64609. dispose(force?: boolean): void;
  64610. private getImpostorHitData;
  64611. private _tick;
  64612. /*** Helpers ***/
  64613. private _prepareCylinder;
  64614. private _intersectsWithCylinder;
  64615. }
  64616. /**
  64617. * Options fot the radial explosion event
  64618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64619. */
  64620. export class PhysicsRadialExplosionEventOptions {
  64621. /**
  64622. * The radius of the sphere for the radial explosion.
  64623. */
  64624. radius: number;
  64625. /**
  64626. * The strenth of the explosion.
  64627. */
  64628. strength: number;
  64629. /**
  64630. * The strenght of the force in correspondence to the distance of the affected object
  64631. */
  64632. falloff: PhysicsRadialImpulseFalloff;
  64633. /**
  64634. * Sphere options for the radial explosion.
  64635. */
  64636. sphere: {
  64637. segments: number;
  64638. diameter: number;
  64639. };
  64640. /**
  64641. * Sphere options for the radial explosion.
  64642. */
  64643. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64644. }
  64645. /**
  64646. * Options fot the updraft event
  64647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64648. */
  64649. export class PhysicsUpdraftEventOptions {
  64650. /**
  64651. * The radius of the cylinder for the vortex
  64652. */
  64653. radius: number;
  64654. /**
  64655. * The strenth of the updraft.
  64656. */
  64657. strength: number;
  64658. /**
  64659. * The height of the cylinder for the updraft.
  64660. */
  64661. height: number;
  64662. /**
  64663. * The mode for the the updraft.
  64664. */
  64665. updraftMode: PhysicsUpdraftMode;
  64666. }
  64667. /**
  64668. * Options fot the vortex event
  64669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64670. */
  64671. export class PhysicsVortexEventOptions {
  64672. /**
  64673. * The radius of the cylinder for the vortex
  64674. */
  64675. radius: number;
  64676. /**
  64677. * The strenth of the vortex.
  64678. */
  64679. strength: number;
  64680. /**
  64681. * The height of the cylinder for the vortex.
  64682. */
  64683. height: number;
  64684. /**
  64685. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64686. */
  64687. centripetalForceThreshold: number;
  64688. /**
  64689. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64690. */
  64691. centripetalForceMultiplier: number;
  64692. /**
  64693. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64694. */
  64695. centrifugalForceMultiplier: number;
  64696. /**
  64697. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64698. */
  64699. updraftForceMultiplier: number;
  64700. }
  64701. /**
  64702. * The strenght of the force in correspondence to the distance of the affected object
  64703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64704. */
  64705. export enum PhysicsRadialImpulseFalloff {
  64706. /** Defines that impulse is constant in strength across it's whole radius */
  64707. Constant = 0,
  64708. /** Defines that impulse gets weaker if it's further from the origin */
  64709. Linear = 1
  64710. }
  64711. /**
  64712. * The strength of the force in correspondence to the distance of the affected object
  64713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64714. */
  64715. export enum PhysicsUpdraftMode {
  64716. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64717. Center = 0,
  64718. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64719. Perpendicular = 1
  64720. }
  64721. /**
  64722. * Interface for a physics hit data
  64723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64724. */
  64725. export interface PhysicsHitData {
  64726. /**
  64727. * The force applied at the contact point
  64728. */
  64729. force: Vector3;
  64730. /**
  64731. * The contact point
  64732. */
  64733. contactPoint: Vector3;
  64734. /**
  64735. * The distance from the origin to the contact point
  64736. */
  64737. distanceFromOrigin: number;
  64738. }
  64739. /**
  64740. * Interface for radial explosion event data
  64741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64742. */
  64743. export interface PhysicsRadialExplosionEventData {
  64744. /**
  64745. * A sphere used for the radial explosion event
  64746. */
  64747. sphere: Mesh;
  64748. }
  64749. /**
  64750. * Interface for gravitational field event data
  64751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64752. */
  64753. export interface PhysicsGravitationalFieldEventData {
  64754. /**
  64755. * A sphere mesh used for the gravitational field event
  64756. */
  64757. sphere: Mesh;
  64758. }
  64759. /**
  64760. * Interface for updraft event data
  64761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64762. */
  64763. export interface PhysicsUpdraftEventData {
  64764. /**
  64765. * A cylinder used for the updraft event
  64766. */
  64767. cylinder: Mesh;
  64768. }
  64769. /**
  64770. * Interface for vortex event data
  64771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64772. */
  64773. export interface PhysicsVortexEventData {
  64774. /**
  64775. * A cylinder used for the vortex event
  64776. */
  64777. cylinder: Mesh;
  64778. }
  64779. /**
  64780. * Interface for an affected physics impostor
  64781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64782. */
  64783. export interface PhysicsAffectedImpostorWithData {
  64784. /**
  64785. * The impostor affected by the effect
  64786. */
  64787. impostor: PhysicsImpostor;
  64788. /**
  64789. * The data about the hit/horce from the explosion
  64790. */
  64791. hitData: PhysicsHitData;
  64792. }
  64793. }
  64794. declare module BABYLON {
  64795. /** @hidden */
  64796. export var blackAndWhitePixelShader: {
  64797. name: string;
  64798. shader: string;
  64799. };
  64800. }
  64801. declare module BABYLON {
  64802. /**
  64803. * Post process used to render in black and white
  64804. */
  64805. export class BlackAndWhitePostProcess extends PostProcess {
  64806. /**
  64807. * Linear about to convert he result to black and white (default: 1)
  64808. */
  64809. degree: number;
  64810. /**
  64811. * Creates a black and white post process
  64812. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64813. * @param name The name of the effect.
  64814. * @param options The required width/height ratio to downsize to before computing the render pass.
  64815. * @param camera The camera to apply the render pass to.
  64816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64817. * @param engine The engine which the post process will be applied. (default: current engine)
  64818. * @param reusable If the post process can be reused on the same frame. (default: false)
  64819. */
  64820. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64821. }
  64822. }
  64823. declare module BABYLON {
  64824. /**
  64825. * This represents a set of one or more post processes in Babylon.
  64826. * A post process can be used to apply a shader to a texture after it is rendered.
  64827. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64828. */
  64829. export class PostProcessRenderEffect {
  64830. private _postProcesses;
  64831. private _getPostProcesses;
  64832. private _singleInstance;
  64833. private _cameras;
  64834. private _indicesForCamera;
  64835. /**
  64836. * Name of the effect
  64837. * @hidden
  64838. */
  64839. _name: string;
  64840. /**
  64841. * Instantiates a post process render effect.
  64842. * A post process can be used to apply a shader to a texture after it is rendered.
  64843. * @param engine The engine the effect is tied to
  64844. * @param name The name of the effect
  64845. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64846. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64847. */
  64848. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64849. /**
  64850. * Checks if all the post processes in the effect are supported.
  64851. */
  64852. get isSupported(): boolean;
  64853. /**
  64854. * Updates the current state of the effect
  64855. * @hidden
  64856. */
  64857. _update(): void;
  64858. /**
  64859. * Attaches the effect on cameras
  64860. * @param cameras The camera to attach to.
  64861. * @hidden
  64862. */
  64863. _attachCameras(cameras: Camera): void;
  64864. /**
  64865. * Attaches the effect on cameras
  64866. * @param cameras The camera to attach to.
  64867. * @hidden
  64868. */
  64869. _attachCameras(cameras: Camera[]): void;
  64870. /**
  64871. * Detaches the effect on cameras
  64872. * @param cameras The camera to detatch from.
  64873. * @hidden
  64874. */
  64875. _detachCameras(cameras: Camera): void;
  64876. /**
  64877. * Detatches the effect on cameras
  64878. * @param cameras The camera to detatch from.
  64879. * @hidden
  64880. */
  64881. _detachCameras(cameras: Camera[]): void;
  64882. /**
  64883. * Enables the effect on given cameras
  64884. * @param cameras The camera to enable.
  64885. * @hidden
  64886. */
  64887. _enable(cameras: Camera): void;
  64888. /**
  64889. * Enables the effect on given cameras
  64890. * @param cameras The camera to enable.
  64891. * @hidden
  64892. */
  64893. _enable(cameras: Nullable<Camera[]>): void;
  64894. /**
  64895. * Disables the effect on the given cameras
  64896. * @param cameras The camera to disable.
  64897. * @hidden
  64898. */
  64899. _disable(cameras: Camera): void;
  64900. /**
  64901. * Disables the effect on the given cameras
  64902. * @param cameras The camera to disable.
  64903. * @hidden
  64904. */
  64905. _disable(cameras: Nullable<Camera[]>): void;
  64906. /**
  64907. * Gets a list of the post processes contained in the effect.
  64908. * @param camera The camera to get the post processes on.
  64909. * @returns The list of the post processes in the effect.
  64910. */
  64911. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64912. }
  64913. }
  64914. declare module BABYLON {
  64915. /** @hidden */
  64916. export var extractHighlightsPixelShader: {
  64917. name: string;
  64918. shader: string;
  64919. };
  64920. }
  64921. declare module BABYLON {
  64922. /**
  64923. * 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.
  64924. */
  64925. export class ExtractHighlightsPostProcess extends PostProcess {
  64926. /**
  64927. * The luminance threshold, pixels below this value will be set to black.
  64928. */
  64929. threshold: number;
  64930. /** @hidden */
  64931. _exposure: number;
  64932. /**
  64933. * Post process which has the input texture to be used when performing highlight extraction
  64934. * @hidden
  64935. */
  64936. _inputPostProcess: Nullable<PostProcess>;
  64937. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64938. }
  64939. }
  64940. declare module BABYLON {
  64941. /** @hidden */
  64942. export var bloomMergePixelShader: {
  64943. name: string;
  64944. shader: string;
  64945. };
  64946. }
  64947. declare module BABYLON {
  64948. /**
  64949. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64950. */
  64951. export class BloomMergePostProcess extends PostProcess {
  64952. /** Weight of the bloom to be added to the original input. */
  64953. weight: number;
  64954. /**
  64955. * Creates a new instance of @see BloomMergePostProcess
  64956. * @param name The name of the effect.
  64957. * @param originalFromInput Post process which's input will be used for the merge.
  64958. * @param blurred Blurred highlights post process which's output will be used.
  64959. * @param weight Weight of the bloom to be added to the original input.
  64960. * @param options The required width/height ratio to downsize to before computing the render pass.
  64961. * @param camera The camera to apply the render pass to.
  64962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64963. * @param engine The engine which the post process will be applied. (default: current engine)
  64964. * @param reusable If the post process can be reused on the same frame. (default: false)
  64965. * @param textureType Type of textures used when performing the post process. (default: 0)
  64966. * @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)
  64967. */
  64968. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64969. /** Weight of the bloom to be added to the original input. */
  64970. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64971. }
  64972. }
  64973. declare module BABYLON {
  64974. /**
  64975. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64976. */
  64977. export class BloomEffect extends PostProcessRenderEffect {
  64978. private bloomScale;
  64979. /**
  64980. * @hidden Internal
  64981. */
  64982. _effects: Array<PostProcess>;
  64983. /**
  64984. * @hidden Internal
  64985. */
  64986. _downscale: ExtractHighlightsPostProcess;
  64987. private _blurX;
  64988. private _blurY;
  64989. private _merge;
  64990. /**
  64991. * The luminance threshold to find bright areas of the image to bloom.
  64992. */
  64993. get threshold(): number;
  64994. set threshold(value: number);
  64995. /**
  64996. * The strength of the bloom.
  64997. */
  64998. get weight(): number;
  64999. set weight(value: number);
  65000. /**
  65001. * Specifies the size of the bloom blur kernel, relative to the final output size
  65002. */
  65003. get kernel(): number;
  65004. set kernel(value: number);
  65005. /**
  65006. * Creates a new instance of @see BloomEffect
  65007. * @param scene The scene the effect belongs to.
  65008. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  65009. * @param bloomKernel The size of the kernel to be used when applying the blur.
  65010. * @param bloomWeight The the strength of bloom.
  65011. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65012. * @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)
  65013. */
  65014. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  65015. /**
  65016. * Disposes each of the internal effects for a given camera.
  65017. * @param camera The camera to dispose the effect on.
  65018. */
  65019. disposeEffects(camera: Camera): void;
  65020. /**
  65021. * @hidden Internal
  65022. */
  65023. _updateEffects(): void;
  65024. /**
  65025. * Internal
  65026. * @returns if all the contained post processes are ready.
  65027. * @hidden
  65028. */
  65029. _isReady(): boolean;
  65030. }
  65031. }
  65032. declare module BABYLON {
  65033. /** @hidden */
  65034. export var chromaticAberrationPixelShader: {
  65035. name: string;
  65036. shader: string;
  65037. };
  65038. }
  65039. declare module BABYLON {
  65040. /**
  65041. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  65042. */
  65043. export class ChromaticAberrationPostProcess extends PostProcess {
  65044. /**
  65045. * The amount of seperation of rgb channels (default: 30)
  65046. */
  65047. aberrationAmount: number;
  65048. /**
  65049. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  65050. */
  65051. radialIntensity: number;
  65052. /**
  65053. * 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))
  65054. */
  65055. direction: Vector2;
  65056. /**
  65057. * 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))
  65058. */
  65059. centerPosition: Vector2;
  65060. /**
  65061. * Creates a new instance ChromaticAberrationPostProcess
  65062. * @param name The name of the effect.
  65063. * @param screenWidth The width of the screen to apply the effect on.
  65064. * @param screenHeight The height of the screen to apply the effect on.
  65065. * @param options The required width/height ratio to downsize to before computing the render pass.
  65066. * @param camera The camera to apply the render pass to.
  65067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65068. * @param engine The engine which the post process will be applied. (default: current engine)
  65069. * @param reusable If the post process can be reused on the same frame. (default: false)
  65070. * @param textureType Type of textures used when performing the post process. (default: 0)
  65071. * @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)
  65072. */
  65073. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65074. }
  65075. }
  65076. declare module BABYLON {
  65077. /** @hidden */
  65078. export var circleOfConfusionPixelShader: {
  65079. name: string;
  65080. shader: string;
  65081. };
  65082. }
  65083. declare module BABYLON {
  65084. /**
  65085. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65086. */
  65087. export class CircleOfConfusionPostProcess extends PostProcess {
  65088. /**
  65089. * 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.
  65090. */
  65091. lensSize: number;
  65092. /**
  65093. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65094. */
  65095. fStop: number;
  65096. /**
  65097. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65098. */
  65099. focusDistance: number;
  65100. /**
  65101. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65102. */
  65103. focalLength: number;
  65104. private _depthTexture;
  65105. /**
  65106. * Creates a new instance CircleOfConfusionPostProcess
  65107. * @param name The name of the effect.
  65108. * @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.
  65109. * @param options The required width/height ratio to downsize to before computing the render pass.
  65110. * @param camera The camera to apply the render pass to.
  65111. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65112. * @param engine The engine which the post process will be applied. (default: current engine)
  65113. * @param reusable If the post process can be reused on the same frame. (default: false)
  65114. * @param textureType Type of textures used when performing the post process. (default: 0)
  65115. * @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)
  65116. */
  65117. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65118. /**
  65119. * 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.
  65120. */
  65121. set depthTexture(value: RenderTargetTexture);
  65122. }
  65123. }
  65124. declare module BABYLON {
  65125. /** @hidden */
  65126. export var colorCorrectionPixelShader: {
  65127. name: string;
  65128. shader: string;
  65129. };
  65130. }
  65131. declare module BABYLON {
  65132. /**
  65133. *
  65134. * This post-process allows the modification of rendered colors by using
  65135. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65136. *
  65137. * The object needs to be provided an url to a texture containing the color
  65138. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65139. * Use an image editing software to tweak the LUT to match your needs.
  65140. *
  65141. * For an example of a color LUT, see here:
  65142. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65143. * For explanations on color grading, see here:
  65144. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65145. *
  65146. */
  65147. export class ColorCorrectionPostProcess extends PostProcess {
  65148. private _colorTableTexture;
  65149. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65150. }
  65151. }
  65152. declare module BABYLON {
  65153. /** @hidden */
  65154. export var convolutionPixelShader: {
  65155. name: string;
  65156. shader: string;
  65157. };
  65158. }
  65159. declare module BABYLON {
  65160. /**
  65161. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65162. * input texture to perform effects such as edge detection or sharpening
  65163. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65164. */
  65165. export class ConvolutionPostProcess extends PostProcess {
  65166. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65167. kernel: number[];
  65168. /**
  65169. * Creates a new instance ConvolutionPostProcess
  65170. * @param name The name of the effect.
  65171. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65172. * @param options The required width/height ratio to downsize to before computing the render pass.
  65173. * @param camera The camera to apply the render pass to.
  65174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65175. * @param engine The engine which the post process will be applied. (default: current engine)
  65176. * @param reusable If the post process can be reused on the same frame. (default: false)
  65177. * @param textureType Type of textures used when performing the post process. (default: 0)
  65178. */
  65179. constructor(name: string,
  65180. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65181. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65182. /**
  65183. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65184. */
  65185. static EdgeDetect0Kernel: number[];
  65186. /**
  65187. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65188. */
  65189. static EdgeDetect1Kernel: number[];
  65190. /**
  65191. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65192. */
  65193. static EdgeDetect2Kernel: number[];
  65194. /**
  65195. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65196. */
  65197. static SharpenKernel: number[];
  65198. /**
  65199. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65200. */
  65201. static EmbossKernel: number[];
  65202. /**
  65203. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65204. */
  65205. static GaussianKernel: number[];
  65206. }
  65207. }
  65208. declare module BABYLON {
  65209. /**
  65210. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65211. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65212. * based on samples that have a large difference in distance than the center pixel.
  65213. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65214. */
  65215. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65216. direction: Vector2;
  65217. /**
  65218. * Creates a new instance CircleOfConfusionPostProcess
  65219. * @param name The name of the effect.
  65220. * @param scene The scene the effect belongs to.
  65221. * @param direction The direction the blur should be applied.
  65222. * @param kernel The size of the kernel used to blur.
  65223. * @param options The required width/height ratio to downsize to before computing the render pass.
  65224. * @param camera The camera to apply the render pass to.
  65225. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65226. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65228. * @param engine The engine which the post process will be applied. (default: current engine)
  65229. * @param reusable If the post process can be reused on the same frame. (default: false)
  65230. * @param textureType Type of textures used when performing the post process. (default: 0)
  65231. * @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)
  65232. */
  65233. 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);
  65234. }
  65235. }
  65236. declare module BABYLON {
  65237. /** @hidden */
  65238. export var depthOfFieldMergePixelShader: {
  65239. name: string;
  65240. shader: string;
  65241. };
  65242. }
  65243. declare module BABYLON {
  65244. /**
  65245. * Options to be set when merging outputs from the default pipeline.
  65246. */
  65247. export class DepthOfFieldMergePostProcessOptions {
  65248. /**
  65249. * The original image to merge on top of
  65250. */
  65251. originalFromInput: PostProcess;
  65252. /**
  65253. * Parameters to perform the merge of the depth of field effect
  65254. */
  65255. depthOfField?: {
  65256. circleOfConfusion: PostProcess;
  65257. blurSteps: Array<PostProcess>;
  65258. };
  65259. /**
  65260. * Parameters to perform the merge of bloom effect
  65261. */
  65262. bloom?: {
  65263. blurred: PostProcess;
  65264. weight: number;
  65265. };
  65266. }
  65267. /**
  65268. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65269. */
  65270. export class DepthOfFieldMergePostProcess extends PostProcess {
  65271. private blurSteps;
  65272. /**
  65273. * Creates a new instance of DepthOfFieldMergePostProcess
  65274. * @param name The name of the effect.
  65275. * @param originalFromInput Post process which's input will be used for the merge.
  65276. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65277. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65278. * @param options The required width/height ratio to downsize to before computing the render pass.
  65279. * @param camera The camera to apply the render pass to.
  65280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65281. * @param engine The engine which the post process will be applied. (default: current engine)
  65282. * @param reusable If the post process can be reused on the same frame. (default: false)
  65283. * @param textureType Type of textures used when performing the post process. (default: 0)
  65284. * @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)
  65285. */
  65286. 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);
  65287. /**
  65288. * Updates the effect with the current post process compile time values and recompiles the shader.
  65289. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65290. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65291. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65292. * @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
  65293. * @param onCompiled Called when the shader has been compiled.
  65294. * @param onError Called if there is an error when compiling a shader.
  65295. */
  65296. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65297. }
  65298. }
  65299. declare module BABYLON {
  65300. /**
  65301. * Specifies the level of max blur that should be applied when using the depth of field effect
  65302. */
  65303. export enum DepthOfFieldEffectBlurLevel {
  65304. /**
  65305. * Subtle blur
  65306. */
  65307. Low = 0,
  65308. /**
  65309. * Medium blur
  65310. */
  65311. Medium = 1,
  65312. /**
  65313. * Large blur
  65314. */
  65315. High = 2
  65316. }
  65317. /**
  65318. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65319. */
  65320. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65321. private _circleOfConfusion;
  65322. /**
  65323. * @hidden Internal, blurs from high to low
  65324. */
  65325. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65326. private _depthOfFieldBlurY;
  65327. private _dofMerge;
  65328. /**
  65329. * @hidden Internal post processes in depth of field effect
  65330. */
  65331. _effects: Array<PostProcess>;
  65332. /**
  65333. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65334. */
  65335. set focalLength(value: number);
  65336. get focalLength(): number;
  65337. /**
  65338. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65339. */
  65340. set fStop(value: number);
  65341. get fStop(): number;
  65342. /**
  65343. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65344. */
  65345. set focusDistance(value: number);
  65346. get focusDistance(): number;
  65347. /**
  65348. * 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.
  65349. */
  65350. set lensSize(value: number);
  65351. get lensSize(): number;
  65352. /**
  65353. * Creates a new instance DepthOfFieldEffect
  65354. * @param scene The scene the effect belongs to.
  65355. * @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.
  65356. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65357. * @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)
  65358. */
  65359. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65360. /**
  65361. * Get the current class name of the current effet
  65362. * @returns "DepthOfFieldEffect"
  65363. */
  65364. getClassName(): string;
  65365. /**
  65366. * 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.
  65367. */
  65368. set depthTexture(value: RenderTargetTexture);
  65369. /**
  65370. * Disposes each of the internal effects for a given camera.
  65371. * @param camera The camera to dispose the effect on.
  65372. */
  65373. disposeEffects(camera: Camera): void;
  65374. /**
  65375. * @hidden Internal
  65376. */
  65377. _updateEffects(): void;
  65378. /**
  65379. * Internal
  65380. * @returns if all the contained post processes are ready.
  65381. * @hidden
  65382. */
  65383. _isReady(): boolean;
  65384. }
  65385. }
  65386. declare module BABYLON {
  65387. /** @hidden */
  65388. export var displayPassPixelShader: {
  65389. name: string;
  65390. shader: string;
  65391. };
  65392. }
  65393. declare module BABYLON {
  65394. /**
  65395. * DisplayPassPostProcess which produces an output the same as it's input
  65396. */
  65397. export class DisplayPassPostProcess extends PostProcess {
  65398. /**
  65399. * Creates the DisplayPassPostProcess
  65400. * @param name The name of the effect.
  65401. * @param options The required width/height ratio to downsize to before computing the render pass.
  65402. * @param camera The camera to apply the render pass to.
  65403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65404. * @param engine The engine which the post process will be applied. (default: current engine)
  65405. * @param reusable If the post process can be reused on the same frame. (default: false)
  65406. */
  65407. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65408. }
  65409. }
  65410. declare module BABYLON {
  65411. /** @hidden */
  65412. export var filterPixelShader: {
  65413. name: string;
  65414. shader: string;
  65415. };
  65416. }
  65417. declare module BABYLON {
  65418. /**
  65419. * Applies a kernel filter to the image
  65420. */
  65421. export class FilterPostProcess extends PostProcess {
  65422. /** The matrix to be applied to the image */
  65423. kernelMatrix: Matrix;
  65424. /**
  65425. *
  65426. * @param name The name of the effect.
  65427. * @param kernelMatrix The matrix to be applied to the image
  65428. * @param options The required width/height ratio to downsize to before computing the render pass.
  65429. * @param camera The camera to apply the render pass to.
  65430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65431. * @param engine The engine which the post process will be applied. (default: current engine)
  65432. * @param reusable If the post process can be reused on the same frame. (default: false)
  65433. */
  65434. constructor(name: string,
  65435. /** The matrix to be applied to the image */
  65436. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65437. }
  65438. }
  65439. declare module BABYLON {
  65440. /** @hidden */
  65441. export var fxaaPixelShader: {
  65442. name: string;
  65443. shader: string;
  65444. };
  65445. }
  65446. declare module BABYLON {
  65447. /** @hidden */
  65448. export var fxaaVertexShader: {
  65449. name: string;
  65450. shader: string;
  65451. };
  65452. }
  65453. declare module BABYLON {
  65454. /**
  65455. * Fxaa post process
  65456. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65457. */
  65458. export class FxaaPostProcess extends PostProcess {
  65459. /** @hidden */
  65460. texelWidth: number;
  65461. /** @hidden */
  65462. texelHeight: number;
  65463. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65464. private _getDefines;
  65465. }
  65466. }
  65467. declare module BABYLON {
  65468. /** @hidden */
  65469. export var grainPixelShader: {
  65470. name: string;
  65471. shader: string;
  65472. };
  65473. }
  65474. declare module BABYLON {
  65475. /**
  65476. * The GrainPostProcess adds noise to the image at mid luminance levels
  65477. */
  65478. export class GrainPostProcess extends PostProcess {
  65479. /**
  65480. * The intensity of the grain added (default: 30)
  65481. */
  65482. intensity: number;
  65483. /**
  65484. * If the grain should be randomized on every frame
  65485. */
  65486. animated: boolean;
  65487. /**
  65488. * Creates a new instance of @see GrainPostProcess
  65489. * @param name The name of the effect.
  65490. * @param options The required width/height ratio to downsize to before computing the render pass.
  65491. * @param camera The camera to apply the render pass to.
  65492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65493. * @param engine The engine which the post process will be applied. (default: current engine)
  65494. * @param reusable If the post process can be reused on the same frame. (default: false)
  65495. * @param textureType Type of textures used when performing the post process. (default: 0)
  65496. * @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)
  65497. */
  65498. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65499. }
  65500. }
  65501. declare module BABYLON {
  65502. /** @hidden */
  65503. export var highlightsPixelShader: {
  65504. name: string;
  65505. shader: string;
  65506. };
  65507. }
  65508. declare module BABYLON {
  65509. /**
  65510. * Extracts highlights from the image
  65511. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65512. */
  65513. export class HighlightsPostProcess extends PostProcess {
  65514. /**
  65515. * Extracts highlights from the image
  65516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65517. * @param name The name of the effect.
  65518. * @param options The required width/height ratio to downsize to before computing the render pass.
  65519. * @param camera The camera to apply the render pass to.
  65520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65521. * @param engine The engine which the post process will be applied. (default: current engine)
  65522. * @param reusable If the post process can be reused on the same frame. (default: false)
  65523. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65524. */
  65525. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65526. }
  65527. }
  65528. declare module BABYLON {
  65529. /** @hidden */
  65530. export var mrtFragmentDeclaration: {
  65531. name: string;
  65532. shader: string;
  65533. };
  65534. }
  65535. declare module BABYLON {
  65536. /** @hidden */
  65537. export var geometryPixelShader: {
  65538. name: string;
  65539. shader: string;
  65540. };
  65541. }
  65542. declare module BABYLON {
  65543. /** @hidden */
  65544. export var geometryVertexShader: {
  65545. name: string;
  65546. shader: string;
  65547. };
  65548. }
  65549. declare module BABYLON {
  65550. /** @hidden */
  65551. interface ISavedTransformationMatrix {
  65552. world: Matrix;
  65553. viewProjection: Matrix;
  65554. }
  65555. /**
  65556. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65557. */
  65558. export class GeometryBufferRenderer {
  65559. /**
  65560. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65561. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65562. */
  65563. static readonly POSITION_TEXTURE_TYPE: number;
  65564. /**
  65565. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65566. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65567. */
  65568. static readonly VELOCITY_TEXTURE_TYPE: number;
  65569. /**
  65570. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65571. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65572. */
  65573. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65574. /**
  65575. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65576. * in order to compute objects velocities when enableVelocity is set to "true"
  65577. * @hidden
  65578. */
  65579. _previousTransformationMatrices: {
  65580. [index: number]: ISavedTransformationMatrix;
  65581. };
  65582. /**
  65583. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65584. * in order to compute objects velocities when enableVelocity is set to "true"
  65585. * @hidden
  65586. */
  65587. _previousBonesTransformationMatrices: {
  65588. [index: number]: Float32Array;
  65589. };
  65590. /**
  65591. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65592. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65593. */
  65594. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65595. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65596. renderTransparentMeshes: boolean;
  65597. private _scene;
  65598. private _multiRenderTarget;
  65599. private _ratio;
  65600. private _enablePosition;
  65601. private _enableVelocity;
  65602. private _enableReflectivity;
  65603. private _positionIndex;
  65604. private _velocityIndex;
  65605. private _reflectivityIndex;
  65606. protected _effect: Effect;
  65607. protected _cachedDefines: string;
  65608. /**
  65609. * Set the render list (meshes to be rendered) used in the G buffer.
  65610. */
  65611. set renderList(meshes: Mesh[]);
  65612. /**
  65613. * Gets wether or not G buffer are supported by the running hardware.
  65614. * This requires draw buffer supports
  65615. */
  65616. get isSupported(): boolean;
  65617. /**
  65618. * Returns the index of the given texture type in the G-Buffer textures array
  65619. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65620. * @returns the index of the given texture type in the G-Buffer textures array
  65621. */
  65622. getTextureIndex(textureType: number): number;
  65623. /**
  65624. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65625. */
  65626. get enablePosition(): boolean;
  65627. /**
  65628. * Sets whether or not objects positions are enabled for the G buffer.
  65629. */
  65630. set enablePosition(enable: boolean);
  65631. /**
  65632. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65633. */
  65634. get enableVelocity(): boolean;
  65635. /**
  65636. * Sets wether or not objects velocities are enabled for the G buffer.
  65637. */
  65638. set enableVelocity(enable: boolean);
  65639. /**
  65640. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65641. */
  65642. get enableReflectivity(): boolean;
  65643. /**
  65644. * Sets wether or not objects roughness are enabled for the G buffer.
  65645. */
  65646. set enableReflectivity(enable: boolean);
  65647. /**
  65648. * Gets the scene associated with the buffer.
  65649. */
  65650. get scene(): Scene;
  65651. /**
  65652. * Gets the ratio used by the buffer during its creation.
  65653. * How big is the buffer related to the main canvas.
  65654. */
  65655. get ratio(): number;
  65656. /** @hidden */
  65657. static _SceneComponentInitialization: (scene: Scene) => void;
  65658. /**
  65659. * Creates a new G Buffer for the scene
  65660. * @param scene The scene the buffer belongs to
  65661. * @param ratio How big is the buffer related to the main canvas.
  65662. */
  65663. constructor(scene: Scene, ratio?: number);
  65664. /**
  65665. * Checks wether everything is ready to render a submesh to the G buffer.
  65666. * @param subMesh the submesh to check readiness for
  65667. * @param useInstances is the mesh drawn using instance or not
  65668. * @returns true if ready otherwise false
  65669. */
  65670. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65671. /**
  65672. * Gets the current underlying G Buffer.
  65673. * @returns the buffer
  65674. */
  65675. getGBuffer(): MultiRenderTarget;
  65676. /**
  65677. * Gets the number of samples used to render the buffer (anti aliasing).
  65678. */
  65679. get samples(): number;
  65680. /**
  65681. * Sets the number of samples used to render the buffer (anti aliasing).
  65682. */
  65683. set samples(value: number);
  65684. /**
  65685. * Disposes the renderer and frees up associated resources.
  65686. */
  65687. dispose(): void;
  65688. protected _createRenderTargets(): void;
  65689. private _copyBonesTransformationMatrices;
  65690. }
  65691. }
  65692. declare module BABYLON {
  65693. interface Scene {
  65694. /** @hidden (Backing field) */
  65695. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65696. /**
  65697. * Gets or Sets the current geometry buffer associated to the scene.
  65698. */
  65699. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65700. /**
  65701. * Enables a GeometryBufferRender and associates it with the scene
  65702. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65703. * @returns the GeometryBufferRenderer
  65704. */
  65705. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65706. /**
  65707. * Disables the GeometryBufferRender associated with the scene
  65708. */
  65709. disableGeometryBufferRenderer(): void;
  65710. }
  65711. /**
  65712. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65713. * in several rendering techniques.
  65714. */
  65715. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65716. /**
  65717. * The component name helpful to identify the component in the list of scene components.
  65718. */
  65719. readonly name: string;
  65720. /**
  65721. * The scene the component belongs to.
  65722. */
  65723. scene: Scene;
  65724. /**
  65725. * Creates a new instance of the component for the given scene
  65726. * @param scene Defines the scene to register the component in
  65727. */
  65728. constructor(scene: Scene);
  65729. /**
  65730. * Registers the component in a given scene
  65731. */
  65732. register(): void;
  65733. /**
  65734. * Rebuilds the elements related to this component in case of
  65735. * context lost for instance.
  65736. */
  65737. rebuild(): void;
  65738. /**
  65739. * Disposes the component and the associated ressources
  65740. */
  65741. dispose(): void;
  65742. private _gatherRenderTargets;
  65743. }
  65744. }
  65745. declare module BABYLON {
  65746. /** @hidden */
  65747. export var motionBlurPixelShader: {
  65748. name: string;
  65749. shader: string;
  65750. };
  65751. }
  65752. declare module BABYLON {
  65753. /**
  65754. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65755. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65756. * As an example, all you have to do is to create the post-process:
  65757. * var mb = new BABYLON.MotionBlurPostProcess(
  65758. * 'mb', // The name of the effect.
  65759. * scene, // The scene containing the objects to blur according to their velocity.
  65760. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65761. * camera // The camera to apply the render pass to.
  65762. * );
  65763. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65764. */
  65765. export class MotionBlurPostProcess extends PostProcess {
  65766. /**
  65767. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65768. */
  65769. motionStrength: number;
  65770. /**
  65771. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65772. */
  65773. get motionBlurSamples(): number;
  65774. /**
  65775. * Sets the number of iterations to be used for motion blur quality
  65776. */
  65777. set motionBlurSamples(samples: number);
  65778. private _motionBlurSamples;
  65779. private _geometryBufferRenderer;
  65780. /**
  65781. * Creates a new instance MotionBlurPostProcess
  65782. * @param name The name of the effect.
  65783. * @param scene The scene containing the objects to blur according to their velocity.
  65784. * @param options The required width/height ratio to downsize to before computing the render pass.
  65785. * @param camera The camera to apply the render pass to.
  65786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65787. * @param engine The engine which the post process will be applied. (default: current engine)
  65788. * @param reusable If the post process can be reused on the same frame. (default: false)
  65789. * @param textureType Type of textures used when performing the post process. (default: 0)
  65790. * @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)
  65791. */
  65792. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65793. /**
  65794. * Excludes the given skinned mesh from computing bones velocities.
  65795. * 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.
  65796. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65797. */
  65798. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65799. /**
  65800. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65801. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65802. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65803. */
  65804. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65805. /**
  65806. * Disposes the post process.
  65807. * @param camera The camera to dispose the post process on.
  65808. */
  65809. dispose(camera?: Camera): void;
  65810. }
  65811. }
  65812. declare module BABYLON {
  65813. /** @hidden */
  65814. export var refractionPixelShader: {
  65815. name: string;
  65816. shader: string;
  65817. };
  65818. }
  65819. declare module BABYLON {
  65820. /**
  65821. * Post process which applies a refractin texture
  65822. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65823. */
  65824. export class RefractionPostProcess extends PostProcess {
  65825. /** the base color of the refraction (used to taint the rendering) */
  65826. color: Color3;
  65827. /** simulated refraction depth */
  65828. depth: number;
  65829. /** the coefficient of the base color (0 to remove base color tainting) */
  65830. colorLevel: number;
  65831. private _refTexture;
  65832. private _ownRefractionTexture;
  65833. /**
  65834. * Gets or sets the refraction texture
  65835. * Please note that you are responsible for disposing the texture if you set it manually
  65836. */
  65837. get refractionTexture(): Texture;
  65838. set refractionTexture(value: Texture);
  65839. /**
  65840. * Initializes the RefractionPostProcess
  65841. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65842. * @param name The name of the effect.
  65843. * @param refractionTextureUrl Url of the refraction texture to use
  65844. * @param color the base color of the refraction (used to taint the rendering)
  65845. * @param depth simulated refraction depth
  65846. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65847. * @param camera The camera to apply the render pass to.
  65848. * @param options The required width/height ratio to downsize to before computing the render pass.
  65849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65850. * @param engine The engine which the post process will be applied. (default: current engine)
  65851. * @param reusable If the post process can be reused on the same frame. (default: false)
  65852. */
  65853. constructor(name: string, refractionTextureUrl: string,
  65854. /** the base color of the refraction (used to taint the rendering) */
  65855. color: Color3,
  65856. /** simulated refraction depth */
  65857. depth: number,
  65858. /** the coefficient of the base color (0 to remove base color tainting) */
  65859. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65860. /**
  65861. * Disposes of the post process
  65862. * @param camera Camera to dispose post process on
  65863. */
  65864. dispose(camera: Camera): void;
  65865. }
  65866. }
  65867. declare module BABYLON {
  65868. /** @hidden */
  65869. export var sharpenPixelShader: {
  65870. name: string;
  65871. shader: string;
  65872. };
  65873. }
  65874. declare module BABYLON {
  65875. /**
  65876. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65877. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65878. */
  65879. export class SharpenPostProcess extends PostProcess {
  65880. /**
  65881. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65882. */
  65883. colorAmount: number;
  65884. /**
  65885. * How much sharpness should be applied (default: 0.3)
  65886. */
  65887. edgeAmount: number;
  65888. /**
  65889. * Creates a new instance ConvolutionPostProcess
  65890. * @param name The name of the effect.
  65891. * @param options The required width/height ratio to downsize to before computing the render pass.
  65892. * @param camera The camera to apply the render pass to.
  65893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65894. * @param engine The engine which the post process will be applied. (default: current engine)
  65895. * @param reusable If the post process can be reused on the same frame. (default: false)
  65896. * @param textureType Type of textures used when performing the post process. (default: 0)
  65897. * @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)
  65898. */
  65899. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65900. }
  65901. }
  65902. declare module BABYLON {
  65903. /**
  65904. * PostProcessRenderPipeline
  65905. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65906. */
  65907. export class PostProcessRenderPipeline {
  65908. private engine;
  65909. private _renderEffects;
  65910. private _renderEffectsForIsolatedPass;
  65911. /**
  65912. * List of inspectable custom properties (used by the Inspector)
  65913. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65914. */
  65915. inspectableCustomProperties: IInspectable[];
  65916. /**
  65917. * @hidden
  65918. */
  65919. protected _cameras: Camera[];
  65920. /** @hidden */
  65921. _name: string;
  65922. /**
  65923. * Gets pipeline name
  65924. */
  65925. get name(): string;
  65926. /** Gets the list of attached cameras */
  65927. get cameras(): Camera[];
  65928. /**
  65929. * Initializes a PostProcessRenderPipeline
  65930. * @param engine engine to add the pipeline to
  65931. * @param name name of the pipeline
  65932. */
  65933. constructor(engine: Engine, name: string);
  65934. /**
  65935. * Gets the class name
  65936. * @returns "PostProcessRenderPipeline"
  65937. */
  65938. getClassName(): string;
  65939. /**
  65940. * If all the render effects in the pipeline are supported
  65941. */
  65942. get isSupported(): boolean;
  65943. /**
  65944. * Adds an effect to the pipeline
  65945. * @param renderEffect the effect to add
  65946. */
  65947. addEffect(renderEffect: PostProcessRenderEffect): void;
  65948. /** @hidden */
  65949. _rebuild(): void;
  65950. /** @hidden */
  65951. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65952. /** @hidden */
  65953. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65954. /** @hidden */
  65955. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65956. /** @hidden */
  65957. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65958. /** @hidden */
  65959. _attachCameras(cameras: Camera, unique: boolean): void;
  65960. /** @hidden */
  65961. _attachCameras(cameras: Camera[], unique: boolean): void;
  65962. /** @hidden */
  65963. _detachCameras(cameras: Camera): void;
  65964. /** @hidden */
  65965. _detachCameras(cameras: Nullable<Camera[]>): void;
  65966. /** @hidden */
  65967. _update(): void;
  65968. /** @hidden */
  65969. _reset(): void;
  65970. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65971. /**
  65972. * Disposes of the pipeline
  65973. */
  65974. dispose(): void;
  65975. }
  65976. }
  65977. declare module BABYLON {
  65978. /**
  65979. * PostProcessRenderPipelineManager class
  65980. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65981. */
  65982. export class PostProcessRenderPipelineManager {
  65983. private _renderPipelines;
  65984. /**
  65985. * Initializes a PostProcessRenderPipelineManager
  65986. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65987. */
  65988. constructor();
  65989. /**
  65990. * Gets the list of supported render pipelines
  65991. */
  65992. get supportedPipelines(): PostProcessRenderPipeline[];
  65993. /**
  65994. * Adds a pipeline to the manager
  65995. * @param renderPipeline The pipeline to add
  65996. */
  65997. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65998. /**
  65999. * Attaches a camera to the pipeline
  66000. * @param renderPipelineName The name of the pipeline to attach to
  66001. * @param cameras the camera to attach
  66002. * @param unique if the camera can be attached multiple times to the pipeline
  66003. */
  66004. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  66005. /**
  66006. * Detaches a camera from the pipeline
  66007. * @param renderPipelineName The name of the pipeline to detach from
  66008. * @param cameras the camera to detach
  66009. */
  66010. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  66011. /**
  66012. * Enables an effect by name on a pipeline
  66013. * @param renderPipelineName the name of the pipeline to enable the effect in
  66014. * @param renderEffectName the name of the effect to enable
  66015. * @param cameras the cameras that the effect should be enabled on
  66016. */
  66017. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66018. /**
  66019. * Disables an effect by name on a pipeline
  66020. * @param renderPipelineName the name of the pipeline to disable the effect in
  66021. * @param renderEffectName the name of the effect to disable
  66022. * @param cameras the cameras that the effect should be disabled on
  66023. */
  66024. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66025. /**
  66026. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  66027. */
  66028. update(): void;
  66029. /** @hidden */
  66030. _rebuild(): void;
  66031. /**
  66032. * Disposes of the manager and pipelines
  66033. */
  66034. dispose(): void;
  66035. }
  66036. }
  66037. declare module BABYLON {
  66038. interface Scene {
  66039. /** @hidden (Backing field) */
  66040. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66041. /**
  66042. * Gets the postprocess render pipeline manager
  66043. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66044. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66045. */
  66046. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66047. }
  66048. /**
  66049. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66050. */
  66051. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66052. /**
  66053. * The component name helpfull to identify the component in the list of scene components.
  66054. */
  66055. readonly name: string;
  66056. /**
  66057. * The scene the component belongs to.
  66058. */
  66059. scene: Scene;
  66060. /**
  66061. * Creates a new instance of the component for the given scene
  66062. * @param scene Defines the scene to register the component in
  66063. */
  66064. constructor(scene: Scene);
  66065. /**
  66066. * Registers the component in a given scene
  66067. */
  66068. register(): void;
  66069. /**
  66070. * Rebuilds the elements related to this component in case of
  66071. * context lost for instance.
  66072. */
  66073. rebuild(): void;
  66074. /**
  66075. * Disposes the component and the associated ressources
  66076. */
  66077. dispose(): void;
  66078. private _gatherRenderTargets;
  66079. }
  66080. }
  66081. declare module BABYLON {
  66082. /**
  66083. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66084. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66085. */
  66086. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66087. private _scene;
  66088. private _camerasToBeAttached;
  66089. /**
  66090. * ID of the sharpen post process,
  66091. */
  66092. private readonly SharpenPostProcessId;
  66093. /**
  66094. * @ignore
  66095. * ID of the image processing post process;
  66096. */
  66097. readonly ImageProcessingPostProcessId: string;
  66098. /**
  66099. * @ignore
  66100. * ID of the Fast Approximate Anti-Aliasing post process;
  66101. */
  66102. readonly FxaaPostProcessId: string;
  66103. /**
  66104. * ID of the chromatic aberration post process,
  66105. */
  66106. private readonly ChromaticAberrationPostProcessId;
  66107. /**
  66108. * ID of the grain post process
  66109. */
  66110. private readonly GrainPostProcessId;
  66111. /**
  66112. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66113. */
  66114. sharpen: SharpenPostProcess;
  66115. private _sharpenEffect;
  66116. private bloom;
  66117. /**
  66118. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66119. */
  66120. depthOfField: DepthOfFieldEffect;
  66121. /**
  66122. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66123. */
  66124. fxaa: FxaaPostProcess;
  66125. /**
  66126. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66127. */
  66128. imageProcessing: ImageProcessingPostProcess;
  66129. /**
  66130. * Chromatic aberration post process which will shift rgb colors in the image
  66131. */
  66132. chromaticAberration: ChromaticAberrationPostProcess;
  66133. private _chromaticAberrationEffect;
  66134. /**
  66135. * Grain post process which add noise to the image
  66136. */
  66137. grain: GrainPostProcess;
  66138. private _grainEffect;
  66139. /**
  66140. * Glow post process which adds a glow to emissive areas of the image
  66141. */
  66142. private _glowLayer;
  66143. /**
  66144. * Animations which can be used to tweak settings over a period of time
  66145. */
  66146. animations: Animation[];
  66147. private _imageProcessingConfigurationObserver;
  66148. private _sharpenEnabled;
  66149. private _bloomEnabled;
  66150. private _depthOfFieldEnabled;
  66151. private _depthOfFieldBlurLevel;
  66152. private _fxaaEnabled;
  66153. private _imageProcessingEnabled;
  66154. private _defaultPipelineTextureType;
  66155. private _bloomScale;
  66156. private _chromaticAberrationEnabled;
  66157. private _grainEnabled;
  66158. private _buildAllowed;
  66159. /**
  66160. * Gets active scene
  66161. */
  66162. get scene(): Scene;
  66163. /**
  66164. * Enable or disable the sharpen process from the pipeline
  66165. */
  66166. set sharpenEnabled(enabled: boolean);
  66167. get sharpenEnabled(): boolean;
  66168. private _resizeObserver;
  66169. private _hardwareScaleLevel;
  66170. private _bloomKernel;
  66171. /**
  66172. * Specifies the size of the bloom blur kernel, relative to the final output size
  66173. */
  66174. get bloomKernel(): number;
  66175. set bloomKernel(value: number);
  66176. /**
  66177. * Specifies the weight of the bloom in the final rendering
  66178. */
  66179. private _bloomWeight;
  66180. /**
  66181. * Specifies the luma threshold for the area that will be blurred by the bloom
  66182. */
  66183. private _bloomThreshold;
  66184. private _hdr;
  66185. /**
  66186. * The strength of the bloom.
  66187. */
  66188. set bloomWeight(value: number);
  66189. get bloomWeight(): number;
  66190. /**
  66191. * The strength of the bloom.
  66192. */
  66193. set bloomThreshold(value: number);
  66194. get bloomThreshold(): number;
  66195. /**
  66196. * The scale of the bloom, lower value will provide better performance.
  66197. */
  66198. set bloomScale(value: number);
  66199. get bloomScale(): number;
  66200. /**
  66201. * Enable or disable the bloom from the pipeline
  66202. */
  66203. set bloomEnabled(enabled: boolean);
  66204. get bloomEnabled(): boolean;
  66205. private _rebuildBloom;
  66206. /**
  66207. * If the depth of field is enabled.
  66208. */
  66209. get depthOfFieldEnabled(): boolean;
  66210. set depthOfFieldEnabled(enabled: boolean);
  66211. /**
  66212. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66213. */
  66214. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66215. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66216. /**
  66217. * If the anti aliasing is enabled.
  66218. */
  66219. set fxaaEnabled(enabled: boolean);
  66220. get fxaaEnabled(): boolean;
  66221. private _samples;
  66222. /**
  66223. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66224. */
  66225. set samples(sampleCount: number);
  66226. get samples(): number;
  66227. /**
  66228. * If image processing is enabled.
  66229. */
  66230. set imageProcessingEnabled(enabled: boolean);
  66231. get imageProcessingEnabled(): boolean;
  66232. /**
  66233. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66234. */
  66235. set glowLayerEnabled(enabled: boolean);
  66236. get glowLayerEnabled(): boolean;
  66237. /**
  66238. * Gets the glow layer (or null if not defined)
  66239. */
  66240. get glowLayer(): Nullable<GlowLayer>;
  66241. /**
  66242. * Enable or disable the chromaticAberration process from the pipeline
  66243. */
  66244. set chromaticAberrationEnabled(enabled: boolean);
  66245. get chromaticAberrationEnabled(): boolean;
  66246. /**
  66247. * Enable or disable the grain process from the pipeline
  66248. */
  66249. set grainEnabled(enabled: boolean);
  66250. get grainEnabled(): boolean;
  66251. /**
  66252. * @constructor
  66253. * @param name - The rendering pipeline name (default: "")
  66254. * @param hdr - If high dynamic range textures should be used (default: true)
  66255. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66256. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66257. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66258. */
  66259. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66260. /**
  66261. * Get the class name
  66262. * @returns "DefaultRenderingPipeline"
  66263. */
  66264. getClassName(): string;
  66265. /**
  66266. * Force the compilation of the entire pipeline.
  66267. */
  66268. prepare(): void;
  66269. private _hasCleared;
  66270. private _prevPostProcess;
  66271. private _prevPrevPostProcess;
  66272. private _setAutoClearAndTextureSharing;
  66273. private _depthOfFieldSceneObserver;
  66274. private _buildPipeline;
  66275. private _disposePostProcesses;
  66276. /**
  66277. * Adds a camera to the pipeline
  66278. * @param camera the camera to be added
  66279. */
  66280. addCamera(camera: Camera): void;
  66281. /**
  66282. * Removes a camera from the pipeline
  66283. * @param camera the camera to remove
  66284. */
  66285. removeCamera(camera: Camera): void;
  66286. /**
  66287. * Dispose of the pipeline and stop all post processes
  66288. */
  66289. dispose(): void;
  66290. /**
  66291. * Serialize the rendering pipeline (Used when exporting)
  66292. * @returns the serialized object
  66293. */
  66294. serialize(): any;
  66295. /**
  66296. * Parse the serialized pipeline
  66297. * @param source Source pipeline.
  66298. * @param scene The scene to load the pipeline to.
  66299. * @param rootUrl The URL of the serialized pipeline.
  66300. * @returns An instantiated pipeline from the serialized object.
  66301. */
  66302. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66303. }
  66304. }
  66305. declare module BABYLON {
  66306. /** @hidden */
  66307. export var lensHighlightsPixelShader: {
  66308. name: string;
  66309. shader: string;
  66310. };
  66311. }
  66312. declare module BABYLON {
  66313. /** @hidden */
  66314. export var depthOfFieldPixelShader: {
  66315. name: string;
  66316. shader: string;
  66317. };
  66318. }
  66319. declare module BABYLON {
  66320. /**
  66321. * BABYLON.JS Chromatic Aberration GLSL Shader
  66322. * Author: Olivier Guyot
  66323. * Separates very slightly R, G and B colors on the edges of the screen
  66324. * Inspired by Francois Tarlier & Martins Upitis
  66325. */
  66326. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66327. /**
  66328. * @ignore
  66329. * The chromatic aberration PostProcess id in the pipeline
  66330. */
  66331. LensChromaticAberrationEffect: string;
  66332. /**
  66333. * @ignore
  66334. * The highlights enhancing PostProcess id in the pipeline
  66335. */
  66336. HighlightsEnhancingEffect: string;
  66337. /**
  66338. * @ignore
  66339. * The depth-of-field PostProcess id in the pipeline
  66340. */
  66341. LensDepthOfFieldEffect: string;
  66342. private _scene;
  66343. private _depthTexture;
  66344. private _grainTexture;
  66345. private _chromaticAberrationPostProcess;
  66346. private _highlightsPostProcess;
  66347. private _depthOfFieldPostProcess;
  66348. private _edgeBlur;
  66349. private _grainAmount;
  66350. private _chromaticAberration;
  66351. private _distortion;
  66352. private _highlightsGain;
  66353. private _highlightsThreshold;
  66354. private _dofDistance;
  66355. private _dofAperture;
  66356. private _dofDarken;
  66357. private _dofPentagon;
  66358. private _blurNoise;
  66359. /**
  66360. * @constructor
  66361. *
  66362. * Effect parameters are as follow:
  66363. * {
  66364. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66365. * edge_blur: number; // from 0 to x (1 for realism)
  66366. * distortion: number; // from 0 to x (1 for realism)
  66367. * grain_amount: number; // from 0 to 1
  66368. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66369. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66370. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66371. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66372. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66373. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66374. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66375. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66376. * }
  66377. * Note: if an effect parameter is unset, effect is disabled
  66378. *
  66379. * @param name The rendering pipeline name
  66380. * @param parameters - An object containing all parameters (see above)
  66381. * @param scene The scene linked to this pipeline
  66382. * @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)
  66383. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66384. */
  66385. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66386. /**
  66387. * Get the class name
  66388. * @returns "LensRenderingPipeline"
  66389. */
  66390. getClassName(): string;
  66391. /**
  66392. * Gets associated scene
  66393. */
  66394. get scene(): Scene;
  66395. /**
  66396. * Gets or sets the edge blur
  66397. */
  66398. get edgeBlur(): number;
  66399. set edgeBlur(value: number);
  66400. /**
  66401. * Gets or sets the grain amount
  66402. */
  66403. get grainAmount(): number;
  66404. set grainAmount(value: number);
  66405. /**
  66406. * Gets or sets the chromatic aberration amount
  66407. */
  66408. get chromaticAberration(): number;
  66409. set chromaticAberration(value: number);
  66410. /**
  66411. * Gets or sets the depth of field aperture
  66412. */
  66413. get dofAperture(): number;
  66414. set dofAperture(value: number);
  66415. /**
  66416. * Gets or sets the edge distortion
  66417. */
  66418. get edgeDistortion(): number;
  66419. set edgeDistortion(value: number);
  66420. /**
  66421. * Gets or sets the depth of field distortion
  66422. */
  66423. get dofDistortion(): number;
  66424. set dofDistortion(value: number);
  66425. /**
  66426. * Gets or sets the darken out of focus amount
  66427. */
  66428. get darkenOutOfFocus(): number;
  66429. set darkenOutOfFocus(value: number);
  66430. /**
  66431. * Gets or sets a boolean indicating if blur noise is enabled
  66432. */
  66433. get blurNoise(): boolean;
  66434. set blurNoise(value: boolean);
  66435. /**
  66436. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66437. */
  66438. get pentagonBokeh(): boolean;
  66439. set pentagonBokeh(value: boolean);
  66440. /**
  66441. * Gets or sets the highlight grain amount
  66442. */
  66443. get highlightsGain(): number;
  66444. set highlightsGain(value: number);
  66445. /**
  66446. * Gets or sets the highlight threshold
  66447. */
  66448. get highlightsThreshold(): number;
  66449. set highlightsThreshold(value: number);
  66450. /**
  66451. * Sets the amount of blur at the edges
  66452. * @param amount blur amount
  66453. */
  66454. setEdgeBlur(amount: number): void;
  66455. /**
  66456. * Sets edge blur to 0
  66457. */
  66458. disableEdgeBlur(): void;
  66459. /**
  66460. * Sets the amout of grain
  66461. * @param amount Amount of grain
  66462. */
  66463. setGrainAmount(amount: number): void;
  66464. /**
  66465. * Set grain amount to 0
  66466. */
  66467. disableGrain(): void;
  66468. /**
  66469. * Sets the chromatic aberration amount
  66470. * @param amount amount of chromatic aberration
  66471. */
  66472. setChromaticAberration(amount: number): void;
  66473. /**
  66474. * Sets chromatic aberration amount to 0
  66475. */
  66476. disableChromaticAberration(): void;
  66477. /**
  66478. * Sets the EdgeDistortion amount
  66479. * @param amount amount of EdgeDistortion
  66480. */
  66481. setEdgeDistortion(amount: number): void;
  66482. /**
  66483. * Sets edge distortion to 0
  66484. */
  66485. disableEdgeDistortion(): void;
  66486. /**
  66487. * Sets the FocusDistance amount
  66488. * @param amount amount of FocusDistance
  66489. */
  66490. setFocusDistance(amount: number): void;
  66491. /**
  66492. * Disables depth of field
  66493. */
  66494. disableDepthOfField(): void;
  66495. /**
  66496. * Sets the Aperture amount
  66497. * @param amount amount of Aperture
  66498. */
  66499. setAperture(amount: number): void;
  66500. /**
  66501. * Sets the DarkenOutOfFocus amount
  66502. * @param amount amount of DarkenOutOfFocus
  66503. */
  66504. setDarkenOutOfFocus(amount: number): void;
  66505. private _pentagonBokehIsEnabled;
  66506. /**
  66507. * Creates a pentagon bokeh effect
  66508. */
  66509. enablePentagonBokeh(): void;
  66510. /**
  66511. * Disables the pentagon bokeh effect
  66512. */
  66513. disablePentagonBokeh(): void;
  66514. /**
  66515. * Enables noise blur
  66516. */
  66517. enableNoiseBlur(): void;
  66518. /**
  66519. * Disables noise blur
  66520. */
  66521. disableNoiseBlur(): void;
  66522. /**
  66523. * Sets the HighlightsGain amount
  66524. * @param amount amount of HighlightsGain
  66525. */
  66526. setHighlightsGain(amount: number): void;
  66527. /**
  66528. * Sets the HighlightsThreshold amount
  66529. * @param amount amount of HighlightsThreshold
  66530. */
  66531. setHighlightsThreshold(amount: number): void;
  66532. /**
  66533. * Disables highlights
  66534. */
  66535. disableHighlights(): void;
  66536. /**
  66537. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66538. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66539. */
  66540. dispose(disableDepthRender?: boolean): void;
  66541. private _createChromaticAberrationPostProcess;
  66542. private _createHighlightsPostProcess;
  66543. private _createDepthOfFieldPostProcess;
  66544. private _createGrainTexture;
  66545. }
  66546. }
  66547. declare module BABYLON {
  66548. /** @hidden */
  66549. export var ssao2PixelShader: {
  66550. name: string;
  66551. shader: string;
  66552. };
  66553. }
  66554. declare module BABYLON {
  66555. /** @hidden */
  66556. export var ssaoCombinePixelShader: {
  66557. name: string;
  66558. shader: string;
  66559. };
  66560. }
  66561. declare module BABYLON {
  66562. /**
  66563. * Render pipeline to produce ssao effect
  66564. */
  66565. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66566. /**
  66567. * @ignore
  66568. * The PassPostProcess id in the pipeline that contains the original scene color
  66569. */
  66570. SSAOOriginalSceneColorEffect: string;
  66571. /**
  66572. * @ignore
  66573. * The SSAO PostProcess id in the pipeline
  66574. */
  66575. SSAORenderEffect: string;
  66576. /**
  66577. * @ignore
  66578. * The horizontal blur PostProcess id in the pipeline
  66579. */
  66580. SSAOBlurHRenderEffect: string;
  66581. /**
  66582. * @ignore
  66583. * The vertical blur PostProcess id in the pipeline
  66584. */
  66585. SSAOBlurVRenderEffect: string;
  66586. /**
  66587. * @ignore
  66588. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66589. */
  66590. SSAOCombineRenderEffect: string;
  66591. /**
  66592. * The output strength of the SSAO post-process. Default value is 1.0.
  66593. */
  66594. totalStrength: number;
  66595. /**
  66596. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66597. */
  66598. maxZ: number;
  66599. /**
  66600. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66601. */
  66602. minZAspect: number;
  66603. private _samples;
  66604. /**
  66605. * Number of samples used for the SSAO calculations. Default value is 8
  66606. */
  66607. set samples(n: number);
  66608. get samples(): number;
  66609. private _textureSamples;
  66610. /**
  66611. * Number of samples to use for antialiasing
  66612. */
  66613. set textureSamples(n: number);
  66614. get textureSamples(): number;
  66615. /**
  66616. * Ratio object used for SSAO ratio and blur ratio
  66617. */
  66618. private _ratio;
  66619. /**
  66620. * Dynamically generated sphere sampler.
  66621. */
  66622. private _sampleSphere;
  66623. /**
  66624. * Blur filter offsets
  66625. */
  66626. private _samplerOffsets;
  66627. private _expensiveBlur;
  66628. /**
  66629. * If bilateral blur should be used
  66630. */
  66631. set expensiveBlur(b: boolean);
  66632. get expensiveBlur(): boolean;
  66633. /**
  66634. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66635. */
  66636. radius: number;
  66637. /**
  66638. * The base color of the SSAO post-process
  66639. * The final result is "base + ssao" between [0, 1]
  66640. */
  66641. base: number;
  66642. /**
  66643. * Support test.
  66644. */
  66645. static get IsSupported(): boolean;
  66646. private _scene;
  66647. private _depthTexture;
  66648. private _normalTexture;
  66649. private _randomTexture;
  66650. private _originalColorPostProcess;
  66651. private _ssaoPostProcess;
  66652. private _blurHPostProcess;
  66653. private _blurVPostProcess;
  66654. private _ssaoCombinePostProcess;
  66655. /**
  66656. * Gets active scene
  66657. */
  66658. get scene(): Scene;
  66659. /**
  66660. * @constructor
  66661. * @param name The rendering pipeline name
  66662. * @param scene The scene linked to this pipeline
  66663. * @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 }
  66664. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66665. */
  66666. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66667. /**
  66668. * Get the class name
  66669. * @returns "SSAO2RenderingPipeline"
  66670. */
  66671. getClassName(): string;
  66672. /**
  66673. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66674. */
  66675. dispose(disableGeometryBufferRenderer?: boolean): void;
  66676. private _createBlurPostProcess;
  66677. /** @hidden */
  66678. _rebuild(): void;
  66679. private _bits;
  66680. private _radicalInverse_VdC;
  66681. private _hammersley;
  66682. private _hemisphereSample_uniform;
  66683. private _generateHemisphere;
  66684. private _createSSAOPostProcess;
  66685. private _createSSAOCombinePostProcess;
  66686. private _createRandomTexture;
  66687. /**
  66688. * Serialize the rendering pipeline (Used when exporting)
  66689. * @returns the serialized object
  66690. */
  66691. serialize(): any;
  66692. /**
  66693. * Parse the serialized pipeline
  66694. * @param source Source pipeline.
  66695. * @param scene The scene to load the pipeline to.
  66696. * @param rootUrl The URL of the serialized pipeline.
  66697. * @returns An instantiated pipeline from the serialized object.
  66698. */
  66699. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66700. }
  66701. }
  66702. declare module BABYLON {
  66703. /** @hidden */
  66704. export var ssaoPixelShader: {
  66705. name: string;
  66706. shader: string;
  66707. };
  66708. }
  66709. declare module BABYLON {
  66710. /**
  66711. * Render pipeline to produce ssao effect
  66712. */
  66713. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66714. /**
  66715. * @ignore
  66716. * The PassPostProcess id in the pipeline that contains the original scene color
  66717. */
  66718. SSAOOriginalSceneColorEffect: string;
  66719. /**
  66720. * @ignore
  66721. * The SSAO PostProcess id in the pipeline
  66722. */
  66723. SSAORenderEffect: string;
  66724. /**
  66725. * @ignore
  66726. * The horizontal blur PostProcess id in the pipeline
  66727. */
  66728. SSAOBlurHRenderEffect: string;
  66729. /**
  66730. * @ignore
  66731. * The vertical blur PostProcess id in the pipeline
  66732. */
  66733. SSAOBlurVRenderEffect: string;
  66734. /**
  66735. * @ignore
  66736. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66737. */
  66738. SSAOCombineRenderEffect: string;
  66739. /**
  66740. * The output strength of the SSAO post-process. Default value is 1.0.
  66741. */
  66742. totalStrength: number;
  66743. /**
  66744. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66745. */
  66746. radius: number;
  66747. /**
  66748. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66749. * Must not be equal to fallOff and superior to fallOff.
  66750. * Default value is 0.0075
  66751. */
  66752. area: number;
  66753. /**
  66754. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66755. * Must not be equal to area and inferior to area.
  66756. * Default value is 0.000001
  66757. */
  66758. fallOff: number;
  66759. /**
  66760. * The base color of the SSAO post-process
  66761. * The final result is "base + ssao" between [0, 1]
  66762. */
  66763. base: number;
  66764. private _scene;
  66765. private _depthTexture;
  66766. private _randomTexture;
  66767. private _originalColorPostProcess;
  66768. private _ssaoPostProcess;
  66769. private _blurHPostProcess;
  66770. private _blurVPostProcess;
  66771. private _ssaoCombinePostProcess;
  66772. private _firstUpdate;
  66773. /**
  66774. * Gets active scene
  66775. */
  66776. get scene(): Scene;
  66777. /**
  66778. * @constructor
  66779. * @param name - The rendering pipeline name
  66780. * @param scene - The scene linked to this pipeline
  66781. * @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 }
  66782. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66783. */
  66784. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66785. /**
  66786. * Get the class name
  66787. * @returns "SSAORenderingPipeline"
  66788. */
  66789. getClassName(): string;
  66790. /**
  66791. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66792. */
  66793. dispose(disableDepthRender?: boolean): void;
  66794. private _createBlurPostProcess;
  66795. /** @hidden */
  66796. _rebuild(): void;
  66797. private _createSSAOPostProcess;
  66798. private _createSSAOCombinePostProcess;
  66799. private _createRandomTexture;
  66800. }
  66801. }
  66802. declare module BABYLON {
  66803. /** @hidden */
  66804. export var screenSpaceReflectionPixelShader: {
  66805. name: string;
  66806. shader: string;
  66807. };
  66808. }
  66809. declare module BABYLON {
  66810. /**
  66811. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66812. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66813. */
  66814. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66815. /**
  66816. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66817. */
  66818. threshold: number;
  66819. /**
  66820. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66821. */
  66822. strength: number;
  66823. /**
  66824. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66825. */
  66826. reflectionSpecularFalloffExponent: number;
  66827. /**
  66828. * 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]
  66829. */
  66830. step: number;
  66831. /**
  66832. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66833. */
  66834. roughnessFactor: number;
  66835. private _geometryBufferRenderer;
  66836. private _enableSmoothReflections;
  66837. private _reflectionSamples;
  66838. private _smoothSteps;
  66839. /**
  66840. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66841. * @param name The name of the effect.
  66842. * @param scene The scene containing the objects to calculate reflections.
  66843. * @param options The required width/height ratio to downsize to before computing the render pass.
  66844. * @param camera The camera to apply the render pass to.
  66845. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66846. * @param engine The engine which the post process will be applied. (default: current engine)
  66847. * @param reusable If the post process can be reused on the same frame. (default: false)
  66848. * @param textureType Type of textures used when performing the post process. (default: 0)
  66849. * @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)
  66850. */
  66851. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66852. /**
  66853. * Gets wether or not smoothing reflections is enabled.
  66854. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66855. */
  66856. get enableSmoothReflections(): boolean;
  66857. /**
  66858. * Sets wether or not smoothing reflections is enabled.
  66859. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66860. */
  66861. set enableSmoothReflections(enabled: boolean);
  66862. /**
  66863. * Gets the number of samples taken while computing reflections. More samples count is high,
  66864. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66865. */
  66866. get reflectionSamples(): number;
  66867. /**
  66868. * Sets the number of samples taken while computing reflections. More samples count is high,
  66869. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66870. */
  66871. set reflectionSamples(samples: number);
  66872. /**
  66873. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66874. * more the post-process will require GPU power and can generate a drop in FPS.
  66875. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66876. */
  66877. get smoothSteps(): number;
  66878. set smoothSteps(steps: number);
  66879. private _updateEffectDefines;
  66880. }
  66881. }
  66882. declare module BABYLON {
  66883. /** @hidden */
  66884. export var standardPixelShader: {
  66885. name: string;
  66886. shader: string;
  66887. };
  66888. }
  66889. declare module BABYLON {
  66890. /**
  66891. * Standard rendering pipeline
  66892. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66893. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66894. */
  66895. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66896. /**
  66897. * Public members
  66898. */
  66899. /**
  66900. * Post-process which contains the original scene color before the pipeline applies all the effects
  66901. */
  66902. originalPostProcess: Nullable<PostProcess>;
  66903. /**
  66904. * Post-process used to down scale an image x4
  66905. */
  66906. downSampleX4PostProcess: Nullable<PostProcess>;
  66907. /**
  66908. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66909. */
  66910. brightPassPostProcess: Nullable<PostProcess>;
  66911. /**
  66912. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66913. */
  66914. blurHPostProcesses: PostProcess[];
  66915. /**
  66916. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66917. */
  66918. blurVPostProcesses: PostProcess[];
  66919. /**
  66920. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66921. */
  66922. textureAdderPostProcess: Nullable<PostProcess>;
  66923. /**
  66924. * Post-process used to create volumetric lighting effect
  66925. */
  66926. volumetricLightPostProcess: Nullable<PostProcess>;
  66927. /**
  66928. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66929. */
  66930. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66931. /**
  66932. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66933. */
  66934. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66935. /**
  66936. * Post-process used to merge the volumetric light effect and the real scene color
  66937. */
  66938. volumetricLightMergePostProces: Nullable<PostProcess>;
  66939. /**
  66940. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66941. */
  66942. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66943. /**
  66944. * Base post-process used to calculate the average luminance of the final image for HDR
  66945. */
  66946. luminancePostProcess: Nullable<PostProcess>;
  66947. /**
  66948. * Post-processes used to create down sample post-processes in order to get
  66949. * the average luminance of the final image for HDR
  66950. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66951. */
  66952. luminanceDownSamplePostProcesses: PostProcess[];
  66953. /**
  66954. * Post-process used to create a HDR effect (light adaptation)
  66955. */
  66956. hdrPostProcess: Nullable<PostProcess>;
  66957. /**
  66958. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66959. */
  66960. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66961. /**
  66962. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66963. */
  66964. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66965. /**
  66966. * Post-process used to merge the final HDR post-process and the real scene color
  66967. */
  66968. hdrFinalPostProcess: Nullable<PostProcess>;
  66969. /**
  66970. * Post-process used to create a lens flare effect
  66971. */
  66972. lensFlarePostProcess: Nullable<PostProcess>;
  66973. /**
  66974. * Post-process that merges the result of the lens flare post-process and the real scene color
  66975. */
  66976. lensFlareComposePostProcess: Nullable<PostProcess>;
  66977. /**
  66978. * Post-process used to create a motion blur effect
  66979. */
  66980. motionBlurPostProcess: Nullable<PostProcess>;
  66981. /**
  66982. * Post-process used to create a depth of field effect
  66983. */
  66984. depthOfFieldPostProcess: Nullable<PostProcess>;
  66985. /**
  66986. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66987. */
  66988. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66989. /**
  66990. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66991. */
  66992. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66993. /**
  66994. * Represents the brightness threshold in order to configure the illuminated surfaces
  66995. */
  66996. brightThreshold: number;
  66997. /**
  66998. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66999. */
  67000. blurWidth: number;
  67001. /**
  67002. * Sets if the blur for highlighted surfaces must be only horizontal
  67003. */
  67004. horizontalBlur: boolean;
  67005. /**
  67006. * Gets the overall exposure used by the pipeline
  67007. */
  67008. get exposure(): number;
  67009. /**
  67010. * Sets the overall exposure used by the pipeline
  67011. */
  67012. set exposure(value: number);
  67013. /**
  67014. * Texture used typically to simulate "dirty" on camera lens
  67015. */
  67016. lensTexture: Nullable<Texture>;
  67017. /**
  67018. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  67019. */
  67020. volumetricLightCoefficient: number;
  67021. /**
  67022. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  67023. */
  67024. volumetricLightPower: number;
  67025. /**
  67026. * Used the set the blur intensity to smooth the volumetric lights
  67027. */
  67028. volumetricLightBlurScale: number;
  67029. /**
  67030. * Light (spot or directional) used to generate the volumetric lights rays
  67031. * The source light must have a shadow generate so the pipeline can get its
  67032. * depth map
  67033. */
  67034. sourceLight: Nullable<SpotLight | DirectionalLight>;
  67035. /**
  67036. * For eye adaptation, represents the minimum luminance the eye can see
  67037. */
  67038. hdrMinimumLuminance: number;
  67039. /**
  67040. * For eye adaptation, represents the decrease luminance speed
  67041. */
  67042. hdrDecreaseRate: number;
  67043. /**
  67044. * For eye adaptation, represents the increase luminance speed
  67045. */
  67046. hdrIncreaseRate: number;
  67047. /**
  67048. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67049. */
  67050. get hdrAutoExposure(): boolean;
  67051. /**
  67052. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67053. */
  67054. set hdrAutoExposure(value: boolean);
  67055. /**
  67056. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  67057. */
  67058. lensColorTexture: Nullable<Texture>;
  67059. /**
  67060. * The overall strengh for the lens flare effect
  67061. */
  67062. lensFlareStrength: number;
  67063. /**
  67064. * Dispersion coefficient for lens flare ghosts
  67065. */
  67066. lensFlareGhostDispersal: number;
  67067. /**
  67068. * Main lens flare halo width
  67069. */
  67070. lensFlareHaloWidth: number;
  67071. /**
  67072. * Based on the lens distortion effect, defines how much the lens flare result
  67073. * is distorted
  67074. */
  67075. lensFlareDistortionStrength: number;
  67076. /**
  67077. * Configures the blur intensity used for for lens flare (halo)
  67078. */
  67079. lensFlareBlurWidth: number;
  67080. /**
  67081. * Lens star texture must be used to simulate rays on the flares and is available
  67082. * in the documentation
  67083. */
  67084. lensStarTexture: Nullable<Texture>;
  67085. /**
  67086. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67087. * flare effect by taking account of the dirt texture
  67088. */
  67089. lensFlareDirtTexture: Nullable<Texture>;
  67090. /**
  67091. * Represents the focal length for the depth of field effect
  67092. */
  67093. depthOfFieldDistance: number;
  67094. /**
  67095. * Represents the blur intensity for the blurred part of the depth of field effect
  67096. */
  67097. depthOfFieldBlurWidth: number;
  67098. /**
  67099. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67100. */
  67101. get motionStrength(): number;
  67102. /**
  67103. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67104. */
  67105. set motionStrength(strength: number);
  67106. /**
  67107. * Gets wether or not the motion blur post-process is object based or screen based.
  67108. */
  67109. get objectBasedMotionBlur(): boolean;
  67110. /**
  67111. * Sets wether or not the motion blur post-process should be object based or screen based
  67112. */
  67113. set objectBasedMotionBlur(value: boolean);
  67114. /**
  67115. * List of animations for the pipeline (IAnimatable implementation)
  67116. */
  67117. animations: Animation[];
  67118. /**
  67119. * Private members
  67120. */
  67121. private _scene;
  67122. private _currentDepthOfFieldSource;
  67123. private _basePostProcess;
  67124. private _fixedExposure;
  67125. private _currentExposure;
  67126. private _hdrAutoExposure;
  67127. private _hdrCurrentLuminance;
  67128. private _motionStrength;
  67129. private _isObjectBasedMotionBlur;
  67130. private _floatTextureType;
  67131. private _camerasToBeAttached;
  67132. private _ratio;
  67133. private _bloomEnabled;
  67134. private _depthOfFieldEnabled;
  67135. private _vlsEnabled;
  67136. private _lensFlareEnabled;
  67137. private _hdrEnabled;
  67138. private _motionBlurEnabled;
  67139. private _fxaaEnabled;
  67140. private _screenSpaceReflectionsEnabled;
  67141. private _motionBlurSamples;
  67142. private _volumetricLightStepsCount;
  67143. private _samples;
  67144. /**
  67145. * @ignore
  67146. * Specifies if the bloom pipeline is enabled
  67147. */
  67148. get BloomEnabled(): boolean;
  67149. set BloomEnabled(enabled: boolean);
  67150. /**
  67151. * @ignore
  67152. * Specifies if the depth of field pipeline is enabed
  67153. */
  67154. get DepthOfFieldEnabled(): boolean;
  67155. set DepthOfFieldEnabled(enabled: boolean);
  67156. /**
  67157. * @ignore
  67158. * Specifies if the lens flare pipeline is enabed
  67159. */
  67160. get LensFlareEnabled(): boolean;
  67161. set LensFlareEnabled(enabled: boolean);
  67162. /**
  67163. * @ignore
  67164. * Specifies if the HDR pipeline is enabled
  67165. */
  67166. get HDREnabled(): boolean;
  67167. set HDREnabled(enabled: boolean);
  67168. /**
  67169. * @ignore
  67170. * Specifies if the volumetric lights scattering effect is enabled
  67171. */
  67172. get VLSEnabled(): boolean;
  67173. set VLSEnabled(enabled: boolean);
  67174. /**
  67175. * @ignore
  67176. * Specifies if the motion blur effect is enabled
  67177. */
  67178. get MotionBlurEnabled(): boolean;
  67179. set MotionBlurEnabled(enabled: boolean);
  67180. /**
  67181. * Specifies if anti-aliasing is enabled
  67182. */
  67183. get fxaaEnabled(): boolean;
  67184. set fxaaEnabled(enabled: boolean);
  67185. /**
  67186. * Specifies if screen space reflections are enabled.
  67187. */
  67188. get screenSpaceReflectionsEnabled(): boolean;
  67189. set screenSpaceReflectionsEnabled(enabled: boolean);
  67190. /**
  67191. * Specifies the number of steps used to calculate the volumetric lights
  67192. * Typically in interval [50, 200]
  67193. */
  67194. get volumetricLightStepsCount(): number;
  67195. set volumetricLightStepsCount(count: number);
  67196. /**
  67197. * Specifies the number of samples used for the motion blur effect
  67198. * Typically in interval [16, 64]
  67199. */
  67200. get motionBlurSamples(): number;
  67201. set motionBlurSamples(samples: number);
  67202. /**
  67203. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67204. */
  67205. get samples(): number;
  67206. set samples(sampleCount: number);
  67207. /**
  67208. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67209. * @constructor
  67210. * @param name The rendering pipeline name
  67211. * @param scene The scene linked to this pipeline
  67212. * @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)
  67213. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67214. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67215. */
  67216. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67217. private _buildPipeline;
  67218. private _createDownSampleX4PostProcess;
  67219. private _createBrightPassPostProcess;
  67220. private _createBlurPostProcesses;
  67221. private _createTextureAdderPostProcess;
  67222. private _createVolumetricLightPostProcess;
  67223. private _createLuminancePostProcesses;
  67224. private _createHdrPostProcess;
  67225. private _createLensFlarePostProcess;
  67226. private _createDepthOfFieldPostProcess;
  67227. private _createMotionBlurPostProcess;
  67228. private _getDepthTexture;
  67229. private _disposePostProcesses;
  67230. /**
  67231. * Dispose of the pipeline and stop all post processes
  67232. */
  67233. dispose(): void;
  67234. /**
  67235. * Serialize the rendering pipeline (Used when exporting)
  67236. * @returns the serialized object
  67237. */
  67238. serialize(): any;
  67239. /**
  67240. * Parse the serialized pipeline
  67241. * @param source Source pipeline.
  67242. * @param scene The scene to load the pipeline to.
  67243. * @param rootUrl The URL of the serialized pipeline.
  67244. * @returns An instantiated pipeline from the serialized object.
  67245. */
  67246. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67247. /**
  67248. * Luminance steps
  67249. */
  67250. static LuminanceSteps: number;
  67251. }
  67252. }
  67253. declare module BABYLON {
  67254. /** @hidden */
  67255. export var stereoscopicInterlacePixelShader: {
  67256. name: string;
  67257. shader: string;
  67258. };
  67259. }
  67260. declare module BABYLON {
  67261. /**
  67262. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  67263. */
  67264. export class StereoscopicInterlacePostProcessI extends PostProcess {
  67265. private _stepSize;
  67266. private _passedProcess;
  67267. /**
  67268. * Initializes a StereoscopicInterlacePostProcessI
  67269. * @param name The name of the effect.
  67270. * @param rigCameras The rig cameras to be appled to the post process
  67271. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  67272. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  67273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67274. * @param engine The engine which the post process will be applied. (default: current engine)
  67275. * @param reusable If the post process can be reused on the same frame. (default: false)
  67276. */
  67277. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67278. }
  67279. /**
  67280. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  67281. */
  67282. export class StereoscopicInterlacePostProcess extends PostProcess {
  67283. private _stepSize;
  67284. private _passedProcess;
  67285. /**
  67286. * Initializes a StereoscopicInterlacePostProcess
  67287. * @param name The name of the effect.
  67288. * @param rigCameras The rig cameras to be appled to the post process
  67289. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  67290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67291. * @param engine The engine which the post process will be applied. (default: current engine)
  67292. * @param reusable If the post process can be reused on the same frame. (default: false)
  67293. */
  67294. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67295. }
  67296. }
  67297. declare module BABYLON {
  67298. /** @hidden */
  67299. export var tonemapPixelShader: {
  67300. name: string;
  67301. shader: string;
  67302. };
  67303. }
  67304. declare module BABYLON {
  67305. /** Defines operator used for tonemapping */
  67306. export enum TonemappingOperator {
  67307. /** Hable */
  67308. Hable = 0,
  67309. /** Reinhard */
  67310. Reinhard = 1,
  67311. /** HejiDawson */
  67312. HejiDawson = 2,
  67313. /** Photographic */
  67314. Photographic = 3
  67315. }
  67316. /**
  67317. * Defines a post process to apply tone mapping
  67318. */
  67319. export class TonemapPostProcess extends PostProcess {
  67320. private _operator;
  67321. /** Defines the required exposure adjustement */
  67322. exposureAdjustment: number;
  67323. /**
  67324. * Creates a new TonemapPostProcess
  67325. * @param name defines the name of the postprocess
  67326. * @param _operator defines the operator to use
  67327. * @param exposureAdjustment defines the required exposure adjustement
  67328. * @param camera defines the camera to use (can be null)
  67329. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67330. * @param engine defines the hosting engine (can be ignore if camera is set)
  67331. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67332. */
  67333. constructor(name: string, _operator: TonemappingOperator,
  67334. /** Defines the required exposure adjustement */
  67335. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67336. }
  67337. }
  67338. declare module BABYLON {
  67339. /** @hidden */
  67340. export var volumetricLightScatteringPixelShader: {
  67341. name: string;
  67342. shader: string;
  67343. };
  67344. }
  67345. declare module BABYLON {
  67346. /** @hidden */
  67347. export var volumetricLightScatteringPassVertexShader: {
  67348. name: string;
  67349. shader: string;
  67350. };
  67351. }
  67352. declare module BABYLON {
  67353. /** @hidden */
  67354. export var volumetricLightScatteringPassPixelShader: {
  67355. name: string;
  67356. shader: string;
  67357. };
  67358. }
  67359. declare module BABYLON {
  67360. /**
  67361. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67362. */
  67363. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67364. private _volumetricLightScatteringPass;
  67365. private _volumetricLightScatteringRTT;
  67366. private _viewPort;
  67367. private _screenCoordinates;
  67368. private _cachedDefines;
  67369. /**
  67370. * If not undefined, the mesh position is computed from the attached node position
  67371. */
  67372. attachedNode: {
  67373. position: Vector3;
  67374. };
  67375. /**
  67376. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67377. */
  67378. customMeshPosition: Vector3;
  67379. /**
  67380. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67381. */
  67382. useCustomMeshPosition: boolean;
  67383. /**
  67384. * If the post-process should inverse the light scattering direction
  67385. */
  67386. invert: boolean;
  67387. /**
  67388. * The internal mesh used by the post-process
  67389. */
  67390. mesh: Mesh;
  67391. /**
  67392. * @hidden
  67393. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67394. */
  67395. get useDiffuseColor(): boolean;
  67396. set useDiffuseColor(useDiffuseColor: boolean);
  67397. /**
  67398. * Array containing the excluded meshes not rendered in the internal pass
  67399. */
  67400. excludedMeshes: AbstractMesh[];
  67401. /**
  67402. * Controls the overall intensity of the post-process
  67403. */
  67404. exposure: number;
  67405. /**
  67406. * Dissipates each sample's contribution in range [0, 1]
  67407. */
  67408. decay: number;
  67409. /**
  67410. * Controls the overall intensity of each sample
  67411. */
  67412. weight: number;
  67413. /**
  67414. * Controls the density of each sample
  67415. */
  67416. density: number;
  67417. /**
  67418. * @constructor
  67419. * @param name The post-process name
  67420. * @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)
  67421. * @param camera The camera that the post-process will be attached to
  67422. * @param mesh The mesh used to create the light scattering
  67423. * @param samples The post-process quality, default 100
  67424. * @param samplingModeThe post-process filtering mode
  67425. * @param engine The babylon engine
  67426. * @param reusable If the post-process is reusable
  67427. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67428. */
  67429. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67430. /**
  67431. * Returns the string "VolumetricLightScatteringPostProcess"
  67432. * @returns "VolumetricLightScatteringPostProcess"
  67433. */
  67434. getClassName(): string;
  67435. private _isReady;
  67436. /**
  67437. * Sets the new light position for light scattering effect
  67438. * @param position The new custom light position
  67439. */
  67440. setCustomMeshPosition(position: Vector3): void;
  67441. /**
  67442. * Returns the light position for light scattering effect
  67443. * @return Vector3 The custom light position
  67444. */
  67445. getCustomMeshPosition(): Vector3;
  67446. /**
  67447. * Disposes the internal assets and detaches the post-process from the camera
  67448. */
  67449. dispose(camera: Camera): void;
  67450. /**
  67451. * Returns the render target texture used by the post-process
  67452. * @return the render target texture used by the post-process
  67453. */
  67454. getPass(): RenderTargetTexture;
  67455. private _meshExcluded;
  67456. private _createPass;
  67457. private _updateMeshScreenCoordinates;
  67458. /**
  67459. * Creates a default mesh for the Volumeric Light Scattering post-process
  67460. * @param name The mesh name
  67461. * @param scene The scene where to create the mesh
  67462. * @return the default mesh
  67463. */
  67464. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67465. }
  67466. }
  67467. declare module BABYLON {
  67468. interface Scene {
  67469. /** @hidden (Backing field) */
  67470. _boundingBoxRenderer: BoundingBoxRenderer;
  67471. /** @hidden (Backing field) */
  67472. _forceShowBoundingBoxes: boolean;
  67473. /**
  67474. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67475. */
  67476. forceShowBoundingBoxes: boolean;
  67477. /**
  67478. * Gets the bounding box renderer associated with the scene
  67479. * @returns a BoundingBoxRenderer
  67480. */
  67481. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67482. }
  67483. interface AbstractMesh {
  67484. /** @hidden (Backing field) */
  67485. _showBoundingBox: boolean;
  67486. /**
  67487. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67488. */
  67489. showBoundingBox: boolean;
  67490. }
  67491. /**
  67492. * Component responsible of rendering the bounding box of the meshes in a scene.
  67493. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67494. */
  67495. export class BoundingBoxRenderer implements ISceneComponent {
  67496. /**
  67497. * The component name helpfull to identify the component in the list of scene components.
  67498. */
  67499. readonly name: string;
  67500. /**
  67501. * The scene the component belongs to.
  67502. */
  67503. scene: Scene;
  67504. /**
  67505. * Color of the bounding box lines placed in front of an object
  67506. */
  67507. frontColor: Color3;
  67508. /**
  67509. * Color of the bounding box lines placed behind an object
  67510. */
  67511. backColor: Color3;
  67512. /**
  67513. * Defines if the renderer should show the back lines or not
  67514. */
  67515. showBackLines: boolean;
  67516. /**
  67517. * @hidden
  67518. */
  67519. renderList: SmartArray<BoundingBox>;
  67520. private _colorShader;
  67521. private _vertexBuffers;
  67522. private _indexBuffer;
  67523. private _fillIndexBuffer;
  67524. private _fillIndexData;
  67525. /**
  67526. * Instantiates a new bounding box renderer in a scene.
  67527. * @param scene the scene the renderer renders in
  67528. */
  67529. constructor(scene: Scene);
  67530. /**
  67531. * Registers the component in a given scene
  67532. */
  67533. register(): void;
  67534. private _evaluateSubMesh;
  67535. private _activeMesh;
  67536. private _prepareRessources;
  67537. private _createIndexBuffer;
  67538. /**
  67539. * Rebuilds the elements related to this component in case of
  67540. * context lost for instance.
  67541. */
  67542. rebuild(): void;
  67543. /**
  67544. * @hidden
  67545. */
  67546. reset(): void;
  67547. /**
  67548. * Render the bounding boxes of a specific rendering group
  67549. * @param renderingGroupId defines the rendering group to render
  67550. */
  67551. render(renderingGroupId: number): void;
  67552. /**
  67553. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67554. * @param mesh Define the mesh to render the occlusion bounding box for
  67555. */
  67556. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67557. /**
  67558. * Dispose and release the resources attached to this renderer.
  67559. */
  67560. dispose(): void;
  67561. }
  67562. }
  67563. declare module BABYLON {
  67564. interface Scene {
  67565. /** @hidden (Backing field) */
  67566. _depthRenderer: {
  67567. [id: string]: DepthRenderer;
  67568. };
  67569. /**
  67570. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67571. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67572. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67573. * @returns the created depth renderer
  67574. */
  67575. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67576. /**
  67577. * Disables a depth renderer for a given camera
  67578. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67579. */
  67580. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67581. }
  67582. /**
  67583. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67584. * in several rendering techniques.
  67585. */
  67586. export class DepthRendererSceneComponent implements ISceneComponent {
  67587. /**
  67588. * The component name helpfull to identify the component in the list of scene components.
  67589. */
  67590. readonly name: string;
  67591. /**
  67592. * The scene the component belongs to.
  67593. */
  67594. scene: Scene;
  67595. /**
  67596. * Creates a new instance of the component for the given scene
  67597. * @param scene Defines the scene to register the component in
  67598. */
  67599. constructor(scene: Scene);
  67600. /**
  67601. * Registers the component in a given scene
  67602. */
  67603. register(): void;
  67604. /**
  67605. * Rebuilds the elements related to this component in case of
  67606. * context lost for instance.
  67607. */
  67608. rebuild(): void;
  67609. /**
  67610. * Disposes the component and the associated ressources
  67611. */
  67612. dispose(): void;
  67613. private _gatherRenderTargets;
  67614. private _gatherActiveCameraRenderTargets;
  67615. }
  67616. }
  67617. declare module BABYLON {
  67618. /** @hidden */
  67619. export var outlinePixelShader: {
  67620. name: string;
  67621. shader: string;
  67622. };
  67623. }
  67624. declare module BABYLON {
  67625. /** @hidden */
  67626. export var outlineVertexShader: {
  67627. name: string;
  67628. shader: string;
  67629. };
  67630. }
  67631. declare module BABYLON {
  67632. interface Scene {
  67633. /** @hidden */
  67634. _outlineRenderer: OutlineRenderer;
  67635. /**
  67636. * Gets the outline renderer associated with the scene
  67637. * @returns a OutlineRenderer
  67638. */
  67639. getOutlineRenderer(): OutlineRenderer;
  67640. }
  67641. interface AbstractMesh {
  67642. /** @hidden (Backing field) */
  67643. _renderOutline: boolean;
  67644. /**
  67645. * Gets or sets a boolean indicating if the outline must be rendered as well
  67646. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67647. */
  67648. renderOutline: boolean;
  67649. /** @hidden (Backing field) */
  67650. _renderOverlay: boolean;
  67651. /**
  67652. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67653. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67654. */
  67655. renderOverlay: boolean;
  67656. }
  67657. /**
  67658. * This class is responsible to draw bothe outline/overlay of meshes.
  67659. * It should not be used directly but through the available method on mesh.
  67660. */
  67661. export class OutlineRenderer implements ISceneComponent {
  67662. /**
  67663. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67664. */
  67665. private static _StencilReference;
  67666. /**
  67667. * The name of the component. Each component must have a unique name.
  67668. */
  67669. name: string;
  67670. /**
  67671. * The scene the component belongs to.
  67672. */
  67673. scene: Scene;
  67674. /**
  67675. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67676. */
  67677. zOffset: number;
  67678. private _engine;
  67679. private _effect;
  67680. private _cachedDefines;
  67681. private _savedDepthWrite;
  67682. /**
  67683. * Instantiates a new outline renderer. (There could be only one per scene).
  67684. * @param scene Defines the scene it belongs to
  67685. */
  67686. constructor(scene: Scene);
  67687. /**
  67688. * Register the component to one instance of a scene.
  67689. */
  67690. register(): void;
  67691. /**
  67692. * Rebuilds the elements related to this component in case of
  67693. * context lost for instance.
  67694. */
  67695. rebuild(): void;
  67696. /**
  67697. * Disposes the component and the associated ressources.
  67698. */
  67699. dispose(): void;
  67700. /**
  67701. * Renders the outline in the canvas.
  67702. * @param subMesh Defines the sumesh to render
  67703. * @param batch Defines the batch of meshes in case of instances
  67704. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67705. */
  67706. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67707. /**
  67708. * Returns whether or not the outline renderer is ready for a given submesh.
  67709. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67710. * @param subMesh Defines the submesh to check readyness for
  67711. * @param useInstances Defines wheter wee are trying to render instances or not
  67712. * @returns true if ready otherwise false
  67713. */
  67714. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67715. private _beforeRenderingMesh;
  67716. private _afterRenderingMesh;
  67717. }
  67718. }
  67719. declare module BABYLON {
  67720. /**
  67721. * Defines the basic options interface of a Sprite Frame Source Size.
  67722. */
  67723. export interface ISpriteJSONSpriteSourceSize {
  67724. /**
  67725. * number of the original width of the Frame
  67726. */
  67727. w: number;
  67728. /**
  67729. * number of the original height of the Frame
  67730. */
  67731. h: number;
  67732. }
  67733. /**
  67734. * Defines the basic options interface of a Sprite Frame Data.
  67735. */
  67736. export interface ISpriteJSONSpriteFrameData {
  67737. /**
  67738. * number of the x offset of the Frame
  67739. */
  67740. x: number;
  67741. /**
  67742. * number of the y offset of the Frame
  67743. */
  67744. y: number;
  67745. /**
  67746. * number of the width of the Frame
  67747. */
  67748. w: number;
  67749. /**
  67750. * number of the height of the Frame
  67751. */
  67752. h: number;
  67753. }
  67754. /**
  67755. * Defines the basic options interface of a JSON Sprite.
  67756. */
  67757. export interface ISpriteJSONSprite {
  67758. /**
  67759. * string name of the Frame
  67760. */
  67761. filename: string;
  67762. /**
  67763. * ISpriteJSONSpriteFrame basic object of the frame data
  67764. */
  67765. frame: ISpriteJSONSpriteFrameData;
  67766. /**
  67767. * boolean to flag is the frame was rotated.
  67768. */
  67769. rotated: boolean;
  67770. /**
  67771. * boolean to flag is the frame was trimmed.
  67772. */
  67773. trimmed: boolean;
  67774. /**
  67775. * ISpriteJSONSpriteFrame basic object of the source data
  67776. */
  67777. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67778. /**
  67779. * ISpriteJSONSpriteFrame basic object of the source data
  67780. */
  67781. sourceSize: ISpriteJSONSpriteSourceSize;
  67782. }
  67783. /**
  67784. * Defines the basic options interface of a JSON atlas.
  67785. */
  67786. export interface ISpriteJSONAtlas {
  67787. /**
  67788. * Array of objects that contain the frame data.
  67789. */
  67790. frames: Array<ISpriteJSONSprite>;
  67791. /**
  67792. * object basic object containing the sprite meta data.
  67793. */
  67794. meta?: object;
  67795. }
  67796. }
  67797. declare module BABYLON {
  67798. /** @hidden */
  67799. export var spriteMapPixelShader: {
  67800. name: string;
  67801. shader: string;
  67802. };
  67803. }
  67804. declare module BABYLON {
  67805. /** @hidden */
  67806. export var spriteMapVertexShader: {
  67807. name: string;
  67808. shader: string;
  67809. };
  67810. }
  67811. declare module BABYLON {
  67812. /**
  67813. * Defines the basic options interface of a SpriteMap
  67814. */
  67815. export interface ISpriteMapOptions {
  67816. /**
  67817. * Vector2 of the number of cells in the grid.
  67818. */
  67819. stageSize?: Vector2;
  67820. /**
  67821. * Vector2 of the size of the output plane in World Units.
  67822. */
  67823. outputSize?: Vector2;
  67824. /**
  67825. * Vector3 of the position of the output plane in World Units.
  67826. */
  67827. outputPosition?: Vector3;
  67828. /**
  67829. * Vector3 of the rotation of the output plane.
  67830. */
  67831. outputRotation?: Vector3;
  67832. /**
  67833. * number of layers that the system will reserve in resources.
  67834. */
  67835. layerCount?: number;
  67836. /**
  67837. * number of max animation frames a single cell will reserve in resources.
  67838. */
  67839. maxAnimationFrames?: number;
  67840. /**
  67841. * number cell index of the base tile when the system compiles.
  67842. */
  67843. baseTile?: number;
  67844. /**
  67845. * boolean flip the sprite after its been repositioned by the framing data.
  67846. */
  67847. flipU?: boolean;
  67848. /**
  67849. * Vector3 scalar of the global RGB values of the SpriteMap.
  67850. */
  67851. colorMultiply?: Vector3;
  67852. }
  67853. /**
  67854. * Defines the IDisposable interface in order to be cleanable from resources.
  67855. */
  67856. export interface ISpriteMap extends IDisposable {
  67857. /**
  67858. * String name of the SpriteMap.
  67859. */
  67860. name: string;
  67861. /**
  67862. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67863. */
  67864. atlasJSON: ISpriteJSONAtlas;
  67865. /**
  67866. * Texture of the SpriteMap.
  67867. */
  67868. spriteSheet: Texture;
  67869. /**
  67870. * The parameters to initialize the SpriteMap with.
  67871. */
  67872. options: ISpriteMapOptions;
  67873. }
  67874. /**
  67875. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67876. */
  67877. export class SpriteMap implements ISpriteMap {
  67878. /** The Name of the spriteMap */
  67879. name: string;
  67880. /** The JSON file with the frame and meta data */
  67881. atlasJSON: ISpriteJSONAtlas;
  67882. /** The systems Sprite Sheet Texture */
  67883. spriteSheet: Texture;
  67884. /** Arguments passed with the Constructor */
  67885. options: ISpriteMapOptions;
  67886. /** Public Sprite Storage array, parsed from atlasJSON */
  67887. sprites: Array<ISpriteJSONSprite>;
  67888. /** Returns the Number of Sprites in the System */
  67889. get spriteCount(): number;
  67890. /** Returns the Position of Output Plane*/
  67891. get position(): Vector3;
  67892. /** Returns the Position of Output Plane*/
  67893. set position(v: Vector3);
  67894. /** Returns the Rotation of Output Plane*/
  67895. get rotation(): Vector3;
  67896. /** Returns the Rotation of Output Plane*/
  67897. set rotation(v: Vector3);
  67898. /** Sets the AnimationMap*/
  67899. get animationMap(): RawTexture;
  67900. /** Sets the AnimationMap*/
  67901. set animationMap(v: RawTexture);
  67902. /** Scene that the SpriteMap was created in */
  67903. private _scene;
  67904. /** Texture Buffer of Float32 that holds tile frame data*/
  67905. private _frameMap;
  67906. /** Texture Buffers of Float32 that holds tileMap data*/
  67907. private _tileMaps;
  67908. /** Texture Buffer of Float32 that holds Animation Data*/
  67909. private _animationMap;
  67910. /** Custom ShaderMaterial Central to the System*/
  67911. private _material;
  67912. /** Custom ShaderMaterial Central to the System*/
  67913. private _output;
  67914. /** Systems Time Ticker*/
  67915. private _time;
  67916. /**
  67917. * Creates a new SpriteMap
  67918. * @param name defines the SpriteMaps Name
  67919. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67920. * @param spriteSheet is the Texture that the Sprites are on.
  67921. * @param options a basic deployment configuration
  67922. * @param scene The Scene that the map is deployed on
  67923. */
  67924. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67925. /**
  67926. * Returns tileID location
  67927. * @returns Vector2 the cell position ID
  67928. */
  67929. getTileID(): Vector2;
  67930. /**
  67931. * Gets the UV location of the mouse over the SpriteMap.
  67932. * @returns Vector2 the UV position of the mouse interaction
  67933. */
  67934. getMousePosition(): Vector2;
  67935. /**
  67936. * Creates the "frame" texture Buffer
  67937. * -------------------------------------
  67938. * Structure of frames
  67939. * "filename": "Falling-Water-2.png",
  67940. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67941. * "rotated": true,
  67942. * "trimmed": true,
  67943. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67944. * "sourceSize": {"w":32,"h":32}
  67945. * @returns RawTexture of the frameMap
  67946. */
  67947. private _createFrameBuffer;
  67948. /**
  67949. * Creates the tileMap texture Buffer
  67950. * @param buffer normally and array of numbers, or a false to generate from scratch
  67951. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67952. * @returns RawTexture of the tileMap
  67953. */
  67954. private _createTileBuffer;
  67955. /**
  67956. * Modifies the data of the tileMaps
  67957. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67958. * @param pos is the iVector2 Coordinates of the Tile
  67959. * @param tile The SpriteIndex of the new Tile
  67960. */
  67961. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67962. /**
  67963. * Creates the animationMap texture Buffer
  67964. * @param buffer normally and array of numbers, or a false to generate from scratch
  67965. * @returns RawTexture of the animationMap
  67966. */
  67967. private _createTileAnimationBuffer;
  67968. /**
  67969. * Modifies the data of the animationMap
  67970. * @param cellID is the Index of the Sprite
  67971. * @param _frame is the target Animation frame
  67972. * @param toCell is the Target Index of the next frame of the animation
  67973. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67974. * @param speed is a global scalar of the time variable on the map.
  67975. */
  67976. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67977. /**
  67978. * Exports the .tilemaps file
  67979. */
  67980. saveTileMaps(): void;
  67981. /**
  67982. * Imports the .tilemaps file
  67983. * @param url of the .tilemaps file
  67984. */
  67985. loadTileMaps(url: string): void;
  67986. /**
  67987. * Release associated resources
  67988. */
  67989. dispose(): void;
  67990. }
  67991. }
  67992. declare module BABYLON {
  67993. /**
  67994. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67995. * @see http://doc.babylonjs.com/babylon101/sprites
  67996. */
  67997. export class SpritePackedManager extends SpriteManager {
  67998. /** defines the packed manager's name */
  67999. name: string;
  68000. /**
  68001. * Creates a new sprite manager from a packed sprite sheet
  68002. * @param name defines the manager's name
  68003. * @param imgUrl defines the sprite sheet url
  68004. * @param capacity defines the maximum allowed number of sprites
  68005. * @param scene defines the hosting scene
  68006. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  68007. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68008. * @param samplingMode defines the smapling mode to use with spritesheet
  68009. * @param fromPacked set to true; do not alter
  68010. */
  68011. constructor(
  68012. /** defines the packed manager's name */
  68013. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  68014. }
  68015. }
  68016. declare module BABYLON {
  68017. /**
  68018. * Defines the list of states available for a task inside a AssetsManager
  68019. */
  68020. export enum AssetTaskState {
  68021. /**
  68022. * Initialization
  68023. */
  68024. INIT = 0,
  68025. /**
  68026. * Running
  68027. */
  68028. RUNNING = 1,
  68029. /**
  68030. * Done
  68031. */
  68032. DONE = 2,
  68033. /**
  68034. * Error
  68035. */
  68036. ERROR = 3
  68037. }
  68038. /**
  68039. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  68040. */
  68041. export abstract class AbstractAssetTask {
  68042. /**
  68043. * Task name
  68044. */ name: string;
  68045. /**
  68046. * Callback called when the task is successful
  68047. */
  68048. onSuccess: (task: any) => void;
  68049. /**
  68050. * Callback called when the task is not successful
  68051. */
  68052. onError: (task: any, message?: string, exception?: any) => void;
  68053. /**
  68054. * Creates a new AssetsManager
  68055. * @param name defines the name of the task
  68056. */
  68057. constructor(
  68058. /**
  68059. * Task name
  68060. */ name: string);
  68061. private _isCompleted;
  68062. private _taskState;
  68063. private _errorObject;
  68064. /**
  68065. * Get if the task is completed
  68066. */
  68067. get isCompleted(): boolean;
  68068. /**
  68069. * Gets the current state of the task
  68070. */
  68071. get taskState(): AssetTaskState;
  68072. /**
  68073. * Gets the current error object (if task is in error)
  68074. */
  68075. get errorObject(): {
  68076. message?: string;
  68077. exception?: any;
  68078. };
  68079. /**
  68080. * Internal only
  68081. * @hidden
  68082. */
  68083. _setErrorObject(message?: string, exception?: any): void;
  68084. /**
  68085. * Execute the current task
  68086. * @param scene defines the scene where you want your assets to be loaded
  68087. * @param onSuccess is a callback called when the task is successfully executed
  68088. * @param onError is a callback called if an error occurs
  68089. */
  68090. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68091. /**
  68092. * Execute the current task
  68093. * @param scene defines the scene where you want your assets to be loaded
  68094. * @param onSuccess is a callback called when the task is successfully executed
  68095. * @param onError is a callback called if an error occurs
  68096. */
  68097. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68098. /**
  68099. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68100. * This can be used with failed tasks that have the reason for failure fixed.
  68101. */
  68102. reset(): void;
  68103. private onErrorCallback;
  68104. private onDoneCallback;
  68105. }
  68106. /**
  68107. * Define the interface used by progress events raised during assets loading
  68108. */
  68109. export interface IAssetsProgressEvent {
  68110. /**
  68111. * Defines the number of remaining tasks to process
  68112. */
  68113. remainingCount: number;
  68114. /**
  68115. * Defines the total number of tasks
  68116. */
  68117. totalCount: number;
  68118. /**
  68119. * Defines the task that was just processed
  68120. */
  68121. task: AbstractAssetTask;
  68122. }
  68123. /**
  68124. * Class used to share progress information about assets loading
  68125. */
  68126. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68127. /**
  68128. * Defines the number of remaining tasks to process
  68129. */
  68130. remainingCount: number;
  68131. /**
  68132. * Defines the total number of tasks
  68133. */
  68134. totalCount: number;
  68135. /**
  68136. * Defines the task that was just processed
  68137. */
  68138. task: AbstractAssetTask;
  68139. /**
  68140. * Creates a AssetsProgressEvent
  68141. * @param remainingCount defines the number of remaining tasks to process
  68142. * @param totalCount defines the total number of tasks
  68143. * @param task defines the task that was just processed
  68144. */
  68145. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68146. }
  68147. /**
  68148. * Define a task used by AssetsManager to load meshes
  68149. */
  68150. export class MeshAssetTask extends AbstractAssetTask {
  68151. /**
  68152. * Defines the name of the task
  68153. */
  68154. name: string;
  68155. /**
  68156. * Defines the list of mesh's names you want to load
  68157. */
  68158. meshesNames: any;
  68159. /**
  68160. * Defines the root url to use as a base to load your meshes and associated resources
  68161. */
  68162. rootUrl: string;
  68163. /**
  68164. * Defines the filename of the scene to load from
  68165. */
  68166. sceneFilename: string;
  68167. /**
  68168. * Gets the list of loaded meshes
  68169. */
  68170. loadedMeshes: Array<AbstractMesh>;
  68171. /**
  68172. * Gets the list of loaded particle systems
  68173. */
  68174. loadedParticleSystems: Array<IParticleSystem>;
  68175. /**
  68176. * Gets the list of loaded skeletons
  68177. */
  68178. loadedSkeletons: Array<Skeleton>;
  68179. /**
  68180. * Gets the list of loaded animation groups
  68181. */
  68182. loadedAnimationGroups: Array<AnimationGroup>;
  68183. /**
  68184. * Callback called when the task is successful
  68185. */
  68186. onSuccess: (task: MeshAssetTask) => void;
  68187. /**
  68188. * Callback called when the task is successful
  68189. */
  68190. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68191. /**
  68192. * Creates a new MeshAssetTask
  68193. * @param name defines the name of the task
  68194. * @param meshesNames defines the list of mesh's names you want to load
  68195. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68196. * @param sceneFilename defines the filename of the scene to load from
  68197. */
  68198. constructor(
  68199. /**
  68200. * Defines the name of the task
  68201. */
  68202. name: string,
  68203. /**
  68204. * Defines the list of mesh's names you want to load
  68205. */
  68206. meshesNames: any,
  68207. /**
  68208. * Defines the root url to use as a base to load your meshes and associated resources
  68209. */
  68210. rootUrl: string,
  68211. /**
  68212. * Defines the filename of the scene to load from
  68213. */
  68214. sceneFilename: string);
  68215. /**
  68216. * Execute the current task
  68217. * @param scene defines the scene where you want your assets to be loaded
  68218. * @param onSuccess is a callback called when the task is successfully executed
  68219. * @param onError is a callback called if an error occurs
  68220. */
  68221. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68222. }
  68223. /**
  68224. * Define a task used by AssetsManager to load text content
  68225. */
  68226. export class TextFileAssetTask extends AbstractAssetTask {
  68227. /**
  68228. * Defines the name of the task
  68229. */
  68230. name: string;
  68231. /**
  68232. * Defines the location of the file to load
  68233. */
  68234. url: string;
  68235. /**
  68236. * Gets the loaded text string
  68237. */
  68238. text: string;
  68239. /**
  68240. * Callback called when the task is successful
  68241. */
  68242. onSuccess: (task: TextFileAssetTask) => void;
  68243. /**
  68244. * Callback called when the task is successful
  68245. */
  68246. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68247. /**
  68248. * Creates a new TextFileAssetTask object
  68249. * @param name defines the name of the task
  68250. * @param url defines the location of the file to load
  68251. */
  68252. constructor(
  68253. /**
  68254. * Defines the name of the task
  68255. */
  68256. name: string,
  68257. /**
  68258. * Defines the location of the file to load
  68259. */
  68260. url: string);
  68261. /**
  68262. * Execute the current task
  68263. * @param scene defines the scene where you want your assets to be loaded
  68264. * @param onSuccess is a callback called when the task is successfully executed
  68265. * @param onError is a callback called if an error occurs
  68266. */
  68267. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68268. }
  68269. /**
  68270. * Define a task used by AssetsManager to load binary data
  68271. */
  68272. export class BinaryFileAssetTask extends AbstractAssetTask {
  68273. /**
  68274. * Defines the name of the task
  68275. */
  68276. name: string;
  68277. /**
  68278. * Defines the location of the file to load
  68279. */
  68280. url: string;
  68281. /**
  68282. * Gets the lodaded data (as an array buffer)
  68283. */
  68284. data: ArrayBuffer;
  68285. /**
  68286. * Callback called when the task is successful
  68287. */
  68288. onSuccess: (task: BinaryFileAssetTask) => void;
  68289. /**
  68290. * Callback called when the task is successful
  68291. */
  68292. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68293. /**
  68294. * Creates a new BinaryFileAssetTask object
  68295. * @param name defines the name of the new task
  68296. * @param url defines the location of the file to load
  68297. */
  68298. constructor(
  68299. /**
  68300. * Defines the name of the task
  68301. */
  68302. name: string,
  68303. /**
  68304. * Defines the location of the file to load
  68305. */
  68306. url: string);
  68307. /**
  68308. * Execute the current task
  68309. * @param scene defines the scene where you want your assets to be loaded
  68310. * @param onSuccess is a callback called when the task is successfully executed
  68311. * @param onError is a callback called if an error occurs
  68312. */
  68313. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68314. }
  68315. /**
  68316. * Define a task used by AssetsManager to load images
  68317. */
  68318. export class ImageAssetTask extends AbstractAssetTask {
  68319. /**
  68320. * Defines the name of the task
  68321. */
  68322. name: string;
  68323. /**
  68324. * Defines the location of the image to load
  68325. */
  68326. url: string;
  68327. /**
  68328. * Gets the loaded images
  68329. */
  68330. image: HTMLImageElement;
  68331. /**
  68332. * Callback called when the task is successful
  68333. */
  68334. onSuccess: (task: ImageAssetTask) => void;
  68335. /**
  68336. * Callback called when the task is successful
  68337. */
  68338. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68339. /**
  68340. * Creates a new ImageAssetTask
  68341. * @param name defines the name of the task
  68342. * @param url defines the location of the image to load
  68343. */
  68344. constructor(
  68345. /**
  68346. * Defines the name of the task
  68347. */
  68348. name: string,
  68349. /**
  68350. * Defines the location of the image to load
  68351. */
  68352. url: string);
  68353. /**
  68354. * Execute the current task
  68355. * @param scene defines the scene where you want your assets to be loaded
  68356. * @param onSuccess is a callback called when the task is successfully executed
  68357. * @param onError is a callback called if an error occurs
  68358. */
  68359. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68360. }
  68361. /**
  68362. * Defines the interface used by texture loading tasks
  68363. */
  68364. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68365. /**
  68366. * Gets the loaded texture
  68367. */
  68368. texture: TEX;
  68369. }
  68370. /**
  68371. * Define a task used by AssetsManager to load 2D textures
  68372. */
  68373. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68374. /**
  68375. * Defines the name of the task
  68376. */
  68377. name: string;
  68378. /**
  68379. * Defines the location of the file to load
  68380. */
  68381. url: string;
  68382. /**
  68383. * Defines if mipmap should not be generated (default is false)
  68384. */
  68385. noMipmap?: boolean | undefined;
  68386. /**
  68387. * Defines if texture must be inverted on Y axis (default is true)
  68388. */
  68389. invertY: boolean;
  68390. /**
  68391. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68392. */
  68393. samplingMode: number;
  68394. /**
  68395. * Gets the loaded texture
  68396. */
  68397. texture: Texture;
  68398. /**
  68399. * Callback called when the task is successful
  68400. */
  68401. onSuccess: (task: TextureAssetTask) => void;
  68402. /**
  68403. * Callback called when the task is successful
  68404. */
  68405. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68406. /**
  68407. * Creates a new TextureAssetTask object
  68408. * @param name defines the name of the task
  68409. * @param url defines the location of the file to load
  68410. * @param noMipmap defines if mipmap should not be generated (default is false)
  68411. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68412. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68413. */
  68414. constructor(
  68415. /**
  68416. * Defines the name of the task
  68417. */
  68418. name: string,
  68419. /**
  68420. * Defines the location of the file to load
  68421. */
  68422. url: string,
  68423. /**
  68424. * Defines if mipmap should not be generated (default is false)
  68425. */
  68426. noMipmap?: boolean | undefined,
  68427. /**
  68428. * Defines if texture must be inverted on Y axis (default is true)
  68429. */
  68430. invertY?: boolean,
  68431. /**
  68432. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68433. */
  68434. samplingMode?: number);
  68435. /**
  68436. * Execute the current task
  68437. * @param scene defines the scene where you want your assets to be loaded
  68438. * @param onSuccess is a callback called when the task is successfully executed
  68439. * @param onError is a callback called if an error occurs
  68440. */
  68441. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68442. }
  68443. /**
  68444. * Define a task used by AssetsManager to load cube textures
  68445. */
  68446. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68447. /**
  68448. * Defines the name of the task
  68449. */
  68450. name: string;
  68451. /**
  68452. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68453. */
  68454. url: string;
  68455. /**
  68456. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68457. */
  68458. extensions?: string[] | undefined;
  68459. /**
  68460. * Defines if mipmaps should not be generated (default is false)
  68461. */
  68462. noMipmap?: boolean | undefined;
  68463. /**
  68464. * Defines the explicit list of files (undefined by default)
  68465. */
  68466. files?: string[] | undefined;
  68467. /**
  68468. * Gets the loaded texture
  68469. */
  68470. texture: CubeTexture;
  68471. /**
  68472. * Callback called when the task is successful
  68473. */
  68474. onSuccess: (task: CubeTextureAssetTask) => void;
  68475. /**
  68476. * Callback called when the task is successful
  68477. */
  68478. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68479. /**
  68480. * Creates a new CubeTextureAssetTask
  68481. * @param name defines the name of the task
  68482. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68483. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68484. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68485. * @param files defines the explicit list of files (undefined by default)
  68486. */
  68487. constructor(
  68488. /**
  68489. * Defines the name of the task
  68490. */
  68491. name: string,
  68492. /**
  68493. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68494. */
  68495. url: string,
  68496. /**
  68497. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68498. */
  68499. extensions?: string[] | undefined,
  68500. /**
  68501. * Defines if mipmaps should not be generated (default is false)
  68502. */
  68503. noMipmap?: boolean | undefined,
  68504. /**
  68505. * Defines the explicit list of files (undefined by default)
  68506. */
  68507. files?: string[] | undefined);
  68508. /**
  68509. * Execute the current task
  68510. * @param scene defines the scene where you want your assets to be loaded
  68511. * @param onSuccess is a callback called when the task is successfully executed
  68512. * @param onError is a callback called if an error occurs
  68513. */
  68514. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68515. }
  68516. /**
  68517. * Define a task used by AssetsManager to load HDR cube textures
  68518. */
  68519. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68520. /**
  68521. * Defines the name of the task
  68522. */
  68523. name: string;
  68524. /**
  68525. * Defines the location of the file to load
  68526. */
  68527. url: string;
  68528. /**
  68529. * Defines the desired size (the more it increases the longer the generation will be)
  68530. */
  68531. size: number;
  68532. /**
  68533. * Defines if mipmaps should not be generated (default is false)
  68534. */
  68535. noMipmap: boolean;
  68536. /**
  68537. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68538. */
  68539. generateHarmonics: boolean;
  68540. /**
  68541. * 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)
  68542. */
  68543. gammaSpace: boolean;
  68544. /**
  68545. * Internal Use Only
  68546. */
  68547. reserved: boolean;
  68548. /**
  68549. * Gets the loaded texture
  68550. */
  68551. texture: HDRCubeTexture;
  68552. /**
  68553. * Callback called when the task is successful
  68554. */
  68555. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68556. /**
  68557. * Callback called when the task is successful
  68558. */
  68559. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68560. /**
  68561. * Creates a new HDRCubeTextureAssetTask object
  68562. * @param name defines the name of the task
  68563. * @param url defines the location of the file to load
  68564. * @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.
  68565. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68566. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68567. * @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)
  68568. * @param reserved Internal use only
  68569. */
  68570. constructor(
  68571. /**
  68572. * Defines the name of the task
  68573. */
  68574. name: string,
  68575. /**
  68576. * Defines the location of the file to load
  68577. */
  68578. url: string,
  68579. /**
  68580. * Defines the desired size (the more it increases the longer the generation will be)
  68581. */
  68582. size: number,
  68583. /**
  68584. * Defines if mipmaps should not be generated (default is false)
  68585. */
  68586. noMipmap?: boolean,
  68587. /**
  68588. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68589. */
  68590. generateHarmonics?: boolean,
  68591. /**
  68592. * 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)
  68593. */
  68594. gammaSpace?: boolean,
  68595. /**
  68596. * Internal Use Only
  68597. */
  68598. reserved?: boolean);
  68599. /**
  68600. * Execute the current task
  68601. * @param scene defines the scene where you want your assets to be loaded
  68602. * @param onSuccess is a callback called when the task is successfully executed
  68603. * @param onError is a callback called if an error occurs
  68604. */
  68605. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68606. }
  68607. /**
  68608. * Define a task used by AssetsManager to load Equirectangular cube textures
  68609. */
  68610. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68611. /**
  68612. * Defines the name of the task
  68613. */
  68614. name: string;
  68615. /**
  68616. * Defines the location of the file to load
  68617. */
  68618. url: string;
  68619. /**
  68620. * Defines the desired size (the more it increases the longer the generation will be)
  68621. */
  68622. size: number;
  68623. /**
  68624. * Defines if mipmaps should not be generated (default is false)
  68625. */
  68626. noMipmap: boolean;
  68627. /**
  68628. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68629. * but the standard material would require them in Gamma space) (default is true)
  68630. */
  68631. gammaSpace: boolean;
  68632. /**
  68633. * Gets the loaded texture
  68634. */
  68635. texture: EquiRectangularCubeTexture;
  68636. /**
  68637. * Callback called when the task is successful
  68638. */
  68639. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68640. /**
  68641. * Callback called when the task is successful
  68642. */
  68643. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68644. /**
  68645. * Creates a new EquiRectangularCubeTextureAssetTask object
  68646. * @param name defines the name of the task
  68647. * @param url defines the location of the file to load
  68648. * @param size defines the desired size (the more it increases the longer the generation will be)
  68649. * If the size is omitted this implies you are using a preprocessed cubemap.
  68650. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68651. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68652. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68653. * (default is true)
  68654. */
  68655. constructor(
  68656. /**
  68657. * Defines the name of the task
  68658. */
  68659. name: string,
  68660. /**
  68661. * Defines the location of the file to load
  68662. */
  68663. url: string,
  68664. /**
  68665. * Defines the desired size (the more it increases the longer the generation will be)
  68666. */
  68667. size: number,
  68668. /**
  68669. * Defines if mipmaps should not be generated (default is false)
  68670. */
  68671. noMipmap?: boolean,
  68672. /**
  68673. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68674. * but the standard material would require them in Gamma space) (default is true)
  68675. */
  68676. gammaSpace?: boolean);
  68677. /**
  68678. * Execute the current task
  68679. * @param scene defines the scene where you want your assets to be loaded
  68680. * @param onSuccess is a callback called when the task is successfully executed
  68681. * @param onError is a callback called if an error occurs
  68682. */
  68683. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68684. }
  68685. /**
  68686. * This class can be used to easily import assets into a scene
  68687. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68688. */
  68689. export class AssetsManager {
  68690. private _scene;
  68691. private _isLoading;
  68692. protected _tasks: AbstractAssetTask[];
  68693. protected _waitingTasksCount: number;
  68694. protected _totalTasksCount: number;
  68695. /**
  68696. * Callback called when all tasks are processed
  68697. */
  68698. onFinish: (tasks: AbstractAssetTask[]) => void;
  68699. /**
  68700. * Callback called when a task is successful
  68701. */
  68702. onTaskSuccess: (task: AbstractAssetTask) => void;
  68703. /**
  68704. * Callback called when a task had an error
  68705. */
  68706. onTaskError: (task: AbstractAssetTask) => void;
  68707. /**
  68708. * Callback called when a task is done (whatever the result is)
  68709. */
  68710. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68711. /**
  68712. * Observable called when all tasks are processed
  68713. */
  68714. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68715. /**
  68716. * Observable called when a task had an error
  68717. */
  68718. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68719. /**
  68720. * Observable called when all tasks were executed
  68721. */
  68722. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68723. /**
  68724. * Observable called when a task is done (whatever the result is)
  68725. */
  68726. onProgressObservable: Observable<IAssetsProgressEvent>;
  68727. /**
  68728. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68729. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68730. */
  68731. useDefaultLoadingScreen: boolean;
  68732. /**
  68733. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68734. * when all assets have been downloaded.
  68735. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68736. */
  68737. autoHideLoadingUI: boolean;
  68738. /**
  68739. * Creates a new AssetsManager
  68740. * @param scene defines the scene to work on
  68741. */
  68742. constructor(scene: Scene);
  68743. /**
  68744. * Add a MeshAssetTask to the list of active tasks
  68745. * @param taskName defines the name of the new task
  68746. * @param meshesNames defines the name of meshes to load
  68747. * @param rootUrl defines the root url to use to locate files
  68748. * @param sceneFilename defines the filename of the scene file
  68749. * @returns a new MeshAssetTask object
  68750. */
  68751. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68752. /**
  68753. * Add a TextFileAssetTask to the list of active tasks
  68754. * @param taskName defines the name of the new task
  68755. * @param url defines the url of the file to load
  68756. * @returns a new TextFileAssetTask object
  68757. */
  68758. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68759. /**
  68760. * Add a BinaryFileAssetTask to the list of active tasks
  68761. * @param taskName defines the name of the new task
  68762. * @param url defines the url of the file to load
  68763. * @returns a new BinaryFileAssetTask object
  68764. */
  68765. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68766. /**
  68767. * Add a ImageAssetTask to the list of active tasks
  68768. * @param taskName defines the name of the new task
  68769. * @param url defines the url of the file to load
  68770. * @returns a new ImageAssetTask object
  68771. */
  68772. addImageTask(taskName: string, url: string): ImageAssetTask;
  68773. /**
  68774. * Add a TextureAssetTask to the list of active tasks
  68775. * @param taskName defines the name of the new task
  68776. * @param url defines the url of the file to load
  68777. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68778. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68779. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68780. * @returns a new TextureAssetTask object
  68781. */
  68782. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68783. /**
  68784. * Add a CubeTextureAssetTask to the list of active tasks
  68785. * @param taskName defines the name of the new task
  68786. * @param url defines the url of the file to load
  68787. * @param extensions defines the extension to use to load the cube map (can be null)
  68788. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68789. * @param files defines the list of files to load (can be null)
  68790. * @returns a new CubeTextureAssetTask object
  68791. */
  68792. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68793. /**
  68794. *
  68795. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68796. * @param taskName defines the name of the new task
  68797. * @param url defines the url of the file to load
  68798. * @param size defines the size you want for the cubemap (can be null)
  68799. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68800. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68801. * @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)
  68802. * @param reserved Internal use only
  68803. * @returns a new HDRCubeTextureAssetTask object
  68804. */
  68805. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68806. /**
  68807. *
  68808. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68809. * @param taskName defines the name of the new task
  68810. * @param url defines the url of the file to load
  68811. * @param size defines the size you want for the cubemap (can be null)
  68812. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68813. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68814. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68815. * @returns a new EquiRectangularCubeTextureAssetTask object
  68816. */
  68817. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68818. /**
  68819. * Remove a task from the assets manager.
  68820. * @param task the task to remove
  68821. */
  68822. removeTask(task: AbstractAssetTask): void;
  68823. private _decreaseWaitingTasksCount;
  68824. private _runTask;
  68825. /**
  68826. * Reset the AssetsManager and remove all tasks
  68827. * @return the current instance of the AssetsManager
  68828. */
  68829. reset(): AssetsManager;
  68830. /**
  68831. * Start the loading process
  68832. * @return the current instance of the AssetsManager
  68833. */
  68834. load(): AssetsManager;
  68835. /**
  68836. * Start the loading process as an async operation
  68837. * @return a promise returning the list of failed tasks
  68838. */
  68839. loadAsync(): Promise<void>;
  68840. }
  68841. }
  68842. declare module BABYLON {
  68843. /**
  68844. * Wrapper class for promise with external resolve and reject.
  68845. */
  68846. export class Deferred<T> {
  68847. /**
  68848. * The promise associated with this deferred object.
  68849. */
  68850. readonly promise: Promise<T>;
  68851. private _resolve;
  68852. private _reject;
  68853. /**
  68854. * The resolve method of the promise associated with this deferred object.
  68855. */
  68856. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68857. /**
  68858. * The reject method of the promise associated with this deferred object.
  68859. */
  68860. get reject(): (reason?: any) => void;
  68861. /**
  68862. * Constructor for this deferred object.
  68863. */
  68864. constructor();
  68865. }
  68866. }
  68867. declare module BABYLON {
  68868. /**
  68869. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68870. */
  68871. export class MeshExploder {
  68872. private _centerMesh;
  68873. private _meshes;
  68874. private _meshesOrigins;
  68875. private _toCenterVectors;
  68876. private _scaledDirection;
  68877. private _newPosition;
  68878. private _centerPosition;
  68879. /**
  68880. * Explodes meshes from a center mesh.
  68881. * @param meshes The meshes to explode.
  68882. * @param centerMesh The mesh to be center of explosion.
  68883. */
  68884. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68885. private _setCenterMesh;
  68886. /**
  68887. * Get class name
  68888. * @returns "MeshExploder"
  68889. */
  68890. getClassName(): string;
  68891. /**
  68892. * "Exploded meshes"
  68893. * @returns Array of meshes with the centerMesh at index 0.
  68894. */
  68895. getMeshes(): Array<Mesh>;
  68896. /**
  68897. * Explodes meshes giving a specific direction
  68898. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68899. */
  68900. explode(direction?: number): void;
  68901. }
  68902. }
  68903. declare module BABYLON {
  68904. /**
  68905. * Class used to help managing file picking and drag'n'drop
  68906. */
  68907. export class FilesInput {
  68908. /**
  68909. * List of files ready to be loaded
  68910. */
  68911. static get FilesToLoad(): {
  68912. [key: string]: File;
  68913. };
  68914. /**
  68915. * Callback called when a file is processed
  68916. */
  68917. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68918. private _engine;
  68919. private _currentScene;
  68920. private _sceneLoadedCallback;
  68921. private _progressCallback;
  68922. private _additionalRenderLoopLogicCallback;
  68923. private _textureLoadingCallback;
  68924. private _startingProcessingFilesCallback;
  68925. private _onReloadCallback;
  68926. private _errorCallback;
  68927. private _elementToMonitor;
  68928. private _sceneFileToLoad;
  68929. private _filesToLoad;
  68930. /**
  68931. * Creates a new FilesInput
  68932. * @param engine defines the rendering engine
  68933. * @param scene defines the hosting scene
  68934. * @param sceneLoadedCallback callback called when scene is loaded
  68935. * @param progressCallback callback called to track progress
  68936. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68937. * @param textureLoadingCallback callback called when a texture is loading
  68938. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68939. * @param onReloadCallback callback called when a reload is requested
  68940. * @param errorCallback callback call if an error occurs
  68941. */
  68942. 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);
  68943. private _dragEnterHandler;
  68944. private _dragOverHandler;
  68945. private _dropHandler;
  68946. /**
  68947. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68948. * @param elementToMonitor defines the DOM element to track
  68949. */
  68950. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68951. /**
  68952. * Release all associated resources
  68953. */
  68954. dispose(): void;
  68955. private renderFunction;
  68956. private drag;
  68957. private drop;
  68958. private _traverseFolder;
  68959. private _processFiles;
  68960. /**
  68961. * Load files from a drop event
  68962. * @param event defines the drop event to use as source
  68963. */
  68964. loadFiles(event: any): void;
  68965. private _processReload;
  68966. /**
  68967. * Reload the current scene from the loaded files
  68968. */
  68969. reload(): void;
  68970. }
  68971. }
  68972. declare module BABYLON {
  68973. /**
  68974. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68975. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68976. */
  68977. export class SceneOptimization {
  68978. /**
  68979. * Defines the priority of this optimization (0 by default which means first in the list)
  68980. */
  68981. priority: number;
  68982. /**
  68983. * Gets a string describing the action executed by the current optimization
  68984. * @returns description string
  68985. */
  68986. getDescription(): string;
  68987. /**
  68988. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68989. * @param scene defines the current scene where to apply this optimization
  68990. * @param optimizer defines the current optimizer
  68991. * @returns true if everything that can be done was applied
  68992. */
  68993. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68994. /**
  68995. * Creates the SceneOptimization object
  68996. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68997. * @param desc defines the description associated with the optimization
  68998. */
  68999. constructor(
  69000. /**
  69001. * Defines the priority of this optimization (0 by default which means first in the list)
  69002. */
  69003. priority?: number);
  69004. }
  69005. /**
  69006. * Defines an optimization used to reduce the size of render target textures
  69007. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69008. */
  69009. export class TextureOptimization extends SceneOptimization {
  69010. /**
  69011. * Defines the priority of this optimization (0 by default which means first in the list)
  69012. */
  69013. priority: number;
  69014. /**
  69015. * 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
  69016. */
  69017. maximumSize: number;
  69018. /**
  69019. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69020. */
  69021. step: number;
  69022. /**
  69023. * Gets a string describing the action executed by the current optimization
  69024. * @returns description string
  69025. */
  69026. getDescription(): string;
  69027. /**
  69028. * Creates the TextureOptimization object
  69029. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69030. * @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
  69031. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69032. */
  69033. constructor(
  69034. /**
  69035. * Defines the priority of this optimization (0 by default which means first in the list)
  69036. */
  69037. priority?: number,
  69038. /**
  69039. * 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
  69040. */
  69041. maximumSize?: number,
  69042. /**
  69043. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69044. */
  69045. step?: number);
  69046. /**
  69047. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69048. * @param scene defines the current scene where to apply this optimization
  69049. * @param optimizer defines the current optimizer
  69050. * @returns true if everything that can be done was applied
  69051. */
  69052. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69053. }
  69054. /**
  69055. * Defines an optimization used to increase or decrease the rendering resolution
  69056. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69057. */
  69058. export class HardwareScalingOptimization extends SceneOptimization {
  69059. /**
  69060. * Defines the priority of this optimization (0 by default which means first in the list)
  69061. */
  69062. priority: number;
  69063. /**
  69064. * Defines the maximum scale to use (2 by default)
  69065. */
  69066. maximumScale: number;
  69067. /**
  69068. * Defines the step to use between two passes (0.5 by default)
  69069. */
  69070. step: number;
  69071. private _currentScale;
  69072. private _directionOffset;
  69073. /**
  69074. * Gets a string describing the action executed by the current optimization
  69075. * @return description string
  69076. */
  69077. getDescription(): string;
  69078. /**
  69079. * Creates the HardwareScalingOptimization object
  69080. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69081. * @param maximumScale defines the maximum scale to use (2 by default)
  69082. * @param step defines the step to use between two passes (0.5 by default)
  69083. */
  69084. constructor(
  69085. /**
  69086. * Defines the priority of this optimization (0 by default which means first in the list)
  69087. */
  69088. priority?: number,
  69089. /**
  69090. * Defines the maximum scale to use (2 by default)
  69091. */
  69092. maximumScale?: number,
  69093. /**
  69094. * Defines the step to use between two passes (0.5 by default)
  69095. */
  69096. step?: number);
  69097. /**
  69098. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69099. * @param scene defines the current scene where to apply this optimization
  69100. * @param optimizer defines the current optimizer
  69101. * @returns true if everything that can be done was applied
  69102. */
  69103. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69104. }
  69105. /**
  69106. * Defines an optimization used to remove shadows
  69107. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69108. */
  69109. export class ShadowsOptimization extends SceneOptimization {
  69110. /**
  69111. * Gets a string describing the action executed by the current optimization
  69112. * @return description string
  69113. */
  69114. getDescription(): string;
  69115. /**
  69116. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69117. * @param scene defines the current scene where to apply this optimization
  69118. * @param optimizer defines the current optimizer
  69119. * @returns true if everything that can be done was applied
  69120. */
  69121. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69122. }
  69123. /**
  69124. * Defines an optimization used to turn post-processes off
  69125. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69126. */
  69127. export class PostProcessesOptimization extends SceneOptimization {
  69128. /**
  69129. * Gets a string describing the action executed by the current optimization
  69130. * @return description string
  69131. */
  69132. getDescription(): string;
  69133. /**
  69134. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69135. * @param scene defines the current scene where to apply this optimization
  69136. * @param optimizer defines the current optimizer
  69137. * @returns true if everything that can be done was applied
  69138. */
  69139. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69140. }
  69141. /**
  69142. * Defines an optimization used to turn lens flares off
  69143. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69144. */
  69145. export class LensFlaresOptimization extends SceneOptimization {
  69146. /**
  69147. * Gets a string describing the action executed by the current optimization
  69148. * @return description string
  69149. */
  69150. getDescription(): string;
  69151. /**
  69152. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69153. * @param scene defines the current scene where to apply this optimization
  69154. * @param optimizer defines the current optimizer
  69155. * @returns true if everything that can be done was applied
  69156. */
  69157. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69158. }
  69159. /**
  69160. * Defines an optimization based on user defined callback.
  69161. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69162. */
  69163. export class CustomOptimization extends SceneOptimization {
  69164. /**
  69165. * Callback called to apply the custom optimization.
  69166. */
  69167. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69168. /**
  69169. * Callback called to get custom description
  69170. */
  69171. onGetDescription: () => string;
  69172. /**
  69173. * Gets a string describing the action executed by the current optimization
  69174. * @returns description string
  69175. */
  69176. getDescription(): string;
  69177. /**
  69178. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69179. * @param scene defines the current scene where to apply this optimization
  69180. * @param optimizer defines the current optimizer
  69181. * @returns true if everything that can be done was applied
  69182. */
  69183. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69184. }
  69185. /**
  69186. * Defines an optimization used to turn particles off
  69187. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69188. */
  69189. export class ParticlesOptimization extends SceneOptimization {
  69190. /**
  69191. * Gets a string describing the action executed by the current optimization
  69192. * @return description string
  69193. */
  69194. getDescription(): string;
  69195. /**
  69196. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69197. * @param scene defines the current scene where to apply this optimization
  69198. * @param optimizer defines the current optimizer
  69199. * @returns true if everything that can be done was applied
  69200. */
  69201. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69202. }
  69203. /**
  69204. * Defines an optimization used to turn render targets off
  69205. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69206. */
  69207. export class RenderTargetsOptimization extends SceneOptimization {
  69208. /**
  69209. * Gets a string describing the action executed by the current optimization
  69210. * @return description string
  69211. */
  69212. getDescription(): string;
  69213. /**
  69214. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69215. * @param scene defines the current scene where to apply this optimization
  69216. * @param optimizer defines the current optimizer
  69217. * @returns true if everything that can be done was applied
  69218. */
  69219. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69220. }
  69221. /**
  69222. * Defines an optimization used to merge meshes with compatible materials
  69223. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69224. */
  69225. export class MergeMeshesOptimization extends SceneOptimization {
  69226. private static _UpdateSelectionTree;
  69227. /**
  69228. * Gets or sets a boolean which defines if optimization octree has to be updated
  69229. */
  69230. static get UpdateSelectionTree(): boolean;
  69231. /**
  69232. * Gets or sets a boolean which defines if optimization octree has to be updated
  69233. */
  69234. static set UpdateSelectionTree(value: boolean);
  69235. /**
  69236. * Gets a string describing the action executed by the current optimization
  69237. * @return description string
  69238. */
  69239. getDescription(): string;
  69240. private _canBeMerged;
  69241. /**
  69242. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69243. * @param scene defines the current scene where to apply this optimization
  69244. * @param optimizer defines the current optimizer
  69245. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69246. * @returns true if everything that can be done was applied
  69247. */
  69248. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69249. }
  69250. /**
  69251. * Defines a list of options used by SceneOptimizer
  69252. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69253. */
  69254. export class SceneOptimizerOptions {
  69255. /**
  69256. * Defines the target frame rate to reach (60 by default)
  69257. */
  69258. targetFrameRate: number;
  69259. /**
  69260. * Defines the interval between two checkes (2000ms by default)
  69261. */
  69262. trackerDuration: number;
  69263. /**
  69264. * Gets the list of optimizations to apply
  69265. */
  69266. optimizations: SceneOptimization[];
  69267. /**
  69268. * Creates a new list of options used by SceneOptimizer
  69269. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69270. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69271. */
  69272. constructor(
  69273. /**
  69274. * Defines the target frame rate to reach (60 by default)
  69275. */
  69276. targetFrameRate?: number,
  69277. /**
  69278. * Defines the interval between two checkes (2000ms by default)
  69279. */
  69280. trackerDuration?: number);
  69281. /**
  69282. * Add a new optimization
  69283. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69284. * @returns the current SceneOptimizerOptions
  69285. */
  69286. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69287. /**
  69288. * Add a new custom optimization
  69289. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69290. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69291. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69292. * @returns the current SceneOptimizerOptions
  69293. */
  69294. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69295. /**
  69296. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69297. * @param targetFrameRate defines the target frame rate (60 by default)
  69298. * @returns a SceneOptimizerOptions object
  69299. */
  69300. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69301. /**
  69302. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69303. * @param targetFrameRate defines the target frame rate (60 by default)
  69304. * @returns a SceneOptimizerOptions object
  69305. */
  69306. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69307. /**
  69308. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69309. * @param targetFrameRate defines the target frame rate (60 by default)
  69310. * @returns a SceneOptimizerOptions object
  69311. */
  69312. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69313. }
  69314. /**
  69315. * Class used to run optimizations in order to reach a target frame rate
  69316. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69317. */
  69318. export class SceneOptimizer implements IDisposable {
  69319. private _isRunning;
  69320. private _options;
  69321. private _scene;
  69322. private _currentPriorityLevel;
  69323. private _targetFrameRate;
  69324. private _trackerDuration;
  69325. private _currentFrameRate;
  69326. private _sceneDisposeObserver;
  69327. private _improvementMode;
  69328. /**
  69329. * Defines an observable called when the optimizer reaches the target frame rate
  69330. */
  69331. onSuccessObservable: Observable<SceneOptimizer>;
  69332. /**
  69333. * Defines an observable called when the optimizer enables an optimization
  69334. */
  69335. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69336. /**
  69337. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69338. */
  69339. onFailureObservable: Observable<SceneOptimizer>;
  69340. /**
  69341. * Gets a boolean indicating if the optimizer is in improvement mode
  69342. */
  69343. get isInImprovementMode(): boolean;
  69344. /**
  69345. * Gets the current priority level (0 at start)
  69346. */
  69347. get currentPriorityLevel(): number;
  69348. /**
  69349. * Gets the current frame rate checked by the SceneOptimizer
  69350. */
  69351. get currentFrameRate(): number;
  69352. /**
  69353. * Gets or sets the current target frame rate (60 by default)
  69354. */
  69355. get targetFrameRate(): number;
  69356. /**
  69357. * Gets or sets the current target frame rate (60 by default)
  69358. */
  69359. set targetFrameRate(value: number);
  69360. /**
  69361. * Gets or sets the current interval between two checks (every 2000ms by default)
  69362. */
  69363. get trackerDuration(): number;
  69364. /**
  69365. * Gets or sets the current interval between two checks (every 2000ms by default)
  69366. */
  69367. set trackerDuration(value: number);
  69368. /**
  69369. * Gets the list of active optimizations
  69370. */
  69371. get optimizations(): SceneOptimization[];
  69372. /**
  69373. * Creates a new SceneOptimizer
  69374. * @param scene defines the scene to work on
  69375. * @param options defines the options to use with the SceneOptimizer
  69376. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69377. * @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)
  69378. */
  69379. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69380. /**
  69381. * Stops the current optimizer
  69382. */
  69383. stop(): void;
  69384. /**
  69385. * Reset the optimizer to initial step (current priority level = 0)
  69386. */
  69387. reset(): void;
  69388. /**
  69389. * Start the optimizer. By default it will try to reach a specific framerate
  69390. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69391. */
  69392. start(): void;
  69393. private _checkCurrentState;
  69394. /**
  69395. * Release all resources
  69396. */
  69397. dispose(): void;
  69398. /**
  69399. * Helper function to create a SceneOptimizer with one single line of code
  69400. * @param scene defines the scene to work on
  69401. * @param options defines the options to use with the SceneOptimizer
  69402. * @param onSuccess defines a callback to call on success
  69403. * @param onFailure defines a callback to call on failure
  69404. * @returns the new SceneOptimizer object
  69405. */
  69406. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69407. }
  69408. }
  69409. declare module BABYLON {
  69410. /**
  69411. * Class used to serialize a scene into a string
  69412. */
  69413. export class SceneSerializer {
  69414. /**
  69415. * Clear cache used by a previous serialization
  69416. */
  69417. static ClearCache(): void;
  69418. /**
  69419. * Serialize a scene into a JSON compatible object
  69420. * @param scene defines the scene to serialize
  69421. * @returns a JSON compatible object
  69422. */
  69423. static Serialize(scene: Scene): any;
  69424. /**
  69425. * Serialize a mesh into a JSON compatible object
  69426. * @param toSerialize defines the mesh to serialize
  69427. * @param withParents defines if parents must be serialized as well
  69428. * @param withChildren defines if children must be serialized as well
  69429. * @returns a JSON compatible object
  69430. */
  69431. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69432. }
  69433. }
  69434. declare module BABYLON {
  69435. /**
  69436. * Class used to host texture specific utilities
  69437. */
  69438. export class TextureTools {
  69439. /**
  69440. * Uses the GPU to create a copy texture rescaled at a given size
  69441. * @param texture Texture to copy from
  69442. * @param width defines the desired width
  69443. * @param height defines the desired height
  69444. * @param useBilinearMode defines if bilinear mode has to be used
  69445. * @return the generated texture
  69446. */
  69447. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69448. }
  69449. }
  69450. declare module BABYLON {
  69451. /**
  69452. * This represents the different options available for the video capture.
  69453. */
  69454. export interface VideoRecorderOptions {
  69455. /** Defines the mime type of the video. */
  69456. mimeType: string;
  69457. /** Defines the FPS the video should be recorded at. */
  69458. fps: number;
  69459. /** Defines the chunk size for the recording data. */
  69460. recordChunckSize: number;
  69461. /** The audio tracks to attach to the recording. */
  69462. audioTracks?: MediaStreamTrack[];
  69463. }
  69464. /**
  69465. * This can help with recording videos from BabylonJS.
  69466. * This is based on the available WebRTC functionalities of the browser.
  69467. *
  69468. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69469. */
  69470. export class VideoRecorder {
  69471. private static readonly _defaultOptions;
  69472. /**
  69473. * Returns whether or not the VideoRecorder is available in your browser.
  69474. * @param engine Defines the Babylon Engine.
  69475. * @returns true if supported otherwise false.
  69476. */
  69477. static IsSupported(engine: Engine): boolean;
  69478. private readonly _options;
  69479. private _canvas;
  69480. private _mediaRecorder;
  69481. private _recordedChunks;
  69482. private _fileName;
  69483. private _resolve;
  69484. private _reject;
  69485. /**
  69486. * True when a recording is already in progress.
  69487. */
  69488. get isRecording(): boolean;
  69489. /**
  69490. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69491. * @param engine Defines the BabylonJS Engine you wish to record.
  69492. * @param options Defines options that can be used to customize the capture.
  69493. */
  69494. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69495. /**
  69496. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69497. */
  69498. stopRecording(): void;
  69499. /**
  69500. * Starts recording the canvas for a max duration specified in parameters.
  69501. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69502. * If null no automatic download will start and you can rely on the promise to get the data back.
  69503. * @param maxDuration Defines the maximum recording time in seconds.
  69504. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69505. * @return A promise callback at the end of the recording with the video data in Blob.
  69506. */
  69507. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69508. /**
  69509. * Releases internal resources used during the recording.
  69510. */
  69511. dispose(): void;
  69512. private _handleDataAvailable;
  69513. private _handleError;
  69514. private _handleStop;
  69515. }
  69516. }
  69517. declare module BABYLON {
  69518. /**
  69519. * Class containing a set of static utilities functions for screenshots
  69520. */
  69521. export class ScreenshotTools {
  69522. /**
  69523. * Captures a screenshot of the current rendering
  69524. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69525. * @param engine defines the rendering engine
  69526. * @param camera defines the source camera
  69527. * @param size This parameter can be set to a single number or to an object with the
  69528. * following (optional) properties: precision, width, height. If a single number is passed,
  69529. * it will be used for both width and height. If an object is passed, the screenshot size
  69530. * will be derived from the parameters. The precision property is a multiplier allowing
  69531. * rendering at a higher or lower resolution
  69532. * @param successCallback defines the callback receives a single parameter which contains the
  69533. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69534. * src parameter of an <img> to display it
  69535. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69536. * Check your browser for supported MIME types
  69537. */
  69538. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69539. /**
  69540. * Captures a screenshot of the current rendering
  69541. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69542. * @param engine defines the rendering engine
  69543. * @param camera defines the source camera
  69544. * @param size This parameter can be set to a single number or to an object with the
  69545. * following (optional) properties: precision, width, height. If a single number is passed,
  69546. * it will be used for both width and height. If an object is passed, the screenshot size
  69547. * will be derived from the parameters. The precision property is a multiplier allowing
  69548. * rendering at a higher or lower resolution
  69549. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69550. * Check your browser for supported MIME types
  69551. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69552. * to the src parameter of an <img> to display it
  69553. */
  69554. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69555. /**
  69556. * Generates an image screenshot from the specified camera.
  69557. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69558. * @param engine The engine to use for rendering
  69559. * @param camera The camera to use for rendering
  69560. * @param size This parameter can be set to a single number or to an object with the
  69561. * following (optional) properties: precision, width, height. If a single number is passed,
  69562. * it will be used for both width and height. If an object is passed, the screenshot size
  69563. * will be derived from the parameters. The precision property is a multiplier allowing
  69564. * rendering at a higher or lower resolution
  69565. * @param successCallback The callback receives a single parameter which contains the
  69566. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69567. * src parameter of an <img> to display it
  69568. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69569. * Check your browser for supported MIME types
  69570. * @param samples Texture samples (default: 1)
  69571. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69572. * @param fileName A name for for the downloaded file.
  69573. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69574. */
  69575. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69576. /**
  69577. * Generates an image screenshot from the specified camera.
  69578. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69579. * @param engine The engine to use for rendering
  69580. * @param camera The camera to use for rendering
  69581. * @param size This parameter can be set to a single number or to an object with the
  69582. * following (optional) properties: precision, width, height. If a single number is passed,
  69583. * it will be used for both width and height. If an object is passed, the screenshot size
  69584. * will be derived from the parameters. The precision property is a multiplier allowing
  69585. * rendering at a higher or lower resolution
  69586. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69587. * Check your browser for supported MIME types
  69588. * @param samples Texture samples (default: 1)
  69589. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69590. * @param fileName A name for for the downloaded file.
  69591. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69592. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69593. * to the src parameter of an <img> to display it
  69594. */
  69595. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69596. /**
  69597. * Gets height and width for screenshot size
  69598. * @private
  69599. */
  69600. private static _getScreenshotSize;
  69601. }
  69602. }
  69603. declare module BABYLON {
  69604. /**
  69605. * Interface for a data buffer
  69606. */
  69607. export interface IDataBuffer {
  69608. /**
  69609. * Reads bytes from the data buffer.
  69610. * @param byteOffset The byte offset to read
  69611. * @param byteLength The byte length to read
  69612. * @returns A promise that resolves when the bytes are read
  69613. */
  69614. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69615. /**
  69616. * The byte length of the buffer.
  69617. */
  69618. readonly byteLength: number;
  69619. }
  69620. /**
  69621. * Utility class for reading from a data buffer
  69622. */
  69623. export class DataReader {
  69624. /**
  69625. * The data buffer associated with this data reader.
  69626. */
  69627. readonly buffer: IDataBuffer;
  69628. /**
  69629. * The current byte offset from the beginning of the data buffer.
  69630. */
  69631. byteOffset: number;
  69632. private _dataView;
  69633. private _dataByteOffset;
  69634. /**
  69635. * Constructor
  69636. * @param buffer The buffer to read
  69637. */
  69638. constructor(buffer: IDataBuffer);
  69639. /**
  69640. * Loads the given byte length.
  69641. * @param byteLength The byte length to load
  69642. * @returns A promise that resolves when the load is complete
  69643. */
  69644. loadAsync(byteLength: number): Promise<void>;
  69645. /**
  69646. * Read a unsigned 32-bit integer from the currently loaded data range.
  69647. * @returns The 32-bit integer read
  69648. */
  69649. readUint32(): number;
  69650. /**
  69651. * Read a byte array from the currently loaded data range.
  69652. * @param byteLength The byte length to read
  69653. * @returns The byte array read
  69654. */
  69655. readUint8Array(byteLength: number): Uint8Array;
  69656. /**
  69657. * Read a string from the currently loaded data range.
  69658. * @param byteLength The byte length to read
  69659. * @returns The string read
  69660. */
  69661. readString(byteLength: number): string;
  69662. /**
  69663. * Skips the given byte length the currently loaded data range.
  69664. * @param byteLength The byte length to skip
  69665. */
  69666. skipBytes(byteLength: number): void;
  69667. }
  69668. }
  69669. declare module BABYLON {
  69670. /**
  69671. * Class for storing data to local storage if available or in-memory storage otherwise
  69672. */
  69673. export class DataStorage {
  69674. private static _Storage;
  69675. private static _GetStorage;
  69676. /**
  69677. * Reads a string from the data storage
  69678. * @param key The key to read
  69679. * @param defaultValue The value if the key doesn't exist
  69680. * @returns The string value
  69681. */
  69682. static ReadString(key: string, defaultValue: string): string;
  69683. /**
  69684. * Writes a string to the data storage
  69685. * @param key The key to write
  69686. * @param value The value to write
  69687. */
  69688. static WriteString(key: string, value: string): void;
  69689. /**
  69690. * Reads a boolean from the data storage
  69691. * @param key The key to read
  69692. * @param defaultValue The value if the key doesn't exist
  69693. * @returns The boolean value
  69694. */
  69695. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69696. /**
  69697. * Writes a boolean to the data storage
  69698. * @param key The key to write
  69699. * @param value The value to write
  69700. */
  69701. static WriteBoolean(key: string, value: boolean): void;
  69702. /**
  69703. * Reads a number from the data storage
  69704. * @param key The key to read
  69705. * @param defaultValue The value if the key doesn't exist
  69706. * @returns The number value
  69707. */
  69708. static ReadNumber(key: string, defaultValue: number): number;
  69709. /**
  69710. * Writes a number to the data storage
  69711. * @param key The key to write
  69712. * @param value The value to write
  69713. */
  69714. static WriteNumber(key: string, value: number): void;
  69715. }
  69716. }
  69717. declare module BABYLON {
  69718. /**
  69719. * Options used for hit testing
  69720. */
  69721. export interface IWebXRLegacyHitTestOptions {
  69722. /**
  69723. * Only test when user interacted with the scene. Default - hit test every frame
  69724. */
  69725. testOnPointerDownOnly?: boolean;
  69726. /**
  69727. * The node to use to transform the local results to world coordinates
  69728. */
  69729. worldParentNode?: TransformNode;
  69730. }
  69731. /**
  69732. * Interface defining the babylon result of raycasting/hit-test
  69733. */
  69734. export interface IWebXRLegacyHitResult {
  69735. /**
  69736. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69737. */
  69738. transformationMatrix: Matrix;
  69739. /**
  69740. * The native hit test result
  69741. */
  69742. xrHitResult: XRHitResult | XRHitTestResult;
  69743. }
  69744. /**
  69745. * The currently-working hit-test module.
  69746. * Hit test (or Ray-casting) is used to interact with the real world.
  69747. * For further information read here - https://github.com/immersive-web/hit-test
  69748. */
  69749. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69750. /**
  69751. * options to use when constructing this feature
  69752. */
  69753. readonly options: IWebXRLegacyHitTestOptions;
  69754. private _direction;
  69755. private _mat;
  69756. private _onSelectEnabled;
  69757. private _origin;
  69758. /**
  69759. * The module's name
  69760. */
  69761. static readonly Name: string;
  69762. /**
  69763. * The (Babylon) version of this module.
  69764. * This is an integer representing the implementation version.
  69765. * This number does not correspond to the WebXR specs version
  69766. */
  69767. static readonly Version: number;
  69768. /**
  69769. * Populated with the last native XR Hit Results
  69770. */
  69771. lastNativeXRHitResults: XRHitResult[];
  69772. /**
  69773. * Triggered when new babylon (transformed) hit test results are available
  69774. */
  69775. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69776. /**
  69777. * Creates a new instance of the (legacy version) hit test feature
  69778. * @param _xrSessionManager an instance of WebXRSessionManager
  69779. * @param options options to use when constructing this feature
  69780. */
  69781. constructor(_xrSessionManager: WebXRSessionManager,
  69782. /**
  69783. * options to use when constructing this feature
  69784. */
  69785. options?: IWebXRLegacyHitTestOptions);
  69786. /**
  69787. * execute a hit test with an XR Ray
  69788. *
  69789. * @param xrSession a native xrSession that will execute this hit test
  69790. * @param xrRay the ray (position and direction) to use for ray-casting
  69791. * @param referenceSpace native XR reference space to use for the hit-test
  69792. * @param filter filter function that will filter the results
  69793. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69794. */
  69795. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69796. /**
  69797. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69798. * @param event the (select) event to use to select with
  69799. * @param referenceSpace the reference space to use for this hit test
  69800. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69801. */
  69802. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69803. /**
  69804. * attach this feature
  69805. * Will usually be called by the features manager
  69806. *
  69807. * @returns true if successful.
  69808. */
  69809. attach(): boolean;
  69810. /**
  69811. * detach this feature.
  69812. * Will usually be called by the features manager
  69813. *
  69814. * @returns true if successful.
  69815. */
  69816. detach(): boolean;
  69817. /**
  69818. * Dispose this feature and all of the resources attached
  69819. */
  69820. dispose(): void;
  69821. protected _onXRFrame(frame: XRFrame): void;
  69822. private _onHitTestResults;
  69823. private _onSelect;
  69824. }
  69825. }
  69826. declare module BABYLON {
  69827. /**
  69828. * Options used in the plane detector module
  69829. */
  69830. export interface IWebXRPlaneDetectorOptions {
  69831. /**
  69832. * The node to use to transform the local results to world coordinates
  69833. */
  69834. worldParentNode?: TransformNode;
  69835. }
  69836. /**
  69837. * A babylon interface for a WebXR plane.
  69838. * A Plane is actually a polygon, built from N points in space
  69839. *
  69840. * Supported in chrome 79, not supported in canary 81 ATM
  69841. */
  69842. export interface IWebXRPlane {
  69843. /**
  69844. * a babylon-assigned ID for this polygon
  69845. */
  69846. id: number;
  69847. /**
  69848. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69849. */
  69850. polygonDefinition: Array<Vector3>;
  69851. /**
  69852. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69853. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69854. */
  69855. transformationMatrix: Matrix;
  69856. /**
  69857. * the native xr-plane object
  69858. */
  69859. xrPlane: XRPlane;
  69860. }
  69861. /**
  69862. * The plane detector is used to detect planes in the real world when in AR
  69863. * For more information see https://github.com/immersive-web/real-world-geometry/
  69864. */
  69865. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69866. private _options;
  69867. private _detectedPlanes;
  69868. private _enabled;
  69869. private _lastFrameDetected;
  69870. /**
  69871. * The module's name
  69872. */
  69873. static readonly Name: string;
  69874. /**
  69875. * The (Babylon) version of this module.
  69876. * This is an integer representing the implementation version.
  69877. * This number does not correspond to the WebXR specs version
  69878. */
  69879. static readonly Version: number;
  69880. /**
  69881. * Observers registered here will be executed when a new plane was added to the session
  69882. */
  69883. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69884. /**
  69885. * Observers registered here will be executed when a plane is no longer detected in the session
  69886. */
  69887. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69888. /**
  69889. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69890. * This can execute N times every frame
  69891. */
  69892. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69893. /**
  69894. * construct a new Plane Detector
  69895. * @param _xrSessionManager an instance of xr Session manager
  69896. * @param _options configuration to use when constructing this feature
  69897. */
  69898. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69899. /**
  69900. * Dispose this feature and all of the resources attached
  69901. */
  69902. dispose(): void;
  69903. protected _onXRFrame(frame: XRFrame): void;
  69904. private _init;
  69905. private _updatePlaneWithXRPlane;
  69906. /**
  69907. * avoiding using Array.find for global support.
  69908. * @param xrPlane the plane to find in the array
  69909. */
  69910. private findIndexInPlaneArray;
  69911. }
  69912. }
  69913. declare module BABYLON {
  69914. /**
  69915. * Configuration options of the anchor system
  69916. */
  69917. export interface IWebXRAnchorSystemOptions {
  69918. /**
  69919. * Should a new anchor be added every time a select event is triggered
  69920. */
  69921. addAnchorOnSelect?: boolean;
  69922. /**
  69923. * should the anchor system use plane detection.
  69924. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69925. */
  69926. usePlaneDetection?: boolean;
  69927. /**
  69928. * a node that will be used to convert local to world coordinates
  69929. */
  69930. worldParentNode?: TransformNode;
  69931. }
  69932. /**
  69933. * A babylon container for an XR Anchor
  69934. */
  69935. export interface IWebXRAnchor {
  69936. /**
  69937. * A babylon-assigned ID for this anchor
  69938. */
  69939. id: number;
  69940. /**
  69941. * Transformation matrix to apply to an object attached to this anchor
  69942. */
  69943. transformationMatrix: Matrix;
  69944. /**
  69945. * The native anchor object
  69946. */
  69947. xrAnchor: XRAnchor;
  69948. }
  69949. /**
  69950. * An implementation of the anchor system of WebXR.
  69951. * Note that the current documented implementation is not available in any browser. Future implementations
  69952. * will use the frame to create an anchor and not the session or a detected plane
  69953. * For further information see https://github.com/immersive-web/anchors/
  69954. */
  69955. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69956. private _options;
  69957. private _enabled;
  69958. private _hitTestModule;
  69959. private _lastFrameDetected;
  69960. private _onSelect;
  69961. private _planeDetector;
  69962. private _trackedAnchors;
  69963. /**
  69964. * The module's name
  69965. */
  69966. static readonly Name: string;
  69967. /**
  69968. * The (Babylon) version of this module.
  69969. * This is an integer representing the implementation version.
  69970. * This number does not correspond to the WebXR specs version
  69971. */
  69972. static readonly Version: number;
  69973. /**
  69974. * Observers registered here will be executed when a new anchor was added to the session
  69975. */
  69976. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69977. /**
  69978. * Observers registered here will be executed when an anchor was removed from the session
  69979. */
  69980. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69981. /**
  69982. * Observers registered here will be executed when an existing anchor updates
  69983. * This can execute N times every frame
  69984. */
  69985. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69986. /**
  69987. * constructs a new anchor system
  69988. * @param _xrSessionManager an instance of WebXRSessionManager
  69989. * @param _options configuration object for this feature
  69990. */
  69991. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69992. /**
  69993. * Add anchor at a specific XR point.
  69994. *
  69995. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69996. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69997. * @returns a promise the fulfills when the anchor was created
  69998. */
  69999. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  70000. /**
  70001. * attach this feature
  70002. * Will usually be called by the features manager
  70003. *
  70004. * @returns true if successful.
  70005. */
  70006. attach(): boolean;
  70007. /**
  70008. * detach this feature.
  70009. * Will usually be called by the features manager
  70010. *
  70011. * @returns true if successful.
  70012. */
  70013. detach(): boolean;
  70014. /**
  70015. * Dispose this feature and all of the resources attached
  70016. */
  70017. dispose(): void;
  70018. /**
  70019. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  70020. * @param hitTestModule the hit-test module to use.
  70021. */
  70022. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  70023. /**
  70024. * set the plane detector to use in order to create anchors from frames
  70025. * @param planeDetector the plane-detector module to use
  70026. * @param enable enable plane-anchors. default is true
  70027. */
  70028. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  70029. protected _onXRFrame(frame: XRFrame): void;
  70030. /**
  70031. * avoiding using Array.find for global support.
  70032. * @param xrAnchor the plane to find in the array
  70033. */
  70034. private _findIndexInAnchorArray;
  70035. private _updateAnchorWithXRFrame;
  70036. }
  70037. }
  70038. declare module BABYLON {
  70039. /**
  70040. * Options interface for the background remover plugin
  70041. */
  70042. export interface IWebXRBackgroundRemoverOptions {
  70043. /**
  70044. * Further background meshes to disable when entering AR
  70045. */
  70046. backgroundMeshes?: AbstractMesh[];
  70047. /**
  70048. * flags to configure the removal of the environment helper.
  70049. * If not set, the entire background will be removed. If set, flags should be set as well.
  70050. */
  70051. environmentHelperRemovalFlags?: {
  70052. /**
  70053. * Should the skybox be removed (default false)
  70054. */
  70055. skyBox?: boolean;
  70056. /**
  70057. * Should the ground be removed (default false)
  70058. */
  70059. ground?: boolean;
  70060. };
  70061. /**
  70062. * don't disable the environment helper
  70063. */
  70064. ignoreEnvironmentHelper?: boolean;
  70065. }
  70066. /**
  70067. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  70068. */
  70069. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  70070. /**
  70071. * read-only options to be used in this module
  70072. */
  70073. readonly options: IWebXRBackgroundRemoverOptions;
  70074. /**
  70075. * The module's name
  70076. */
  70077. static readonly Name: string;
  70078. /**
  70079. * The (Babylon) version of this module.
  70080. * This is an integer representing the implementation version.
  70081. * This number does not correspond to the WebXR specs version
  70082. */
  70083. static readonly Version: number;
  70084. /**
  70085. * registered observers will be triggered when the background state changes
  70086. */
  70087. onBackgroundStateChangedObservable: Observable<boolean>;
  70088. /**
  70089. * constructs a new background remover module
  70090. * @param _xrSessionManager the session manager for this module
  70091. * @param options read-only options to be used in this module
  70092. */
  70093. constructor(_xrSessionManager: WebXRSessionManager,
  70094. /**
  70095. * read-only options to be used in this module
  70096. */
  70097. options?: IWebXRBackgroundRemoverOptions);
  70098. /**
  70099. * attach this feature
  70100. * Will usually be called by the features manager
  70101. *
  70102. * @returns true if successful.
  70103. */
  70104. attach(): boolean;
  70105. /**
  70106. * detach this feature.
  70107. * Will usually be called by the features manager
  70108. *
  70109. * @returns true if successful.
  70110. */
  70111. detach(): boolean;
  70112. /**
  70113. * Dispose this feature and all of the resources attached
  70114. */
  70115. dispose(): void;
  70116. protected _onXRFrame(_xrFrame: XRFrame): void;
  70117. private _setBackgroundState;
  70118. }
  70119. }
  70120. declare module BABYLON {
  70121. /**
  70122. * Options for the controller physics feature
  70123. */
  70124. export class IWebXRControllerPhysicsOptions {
  70125. /**
  70126. * Should the headset get its own impostor
  70127. */
  70128. enableHeadsetImpostor?: boolean;
  70129. /**
  70130. * Optional parameters for the headset impostor
  70131. */
  70132. headsetImpostorParams?: {
  70133. /**
  70134. * The type of impostor to create. Default is sphere
  70135. */
  70136. impostorType: number;
  70137. /**
  70138. * the size of the impostor. Defaults to 10cm
  70139. */
  70140. impostorSize?: number | {
  70141. width: number;
  70142. height: number;
  70143. depth: number;
  70144. };
  70145. /**
  70146. * Friction definitions
  70147. */
  70148. friction?: number;
  70149. /**
  70150. * Restitution
  70151. */
  70152. restitution?: number;
  70153. };
  70154. /**
  70155. * The physics properties of the future impostors
  70156. */
  70157. physicsProperties?: {
  70158. /**
  70159. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  70160. * Note that this requires a physics engine that supports mesh impostors!
  70161. */
  70162. useControllerMesh?: boolean;
  70163. /**
  70164. * The type of impostor to create. Default is sphere
  70165. */
  70166. impostorType?: number;
  70167. /**
  70168. * the size of the impostor. Defaults to 10cm
  70169. */
  70170. impostorSize?: number | {
  70171. width: number;
  70172. height: number;
  70173. depth: number;
  70174. };
  70175. /**
  70176. * Friction definitions
  70177. */
  70178. friction?: number;
  70179. /**
  70180. * Restitution
  70181. */
  70182. restitution?: number;
  70183. };
  70184. /**
  70185. * the xr input to use with this pointer selection
  70186. */
  70187. xrInput: WebXRInput;
  70188. }
  70189. /**
  70190. * Add physics impostor to your webxr controllers,
  70191. * including naive calculation of their linear and angular velocity
  70192. */
  70193. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  70194. private readonly _options;
  70195. private _attachController;
  70196. private _controllers;
  70197. private _debugMode;
  70198. private _delta;
  70199. private _headsetImpostor?;
  70200. private _headsetMesh?;
  70201. private _lastTimestamp;
  70202. private _tmpQuaternion;
  70203. private _tmpVector;
  70204. /**
  70205. * The module's name
  70206. */
  70207. static readonly Name: string;
  70208. /**
  70209. * The (Babylon) version of this module.
  70210. * This is an integer representing the implementation version.
  70211. * This number does not correspond to the webxr specs version
  70212. */
  70213. static readonly Version: number;
  70214. /**
  70215. * Construct a new Controller Physics Feature
  70216. * @param _xrSessionManager the corresponding xr session manager
  70217. * @param _options options to create this feature with
  70218. */
  70219. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  70220. /**
  70221. * @hidden
  70222. * enable debugging - will show console outputs and the impostor mesh
  70223. */
  70224. _enablePhysicsDebug(): void;
  70225. /**
  70226. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  70227. * @param xrController the controller to add
  70228. */
  70229. addController(xrController: WebXRInputSource): void;
  70230. /**
  70231. * attach this feature
  70232. * Will usually be called by the features manager
  70233. *
  70234. * @returns true if successful.
  70235. */
  70236. attach(): boolean;
  70237. /**
  70238. * detach this feature.
  70239. * Will usually be called by the features manager
  70240. *
  70241. * @returns true if successful.
  70242. */
  70243. detach(): boolean;
  70244. /**
  70245. * Get the headset impostor, if enabled
  70246. * @returns the impostor
  70247. */
  70248. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70249. /**
  70250. * Get the physics impostor of a specific controller.
  70251. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70252. * @param controller the controller or the controller id of which to get the impostor
  70253. * @returns the impostor or null
  70254. */
  70255. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70256. /**
  70257. * Update the physics properties provided in the constructor
  70258. * @param newProperties the new properties object
  70259. */
  70260. setPhysicsProperties(newProperties: {
  70261. impostorType?: number;
  70262. impostorSize?: number | {
  70263. width: number;
  70264. height: number;
  70265. depth: number;
  70266. };
  70267. friction?: number;
  70268. restitution?: number;
  70269. }): void;
  70270. protected _onXRFrame(_xrFrame: any): void;
  70271. private _detachController;
  70272. }
  70273. }
  70274. declare module BABYLON {
  70275. /**
  70276. * Options used for hit testing (version 2)
  70277. */
  70278. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70279. /**
  70280. * Do not create a permanent hit test. Will usually be used when only
  70281. * transient inputs are needed.
  70282. */
  70283. disablePermanentHitTest?: boolean;
  70284. /**
  70285. * Enable transient (for example touch-based) hit test inspections
  70286. */
  70287. enableTransientHitTest?: boolean;
  70288. /**
  70289. * Offset ray for the permanent hit test
  70290. */
  70291. offsetRay?: Vector3;
  70292. /**
  70293. * Offset ray for the transient hit test
  70294. */
  70295. transientOffsetRay?: Vector3;
  70296. /**
  70297. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70298. */
  70299. useReferenceSpace?: boolean;
  70300. }
  70301. /**
  70302. * Interface defining the babylon result of hit-test
  70303. */
  70304. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70305. /**
  70306. * The input source that generated this hit test (if transient)
  70307. */
  70308. inputSource?: XRInputSource;
  70309. /**
  70310. * Is this a transient hit test
  70311. */
  70312. isTransient?: boolean;
  70313. /**
  70314. * Position of the hit test result
  70315. */
  70316. position: Vector3;
  70317. /**
  70318. * Rotation of the hit test result
  70319. */
  70320. rotationQuaternion: Quaternion;
  70321. }
  70322. /**
  70323. * The currently-working hit-test module.
  70324. * Hit test (or Ray-casting) is used to interact with the real world.
  70325. * For further information read here - https://github.com/immersive-web/hit-test
  70326. *
  70327. * Tested on chrome (mobile) 80.
  70328. */
  70329. export class WebXRHitTest extends WebXRAbstractFeature {
  70330. /**
  70331. * options to use when constructing this feature
  70332. */
  70333. readonly options: IWebXRHitTestOptions;
  70334. private _tmpMat;
  70335. private _tmpPos;
  70336. private _tmpQuat;
  70337. private _transientXrHitTestSource;
  70338. private _xrHitTestSource;
  70339. private initHitTestSource;
  70340. /**
  70341. * The module's name
  70342. */
  70343. static readonly Name: string;
  70344. /**
  70345. * The (Babylon) version of this module.
  70346. * This is an integer representing the implementation version.
  70347. * This number does not correspond to the WebXR specs version
  70348. */
  70349. static readonly Version: number;
  70350. /**
  70351. * When set to true, each hit test will have its own position/rotation objects
  70352. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70353. * the developers will clone them or copy them as they see fit.
  70354. */
  70355. autoCloneTransformation: boolean;
  70356. /**
  70357. * Populated with the last native XR Hit Results
  70358. */
  70359. lastNativeXRHitResults: XRHitResult[];
  70360. /**
  70361. * Triggered when new babylon (transformed) hit test results are available
  70362. */
  70363. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70364. /**
  70365. * Use this to temporarily pause hit test checks.
  70366. */
  70367. paused: boolean;
  70368. /**
  70369. * Creates a new instance of the hit test feature
  70370. * @param _xrSessionManager an instance of WebXRSessionManager
  70371. * @param options options to use when constructing this feature
  70372. */
  70373. constructor(_xrSessionManager: WebXRSessionManager,
  70374. /**
  70375. * options to use when constructing this feature
  70376. */
  70377. options?: IWebXRHitTestOptions);
  70378. /**
  70379. * attach this feature
  70380. * Will usually be called by the features manager
  70381. *
  70382. * @returns true if successful.
  70383. */
  70384. attach(): boolean;
  70385. /**
  70386. * detach this feature.
  70387. * Will usually be called by the features manager
  70388. *
  70389. * @returns true if successful.
  70390. */
  70391. detach(): boolean;
  70392. /**
  70393. * Dispose this feature and all of the resources attached
  70394. */
  70395. dispose(): void;
  70396. protected _onXRFrame(frame: XRFrame): void;
  70397. private _processWebXRHitTestResult;
  70398. }
  70399. }
  70400. declare module BABYLON {
  70401. /**
  70402. * The motion controller class for all microsoft mixed reality controllers
  70403. */
  70404. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70405. protected readonly _mapping: {
  70406. defaultButton: {
  70407. valueNodeName: string;
  70408. unpressedNodeName: string;
  70409. pressedNodeName: string;
  70410. };
  70411. defaultAxis: {
  70412. valueNodeName: string;
  70413. minNodeName: string;
  70414. maxNodeName: string;
  70415. };
  70416. buttons: {
  70417. "xr-standard-trigger": {
  70418. rootNodeName: string;
  70419. componentProperty: string;
  70420. states: string[];
  70421. };
  70422. "xr-standard-squeeze": {
  70423. rootNodeName: string;
  70424. componentProperty: string;
  70425. states: string[];
  70426. };
  70427. "xr-standard-touchpad": {
  70428. rootNodeName: string;
  70429. labelAnchorNodeName: string;
  70430. touchPointNodeName: string;
  70431. };
  70432. "xr-standard-thumbstick": {
  70433. rootNodeName: string;
  70434. componentProperty: string;
  70435. states: string[];
  70436. };
  70437. };
  70438. axes: {
  70439. "xr-standard-touchpad": {
  70440. "x-axis": {
  70441. rootNodeName: string;
  70442. };
  70443. "y-axis": {
  70444. rootNodeName: string;
  70445. };
  70446. };
  70447. "xr-standard-thumbstick": {
  70448. "x-axis": {
  70449. rootNodeName: string;
  70450. };
  70451. "y-axis": {
  70452. rootNodeName: string;
  70453. };
  70454. };
  70455. };
  70456. };
  70457. /**
  70458. * The base url used to load the left and right controller models
  70459. */
  70460. static MODEL_BASE_URL: string;
  70461. /**
  70462. * The name of the left controller model file
  70463. */
  70464. static MODEL_LEFT_FILENAME: string;
  70465. /**
  70466. * The name of the right controller model file
  70467. */
  70468. static MODEL_RIGHT_FILENAME: string;
  70469. profileId: string;
  70470. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  70471. protected _getFilenameAndPath(): {
  70472. filename: string;
  70473. path: string;
  70474. };
  70475. protected _getModelLoadingConstraints(): boolean;
  70476. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70477. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70478. protected _updateModel(): void;
  70479. }
  70480. }
  70481. declare module BABYLON {
  70482. /**
  70483. * The motion controller class for oculus touch (quest, rift).
  70484. * This class supports legacy mapping as well the standard xr mapping
  70485. */
  70486. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70487. private _forceLegacyControllers;
  70488. private _modelRootNode;
  70489. /**
  70490. * The base url used to load the left and right controller models
  70491. */
  70492. static MODEL_BASE_URL: string;
  70493. /**
  70494. * The name of the left controller model file
  70495. */
  70496. static MODEL_LEFT_FILENAME: string;
  70497. /**
  70498. * The name of the right controller model file
  70499. */
  70500. static MODEL_RIGHT_FILENAME: string;
  70501. /**
  70502. * Base Url for the Quest controller model.
  70503. */
  70504. static QUEST_MODEL_BASE_URL: string;
  70505. profileId: string;
  70506. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70507. protected _getFilenameAndPath(): {
  70508. filename: string;
  70509. path: string;
  70510. };
  70511. protected _getModelLoadingConstraints(): boolean;
  70512. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70513. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70514. protected _updateModel(): void;
  70515. /**
  70516. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70517. * between the touch and touch 2.
  70518. */
  70519. private _isQuest;
  70520. }
  70521. }
  70522. declare module BABYLON {
  70523. /**
  70524. * The motion controller class for the standard HTC-Vive controllers
  70525. */
  70526. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70527. private _modelRootNode;
  70528. /**
  70529. * The base url used to load the left and right controller models
  70530. */
  70531. static MODEL_BASE_URL: string;
  70532. /**
  70533. * File name for the controller model.
  70534. */
  70535. static MODEL_FILENAME: string;
  70536. profileId: string;
  70537. /**
  70538. * Create a new Vive motion controller object
  70539. * @param scene the scene to use to create this controller
  70540. * @param gamepadObject the corresponding gamepad object
  70541. * @param handedness the handedness of the controller
  70542. */
  70543. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  70544. protected _getFilenameAndPath(): {
  70545. filename: string;
  70546. path: string;
  70547. };
  70548. protected _getModelLoadingConstraints(): boolean;
  70549. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70550. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70551. protected _updateModel(): void;
  70552. }
  70553. }
  70554. declare module BABYLON {
  70555. /**
  70556. * A cursor which tracks a point on a path
  70557. */
  70558. export class PathCursor {
  70559. private path;
  70560. /**
  70561. * Stores path cursor callbacks for when an onchange event is triggered
  70562. */
  70563. private _onchange;
  70564. /**
  70565. * The value of the path cursor
  70566. */
  70567. value: number;
  70568. /**
  70569. * The animation array of the path cursor
  70570. */
  70571. animations: Animation[];
  70572. /**
  70573. * Initializes the path cursor
  70574. * @param path The path to track
  70575. */
  70576. constructor(path: Path2);
  70577. /**
  70578. * Gets the cursor point on the path
  70579. * @returns A point on the path cursor at the cursor location
  70580. */
  70581. getPoint(): Vector3;
  70582. /**
  70583. * Moves the cursor ahead by the step amount
  70584. * @param step The amount to move the cursor forward
  70585. * @returns This path cursor
  70586. */
  70587. moveAhead(step?: number): PathCursor;
  70588. /**
  70589. * Moves the cursor behind by the step amount
  70590. * @param step The amount to move the cursor back
  70591. * @returns This path cursor
  70592. */
  70593. moveBack(step?: number): PathCursor;
  70594. /**
  70595. * Moves the cursor by the step amount
  70596. * If the step amount is greater than one, an exception is thrown
  70597. * @param step The amount to move the cursor
  70598. * @returns This path cursor
  70599. */
  70600. move(step: number): PathCursor;
  70601. /**
  70602. * Ensures that the value is limited between zero and one
  70603. * @returns This path cursor
  70604. */
  70605. private ensureLimits;
  70606. /**
  70607. * Runs onchange callbacks on change (used by the animation engine)
  70608. * @returns This path cursor
  70609. */
  70610. private raiseOnChange;
  70611. /**
  70612. * Executes a function on change
  70613. * @param f A path cursor onchange callback
  70614. * @returns This path cursor
  70615. */
  70616. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70617. }
  70618. }
  70619. declare module BABYLON {
  70620. /** @hidden */
  70621. export var blurPixelShader: {
  70622. name: string;
  70623. shader: string;
  70624. };
  70625. }
  70626. declare module BABYLON {
  70627. /** @hidden */
  70628. export var pointCloudVertexDeclaration: {
  70629. name: string;
  70630. shader: string;
  70631. };
  70632. }
  70633. // Mixins
  70634. interface Window {
  70635. mozIndexedDB: IDBFactory;
  70636. webkitIndexedDB: IDBFactory;
  70637. msIndexedDB: IDBFactory;
  70638. webkitURL: typeof URL;
  70639. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70640. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70641. WebGLRenderingContext: WebGLRenderingContext;
  70642. MSGesture: MSGesture;
  70643. CANNON: any;
  70644. AudioContext: AudioContext;
  70645. webkitAudioContext: AudioContext;
  70646. PointerEvent: any;
  70647. Math: Math;
  70648. Uint8Array: Uint8ArrayConstructor;
  70649. Float32Array: Float32ArrayConstructor;
  70650. mozURL: typeof URL;
  70651. msURL: typeof URL;
  70652. VRFrameData: any; // WebVR, from specs 1.1
  70653. DracoDecoderModule: any;
  70654. setImmediate(handler: (...args: any[]) => void): number;
  70655. }
  70656. interface HTMLCanvasElement {
  70657. requestPointerLock(): void;
  70658. msRequestPointerLock?(): void;
  70659. mozRequestPointerLock?(): void;
  70660. webkitRequestPointerLock?(): void;
  70661. /** Track wether a record is in progress */
  70662. isRecording: boolean;
  70663. /** Capture Stream method defined by some browsers */
  70664. captureStream(fps?: number): MediaStream;
  70665. }
  70666. interface CanvasRenderingContext2D {
  70667. msImageSmoothingEnabled: boolean;
  70668. }
  70669. interface MouseEvent {
  70670. mozMovementX: number;
  70671. mozMovementY: number;
  70672. webkitMovementX: number;
  70673. webkitMovementY: number;
  70674. msMovementX: number;
  70675. msMovementY: number;
  70676. }
  70677. interface Navigator {
  70678. mozGetVRDevices: (any: any) => any;
  70679. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70680. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70681. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70682. webkitGetGamepads(): Gamepad[];
  70683. msGetGamepads(): Gamepad[];
  70684. webkitGamepads(): Gamepad[];
  70685. }
  70686. interface HTMLVideoElement {
  70687. mozSrcObject: any;
  70688. }
  70689. interface Math {
  70690. fround(x: number): number;
  70691. imul(a: number, b: number): number;
  70692. }
  70693. interface WebGLRenderingContext {
  70694. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70695. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70696. vertexAttribDivisor(index: number, divisor: number): void;
  70697. createVertexArray(): any;
  70698. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70699. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70700. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70701. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70702. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70703. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70704. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70705. // Queries
  70706. createQuery(): WebGLQuery;
  70707. deleteQuery(query: WebGLQuery): void;
  70708. beginQuery(target: number, query: WebGLQuery): void;
  70709. endQuery(target: number): void;
  70710. getQueryParameter(query: WebGLQuery, pname: number): any;
  70711. getQuery(target: number, pname: number): any;
  70712. MAX_SAMPLES: number;
  70713. RGBA8: number;
  70714. READ_FRAMEBUFFER: number;
  70715. DRAW_FRAMEBUFFER: number;
  70716. UNIFORM_BUFFER: number;
  70717. HALF_FLOAT_OES: number;
  70718. RGBA16F: number;
  70719. RGBA32F: number;
  70720. R32F: number;
  70721. RG32F: number;
  70722. RGB32F: number;
  70723. R16F: number;
  70724. RG16F: number;
  70725. RGB16F: number;
  70726. RED: number;
  70727. RG: number;
  70728. R8: number;
  70729. RG8: number;
  70730. UNSIGNED_INT_24_8: number;
  70731. DEPTH24_STENCIL8: number;
  70732. MIN: number;
  70733. MAX: number;
  70734. /* Multiple Render Targets */
  70735. drawBuffers(buffers: number[]): void;
  70736. readBuffer(src: number): void;
  70737. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70738. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70739. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70740. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70741. // Occlusion Query
  70742. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70743. ANY_SAMPLES_PASSED: number;
  70744. QUERY_RESULT_AVAILABLE: number;
  70745. QUERY_RESULT: number;
  70746. }
  70747. interface WebGLProgram {
  70748. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70749. }
  70750. interface EXT_disjoint_timer_query {
  70751. QUERY_COUNTER_BITS_EXT: number;
  70752. TIME_ELAPSED_EXT: number;
  70753. TIMESTAMP_EXT: number;
  70754. GPU_DISJOINT_EXT: number;
  70755. QUERY_RESULT_EXT: number;
  70756. QUERY_RESULT_AVAILABLE_EXT: number;
  70757. queryCounterEXT(query: WebGLQuery, target: number): void;
  70758. createQueryEXT(): WebGLQuery;
  70759. beginQueryEXT(target: number, query: WebGLQuery): void;
  70760. endQueryEXT(target: number): void;
  70761. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70762. deleteQueryEXT(query: WebGLQuery): void;
  70763. }
  70764. interface WebGLUniformLocation {
  70765. _currentState: any;
  70766. }
  70767. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70768. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70769. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70770. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70771. interface WebGLRenderingContext {
  70772. readonly RASTERIZER_DISCARD: number;
  70773. readonly DEPTH_COMPONENT24: number;
  70774. readonly TEXTURE_3D: number;
  70775. readonly TEXTURE_2D_ARRAY: number;
  70776. readonly TEXTURE_COMPARE_FUNC: number;
  70777. readonly TEXTURE_COMPARE_MODE: number;
  70778. readonly COMPARE_REF_TO_TEXTURE: number;
  70779. readonly TEXTURE_WRAP_R: number;
  70780. readonly HALF_FLOAT: number;
  70781. readonly RGB8: number;
  70782. readonly RED_INTEGER: number;
  70783. readonly RG_INTEGER: number;
  70784. readonly RGB_INTEGER: number;
  70785. readonly RGBA_INTEGER: number;
  70786. readonly R8_SNORM: number;
  70787. readonly RG8_SNORM: number;
  70788. readonly RGB8_SNORM: number;
  70789. readonly RGBA8_SNORM: number;
  70790. readonly R8I: number;
  70791. readonly RG8I: number;
  70792. readonly RGB8I: number;
  70793. readonly RGBA8I: number;
  70794. readonly R8UI: number;
  70795. readonly RG8UI: number;
  70796. readonly RGB8UI: number;
  70797. readonly RGBA8UI: number;
  70798. readonly R16I: number;
  70799. readonly RG16I: number;
  70800. readonly RGB16I: number;
  70801. readonly RGBA16I: number;
  70802. readonly R16UI: number;
  70803. readonly RG16UI: number;
  70804. readonly RGB16UI: number;
  70805. readonly RGBA16UI: number;
  70806. readonly R32I: number;
  70807. readonly RG32I: number;
  70808. readonly RGB32I: number;
  70809. readonly RGBA32I: number;
  70810. readonly R32UI: number;
  70811. readonly RG32UI: number;
  70812. readonly RGB32UI: number;
  70813. readonly RGBA32UI: number;
  70814. readonly RGB10_A2UI: number;
  70815. readonly R11F_G11F_B10F: number;
  70816. readonly RGB9_E5: number;
  70817. readonly RGB10_A2: number;
  70818. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70819. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70820. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70821. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70822. readonly DEPTH_COMPONENT32F: number;
  70823. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70824. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70825. 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;
  70826. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70827. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70828. readonly TRANSFORM_FEEDBACK: number;
  70829. readonly INTERLEAVED_ATTRIBS: number;
  70830. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70831. createTransformFeedback(): WebGLTransformFeedback;
  70832. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70833. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70834. beginTransformFeedback(primitiveMode: number): void;
  70835. endTransformFeedback(): void;
  70836. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70837. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70838. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70839. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70840. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70841. }
  70842. interface ImageBitmap {
  70843. readonly width: number;
  70844. readonly height: number;
  70845. close(): void;
  70846. }
  70847. interface WebGLQuery extends WebGLObject {
  70848. }
  70849. declare var WebGLQuery: {
  70850. prototype: WebGLQuery;
  70851. new(): WebGLQuery;
  70852. };
  70853. interface WebGLSampler extends WebGLObject {
  70854. }
  70855. declare var WebGLSampler: {
  70856. prototype: WebGLSampler;
  70857. new(): WebGLSampler;
  70858. };
  70859. interface WebGLSync extends WebGLObject {
  70860. }
  70861. declare var WebGLSync: {
  70862. prototype: WebGLSync;
  70863. new(): WebGLSync;
  70864. };
  70865. interface WebGLTransformFeedback extends WebGLObject {
  70866. }
  70867. declare var WebGLTransformFeedback: {
  70868. prototype: WebGLTransformFeedback;
  70869. new(): WebGLTransformFeedback;
  70870. };
  70871. interface WebGLVertexArrayObject extends WebGLObject {
  70872. }
  70873. declare var WebGLVertexArrayObject: {
  70874. prototype: WebGLVertexArrayObject;
  70875. new(): WebGLVertexArrayObject;
  70876. };
  70877. // Type definitions for WebVR API
  70878. // Project: https://w3c.github.io/webvr/
  70879. // Definitions by: six a <https://github.com/lostfictions>
  70880. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70881. interface VRDisplay extends EventTarget {
  70882. /**
  70883. * Dictionary of capabilities describing the VRDisplay.
  70884. */
  70885. readonly capabilities: VRDisplayCapabilities;
  70886. /**
  70887. * z-depth defining the far plane of the eye view frustum
  70888. * enables mapping of values in the render target depth
  70889. * attachment to scene coordinates. Initially set to 10000.0.
  70890. */
  70891. depthFar: number;
  70892. /**
  70893. * z-depth defining the near plane of the eye view frustum
  70894. * enables mapping of values in the render target depth
  70895. * attachment to scene coordinates. Initially set to 0.01.
  70896. */
  70897. depthNear: number;
  70898. /**
  70899. * An identifier for this distinct VRDisplay. Used as an
  70900. * association point in the Gamepad API.
  70901. */
  70902. readonly displayId: number;
  70903. /**
  70904. * A display name, a user-readable name identifying it.
  70905. */
  70906. readonly displayName: string;
  70907. readonly isConnected: boolean;
  70908. readonly isPresenting: boolean;
  70909. /**
  70910. * If this VRDisplay supports room-scale experiences, the optional
  70911. * stage attribute contains details on the room-scale parameters.
  70912. */
  70913. readonly stageParameters: VRStageParameters | null;
  70914. /**
  70915. * Passing the value returned by `requestAnimationFrame` to
  70916. * `cancelAnimationFrame` will unregister the callback.
  70917. * @param handle Define the hanle of the request to cancel
  70918. */
  70919. cancelAnimationFrame(handle: number): void;
  70920. /**
  70921. * Stops presenting to the VRDisplay.
  70922. * @returns a promise to know when it stopped
  70923. */
  70924. exitPresent(): Promise<void>;
  70925. /**
  70926. * Return the current VREyeParameters for the given eye.
  70927. * @param whichEye Define the eye we want the parameter for
  70928. * @returns the eye parameters
  70929. */
  70930. getEyeParameters(whichEye: string): VREyeParameters;
  70931. /**
  70932. * Populates the passed VRFrameData with the information required to render
  70933. * the current frame.
  70934. * @param frameData Define the data structure to populate
  70935. * @returns true if ok otherwise false
  70936. */
  70937. getFrameData(frameData: VRFrameData): boolean;
  70938. /**
  70939. * Get the layers currently being presented.
  70940. * @returns the list of VR layers
  70941. */
  70942. getLayers(): VRLayer[];
  70943. /**
  70944. * Return a VRPose containing the future predicted pose of the VRDisplay
  70945. * when the current frame will be presented. The value returned will not
  70946. * change until JavaScript has returned control to the browser.
  70947. *
  70948. * The VRPose will contain the position, orientation, velocity,
  70949. * and acceleration of each of these properties.
  70950. * @returns the pose object
  70951. */
  70952. getPose(): VRPose;
  70953. /**
  70954. * Return the current instantaneous pose of the VRDisplay, with no
  70955. * prediction applied.
  70956. * @returns the current instantaneous pose
  70957. */
  70958. getImmediatePose(): VRPose;
  70959. /**
  70960. * The callback passed to `requestAnimationFrame` will be called
  70961. * any time a new frame should be rendered. When the VRDisplay is
  70962. * presenting the callback will be called at the native refresh
  70963. * rate of the HMD. When not presenting this function acts
  70964. * identically to how window.requestAnimationFrame acts. Content should
  70965. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70966. * asynchronously from other displays and at differing refresh rates.
  70967. * @param callback Define the eaction to run next frame
  70968. * @returns the request handle it
  70969. */
  70970. requestAnimationFrame(callback: FrameRequestCallback): number;
  70971. /**
  70972. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70973. * Repeat calls while already presenting will update the VRLayers being displayed.
  70974. * @param layers Define the list of layer to present
  70975. * @returns a promise to know when the request has been fulfilled
  70976. */
  70977. requestPresent(layers: VRLayer[]): Promise<void>;
  70978. /**
  70979. * Reset the pose for this display, treating its current position and
  70980. * orientation as the "origin/zero" values. VRPose.position,
  70981. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70982. * updated when calling resetPose(). This should be called in only
  70983. * sitting-space experiences.
  70984. */
  70985. resetPose(): void;
  70986. /**
  70987. * The VRLayer provided to the VRDisplay will be captured and presented
  70988. * in the HMD. Calling this function has the same effect on the source
  70989. * canvas as any other operation that uses its source image, and canvases
  70990. * created without preserveDrawingBuffer set to true will be cleared.
  70991. * @param pose Define the pose to submit
  70992. */
  70993. submitFrame(pose?: VRPose): void;
  70994. }
  70995. declare var VRDisplay: {
  70996. prototype: VRDisplay;
  70997. new(): VRDisplay;
  70998. };
  70999. interface VRLayer {
  71000. leftBounds?: number[] | Float32Array | null;
  71001. rightBounds?: number[] | Float32Array | null;
  71002. source?: HTMLCanvasElement | null;
  71003. }
  71004. interface VRDisplayCapabilities {
  71005. readonly canPresent: boolean;
  71006. readonly hasExternalDisplay: boolean;
  71007. readonly hasOrientation: boolean;
  71008. readonly hasPosition: boolean;
  71009. readonly maxLayers: number;
  71010. }
  71011. interface VREyeParameters {
  71012. /** @deprecated */
  71013. readonly fieldOfView: VRFieldOfView;
  71014. readonly offset: Float32Array;
  71015. readonly renderHeight: number;
  71016. readonly renderWidth: number;
  71017. }
  71018. interface VRFieldOfView {
  71019. readonly downDegrees: number;
  71020. readonly leftDegrees: number;
  71021. readonly rightDegrees: number;
  71022. readonly upDegrees: number;
  71023. }
  71024. interface VRFrameData {
  71025. readonly leftProjectionMatrix: Float32Array;
  71026. readonly leftViewMatrix: Float32Array;
  71027. readonly pose: VRPose;
  71028. readonly rightProjectionMatrix: Float32Array;
  71029. readonly rightViewMatrix: Float32Array;
  71030. readonly timestamp: number;
  71031. }
  71032. interface VRPose {
  71033. readonly angularAcceleration: Float32Array | null;
  71034. readonly angularVelocity: Float32Array | null;
  71035. readonly linearAcceleration: Float32Array | null;
  71036. readonly linearVelocity: Float32Array | null;
  71037. readonly orientation: Float32Array | null;
  71038. readonly position: Float32Array | null;
  71039. readonly timestamp: number;
  71040. }
  71041. interface VRStageParameters {
  71042. sittingToStandingTransform?: Float32Array;
  71043. sizeX?: number;
  71044. sizeY?: number;
  71045. }
  71046. interface Navigator {
  71047. getVRDisplays(): Promise<VRDisplay[]>;
  71048. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  71049. }
  71050. interface Window {
  71051. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  71052. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  71053. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  71054. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  71055. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  71056. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  71057. }
  71058. interface Gamepad {
  71059. readonly displayId: number;
  71060. }
  71061. type XRSessionMode =
  71062. | "inline"
  71063. | "immersive-vr"
  71064. | "immersive-ar";
  71065. type XRReferenceSpaceType =
  71066. | "viewer"
  71067. | "local"
  71068. | "local-floor"
  71069. | "bounded-floor"
  71070. | "unbounded";
  71071. type XREnvironmentBlendMode =
  71072. | "opaque"
  71073. | "additive"
  71074. | "alpha-blend";
  71075. type XRVisibilityState =
  71076. | "visible"
  71077. | "visible-blurred"
  71078. | "hidden";
  71079. type XRHandedness =
  71080. | "none"
  71081. | "left"
  71082. | "right";
  71083. type XRTargetRayMode =
  71084. | "gaze"
  71085. | "tracked-pointer"
  71086. | "screen";
  71087. type XREye =
  71088. | "none"
  71089. | "left"
  71090. | "right";
  71091. type XREventType =
  71092. | "devicechange"
  71093. | "visibilitychange"
  71094. | "end"
  71095. | "inputsourceschange"
  71096. | "select"
  71097. | "selectstart"
  71098. | "selectend"
  71099. | "squeeze"
  71100. | "squeezestart"
  71101. | "squeezeend"
  71102. | "reset";
  71103. interface XRSpace extends EventTarget {
  71104. }
  71105. interface XRRenderState {
  71106. depthNear?: number;
  71107. depthFar?: number;
  71108. inlineVerticalFieldOfView?: number;
  71109. baseLayer?: XRWebGLLayer;
  71110. }
  71111. interface XRInputSource {
  71112. handedness: XRHandedness;
  71113. targetRayMode: XRTargetRayMode;
  71114. targetRaySpace: XRSpace;
  71115. gripSpace: XRSpace | undefined;
  71116. gamepad: Gamepad | undefined;
  71117. profiles: Array<string>;
  71118. }
  71119. interface XRSessionInit {
  71120. optionalFeatures?: XRReferenceSpaceType[];
  71121. requiredFeatures?: XRReferenceSpaceType[];
  71122. }
  71123. interface XRSession extends XRAnchorCreator {
  71124. addEventListener: Function;
  71125. removeEventListener: Function;
  71126. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  71127. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  71128. requestAnimationFrame: Function;
  71129. end(): Promise<void>;
  71130. renderState: XRRenderState;
  71131. inputSources: Array<XRInputSource>;
  71132. // hit test
  71133. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  71134. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  71135. // legacy AR hit test
  71136. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  71137. // legacy plane detection
  71138. updateWorldTrackingState(options: {
  71139. planeDetectionState?: { enabled: boolean; }
  71140. }): void;
  71141. }
  71142. interface XRReferenceSpace extends XRSpace {
  71143. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  71144. onreset: any;
  71145. }
  71146. type XRPlaneSet = Set<XRPlane>;
  71147. type XRAnchorSet = Set<XRAnchor>;
  71148. interface XRFrame {
  71149. session: XRSession;
  71150. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  71151. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  71152. // AR
  71153. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  71154. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  71155. // Anchors
  71156. trackedAnchors?: XRAnchorSet;
  71157. // Planes
  71158. worldInformation: {
  71159. detectedPlanes?: XRPlaneSet;
  71160. };
  71161. }
  71162. interface XRViewerPose extends XRPose {
  71163. views: Array<XRView>;
  71164. }
  71165. interface XRPose {
  71166. transform: XRRigidTransform;
  71167. emulatedPosition: boolean;
  71168. }
  71169. interface XRWebGLLayerOptions {
  71170. antialias?: boolean;
  71171. depth?: boolean;
  71172. stencil?: boolean;
  71173. alpha?: boolean;
  71174. multiview?: boolean;
  71175. framebufferScaleFactor?: number;
  71176. }
  71177. declare var XRWebGLLayer: {
  71178. prototype: XRWebGLLayer;
  71179. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  71180. };
  71181. interface XRWebGLLayer {
  71182. framebuffer: WebGLFramebuffer;
  71183. framebufferWidth: number;
  71184. framebufferHeight: number;
  71185. getViewport: Function;
  71186. }
  71187. declare class XRRigidTransform {
  71188. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  71189. position: DOMPointReadOnly;
  71190. orientation: DOMPointReadOnly;
  71191. matrix: Float32Array;
  71192. inverse: XRRigidTransform;
  71193. }
  71194. interface XRView {
  71195. eye: XREye;
  71196. projectionMatrix: Float32Array;
  71197. transform: XRRigidTransform;
  71198. }
  71199. interface XRInputSourceChangeEvent {
  71200. session: XRSession;
  71201. removed: Array<XRInputSource>;
  71202. added: Array<XRInputSource>;
  71203. }
  71204. interface XRInputSourceEvent extends Event {
  71205. readonly frame: XRFrame;
  71206. readonly inputSource: XRInputSource;
  71207. }
  71208. // Experimental(er) features
  71209. declare class XRRay {
  71210. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  71211. origin: DOMPointReadOnly;
  71212. direction: DOMPointReadOnly;
  71213. matrix: Float32Array;
  71214. }
  71215. declare enum XRHitTestTrackableType {
  71216. "point",
  71217. "plane"
  71218. }
  71219. interface XRHitResult {
  71220. hitMatrix: Float32Array;
  71221. }
  71222. interface XRTransientInputHitTestResult {
  71223. readonly inputSource: XRInputSource;
  71224. readonly results: Array<XRHitTestResult>;
  71225. }
  71226. interface XRHitTestResult {
  71227. getPose(baseSpace: XRSpace): XRPose | undefined;
  71228. }
  71229. interface XRHitTestSource {
  71230. cancel(): void;
  71231. }
  71232. interface XRTransientInputHitTestSource {
  71233. cancel(): void;
  71234. }
  71235. interface XRHitTestOptionsInit {
  71236. space: XRSpace;
  71237. entityTypes?: Array<XRHitTestTrackableType>;
  71238. offsetRay?: XRRay;
  71239. }
  71240. interface XRTransientInputHitTestOptionsInit {
  71241. profile: string;
  71242. entityTypes?: Array<XRHitTestTrackableType>;
  71243. offsetRay?: XRRay;
  71244. }
  71245. interface XRAnchor {
  71246. // remove?
  71247. id?: string;
  71248. anchorSpace: XRSpace;
  71249. lastChangedTime: number;
  71250. detach(): void;
  71251. }
  71252. interface XRPlane extends XRAnchorCreator {
  71253. orientation: "Horizontal" | "Vertical";
  71254. planeSpace: XRSpace;
  71255. polygon: Array<DOMPointReadOnly>;
  71256. lastChangedTime: number;
  71257. }
  71258. interface XRAnchorCreator {
  71259. // AR Anchors
  71260. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71261. }
  71262. /**
  71263. * @ignore
  71264. */
  71265. declare module BABYLON.GLTF2.Exporter {
  71266. }
  71267. /**
  71268. * @ignore
  71269. */
  71270. declare module BABYLON.GLTF1 {
  71271. }
  71272. declare module BABYLON.GUI {
  71273. /**
  71274. * Class used to specific a value and its associated unit
  71275. */
  71276. export class ValueAndUnit {
  71277. /** defines the unit to store */
  71278. unit: number;
  71279. /** defines a boolean indicating if the value can be negative */
  71280. negativeValueAllowed: boolean;
  71281. private _value;
  71282. private _originalUnit;
  71283. /**
  71284. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  71285. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71286. */
  71287. ignoreAdaptiveScaling: boolean;
  71288. /**
  71289. * Creates a new ValueAndUnit
  71290. * @param value defines the value to store
  71291. * @param unit defines the unit to store
  71292. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  71293. */
  71294. constructor(value: number,
  71295. /** defines the unit to store */
  71296. unit?: number,
  71297. /** defines a boolean indicating if the value can be negative */
  71298. negativeValueAllowed?: boolean);
  71299. /** Gets a boolean indicating if the value is a percentage */
  71300. get isPercentage(): boolean;
  71301. /** Gets a boolean indicating if the value is store as pixel */
  71302. get isPixel(): boolean;
  71303. /** Gets direct internal value */
  71304. get internalValue(): number;
  71305. /**
  71306. * Gets value as pixel
  71307. * @param host defines the root host
  71308. * @param refValue defines the reference value for percentages
  71309. * @returns the value as pixel
  71310. */
  71311. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  71312. /**
  71313. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  71314. * @param value defines the value to store
  71315. * @param unit defines the unit to store
  71316. * @returns the current ValueAndUnit
  71317. */
  71318. updateInPlace(value: number, unit?: number): ValueAndUnit;
  71319. /**
  71320. * Gets the value accordingly to its unit
  71321. * @param host defines the root host
  71322. * @returns the value
  71323. */
  71324. getValue(host: AdvancedDynamicTexture): number;
  71325. /**
  71326. * Gets a string representation of the value
  71327. * @param host defines the root host
  71328. * @param decimals defines an optional number of decimals to display
  71329. * @returns a string
  71330. */
  71331. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  71332. /**
  71333. * Store a value parsed from a string
  71334. * @param source defines the source string
  71335. * @returns true if the value was successfully parsed
  71336. */
  71337. fromString(source: string | number): boolean;
  71338. private static _Regex;
  71339. private static _UNITMODE_PERCENTAGE;
  71340. private static _UNITMODE_PIXEL;
  71341. /** UNITMODE_PERCENTAGE */
  71342. static get UNITMODE_PERCENTAGE(): number;
  71343. /** UNITMODE_PIXEL */
  71344. static get UNITMODE_PIXEL(): number;
  71345. }
  71346. }
  71347. declare module BABYLON.GUI {
  71348. /**
  71349. * Define a style used by control to automatically setup properties based on a template.
  71350. * Only support font related properties so far
  71351. */
  71352. export class Style implements BABYLON.IDisposable {
  71353. private _fontFamily;
  71354. private _fontStyle;
  71355. private _fontWeight;
  71356. /** @hidden */
  71357. _host: AdvancedDynamicTexture;
  71358. /** @hidden */
  71359. _fontSize: ValueAndUnit;
  71360. /**
  71361. * BABYLON.Observable raised when the style values are changed
  71362. */
  71363. onChangedObservable: BABYLON.Observable<Style>;
  71364. /**
  71365. * Creates a new style object
  71366. * @param host defines the AdvancedDynamicTexture which hosts this style
  71367. */
  71368. constructor(host: AdvancedDynamicTexture);
  71369. /**
  71370. * Gets or sets the font size
  71371. */
  71372. get fontSize(): string | number;
  71373. set fontSize(value: string | number);
  71374. /**
  71375. * Gets or sets the font family
  71376. */
  71377. get fontFamily(): string;
  71378. set fontFamily(value: string);
  71379. /**
  71380. * Gets or sets the font style
  71381. */
  71382. get fontStyle(): string;
  71383. set fontStyle(value: string);
  71384. /** Gets or sets font weight */
  71385. get fontWeight(): string;
  71386. set fontWeight(value: string);
  71387. /** Dispose all associated resources */
  71388. dispose(): void;
  71389. }
  71390. }
  71391. declare module BABYLON.GUI {
  71392. /**
  71393. * Class used to transport BABYLON.Vector2 information for pointer events
  71394. */
  71395. export class Vector2WithInfo extends BABYLON.Vector2 {
  71396. /** defines the current mouse button index */
  71397. buttonIndex: number;
  71398. /**
  71399. * Creates a new Vector2WithInfo
  71400. * @param source defines the vector2 data to transport
  71401. * @param buttonIndex defines the current mouse button index
  71402. */
  71403. constructor(source: BABYLON.Vector2,
  71404. /** defines the current mouse button index */
  71405. buttonIndex?: number);
  71406. }
  71407. /** Class used to provide 2D matrix features */
  71408. export class Matrix2D {
  71409. /** Gets the internal array of 6 floats used to store matrix data */
  71410. m: Float32Array;
  71411. /**
  71412. * Creates a new matrix
  71413. * @param m00 defines value for (0, 0)
  71414. * @param m01 defines value for (0, 1)
  71415. * @param m10 defines value for (1, 0)
  71416. * @param m11 defines value for (1, 1)
  71417. * @param m20 defines value for (2, 0)
  71418. * @param m21 defines value for (2, 1)
  71419. */
  71420. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  71421. /**
  71422. * Fills the matrix from direct values
  71423. * @param m00 defines value for (0, 0)
  71424. * @param m01 defines value for (0, 1)
  71425. * @param m10 defines value for (1, 0)
  71426. * @param m11 defines value for (1, 1)
  71427. * @param m20 defines value for (2, 0)
  71428. * @param m21 defines value for (2, 1)
  71429. * @returns the current modified matrix
  71430. */
  71431. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  71432. /**
  71433. * Gets matrix determinant
  71434. * @returns the determinant
  71435. */
  71436. determinant(): number;
  71437. /**
  71438. * Inverses the matrix and stores it in a target matrix
  71439. * @param result defines the target matrix
  71440. * @returns the current matrix
  71441. */
  71442. invertToRef(result: Matrix2D): Matrix2D;
  71443. /**
  71444. * Multiplies the current matrix with another one
  71445. * @param other defines the second operand
  71446. * @param result defines the target matrix
  71447. * @returns the current matrix
  71448. */
  71449. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71450. /**
  71451. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71452. * @param x defines the x coordinate to transform
  71453. * @param y defines the x coordinate to transform
  71454. * @param result defines the target vector2
  71455. * @returns the current matrix
  71456. */
  71457. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71458. /**
  71459. * Creates an identity matrix
  71460. * @returns a new matrix
  71461. */
  71462. static Identity(): Matrix2D;
  71463. /**
  71464. * Creates a translation matrix and stores it in a target matrix
  71465. * @param x defines the x coordinate of the translation
  71466. * @param y defines the y coordinate of the translation
  71467. * @param result defines the target matrix
  71468. */
  71469. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71470. /**
  71471. * Creates a scaling matrix and stores it in a target matrix
  71472. * @param x defines the x coordinate of the scaling
  71473. * @param y defines the y coordinate of the scaling
  71474. * @param result defines the target matrix
  71475. */
  71476. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71477. /**
  71478. * Creates a rotation matrix and stores it in a target matrix
  71479. * @param angle defines the rotation angle
  71480. * @param result defines the target matrix
  71481. */
  71482. static RotationToRef(angle: number, result: Matrix2D): void;
  71483. private static _TempPreTranslationMatrix;
  71484. private static _TempPostTranslationMatrix;
  71485. private static _TempRotationMatrix;
  71486. private static _TempScalingMatrix;
  71487. private static _TempCompose0;
  71488. private static _TempCompose1;
  71489. private static _TempCompose2;
  71490. /**
  71491. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71492. * @param tx defines the x coordinate of the translation
  71493. * @param ty defines the y coordinate of the translation
  71494. * @param angle defines the rotation angle
  71495. * @param scaleX defines the x coordinate of the scaling
  71496. * @param scaleY defines the y coordinate of the scaling
  71497. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71498. * @param result defines the target matrix
  71499. */
  71500. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71501. }
  71502. }
  71503. declare module BABYLON.GUI {
  71504. /**
  71505. * Class used to store 2D control sizes
  71506. */
  71507. export class Measure {
  71508. /** defines left coordinate */
  71509. left: number;
  71510. /** defines top coordinate */
  71511. top: number;
  71512. /** defines width dimension */
  71513. width: number;
  71514. /** defines height dimension */
  71515. height: number;
  71516. /**
  71517. * Creates a new measure
  71518. * @param left defines left coordinate
  71519. * @param top defines top coordinate
  71520. * @param width defines width dimension
  71521. * @param height defines height dimension
  71522. */
  71523. constructor(
  71524. /** defines left coordinate */
  71525. left: number,
  71526. /** defines top coordinate */
  71527. top: number,
  71528. /** defines width dimension */
  71529. width: number,
  71530. /** defines height dimension */
  71531. height: number);
  71532. /**
  71533. * Copy from another measure
  71534. * @param other defines the other measure to copy from
  71535. */
  71536. copyFrom(other: Measure): void;
  71537. /**
  71538. * Copy from a group of 4 floats
  71539. * @param left defines left coordinate
  71540. * @param top defines top coordinate
  71541. * @param width defines width dimension
  71542. * @param height defines height dimension
  71543. */
  71544. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71545. /**
  71546. * Computes the axis aligned bounding box measure for two given measures
  71547. * @param a Input measure
  71548. * @param b Input measure
  71549. * @param result the resulting bounding measure
  71550. */
  71551. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71552. /**
  71553. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71554. * @param transform the matrix to transform the measure before computing the AABB
  71555. * @param result the resulting AABB
  71556. */
  71557. transformToRef(transform: Matrix2D, result: Measure): void;
  71558. /**
  71559. * Check equality between this measure and another one
  71560. * @param other defines the other measures
  71561. * @returns true if both measures are equals
  71562. */
  71563. isEqualsTo(other: Measure): boolean;
  71564. /**
  71565. * Creates an empty measure
  71566. * @returns a new measure
  71567. */
  71568. static Empty(): Measure;
  71569. }
  71570. }
  71571. declare module BABYLON.GUI {
  71572. /**
  71573. * Interface used to define a control that can receive focus
  71574. */
  71575. export interface IFocusableControl {
  71576. /**
  71577. * Function called when the control receives the focus
  71578. */
  71579. onFocus(): void;
  71580. /**
  71581. * Function called when the control loses the focus
  71582. */
  71583. onBlur(): void;
  71584. /**
  71585. * Function called to let the control handle keyboard events
  71586. * @param evt defines the current keyboard event
  71587. */
  71588. processKeyboard(evt: KeyboardEvent): void;
  71589. /**
  71590. * Function called to get the list of controls that should not steal the focus from this control
  71591. * @returns an array of controls
  71592. */
  71593. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71594. }
  71595. /**
  71596. * Class used to create texture to support 2D GUI elements
  71597. * @see http://doc.babylonjs.com/how_to/gui
  71598. */
  71599. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71600. private _isDirty;
  71601. private _renderObserver;
  71602. private _resizeObserver;
  71603. private _preKeyboardObserver;
  71604. private _pointerMoveObserver;
  71605. private _pointerObserver;
  71606. private _canvasPointerOutObserver;
  71607. private _background;
  71608. /** @hidden */
  71609. _rootContainer: Container;
  71610. /** @hidden */
  71611. _lastPickedControl: Control;
  71612. /** @hidden */
  71613. _lastControlOver: {
  71614. [pointerId: number]: Control;
  71615. };
  71616. /** @hidden */
  71617. _lastControlDown: {
  71618. [pointerId: number]: Control;
  71619. };
  71620. /** @hidden */
  71621. _capturingControl: {
  71622. [pointerId: number]: Control;
  71623. };
  71624. /** @hidden */
  71625. _shouldBlockPointer: boolean;
  71626. /** @hidden */
  71627. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71628. /** @hidden */
  71629. _linkedControls: Control[];
  71630. private _isFullscreen;
  71631. private _fullscreenViewport;
  71632. private _idealWidth;
  71633. private _idealHeight;
  71634. private _useSmallestIdeal;
  71635. private _renderAtIdealSize;
  71636. private _focusedControl;
  71637. private _blockNextFocusCheck;
  71638. private _renderScale;
  71639. private _rootElement;
  71640. private _cursorChanged;
  71641. private _defaultMousePointerId;
  71642. /** @hidden */
  71643. _numLayoutCalls: number;
  71644. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71645. get numLayoutCalls(): number;
  71646. /** @hidden */
  71647. _numRenderCalls: number;
  71648. /** Gets the number of render calls made the last time the ADT has been rendered */
  71649. get numRenderCalls(): number;
  71650. /**
  71651. * Define type to string to ensure compatibility across browsers
  71652. * Safari doesn't support DataTransfer constructor
  71653. */
  71654. private _clipboardData;
  71655. /**
  71656. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71657. */
  71658. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71659. /**
  71660. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71661. */
  71662. onControlPickedObservable: BABYLON.Observable<Control>;
  71663. /**
  71664. * BABYLON.Observable event triggered before layout is evaluated
  71665. */
  71666. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71667. /**
  71668. * BABYLON.Observable event triggered after the layout was evaluated
  71669. */
  71670. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71671. /**
  71672. * BABYLON.Observable event triggered before the texture is rendered
  71673. */
  71674. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71675. /**
  71676. * BABYLON.Observable event triggered after the texture was rendered
  71677. */
  71678. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71679. /**
  71680. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71681. */
  71682. premulAlpha: boolean;
  71683. /**
  71684. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71685. * Useful when you want more antialiasing
  71686. */
  71687. get renderScale(): number;
  71688. set renderScale(value: number);
  71689. /** Gets or sets the background color */
  71690. get background(): string;
  71691. set background(value: string);
  71692. /**
  71693. * Gets or sets the ideal width used to design controls.
  71694. * The GUI will then rescale everything accordingly
  71695. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71696. */
  71697. get idealWidth(): number;
  71698. set idealWidth(value: number);
  71699. /**
  71700. * Gets or sets the ideal height used to design controls.
  71701. * The GUI will then rescale everything accordingly
  71702. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71703. */
  71704. get idealHeight(): number;
  71705. set idealHeight(value: number);
  71706. /**
  71707. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71708. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71709. */
  71710. get useSmallestIdeal(): boolean;
  71711. set useSmallestIdeal(value: boolean);
  71712. /**
  71713. * Gets or sets a boolean indicating if adaptive scaling must be used
  71714. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71715. */
  71716. get renderAtIdealSize(): boolean;
  71717. set renderAtIdealSize(value: boolean);
  71718. /**
  71719. * Gets the ratio used when in "ideal mode"
  71720. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71721. * */
  71722. get idealRatio(): number;
  71723. /**
  71724. * Gets the underlying layer used to render the texture when in fullscreen mode
  71725. */
  71726. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71727. /**
  71728. * Gets the root container control
  71729. */
  71730. get rootContainer(): Container;
  71731. /**
  71732. * Returns an array containing the root container.
  71733. * This is mostly used to let the Inspector introspects the ADT
  71734. * @returns an array containing the rootContainer
  71735. */
  71736. getChildren(): Array<Container>;
  71737. /**
  71738. * Will return all controls that are inside this texture
  71739. * @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
  71740. * @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
  71741. * @return all child controls
  71742. */
  71743. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71744. /**
  71745. * Gets or sets the current focused control
  71746. */
  71747. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71748. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71749. /**
  71750. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71751. */
  71752. get isForeground(): boolean;
  71753. set isForeground(value: boolean);
  71754. /**
  71755. * Gets or set information about clipboardData
  71756. */
  71757. get clipboardData(): string;
  71758. set clipboardData(value: string);
  71759. /**
  71760. * Creates a new AdvancedDynamicTexture
  71761. * @param name defines the name of the texture
  71762. * @param width defines the width of the texture
  71763. * @param height defines the height of the texture
  71764. * @param scene defines the hosting scene
  71765. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71766. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71767. */
  71768. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71769. /**
  71770. * Get the current class name of the texture useful for serialization or dynamic coding.
  71771. * @returns "AdvancedDynamicTexture"
  71772. */
  71773. getClassName(): string;
  71774. /**
  71775. * Function used to execute a function on all controls
  71776. * @param func defines the function to execute
  71777. * @param container defines the container where controls belong. If null the root container will be used
  71778. */
  71779. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71780. private _useInvalidateRectOptimization;
  71781. /**
  71782. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71783. */
  71784. get useInvalidateRectOptimization(): boolean;
  71785. set useInvalidateRectOptimization(value: boolean);
  71786. private _invalidatedRectangle;
  71787. /**
  71788. * Invalidates a rectangle area on the gui texture
  71789. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71790. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71791. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71792. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71793. */
  71794. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71795. /**
  71796. * Marks the texture as dirty forcing a complete update
  71797. */
  71798. markAsDirty(): void;
  71799. /**
  71800. * Helper function used to create a new style
  71801. * @returns a new style
  71802. * @see http://doc.babylonjs.com/how_to/gui#styles
  71803. */
  71804. createStyle(): Style;
  71805. /**
  71806. * Adds a new control to the root container
  71807. * @param control defines the control to add
  71808. * @returns the current texture
  71809. */
  71810. addControl(control: Control): AdvancedDynamicTexture;
  71811. /**
  71812. * Removes a control from the root container
  71813. * @param control defines the control to remove
  71814. * @returns the current texture
  71815. */
  71816. removeControl(control: Control): AdvancedDynamicTexture;
  71817. /**
  71818. * Release all resources
  71819. */
  71820. dispose(): void;
  71821. private _onResize;
  71822. /** @hidden */
  71823. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71824. /**
  71825. * Get screen coordinates for a vector3
  71826. * @param position defines the position to project
  71827. * @param worldMatrix defines the world matrix to use
  71828. * @returns the projected position
  71829. */
  71830. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71831. private _checkUpdate;
  71832. private _clearMeasure;
  71833. private _render;
  71834. /** @hidden */
  71835. _changeCursor(cursor: string): void;
  71836. /** @hidden */
  71837. _registerLastControlDown(control: Control, pointerId: number): void;
  71838. private _doPicking;
  71839. /** @hidden */
  71840. _cleanControlAfterRemovalFromList(list: {
  71841. [pointerId: number]: Control;
  71842. }, control: Control): void;
  71843. /** @hidden */
  71844. _cleanControlAfterRemoval(control: Control): void;
  71845. /** Attach to all scene events required to support pointer events */
  71846. attach(): void;
  71847. /** @hidden */
  71848. private onClipboardCopy;
  71849. /** @hidden */
  71850. private onClipboardCut;
  71851. /** @hidden */
  71852. private onClipboardPaste;
  71853. /**
  71854. * Register the clipboard Events onto the canvas
  71855. */
  71856. registerClipboardEvents(): void;
  71857. /**
  71858. * Unregister the clipboard Events from the canvas
  71859. */
  71860. unRegisterClipboardEvents(): void;
  71861. /**
  71862. * Connect the texture to a hosting mesh to enable interactions
  71863. * @param mesh defines the mesh to attach to
  71864. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71865. */
  71866. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71867. /**
  71868. * Move the focus to a specific control
  71869. * @param control defines the control which will receive the focus
  71870. */
  71871. moveFocusToControl(control: IFocusableControl): void;
  71872. private _manageFocus;
  71873. private _attachToOnPointerOut;
  71874. /**
  71875. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71876. * @param mesh defines the mesh which will receive the texture
  71877. * @param width defines the texture width (1024 by default)
  71878. * @param height defines the texture height (1024 by default)
  71879. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71880. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71881. * @returns a new AdvancedDynamicTexture
  71882. */
  71883. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71884. /**
  71885. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71886. * In this mode the texture will rely on a layer for its rendering.
  71887. * This allows it to be treated like any other layer.
  71888. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71889. * LayerMask is set through advancedTexture.layer.layerMask
  71890. * @param name defines name for the texture
  71891. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71892. * @param scene defines the hsoting scene
  71893. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71894. * @returns a new AdvancedDynamicTexture
  71895. */
  71896. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71897. }
  71898. }
  71899. declare module BABYLON.GUI {
  71900. /**
  71901. * Root class used for all 2D controls
  71902. * @see http://doc.babylonjs.com/how_to/gui#controls
  71903. */
  71904. export class Control {
  71905. /** defines the name of the control */
  71906. name?: string | undefined;
  71907. /**
  71908. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71909. */
  71910. static AllowAlphaInheritance: boolean;
  71911. private _alpha;
  71912. private _alphaSet;
  71913. private _zIndex;
  71914. /** @hidden */
  71915. _host: AdvancedDynamicTexture;
  71916. /** Gets or sets the control parent */
  71917. parent: BABYLON.Nullable<Container>;
  71918. /** @hidden */
  71919. _currentMeasure: Measure;
  71920. private _fontFamily;
  71921. private _fontStyle;
  71922. private _fontWeight;
  71923. private _fontSize;
  71924. private _font;
  71925. /** @hidden */
  71926. _width: ValueAndUnit;
  71927. /** @hidden */
  71928. _height: ValueAndUnit;
  71929. /** @hidden */
  71930. protected _fontOffset: {
  71931. ascent: number;
  71932. height: number;
  71933. descent: number;
  71934. };
  71935. private _color;
  71936. private _style;
  71937. private _styleObserver;
  71938. /** @hidden */
  71939. protected _horizontalAlignment: number;
  71940. /** @hidden */
  71941. protected _verticalAlignment: number;
  71942. /** @hidden */
  71943. protected _isDirty: boolean;
  71944. /** @hidden */
  71945. protected _wasDirty: boolean;
  71946. /** @hidden */
  71947. _tempParentMeasure: Measure;
  71948. /** @hidden */
  71949. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71950. /** @hidden */
  71951. protected _cachedParentMeasure: Measure;
  71952. private _paddingLeft;
  71953. private _paddingRight;
  71954. private _paddingTop;
  71955. private _paddingBottom;
  71956. /** @hidden */
  71957. _left: ValueAndUnit;
  71958. /** @hidden */
  71959. _top: ValueAndUnit;
  71960. private _scaleX;
  71961. private _scaleY;
  71962. private _rotation;
  71963. private _transformCenterX;
  71964. private _transformCenterY;
  71965. /** @hidden */
  71966. _transformMatrix: Matrix2D;
  71967. /** @hidden */
  71968. protected _invertTransformMatrix: Matrix2D;
  71969. /** @hidden */
  71970. protected _transformedPosition: BABYLON.Vector2;
  71971. private _isMatrixDirty;
  71972. private _cachedOffsetX;
  71973. private _cachedOffsetY;
  71974. private _isVisible;
  71975. private _isHighlighted;
  71976. /** @hidden */
  71977. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71978. private _fontSet;
  71979. private _dummyVector2;
  71980. private _downCount;
  71981. private _enterCount;
  71982. private _doNotRender;
  71983. private _downPointerIds;
  71984. protected _isEnabled: boolean;
  71985. protected _disabledColor: string;
  71986. protected _disabledColorItem: string;
  71987. /** @hidden */
  71988. protected _rebuildLayout: boolean;
  71989. /** @hidden */
  71990. _customData: any;
  71991. /** @hidden */
  71992. _isClipped: boolean;
  71993. /** @hidden */
  71994. _automaticSize: boolean;
  71995. /** @hidden */
  71996. _tag: any;
  71997. /**
  71998. * 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
  71999. */
  72000. uniqueId: number;
  72001. /**
  72002. * Gets or sets an object used to store user defined information for the node
  72003. */
  72004. metadata: any;
  72005. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  72006. isHitTestVisible: boolean;
  72007. /** Gets or sets a boolean indicating if the control can block pointer events */
  72008. isPointerBlocker: boolean;
  72009. /** Gets or sets a boolean indicating if the control can be focusable */
  72010. isFocusInvisible: boolean;
  72011. /**
  72012. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  72013. * 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
  72014. */
  72015. clipChildren: boolean;
  72016. /**
  72017. * Gets or sets a boolean indicating that control content must be clipped
  72018. * 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
  72019. */
  72020. clipContent: boolean;
  72021. /**
  72022. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  72023. */
  72024. useBitmapCache: boolean;
  72025. private _cacheData;
  72026. private _shadowOffsetX;
  72027. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  72028. get shadowOffsetX(): number;
  72029. set shadowOffsetX(value: number);
  72030. private _shadowOffsetY;
  72031. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  72032. get shadowOffsetY(): number;
  72033. set shadowOffsetY(value: number);
  72034. private _shadowBlur;
  72035. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  72036. get shadowBlur(): number;
  72037. set shadowBlur(value: number);
  72038. private _shadowColor;
  72039. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  72040. get shadowColor(): string;
  72041. set shadowColor(value: string);
  72042. /** Gets or sets the cursor to use when the control is hovered */
  72043. hoverCursor: string;
  72044. /** @hidden */
  72045. protected _linkOffsetX: ValueAndUnit;
  72046. /** @hidden */
  72047. protected _linkOffsetY: ValueAndUnit;
  72048. /** Gets the control type name */
  72049. get typeName(): string;
  72050. /**
  72051. * Get the current class name of the control.
  72052. * @returns current class name
  72053. */
  72054. getClassName(): string;
  72055. /**
  72056. * An event triggered when pointer wheel is scrolled
  72057. */
  72058. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  72059. /**
  72060. * An event triggered when the pointer move over the control.
  72061. */
  72062. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  72063. /**
  72064. * An event triggered when the pointer move out of the control.
  72065. */
  72066. onPointerOutObservable: BABYLON.Observable<Control>;
  72067. /**
  72068. * An event triggered when the pointer taps the control
  72069. */
  72070. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  72071. /**
  72072. * An event triggered when pointer up
  72073. */
  72074. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  72075. /**
  72076. * An event triggered when a control is clicked on
  72077. */
  72078. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  72079. /**
  72080. * An event triggered when pointer enters the control
  72081. */
  72082. onPointerEnterObservable: BABYLON.Observable<Control>;
  72083. /**
  72084. * An event triggered when the control is marked as dirty
  72085. */
  72086. onDirtyObservable: BABYLON.Observable<Control>;
  72087. /**
  72088. * An event triggered before drawing the control
  72089. */
  72090. onBeforeDrawObservable: BABYLON.Observable<Control>;
  72091. /**
  72092. * An event triggered after the control was drawn
  72093. */
  72094. onAfterDrawObservable: BABYLON.Observable<Control>;
  72095. /**
  72096. * Get the hosting AdvancedDynamicTexture
  72097. */
  72098. get host(): AdvancedDynamicTexture;
  72099. /** Gets or set information about font offsets (used to render and align text) */
  72100. get fontOffset(): {
  72101. ascent: number;
  72102. height: number;
  72103. descent: number;
  72104. };
  72105. set fontOffset(offset: {
  72106. ascent: number;
  72107. height: number;
  72108. descent: number;
  72109. });
  72110. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  72111. get alpha(): number;
  72112. set alpha(value: number);
  72113. /**
  72114. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  72115. */
  72116. get isHighlighted(): boolean;
  72117. set isHighlighted(value: boolean);
  72118. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  72119. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72120. */
  72121. get scaleX(): number;
  72122. set scaleX(value: number);
  72123. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  72124. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72125. */
  72126. get scaleY(): number;
  72127. set scaleY(value: number);
  72128. /** Gets or sets the rotation angle (0 by default)
  72129. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72130. */
  72131. get rotation(): number;
  72132. set rotation(value: number);
  72133. /** Gets or sets the transformation center on Y axis (0 by default)
  72134. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72135. */
  72136. get transformCenterY(): number;
  72137. set transformCenterY(value: number);
  72138. /** Gets or sets the transformation center on X axis (0 by default)
  72139. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72140. */
  72141. get transformCenterX(): number;
  72142. set transformCenterX(value: number);
  72143. /**
  72144. * Gets or sets the horizontal alignment
  72145. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72146. */
  72147. get horizontalAlignment(): number;
  72148. set horizontalAlignment(value: number);
  72149. /**
  72150. * Gets or sets the vertical alignment
  72151. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72152. */
  72153. get verticalAlignment(): number;
  72154. set verticalAlignment(value: number);
  72155. /**
  72156. * Gets or sets control width
  72157. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72158. */
  72159. get width(): string | number;
  72160. set width(value: string | number);
  72161. /**
  72162. * Gets or sets the control width in pixel
  72163. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72164. */
  72165. get widthInPixels(): number;
  72166. set widthInPixels(value: number);
  72167. /**
  72168. * Gets or sets control height
  72169. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72170. */
  72171. get height(): string | number;
  72172. set height(value: string | number);
  72173. /**
  72174. * Gets or sets control height in pixel
  72175. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72176. */
  72177. get heightInPixels(): number;
  72178. set heightInPixels(value: number);
  72179. /** Gets or set font family */
  72180. get fontFamily(): string;
  72181. set fontFamily(value: string);
  72182. /** Gets or sets font style */
  72183. get fontStyle(): string;
  72184. set fontStyle(value: string);
  72185. /** Gets or sets font weight */
  72186. get fontWeight(): string;
  72187. set fontWeight(value: string);
  72188. /**
  72189. * Gets or sets style
  72190. * @see http://doc.babylonjs.com/how_to/gui#styles
  72191. */
  72192. get style(): BABYLON.Nullable<Style>;
  72193. set style(value: BABYLON.Nullable<Style>);
  72194. /** @hidden */
  72195. get _isFontSizeInPercentage(): boolean;
  72196. /** Gets or sets font size in pixels */
  72197. get fontSizeInPixels(): number;
  72198. set fontSizeInPixels(value: number);
  72199. /** Gets or sets font size */
  72200. get fontSize(): string | number;
  72201. set fontSize(value: string | number);
  72202. /** Gets or sets foreground color */
  72203. get color(): string;
  72204. set color(value: string);
  72205. /** Gets or sets z index which is used to reorder controls on the z axis */
  72206. get zIndex(): number;
  72207. set zIndex(value: number);
  72208. /** Gets or sets a boolean indicating if the control can be rendered */
  72209. get notRenderable(): boolean;
  72210. set notRenderable(value: boolean);
  72211. /** Gets or sets a boolean indicating if the control is visible */
  72212. get isVisible(): boolean;
  72213. set isVisible(value: boolean);
  72214. /** Gets a boolean indicating that the control needs to update its rendering */
  72215. get isDirty(): boolean;
  72216. /**
  72217. * Gets the current linked mesh (or null if none)
  72218. */
  72219. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72220. /**
  72221. * Gets or sets a value indicating the padding to use on the left of the control
  72222. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72223. */
  72224. get paddingLeft(): string | number;
  72225. set paddingLeft(value: string | number);
  72226. /**
  72227. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  72228. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72229. */
  72230. get paddingLeftInPixels(): number;
  72231. set paddingLeftInPixels(value: number);
  72232. /**
  72233. * Gets or sets a value indicating the padding to use on the right of the control
  72234. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72235. */
  72236. get paddingRight(): string | number;
  72237. set paddingRight(value: string | number);
  72238. /**
  72239. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  72240. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72241. */
  72242. get paddingRightInPixels(): number;
  72243. set paddingRightInPixels(value: number);
  72244. /**
  72245. * Gets or sets a value indicating the padding to use on the top of the control
  72246. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72247. */
  72248. get paddingTop(): string | number;
  72249. set paddingTop(value: string | number);
  72250. /**
  72251. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  72252. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72253. */
  72254. get paddingTopInPixels(): number;
  72255. set paddingTopInPixels(value: number);
  72256. /**
  72257. * Gets or sets a value indicating the padding to use on the bottom of the control
  72258. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72259. */
  72260. get paddingBottom(): string | number;
  72261. set paddingBottom(value: string | number);
  72262. /**
  72263. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  72264. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72265. */
  72266. get paddingBottomInPixels(): number;
  72267. set paddingBottomInPixels(value: number);
  72268. /**
  72269. * Gets or sets a value indicating the left coordinate of the control
  72270. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72271. */
  72272. get left(): string | number;
  72273. set left(value: string | number);
  72274. /**
  72275. * Gets or sets a value indicating the left coordinate in pixels of the control
  72276. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72277. */
  72278. get leftInPixels(): number;
  72279. set leftInPixels(value: number);
  72280. /**
  72281. * Gets or sets a value indicating the top coordinate of the control
  72282. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72283. */
  72284. get top(): string | number;
  72285. set top(value: string | number);
  72286. /**
  72287. * Gets or sets a value indicating the top coordinate in pixels of the control
  72288. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72289. */
  72290. get topInPixels(): number;
  72291. set topInPixels(value: number);
  72292. /**
  72293. * Gets or sets a value indicating the offset on X axis to the linked mesh
  72294. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72295. */
  72296. get linkOffsetX(): string | number;
  72297. set linkOffsetX(value: string | number);
  72298. /**
  72299. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  72300. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72301. */
  72302. get linkOffsetXInPixels(): number;
  72303. set linkOffsetXInPixels(value: number);
  72304. /**
  72305. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  72306. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72307. */
  72308. get linkOffsetY(): string | number;
  72309. set linkOffsetY(value: string | number);
  72310. /**
  72311. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  72312. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72313. */
  72314. get linkOffsetYInPixels(): number;
  72315. set linkOffsetYInPixels(value: number);
  72316. /** Gets the center coordinate on X axis */
  72317. get centerX(): number;
  72318. /** Gets the center coordinate on Y axis */
  72319. get centerY(): number;
  72320. /** Gets or sets if control is Enabled*/
  72321. get isEnabled(): boolean;
  72322. set isEnabled(value: boolean);
  72323. /** Gets or sets background color of control if it's disabled*/
  72324. get disabledColor(): string;
  72325. set disabledColor(value: string);
  72326. /** Gets or sets front color of control if it's disabled*/
  72327. get disabledColorItem(): string;
  72328. set disabledColorItem(value: string);
  72329. /**
  72330. * Creates a new control
  72331. * @param name defines the name of the control
  72332. */
  72333. constructor(
  72334. /** defines the name of the control */
  72335. name?: string | undefined);
  72336. /** @hidden */
  72337. protected _getTypeName(): string;
  72338. /**
  72339. * Gets the first ascendant in the hierarchy of the given type
  72340. * @param className defines the required type
  72341. * @returns the ascendant or null if not found
  72342. */
  72343. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  72344. /** @hidden */
  72345. _resetFontCache(): void;
  72346. /**
  72347. * Determines if a container is an ascendant of the current control
  72348. * @param container defines the container to look for
  72349. * @returns true if the container is one of the ascendant of the control
  72350. */
  72351. isAscendant(container: Control): boolean;
  72352. /**
  72353. * Gets coordinates in local control space
  72354. * @param globalCoordinates defines the coordinates to transform
  72355. * @returns the new coordinates in local space
  72356. */
  72357. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72358. /**
  72359. * Gets coordinates in local control space
  72360. * @param globalCoordinates defines the coordinates to transform
  72361. * @param result defines the target vector2 where to store the result
  72362. * @returns the current control
  72363. */
  72364. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  72365. /**
  72366. * Gets coordinates in parent local control space
  72367. * @param globalCoordinates defines the coordinates to transform
  72368. * @returns the new coordinates in parent local space
  72369. */
  72370. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72371. /**
  72372. * Move the current control to a vector3 position projected onto the screen.
  72373. * @param position defines the target position
  72374. * @param scene defines the hosting scene
  72375. */
  72376. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  72377. /**
  72378. * Will store all controls that have this control as ascendant in a given array
  72379. * @param results defines the array where to store the descendants
  72380. * @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
  72381. * @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
  72382. */
  72383. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72384. /**
  72385. * Will return all controls that have this control as ascendant
  72386. * @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
  72387. * @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
  72388. * @return all child controls
  72389. */
  72390. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72391. /**
  72392. * Link current control with a target mesh
  72393. * @param mesh defines the mesh to link with
  72394. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72395. */
  72396. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  72397. /** @hidden */
  72398. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  72399. /** @hidden */
  72400. _offsetLeft(offset: number): void;
  72401. /** @hidden */
  72402. _offsetTop(offset: number): void;
  72403. /** @hidden */
  72404. _markMatrixAsDirty(): void;
  72405. /** @hidden */
  72406. _flagDescendantsAsMatrixDirty(): void;
  72407. /** @hidden */
  72408. _intersectsRect(rect: Measure): boolean;
  72409. /** @hidden */
  72410. protected invalidateRect(): void;
  72411. /** @hidden */
  72412. _markAsDirty(force?: boolean): void;
  72413. /** @hidden */
  72414. _markAllAsDirty(): void;
  72415. /** @hidden */
  72416. _link(host: AdvancedDynamicTexture): void;
  72417. /** @hidden */
  72418. protected _transform(context?: CanvasRenderingContext2D): void;
  72419. /** @hidden */
  72420. _renderHighlight(context: CanvasRenderingContext2D): void;
  72421. /** @hidden */
  72422. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72423. /** @hidden */
  72424. protected _applyStates(context: CanvasRenderingContext2D): void;
  72425. /** @hidden */
  72426. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72427. /** @hidden */
  72428. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72429. protected _evaluateClippingState(parentMeasure: Measure): void;
  72430. /** @hidden */
  72431. _measure(): void;
  72432. /** @hidden */
  72433. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72434. /** @hidden */
  72435. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72436. /** @hidden */
  72437. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72438. /** @hidden */
  72439. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72440. private static _ClipMeasure;
  72441. private _tmpMeasureA;
  72442. private _clip;
  72443. /** @hidden */
  72444. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72445. /** @hidden */
  72446. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72447. /**
  72448. * Tests if a given coordinates belong to the current control
  72449. * @param x defines x coordinate to test
  72450. * @param y defines y coordinate to test
  72451. * @returns true if the coordinates are inside the control
  72452. */
  72453. contains(x: number, y: number): boolean;
  72454. /** @hidden */
  72455. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72456. /** @hidden */
  72457. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72458. /** @hidden */
  72459. _onPointerEnter(target: Control): boolean;
  72460. /** @hidden */
  72461. _onPointerOut(target: Control, force?: boolean): void;
  72462. /** @hidden */
  72463. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72464. /** @hidden */
  72465. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72466. /** @hidden */
  72467. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72468. /** @hidden */
  72469. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72470. /** @hidden */
  72471. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72472. private _prepareFont;
  72473. /** Releases associated resources */
  72474. dispose(): void;
  72475. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72476. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72477. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72478. private static _VERTICAL_ALIGNMENT_TOP;
  72479. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72480. private static _VERTICAL_ALIGNMENT_CENTER;
  72481. /** HORIZONTAL_ALIGNMENT_LEFT */
  72482. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72483. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72484. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72485. /** HORIZONTAL_ALIGNMENT_CENTER */
  72486. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72487. /** VERTICAL_ALIGNMENT_TOP */
  72488. static get VERTICAL_ALIGNMENT_TOP(): number;
  72489. /** VERTICAL_ALIGNMENT_BOTTOM */
  72490. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72491. /** VERTICAL_ALIGNMENT_CENTER */
  72492. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72493. private static _FontHeightSizes;
  72494. /** @hidden */
  72495. static _GetFontOffset(font: string): {
  72496. ascent: number;
  72497. height: number;
  72498. descent: number;
  72499. };
  72500. /**
  72501. * Creates a stack panel that can be used to render headers
  72502. * @param control defines the control to associate with the header
  72503. * @param text defines the text of the header
  72504. * @param size defines the size of the header
  72505. * @param options defines options used to configure the header
  72506. * @returns a new StackPanel
  72507. * @ignore
  72508. * @hidden
  72509. */
  72510. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72511. isHorizontal: boolean;
  72512. controlFirst: boolean;
  72513. }) => any;
  72514. /** @hidden */
  72515. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72516. }
  72517. }
  72518. declare module BABYLON.GUI {
  72519. /**
  72520. * Root class for 2D containers
  72521. * @see http://doc.babylonjs.com/how_to/gui#containers
  72522. */
  72523. export class Container extends Control {
  72524. name?: string | undefined;
  72525. /** @hidden */
  72526. _children: Control[];
  72527. /** @hidden */
  72528. protected _measureForChildren: Measure;
  72529. /** @hidden */
  72530. protected _background: string;
  72531. /** @hidden */
  72532. protected _adaptWidthToChildren: boolean;
  72533. /** @hidden */
  72534. protected _adaptHeightToChildren: boolean;
  72535. /**
  72536. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72537. */
  72538. logLayoutCycleErrors: boolean;
  72539. /**
  72540. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72541. */
  72542. maxLayoutCycle: number;
  72543. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72544. get adaptHeightToChildren(): boolean;
  72545. set adaptHeightToChildren(value: boolean);
  72546. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72547. get adaptWidthToChildren(): boolean;
  72548. set adaptWidthToChildren(value: boolean);
  72549. /** Gets or sets background color */
  72550. get background(): string;
  72551. set background(value: string);
  72552. /** Gets the list of children */
  72553. get children(): Control[];
  72554. /**
  72555. * Creates a new Container
  72556. * @param name defines the name of the container
  72557. */
  72558. constructor(name?: string | undefined);
  72559. protected _getTypeName(): string;
  72560. _flagDescendantsAsMatrixDirty(): void;
  72561. /**
  72562. * Gets a child using its name
  72563. * @param name defines the child name to look for
  72564. * @returns the child control if found
  72565. */
  72566. getChildByName(name: string): BABYLON.Nullable<Control>;
  72567. /**
  72568. * Gets a child using its type and its name
  72569. * @param name defines the child name to look for
  72570. * @param type defines the child type to look for
  72571. * @returns the child control if found
  72572. */
  72573. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72574. /**
  72575. * Search for a specific control in children
  72576. * @param control defines the control to look for
  72577. * @returns true if the control is in child list
  72578. */
  72579. containsControl(control: Control): boolean;
  72580. /**
  72581. * Adds a new control to the current container
  72582. * @param control defines the control to add
  72583. * @returns the current container
  72584. */
  72585. addControl(control: BABYLON.Nullable<Control>): Container;
  72586. /**
  72587. * Removes all controls from the current container
  72588. * @returns the current container
  72589. */
  72590. clearControls(): Container;
  72591. /**
  72592. * Removes a control from the current container
  72593. * @param control defines the control to remove
  72594. * @returns the current container
  72595. */
  72596. removeControl(control: Control): Container;
  72597. /** @hidden */
  72598. _reOrderControl(control: Control): void;
  72599. /** @hidden */
  72600. _offsetLeft(offset: number): void;
  72601. /** @hidden */
  72602. _offsetTop(offset: number): void;
  72603. /** @hidden */
  72604. _markAllAsDirty(): void;
  72605. /** @hidden */
  72606. protected _localDraw(context: CanvasRenderingContext2D): void;
  72607. /** @hidden */
  72608. _link(host: AdvancedDynamicTexture): void;
  72609. /** @hidden */
  72610. protected _beforeLayout(): void;
  72611. /** @hidden */
  72612. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72613. /** @hidden */
  72614. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72615. protected _postMeasure(): void;
  72616. /** @hidden */
  72617. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72618. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72619. /** @hidden */
  72620. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72621. /** @hidden */
  72622. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72623. /** Releases associated resources */
  72624. dispose(): void;
  72625. }
  72626. }
  72627. declare module BABYLON.GUI {
  72628. /** Class used to create rectangle container */
  72629. export class Rectangle extends Container {
  72630. name?: string | undefined;
  72631. private _thickness;
  72632. private _cornerRadius;
  72633. /** Gets or sets border thickness */
  72634. get thickness(): number;
  72635. set thickness(value: number);
  72636. /** Gets or sets the corner radius angle */
  72637. get cornerRadius(): number;
  72638. set cornerRadius(value: number);
  72639. /**
  72640. * Creates a new Rectangle
  72641. * @param name defines the control name
  72642. */
  72643. constructor(name?: string | undefined);
  72644. protected _getTypeName(): string;
  72645. protected _localDraw(context: CanvasRenderingContext2D): void;
  72646. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72647. private _drawRoundedRect;
  72648. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72649. }
  72650. }
  72651. declare module BABYLON.GUI {
  72652. /**
  72653. * Enum that determines the text-wrapping mode to use.
  72654. */
  72655. export enum TextWrapping {
  72656. /**
  72657. * Clip the text when it's larger than Control.width; this is the default mode.
  72658. */
  72659. Clip = 0,
  72660. /**
  72661. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72662. */
  72663. WordWrap = 1,
  72664. /**
  72665. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72666. */
  72667. Ellipsis = 2
  72668. }
  72669. /**
  72670. * Class used to create text block control
  72671. */
  72672. export class TextBlock extends Control {
  72673. /**
  72674. * Defines the name of the control
  72675. */
  72676. name?: string | undefined;
  72677. private _text;
  72678. private _textWrapping;
  72679. private _textHorizontalAlignment;
  72680. private _textVerticalAlignment;
  72681. private _lines;
  72682. private _resizeToFit;
  72683. private _lineSpacing;
  72684. private _outlineWidth;
  72685. private _outlineColor;
  72686. /**
  72687. * An event triggered after the text is changed
  72688. */
  72689. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72690. /**
  72691. * An event triggered after the text was broken up into lines
  72692. */
  72693. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72694. /**
  72695. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72696. */
  72697. get lines(): any[];
  72698. /**
  72699. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72700. */
  72701. get resizeToFit(): boolean;
  72702. /**
  72703. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72704. */
  72705. set resizeToFit(value: boolean);
  72706. /**
  72707. * Gets or sets a boolean indicating if text must be wrapped
  72708. */
  72709. get textWrapping(): TextWrapping | boolean;
  72710. /**
  72711. * Gets or sets a boolean indicating if text must be wrapped
  72712. */
  72713. set textWrapping(value: TextWrapping | boolean);
  72714. /**
  72715. * Gets or sets text to display
  72716. */
  72717. get text(): string;
  72718. /**
  72719. * Gets or sets text to display
  72720. */
  72721. set text(value: string);
  72722. /**
  72723. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72724. */
  72725. get textHorizontalAlignment(): number;
  72726. /**
  72727. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72728. */
  72729. set textHorizontalAlignment(value: number);
  72730. /**
  72731. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72732. */
  72733. get textVerticalAlignment(): number;
  72734. /**
  72735. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72736. */
  72737. set textVerticalAlignment(value: number);
  72738. /**
  72739. * Gets or sets line spacing value
  72740. */
  72741. set lineSpacing(value: string | number);
  72742. /**
  72743. * Gets or sets line spacing value
  72744. */
  72745. get lineSpacing(): string | number;
  72746. /**
  72747. * Gets or sets outlineWidth of the text to display
  72748. */
  72749. get outlineWidth(): number;
  72750. /**
  72751. * Gets or sets outlineWidth of the text to display
  72752. */
  72753. set outlineWidth(value: number);
  72754. /**
  72755. * Gets or sets outlineColor of the text to display
  72756. */
  72757. get outlineColor(): string;
  72758. /**
  72759. * Gets or sets outlineColor of the text to display
  72760. */
  72761. set outlineColor(value: string);
  72762. /**
  72763. * Creates a new TextBlock object
  72764. * @param name defines the name of the control
  72765. * @param text defines the text to display (emptry string by default)
  72766. */
  72767. constructor(
  72768. /**
  72769. * Defines the name of the control
  72770. */
  72771. name?: string | undefined, text?: string);
  72772. protected _getTypeName(): string;
  72773. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72774. private _drawText;
  72775. /** @hidden */
  72776. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72777. protected _applyStates(context: CanvasRenderingContext2D): void;
  72778. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72779. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72780. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72781. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72782. protected _renderLines(context: CanvasRenderingContext2D): void;
  72783. /**
  72784. * Given a width constraint applied on the text block, find the expected height
  72785. * @returns expected height
  72786. */
  72787. computeExpectedHeight(): number;
  72788. dispose(): void;
  72789. }
  72790. }
  72791. declare module BABYLON.GUI {
  72792. /**
  72793. * Class used to create 2D images
  72794. */
  72795. export class Image extends Control {
  72796. name?: string | undefined;
  72797. private _workingCanvas;
  72798. private _domImage;
  72799. private _imageWidth;
  72800. private _imageHeight;
  72801. private _loaded;
  72802. private _stretch;
  72803. private _source;
  72804. private _autoScale;
  72805. private _sourceLeft;
  72806. private _sourceTop;
  72807. private _sourceWidth;
  72808. private _sourceHeight;
  72809. private _svgAttributesComputationCompleted;
  72810. private _isSVG;
  72811. private _cellWidth;
  72812. private _cellHeight;
  72813. private _cellId;
  72814. private _populateNinePatchSlicesFromImage;
  72815. private _sliceLeft;
  72816. private _sliceRight;
  72817. private _sliceTop;
  72818. private _sliceBottom;
  72819. private _detectPointerOnOpaqueOnly;
  72820. /**
  72821. * BABYLON.Observable notified when the content is loaded
  72822. */
  72823. onImageLoadedObservable: BABYLON.Observable<Image>;
  72824. /**
  72825. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72826. */
  72827. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72828. /**
  72829. * Gets a boolean indicating that the content is loaded
  72830. */
  72831. get isLoaded(): boolean;
  72832. /**
  72833. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72834. */
  72835. get populateNinePatchSlicesFromImage(): boolean;
  72836. set populateNinePatchSlicesFromImage(value: boolean);
  72837. /**
  72838. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72839. * Beware using this as this will comsume more memory as the image has to be stored twice
  72840. */
  72841. get detectPointerOnOpaqueOnly(): boolean;
  72842. set detectPointerOnOpaqueOnly(value: boolean);
  72843. /**
  72844. * Gets or sets the left value for slicing (9-patch)
  72845. */
  72846. get sliceLeft(): number;
  72847. set sliceLeft(value: number);
  72848. /**
  72849. * Gets or sets the right value for slicing (9-patch)
  72850. */
  72851. get sliceRight(): number;
  72852. set sliceRight(value: number);
  72853. /**
  72854. * Gets or sets the top value for slicing (9-patch)
  72855. */
  72856. get sliceTop(): number;
  72857. set sliceTop(value: number);
  72858. /**
  72859. * Gets or sets the bottom value for slicing (9-patch)
  72860. */
  72861. get sliceBottom(): number;
  72862. set sliceBottom(value: number);
  72863. /**
  72864. * Gets or sets the left coordinate in the source image
  72865. */
  72866. get sourceLeft(): number;
  72867. set sourceLeft(value: number);
  72868. /**
  72869. * Gets or sets the top coordinate in the source image
  72870. */
  72871. get sourceTop(): number;
  72872. set sourceTop(value: number);
  72873. /**
  72874. * Gets or sets the width to capture in the source image
  72875. */
  72876. get sourceWidth(): number;
  72877. set sourceWidth(value: number);
  72878. /**
  72879. * Gets or sets the height to capture in the source image
  72880. */
  72881. get sourceHeight(): number;
  72882. set sourceHeight(value: number);
  72883. /** Indicates if the format of the image is SVG */
  72884. get isSVG(): boolean;
  72885. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72886. get svgAttributesComputationCompleted(): boolean;
  72887. /**
  72888. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72889. * @see http://doc.babylonjs.com/how_to/gui#image
  72890. */
  72891. get autoScale(): boolean;
  72892. set autoScale(value: boolean);
  72893. /** Gets or sets the streching mode used by the image */
  72894. get stretch(): number;
  72895. set stretch(value: number);
  72896. /** @hidden */
  72897. _rotate90(n: number, preserveProperties?: boolean): Image;
  72898. private _handleRotationForSVGImage;
  72899. private _rotate90SourceProperties;
  72900. /**
  72901. * Gets or sets the internal DOM image used to render the control
  72902. */
  72903. set domImage(value: HTMLImageElement);
  72904. get domImage(): HTMLImageElement;
  72905. private _onImageLoaded;
  72906. private _extractNinePatchSliceDataFromImage;
  72907. /**
  72908. * Gets or sets image source url
  72909. */
  72910. set source(value: BABYLON.Nullable<string>);
  72911. /**
  72912. * Checks for svg document with icon id present
  72913. */
  72914. private _svgCheck;
  72915. /**
  72916. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72917. * given external svg file and icon id
  72918. */
  72919. private _getSVGAttribs;
  72920. /**
  72921. * Gets or sets the cell width to use when animation sheet is enabled
  72922. * @see http://doc.babylonjs.com/how_to/gui#image
  72923. */
  72924. get cellWidth(): number;
  72925. set cellWidth(value: number);
  72926. /**
  72927. * Gets or sets the cell height to use when animation sheet is enabled
  72928. * @see http://doc.babylonjs.com/how_to/gui#image
  72929. */
  72930. get cellHeight(): number;
  72931. set cellHeight(value: number);
  72932. /**
  72933. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72934. * @see http://doc.babylonjs.com/how_to/gui#image
  72935. */
  72936. get cellId(): number;
  72937. set cellId(value: number);
  72938. /**
  72939. * Creates a new Image
  72940. * @param name defines the control name
  72941. * @param url defines the image url
  72942. */
  72943. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72944. /**
  72945. * Tests if a given coordinates belong to the current control
  72946. * @param x defines x coordinate to test
  72947. * @param y defines y coordinate to test
  72948. * @returns true if the coordinates are inside the control
  72949. */
  72950. contains(x: number, y: number): boolean;
  72951. protected _getTypeName(): string;
  72952. /** Force the control to synchronize with its content */
  72953. synchronizeSizeWithContent(): void;
  72954. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72955. private _prepareWorkingCanvasForOpaqueDetection;
  72956. private _drawImage;
  72957. _draw(context: CanvasRenderingContext2D): void;
  72958. private _renderCornerPatch;
  72959. private _renderNinePatch;
  72960. dispose(): void;
  72961. /** STRETCH_NONE */
  72962. static readonly STRETCH_NONE: number;
  72963. /** STRETCH_FILL */
  72964. static readonly STRETCH_FILL: number;
  72965. /** STRETCH_UNIFORM */
  72966. static readonly STRETCH_UNIFORM: number;
  72967. /** STRETCH_EXTEND */
  72968. static readonly STRETCH_EXTEND: number;
  72969. /** NINE_PATCH */
  72970. static readonly STRETCH_NINE_PATCH: number;
  72971. }
  72972. }
  72973. declare module BABYLON.GUI {
  72974. /**
  72975. * Class used to create 2D buttons
  72976. */
  72977. export class Button extends Rectangle {
  72978. name?: string | undefined;
  72979. /**
  72980. * Function called to generate a pointer enter animation
  72981. */
  72982. pointerEnterAnimation: () => void;
  72983. /**
  72984. * Function called to generate a pointer out animation
  72985. */
  72986. pointerOutAnimation: () => void;
  72987. /**
  72988. * Function called to generate a pointer down animation
  72989. */
  72990. pointerDownAnimation: () => void;
  72991. /**
  72992. * Function called to generate a pointer up animation
  72993. */
  72994. pointerUpAnimation: () => void;
  72995. /**
  72996. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72997. */
  72998. delegatePickingToChildren: boolean;
  72999. private _image;
  73000. /**
  73001. * Returns the image part of the button (if any)
  73002. */
  73003. get image(): BABYLON.Nullable<Image>;
  73004. private _textBlock;
  73005. /**
  73006. * Returns the image part of the button (if any)
  73007. */
  73008. get textBlock(): BABYLON.Nullable<TextBlock>;
  73009. /**
  73010. * Creates a new Button
  73011. * @param name defines the name of the button
  73012. */
  73013. constructor(name?: string | undefined);
  73014. protected _getTypeName(): string;
  73015. /** @hidden */
  73016. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73017. /** @hidden */
  73018. _onPointerEnter(target: Control): boolean;
  73019. /** @hidden */
  73020. _onPointerOut(target: Control, force?: boolean): void;
  73021. /** @hidden */
  73022. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73023. /** @hidden */
  73024. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73025. /**
  73026. * Creates a new button made with an image and a text
  73027. * @param name defines the name of the button
  73028. * @param text defines the text of the button
  73029. * @param imageUrl defines the url of the image
  73030. * @returns a new Button
  73031. */
  73032. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  73033. /**
  73034. * Creates a new button made with an image
  73035. * @param name defines the name of the button
  73036. * @param imageUrl defines the url of the image
  73037. * @returns a new Button
  73038. */
  73039. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  73040. /**
  73041. * Creates a new button made with a text
  73042. * @param name defines the name of the button
  73043. * @param text defines the text of the button
  73044. * @returns a new Button
  73045. */
  73046. static CreateSimpleButton(name: string, text: string): Button;
  73047. /**
  73048. * Creates a new button made with an image and a centered text
  73049. * @param name defines the name of the button
  73050. * @param text defines the text of the button
  73051. * @param imageUrl defines the url of the image
  73052. * @returns a new Button
  73053. */
  73054. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  73055. }
  73056. }
  73057. declare module BABYLON.GUI {
  73058. /**
  73059. * Class used to create a 2D stack panel container
  73060. */
  73061. export class StackPanel extends Container {
  73062. name?: string | undefined;
  73063. private _isVertical;
  73064. private _manualWidth;
  73065. private _manualHeight;
  73066. private _doNotTrackManualChanges;
  73067. /**
  73068. * Gets or sets a boolean indicating that layou warnings should be ignored
  73069. */
  73070. ignoreLayoutWarnings: boolean;
  73071. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  73072. get isVertical(): boolean;
  73073. set isVertical(value: boolean);
  73074. /**
  73075. * Gets or sets panel width.
  73076. * This value should not be set when in horizontal mode as it will be computed automatically
  73077. */
  73078. set width(value: string | number);
  73079. get width(): string | number;
  73080. /**
  73081. * Gets or sets panel height.
  73082. * This value should not be set when in vertical mode as it will be computed automatically
  73083. */
  73084. set height(value: string | number);
  73085. get height(): string | number;
  73086. /**
  73087. * Creates a new StackPanel
  73088. * @param name defines control name
  73089. */
  73090. constructor(name?: string | undefined);
  73091. protected _getTypeName(): string;
  73092. /** @hidden */
  73093. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73094. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73095. protected _postMeasure(): void;
  73096. }
  73097. }
  73098. declare module BABYLON.GUI {
  73099. /**
  73100. * Class used to represent a 2D checkbox
  73101. */
  73102. export class Checkbox extends Control {
  73103. name?: string | undefined;
  73104. private _isChecked;
  73105. private _background;
  73106. private _checkSizeRatio;
  73107. private _thickness;
  73108. /** Gets or sets border thickness */
  73109. get thickness(): number;
  73110. set thickness(value: number);
  73111. /**
  73112. * BABYLON.Observable raised when isChecked property changes
  73113. */
  73114. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73115. /** Gets or sets a value indicating the ratio between overall size and check size */
  73116. get checkSizeRatio(): number;
  73117. set checkSizeRatio(value: number);
  73118. /** Gets or sets background color */
  73119. get background(): string;
  73120. set background(value: string);
  73121. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73122. get isChecked(): boolean;
  73123. set isChecked(value: boolean);
  73124. /**
  73125. * Creates a new CheckBox
  73126. * @param name defines the control name
  73127. */
  73128. constructor(name?: string | undefined);
  73129. protected _getTypeName(): string;
  73130. /** @hidden */
  73131. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73132. /** @hidden */
  73133. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73134. /**
  73135. * Utility function to easily create a checkbox with a header
  73136. * @param title defines the label to use for the header
  73137. * @param onValueChanged defines the callback to call when value changes
  73138. * @returns a StackPanel containing the checkbox and a textBlock
  73139. */
  73140. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  73141. }
  73142. }
  73143. declare module BABYLON.GUI {
  73144. /**
  73145. * Class used to store key control properties
  73146. */
  73147. export class KeyPropertySet {
  73148. /** Width */
  73149. width?: string;
  73150. /** Height */
  73151. height?: string;
  73152. /** Left padding */
  73153. paddingLeft?: string;
  73154. /** Right padding */
  73155. paddingRight?: string;
  73156. /** Top padding */
  73157. paddingTop?: string;
  73158. /** Bottom padding */
  73159. paddingBottom?: string;
  73160. /** Foreground color */
  73161. color?: string;
  73162. /** Background color */
  73163. background?: string;
  73164. }
  73165. /**
  73166. * Class used to create virtual keyboard
  73167. */
  73168. export class VirtualKeyboard extends StackPanel {
  73169. /** BABYLON.Observable raised when a key is pressed */
  73170. onKeyPressObservable: BABYLON.Observable<string>;
  73171. /** Gets or sets default key button width */
  73172. defaultButtonWidth: string;
  73173. /** Gets or sets default key button height */
  73174. defaultButtonHeight: string;
  73175. /** Gets or sets default key button left padding */
  73176. defaultButtonPaddingLeft: string;
  73177. /** Gets or sets default key button right padding */
  73178. defaultButtonPaddingRight: string;
  73179. /** Gets or sets default key button top padding */
  73180. defaultButtonPaddingTop: string;
  73181. /** Gets or sets default key button bottom padding */
  73182. defaultButtonPaddingBottom: string;
  73183. /** Gets or sets default key button foreground color */
  73184. defaultButtonColor: string;
  73185. /** Gets or sets default key button background color */
  73186. defaultButtonBackground: string;
  73187. /** Gets or sets shift button foreground color */
  73188. shiftButtonColor: string;
  73189. /** Gets or sets shift button thickness*/
  73190. selectedShiftThickness: number;
  73191. /** Gets shift key state */
  73192. shiftState: number;
  73193. protected _getTypeName(): string;
  73194. private _createKey;
  73195. /**
  73196. * Adds a new row of keys
  73197. * @param keys defines the list of keys to add
  73198. * @param propertySets defines the associated property sets
  73199. */
  73200. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  73201. /**
  73202. * Set the shift key to a specific state
  73203. * @param shiftState defines the new shift state
  73204. */
  73205. applyShiftState(shiftState: number): void;
  73206. private _currentlyConnectedInputText;
  73207. private _connectedInputTexts;
  73208. private _onKeyPressObserver;
  73209. /** Gets the input text control currently attached to the keyboard */
  73210. get connectedInputText(): BABYLON.Nullable<InputText>;
  73211. /**
  73212. * Connects the keyboard with an input text control
  73213. *
  73214. * @param input defines the target control
  73215. */
  73216. connect(input: InputText): void;
  73217. /**
  73218. * Disconnects the keyboard from connected InputText controls
  73219. *
  73220. * @param input optionally defines a target control, otherwise all are disconnected
  73221. */
  73222. disconnect(input?: InputText): void;
  73223. private _removeConnectedInputObservables;
  73224. /**
  73225. * Release all resources
  73226. */
  73227. dispose(): void;
  73228. /**
  73229. * Creates a new keyboard using a default layout
  73230. *
  73231. * @param name defines control name
  73232. * @returns a new VirtualKeyboard
  73233. */
  73234. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  73235. }
  73236. }
  73237. declare module BABYLON.GUI {
  73238. /**
  73239. * Class used to create input text control
  73240. */
  73241. export class InputText extends Control implements IFocusableControl {
  73242. name?: string | undefined;
  73243. private _text;
  73244. private _placeholderText;
  73245. private _background;
  73246. private _focusedBackground;
  73247. private _focusedColor;
  73248. private _placeholderColor;
  73249. private _thickness;
  73250. private _margin;
  73251. private _autoStretchWidth;
  73252. private _maxWidth;
  73253. private _isFocused;
  73254. private _blinkTimeout;
  73255. private _blinkIsEven;
  73256. private _cursorOffset;
  73257. private _scrollLeft;
  73258. private _textWidth;
  73259. private _clickedCoordinate;
  73260. private _deadKey;
  73261. private _addKey;
  73262. private _currentKey;
  73263. private _isTextHighlightOn;
  73264. private _textHighlightColor;
  73265. private _highligherOpacity;
  73266. private _highlightedText;
  73267. private _startHighlightIndex;
  73268. private _endHighlightIndex;
  73269. private _cursorIndex;
  73270. private _onFocusSelectAll;
  73271. private _isPointerDown;
  73272. private _onClipboardObserver;
  73273. private _onPointerDblTapObserver;
  73274. /** @hidden */
  73275. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  73276. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  73277. promptMessage: string;
  73278. /** Force disable prompt on mobile device */
  73279. disableMobilePrompt: boolean;
  73280. /** BABYLON.Observable raised when the text changes */
  73281. onTextChangedObservable: BABYLON.Observable<InputText>;
  73282. /** BABYLON.Observable raised just before an entered character is to be added */
  73283. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  73284. /** BABYLON.Observable raised when the control gets the focus */
  73285. onFocusObservable: BABYLON.Observable<InputText>;
  73286. /** BABYLON.Observable raised when the control loses the focus */
  73287. onBlurObservable: BABYLON.Observable<InputText>;
  73288. /**Observable raised when the text is highlighted */
  73289. onTextHighlightObservable: BABYLON.Observable<InputText>;
  73290. /**Observable raised when copy event is triggered */
  73291. onTextCopyObservable: BABYLON.Observable<InputText>;
  73292. /** BABYLON.Observable raised when cut event is triggered */
  73293. onTextCutObservable: BABYLON.Observable<InputText>;
  73294. /** BABYLON.Observable raised when paste event is triggered */
  73295. onTextPasteObservable: BABYLON.Observable<InputText>;
  73296. /** BABYLON.Observable raised when a key event was processed */
  73297. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  73298. /** Gets or sets the maximum width allowed by the control */
  73299. get maxWidth(): string | number;
  73300. /** Gets the maximum width allowed by the control in pixels */
  73301. get maxWidthInPixels(): number;
  73302. set maxWidth(value: string | number);
  73303. /** Gets or sets the text highlighter transparency; default: 0.4 */
  73304. get highligherOpacity(): number;
  73305. set highligherOpacity(value: number);
  73306. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  73307. get onFocusSelectAll(): boolean;
  73308. set onFocusSelectAll(value: boolean);
  73309. /** Gets or sets the text hightlight color */
  73310. get textHighlightColor(): string;
  73311. set textHighlightColor(value: string);
  73312. /** Gets or sets control margin */
  73313. get margin(): string;
  73314. /** Gets control margin in pixels */
  73315. get marginInPixels(): number;
  73316. set margin(value: string);
  73317. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  73318. get autoStretchWidth(): boolean;
  73319. set autoStretchWidth(value: boolean);
  73320. /** Gets or sets border thickness */
  73321. get thickness(): number;
  73322. set thickness(value: number);
  73323. /** Gets or sets the background color when focused */
  73324. get focusedBackground(): string;
  73325. set focusedBackground(value: string);
  73326. /** Gets or sets the background color when focused */
  73327. get focusedColor(): string;
  73328. set focusedColor(value: string);
  73329. /** Gets or sets the background color */
  73330. get background(): string;
  73331. set background(value: string);
  73332. /** Gets or sets the placeholder color */
  73333. get placeholderColor(): string;
  73334. set placeholderColor(value: string);
  73335. /** Gets or sets the text displayed when the control is empty */
  73336. get placeholderText(): string;
  73337. set placeholderText(value: string);
  73338. /** Gets or sets the dead key flag */
  73339. get deadKey(): boolean;
  73340. set deadKey(flag: boolean);
  73341. /** Gets or sets the highlight text */
  73342. get highlightedText(): string;
  73343. set highlightedText(text: string);
  73344. /** Gets or sets if the current key should be added */
  73345. get addKey(): boolean;
  73346. set addKey(flag: boolean);
  73347. /** Gets or sets the value of the current key being entered */
  73348. get currentKey(): string;
  73349. set currentKey(key: string);
  73350. /** Gets or sets the text displayed in the control */
  73351. get text(): string;
  73352. set text(value: string);
  73353. /** Gets or sets control width */
  73354. get width(): string | number;
  73355. set width(value: string | number);
  73356. /**
  73357. * Creates a new InputText
  73358. * @param name defines the control name
  73359. * @param text defines the text of the control
  73360. */
  73361. constructor(name?: string | undefined, text?: string);
  73362. /** @hidden */
  73363. onBlur(): void;
  73364. /** @hidden */
  73365. onFocus(): void;
  73366. protected _getTypeName(): string;
  73367. /**
  73368. * Function called to get the list of controls that should not steal the focus from this control
  73369. * @returns an array of controls
  73370. */
  73371. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73372. /** @hidden */
  73373. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  73374. /** @hidden */
  73375. private _updateValueFromCursorIndex;
  73376. /** @hidden */
  73377. private _processDblClick;
  73378. /** @hidden */
  73379. private _selectAllText;
  73380. /**
  73381. * Handles the keyboard event
  73382. * @param evt Defines the KeyboardEvent
  73383. */
  73384. processKeyboard(evt: KeyboardEvent): void;
  73385. /** @hidden */
  73386. private _onCopyText;
  73387. /** @hidden */
  73388. private _onCutText;
  73389. /** @hidden */
  73390. private _onPasteText;
  73391. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73392. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73393. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73394. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73395. protected _beforeRenderText(text: string): string;
  73396. dispose(): void;
  73397. }
  73398. }
  73399. declare module BABYLON.GUI {
  73400. /**
  73401. * Class used to create a 2D grid container
  73402. */
  73403. export class Grid extends Container {
  73404. name?: string | undefined;
  73405. private _rowDefinitions;
  73406. private _columnDefinitions;
  73407. private _cells;
  73408. private _childControls;
  73409. /**
  73410. * Gets the number of columns
  73411. */
  73412. get columnCount(): number;
  73413. /**
  73414. * Gets the number of rows
  73415. */
  73416. get rowCount(): number;
  73417. /** Gets the list of children */
  73418. get children(): Control[];
  73419. /** Gets the list of cells (e.g. the containers) */
  73420. get cells(): {
  73421. [key: string]: Container;
  73422. };
  73423. /**
  73424. * Gets the definition of a specific row
  73425. * @param index defines the index of the row
  73426. * @returns the row definition
  73427. */
  73428. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73429. /**
  73430. * Gets the definition of a specific column
  73431. * @param index defines the index of the column
  73432. * @returns the column definition
  73433. */
  73434. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73435. /**
  73436. * Adds a new row to the grid
  73437. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73438. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73439. * @returns the current grid
  73440. */
  73441. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73442. /**
  73443. * Adds a new column to the grid
  73444. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73445. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73446. * @returns the current grid
  73447. */
  73448. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73449. /**
  73450. * Update a row definition
  73451. * @param index defines the index of the row to update
  73452. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73453. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73454. * @returns the current grid
  73455. */
  73456. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73457. /**
  73458. * Update a column definition
  73459. * @param index defines the index of the column to update
  73460. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73461. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73462. * @returns the current grid
  73463. */
  73464. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73465. /**
  73466. * Gets the list of children stored in a specific cell
  73467. * @param row defines the row to check
  73468. * @param column defines the column to check
  73469. * @returns the list of controls
  73470. */
  73471. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73472. /**
  73473. * Gets a string representing the child cell info (row x column)
  73474. * @param child defines the control to get info from
  73475. * @returns a string containing the child cell info (row x column)
  73476. */
  73477. getChildCellInfo(child: Control): string;
  73478. private _removeCell;
  73479. private _offsetCell;
  73480. /**
  73481. * Remove a column definition at specified index
  73482. * @param index defines the index of the column to remove
  73483. * @returns the current grid
  73484. */
  73485. removeColumnDefinition(index: number): Grid;
  73486. /**
  73487. * Remove a row definition at specified index
  73488. * @param index defines the index of the row to remove
  73489. * @returns the current grid
  73490. */
  73491. removeRowDefinition(index: number): Grid;
  73492. /**
  73493. * Adds a new control to the current grid
  73494. * @param control defines the control to add
  73495. * @param row defines the row where to add the control (0 by default)
  73496. * @param column defines the column where to add the control (0 by default)
  73497. * @returns the current grid
  73498. */
  73499. addControl(control: Control, row?: number, column?: number): Grid;
  73500. /**
  73501. * Removes a control from the current container
  73502. * @param control defines the control to remove
  73503. * @returns the current container
  73504. */
  73505. removeControl(control: Control): Container;
  73506. /**
  73507. * Creates a new Grid
  73508. * @param name defines control name
  73509. */
  73510. constructor(name?: string | undefined);
  73511. protected _getTypeName(): string;
  73512. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73513. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73514. _flagDescendantsAsMatrixDirty(): void;
  73515. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73516. /** Releases associated resources */
  73517. dispose(): void;
  73518. }
  73519. }
  73520. declare module BABYLON.GUI {
  73521. /** Class used to create color pickers */
  73522. export class ColorPicker extends Control {
  73523. name?: string | undefined;
  73524. private static _Epsilon;
  73525. private _colorWheelCanvas;
  73526. private _value;
  73527. private _tmpColor;
  73528. private _pointerStartedOnSquare;
  73529. private _pointerStartedOnWheel;
  73530. private _squareLeft;
  73531. private _squareTop;
  73532. private _squareSize;
  73533. private _h;
  73534. private _s;
  73535. private _v;
  73536. private _lastPointerDownID;
  73537. /**
  73538. * BABYLON.Observable raised when the value changes
  73539. */
  73540. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73541. /** Gets or sets the color of the color picker */
  73542. get value(): BABYLON.Color3;
  73543. set value(value: BABYLON.Color3);
  73544. /**
  73545. * Gets or sets control width
  73546. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73547. */
  73548. get width(): string | number;
  73549. set width(value: string | number);
  73550. /**
  73551. * Gets or sets control height
  73552. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73553. */
  73554. get height(): string | number;
  73555. /** Gets or sets control height */
  73556. set height(value: string | number);
  73557. /** Gets or sets control size */
  73558. get size(): string | number;
  73559. set size(value: string | number);
  73560. /**
  73561. * Creates a new ColorPicker
  73562. * @param name defines the control name
  73563. */
  73564. constructor(name?: string | undefined);
  73565. protected _getTypeName(): string;
  73566. /** @hidden */
  73567. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73568. private _updateSquareProps;
  73569. private _drawGradientSquare;
  73570. private _drawCircle;
  73571. private _createColorWheelCanvas;
  73572. /** @hidden */
  73573. _draw(context: CanvasRenderingContext2D): void;
  73574. private _pointerIsDown;
  73575. private _updateValueFromPointer;
  73576. private _isPointOnSquare;
  73577. private _isPointOnWheel;
  73578. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73579. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73580. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73581. /**
  73582. * This function expands the color picker by creating a color picker dialog with manual
  73583. * color value input and the ability to save colors into an array to be used later in
  73584. * subsequent launches of the dialogue.
  73585. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73586. * @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.
  73587. * @returns picked color as a hex string and the saved colors array as hex strings.
  73588. */
  73589. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73590. pickerWidth?: string;
  73591. pickerHeight?: string;
  73592. headerHeight?: string;
  73593. lastColor?: string;
  73594. swatchLimit?: number;
  73595. numSwatchesPerLine?: number;
  73596. savedColors?: Array<string>;
  73597. }): Promise<{
  73598. savedColors?: string[];
  73599. pickedColor: string;
  73600. }>;
  73601. }
  73602. }
  73603. declare module BABYLON.GUI {
  73604. /** Class used to create 2D ellipse containers */
  73605. export class Ellipse extends Container {
  73606. name?: string | undefined;
  73607. private _thickness;
  73608. /** Gets or sets border thickness */
  73609. get thickness(): number;
  73610. set thickness(value: number);
  73611. /**
  73612. * Creates a new Ellipse
  73613. * @param name defines the control name
  73614. */
  73615. constructor(name?: string | undefined);
  73616. protected _getTypeName(): string;
  73617. protected _localDraw(context: CanvasRenderingContext2D): void;
  73618. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73619. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73620. }
  73621. }
  73622. declare module BABYLON.GUI {
  73623. /**
  73624. * Class used to create a password control
  73625. */
  73626. export class InputPassword extends InputText {
  73627. protected _beforeRenderText(text: string): string;
  73628. }
  73629. }
  73630. declare module BABYLON.GUI {
  73631. /** Class used to render 2D lines */
  73632. export class Line extends Control {
  73633. name?: string | undefined;
  73634. private _lineWidth;
  73635. private _x1;
  73636. private _y1;
  73637. private _x2;
  73638. private _y2;
  73639. private _dash;
  73640. private _connectedControl;
  73641. private _connectedControlDirtyObserver;
  73642. /** Gets or sets the dash pattern */
  73643. get dash(): Array<number>;
  73644. set dash(value: Array<number>);
  73645. /** Gets or sets the control connected with the line end */
  73646. get connectedControl(): Control;
  73647. set connectedControl(value: Control);
  73648. /** Gets or sets start coordinates on X axis */
  73649. get x1(): string | number;
  73650. set x1(value: string | number);
  73651. /** Gets or sets start coordinates on Y axis */
  73652. get y1(): string | number;
  73653. set y1(value: string | number);
  73654. /** Gets or sets end coordinates on X axis */
  73655. get x2(): string | number;
  73656. set x2(value: string | number);
  73657. /** Gets or sets end coordinates on Y axis */
  73658. get y2(): string | number;
  73659. set y2(value: string | number);
  73660. /** Gets or sets line width */
  73661. get lineWidth(): number;
  73662. set lineWidth(value: number);
  73663. /** Gets or sets horizontal alignment */
  73664. set horizontalAlignment(value: number);
  73665. /** Gets or sets vertical alignment */
  73666. set verticalAlignment(value: number);
  73667. private get _effectiveX2();
  73668. private get _effectiveY2();
  73669. /**
  73670. * Creates a new Line
  73671. * @param name defines the control name
  73672. */
  73673. constructor(name?: string | undefined);
  73674. protected _getTypeName(): string;
  73675. _draw(context: CanvasRenderingContext2D): void;
  73676. _measure(): void;
  73677. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73678. /**
  73679. * Move one end of the line given 3D cartesian coordinates.
  73680. * @param position Targeted world position
  73681. * @param scene BABYLON.Scene
  73682. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73683. */
  73684. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73685. /**
  73686. * Move one end of the line to a position in screen absolute space.
  73687. * @param projectedPosition Position in screen absolute space (X, Y)
  73688. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73689. */
  73690. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73691. }
  73692. }
  73693. declare module BABYLON.GUI {
  73694. /**
  73695. * Class used to store a point for a MultiLine object.
  73696. * The point can be pure 2D coordinates, a mesh or a control
  73697. */
  73698. export class MultiLinePoint {
  73699. private _multiLine;
  73700. private _x;
  73701. private _y;
  73702. private _control;
  73703. private _mesh;
  73704. private _controlObserver;
  73705. private _meshObserver;
  73706. /** @hidden */
  73707. _point: BABYLON.Vector2;
  73708. /**
  73709. * Creates a new MultiLinePoint
  73710. * @param multiLine defines the source MultiLine object
  73711. */
  73712. constructor(multiLine: MultiLine);
  73713. /** Gets or sets x coordinate */
  73714. get x(): string | number;
  73715. set x(value: string | number);
  73716. /** Gets or sets y coordinate */
  73717. get y(): string | number;
  73718. set y(value: string | number);
  73719. /** Gets or sets the control associated with this point */
  73720. get control(): BABYLON.Nullable<Control>;
  73721. set control(value: BABYLON.Nullable<Control>);
  73722. /** Gets or sets the mesh associated with this point */
  73723. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73724. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73725. /** Resets links */
  73726. resetLinks(): void;
  73727. /**
  73728. * Gets a translation vector
  73729. * @returns the translation vector
  73730. */
  73731. translate(): BABYLON.Vector2;
  73732. private _translatePoint;
  73733. /** Release associated resources */
  73734. dispose(): void;
  73735. }
  73736. }
  73737. declare module BABYLON.GUI {
  73738. /**
  73739. * Class used to create multi line control
  73740. */
  73741. export class MultiLine extends Control {
  73742. name?: string | undefined;
  73743. private _lineWidth;
  73744. private _dash;
  73745. private _points;
  73746. private _minX;
  73747. private _minY;
  73748. private _maxX;
  73749. private _maxY;
  73750. /**
  73751. * Creates a new MultiLine
  73752. * @param name defines the control name
  73753. */
  73754. constructor(name?: string | undefined);
  73755. /** Gets or sets dash pattern */
  73756. get dash(): Array<number>;
  73757. set dash(value: Array<number>);
  73758. /**
  73759. * Gets point stored at specified index
  73760. * @param index defines the index to look for
  73761. * @returns the requested point if found
  73762. */
  73763. getAt(index: number): MultiLinePoint;
  73764. /** Function called when a point is updated */
  73765. onPointUpdate: () => void;
  73766. /**
  73767. * Adds new points to the point collection
  73768. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73769. * @returns the list of created MultiLinePoint
  73770. */
  73771. add(...items: (AbstractMesh | Control | {
  73772. x: string | number;
  73773. y: string | number;
  73774. })[]): MultiLinePoint[];
  73775. /**
  73776. * Adds a new point to the point collection
  73777. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73778. * @returns the created MultiLinePoint
  73779. */
  73780. push(item?: (AbstractMesh | Control | {
  73781. x: string | number;
  73782. y: string | number;
  73783. })): MultiLinePoint;
  73784. /**
  73785. * Remove a specific value or point from the active point collection
  73786. * @param value defines the value or point to remove
  73787. */
  73788. remove(value: number | MultiLinePoint): void;
  73789. /**
  73790. * Resets this object to initial state (no point)
  73791. */
  73792. reset(): void;
  73793. /**
  73794. * Resets all links
  73795. */
  73796. resetLinks(): void;
  73797. /** Gets or sets line width */
  73798. get lineWidth(): number;
  73799. set lineWidth(value: number);
  73800. set horizontalAlignment(value: number);
  73801. set verticalAlignment(value: number);
  73802. protected _getTypeName(): string;
  73803. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73804. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73805. _measure(): void;
  73806. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73807. dispose(): void;
  73808. }
  73809. }
  73810. declare module BABYLON.GUI {
  73811. /**
  73812. * Class used to create radio button controls
  73813. */
  73814. export class RadioButton extends Control {
  73815. name?: string | undefined;
  73816. private _isChecked;
  73817. private _background;
  73818. private _checkSizeRatio;
  73819. private _thickness;
  73820. /** Gets or sets border thickness */
  73821. get thickness(): number;
  73822. set thickness(value: number);
  73823. /** Gets or sets group name */
  73824. group: string;
  73825. /** BABYLON.Observable raised when isChecked is changed */
  73826. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73827. /** Gets or sets a value indicating the ratio between overall size and check size */
  73828. get checkSizeRatio(): number;
  73829. set checkSizeRatio(value: number);
  73830. /** Gets or sets background color */
  73831. get background(): string;
  73832. set background(value: string);
  73833. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73834. get isChecked(): boolean;
  73835. set isChecked(value: boolean);
  73836. /**
  73837. * Creates a new RadioButton
  73838. * @param name defines the control name
  73839. */
  73840. constructor(name?: string | undefined);
  73841. protected _getTypeName(): string;
  73842. _draw(context: CanvasRenderingContext2D): void;
  73843. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73844. /**
  73845. * Utility function to easily create a radio button with a header
  73846. * @param title defines the label to use for the header
  73847. * @param group defines the group to use for the radio button
  73848. * @param isChecked defines the initial state of the radio button
  73849. * @param onValueChanged defines the callback to call when value changes
  73850. * @returns a StackPanel containing the radio button and a textBlock
  73851. */
  73852. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73853. }
  73854. }
  73855. declare module BABYLON.GUI {
  73856. /**
  73857. * Class used to create slider controls
  73858. */
  73859. export class BaseSlider extends Control {
  73860. name?: string | undefined;
  73861. protected _thumbWidth: ValueAndUnit;
  73862. private _minimum;
  73863. private _maximum;
  73864. private _value;
  73865. private _isVertical;
  73866. protected _barOffset: ValueAndUnit;
  73867. private _isThumbClamped;
  73868. protected _displayThumb: boolean;
  73869. private _step;
  73870. private _lastPointerDownID;
  73871. protected _effectiveBarOffset: number;
  73872. protected _renderLeft: number;
  73873. protected _renderTop: number;
  73874. protected _renderWidth: number;
  73875. protected _renderHeight: number;
  73876. protected _backgroundBoxLength: number;
  73877. protected _backgroundBoxThickness: number;
  73878. protected _effectiveThumbThickness: number;
  73879. /** BABYLON.Observable raised when the sldier value changes */
  73880. onValueChangedObservable: BABYLON.Observable<number>;
  73881. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73882. get displayThumb(): boolean;
  73883. set displayThumb(value: boolean);
  73884. /** Gets or sets a step to apply to values (0 by default) */
  73885. get step(): number;
  73886. set step(value: number);
  73887. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73888. get barOffset(): string | number;
  73889. /** Gets main bar offset in pixels*/
  73890. get barOffsetInPixels(): number;
  73891. set barOffset(value: string | number);
  73892. /** Gets or sets thumb width */
  73893. get thumbWidth(): string | number;
  73894. /** Gets thumb width in pixels */
  73895. get thumbWidthInPixels(): number;
  73896. set thumbWidth(value: string | number);
  73897. /** Gets or sets minimum value */
  73898. get minimum(): number;
  73899. set minimum(value: number);
  73900. /** Gets or sets maximum value */
  73901. get maximum(): number;
  73902. set maximum(value: number);
  73903. /** Gets or sets current value */
  73904. get value(): number;
  73905. set value(value: number);
  73906. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73907. get isVertical(): boolean;
  73908. set isVertical(value: boolean);
  73909. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73910. get isThumbClamped(): boolean;
  73911. set isThumbClamped(value: boolean);
  73912. /**
  73913. * Creates a new BaseSlider
  73914. * @param name defines the control name
  73915. */
  73916. constructor(name?: string | undefined);
  73917. protected _getTypeName(): string;
  73918. protected _getThumbPosition(): number;
  73919. protected _getThumbThickness(type: string): number;
  73920. protected _prepareRenderingData(type: string): void;
  73921. private _pointerIsDown;
  73922. /** @hidden */
  73923. protected _updateValueFromPointer(x: number, y: number): void;
  73924. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73925. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73926. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73927. }
  73928. }
  73929. declare module BABYLON.GUI {
  73930. /**
  73931. * Class used to create slider controls
  73932. */
  73933. export class Slider extends BaseSlider {
  73934. name?: string | undefined;
  73935. private _background;
  73936. private _borderColor;
  73937. private _isThumbCircle;
  73938. protected _displayValueBar: boolean;
  73939. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73940. get displayValueBar(): boolean;
  73941. set displayValueBar(value: boolean);
  73942. /** Gets or sets border color */
  73943. get borderColor(): string;
  73944. set borderColor(value: string);
  73945. /** Gets or sets background color */
  73946. get background(): string;
  73947. set background(value: string);
  73948. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73949. get isThumbCircle(): boolean;
  73950. set isThumbCircle(value: boolean);
  73951. /**
  73952. * Creates a new Slider
  73953. * @param name defines the control name
  73954. */
  73955. constructor(name?: string | undefined);
  73956. protected _getTypeName(): string;
  73957. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73958. }
  73959. }
  73960. declare module BABYLON.GUI {
  73961. /** Class used to create a RadioGroup
  73962. * which contains groups of radio buttons
  73963. */
  73964. export class SelectorGroup {
  73965. /** name of SelectorGroup */
  73966. name: string;
  73967. private _groupPanel;
  73968. private _selectors;
  73969. private _groupHeader;
  73970. /**
  73971. * Creates a new SelectorGroup
  73972. * @param name of group, used as a group heading
  73973. */
  73974. constructor(
  73975. /** name of SelectorGroup */
  73976. name: string);
  73977. /** Gets the groupPanel of the SelectorGroup */
  73978. get groupPanel(): StackPanel;
  73979. /** Gets the selectors array */
  73980. get selectors(): StackPanel[];
  73981. /** Gets and sets the group header */
  73982. get header(): string;
  73983. set header(label: string);
  73984. /** @hidden */
  73985. private _addGroupHeader;
  73986. /** @hidden*/
  73987. _getSelector(selectorNb: number): StackPanel | undefined;
  73988. /** Removes the selector at the given position
  73989. * @param selectorNb the position of the selector within the group
  73990. */
  73991. removeSelector(selectorNb: number): void;
  73992. }
  73993. /** Class used to create a CheckboxGroup
  73994. * which contains groups of checkbox buttons
  73995. */
  73996. export class CheckboxGroup extends SelectorGroup {
  73997. /** Adds a checkbox as a control
  73998. * @param text is the label for the selector
  73999. * @param func is the function called when the Selector is checked
  74000. * @param checked is true when Selector is checked
  74001. */
  74002. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  74003. /** @hidden */
  74004. _setSelectorLabel(selectorNb: number, label: string): void;
  74005. /** @hidden */
  74006. _setSelectorLabelColor(selectorNb: number, color: string): void;
  74007. /** @hidden */
  74008. _setSelectorButtonColor(selectorNb: number, color: string): void;
  74009. /** @hidden */
  74010. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  74011. }
  74012. /** Class used to create a RadioGroup
  74013. * which contains groups of radio buttons
  74014. */
  74015. export class RadioGroup extends SelectorGroup {
  74016. private _selectNb;
  74017. /** Adds a radio button as a control
  74018. * @param label is the label for the selector
  74019. * @param func is the function called when the Selector is checked
  74020. * @param checked is true when Selector is checked
  74021. */
  74022. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  74023. /** @hidden */
  74024. _setSelectorLabel(selectorNb: number, label: string): void;
  74025. /** @hidden */
  74026. _setSelectorLabelColor(selectorNb: number, color: string): void;
  74027. /** @hidden */
  74028. _setSelectorButtonColor(selectorNb: number, color: string): void;
  74029. /** @hidden */
  74030. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  74031. }
  74032. /** Class used to create a SliderGroup
  74033. * which contains groups of slider buttons
  74034. */
  74035. export class SliderGroup extends SelectorGroup {
  74036. /**
  74037. * Adds a slider to the SelectorGroup
  74038. * @param label is the label for the SliderBar
  74039. * @param func is the function called when the Slider moves
  74040. * @param unit is a string describing the units used, eg degrees or metres
  74041. * @param min is the minimum value for the Slider
  74042. * @param max is the maximum value for the Slider
  74043. * @param value is the start value for the Slider between min and max
  74044. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  74045. */
  74046. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  74047. /** @hidden */
  74048. _setSelectorLabel(selectorNb: number, label: string): void;
  74049. /** @hidden */
  74050. _setSelectorLabelColor(selectorNb: number, color: string): void;
  74051. /** @hidden */
  74052. _setSelectorButtonColor(selectorNb: number, color: string): void;
  74053. /** @hidden */
  74054. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  74055. }
  74056. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  74057. * @see http://doc.babylonjs.com/how_to/selector
  74058. */
  74059. export class SelectionPanel extends Rectangle {
  74060. /** name of SelectionPanel */
  74061. name: string;
  74062. /** an array of SelectionGroups */
  74063. groups: SelectorGroup[];
  74064. private _panel;
  74065. private _buttonColor;
  74066. private _buttonBackground;
  74067. private _headerColor;
  74068. private _barColor;
  74069. private _barHeight;
  74070. private _spacerHeight;
  74071. private _labelColor;
  74072. private _groups;
  74073. private _bars;
  74074. /**
  74075. * Creates a new SelectionPanel
  74076. * @param name of SelectionPanel
  74077. * @param groups is an array of SelectionGroups
  74078. */
  74079. constructor(
  74080. /** name of SelectionPanel */
  74081. name: string,
  74082. /** an array of SelectionGroups */
  74083. groups?: SelectorGroup[]);
  74084. protected _getTypeName(): string;
  74085. /** Gets or sets the headerColor */
  74086. get headerColor(): string;
  74087. set headerColor(color: string);
  74088. private _setHeaderColor;
  74089. /** Gets or sets the button color */
  74090. get buttonColor(): string;
  74091. set buttonColor(color: string);
  74092. private _setbuttonColor;
  74093. /** Gets or sets the label color */
  74094. get labelColor(): string;
  74095. set labelColor(color: string);
  74096. private _setLabelColor;
  74097. /** Gets or sets the button background */
  74098. get buttonBackground(): string;
  74099. set buttonBackground(color: string);
  74100. private _setButtonBackground;
  74101. /** Gets or sets the color of separator bar */
  74102. get barColor(): string;
  74103. set barColor(color: string);
  74104. private _setBarColor;
  74105. /** Gets or sets the height of separator bar */
  74106. get barHeight(): string;
  74107. set barHeight(value: string);
  74108. private _setBarHeight;
  74109. /** Gets or sets the height of spacers*/
  74110. get spacerHeight(): string;
  74111. set spacerHeight(value: string);
  74112. private _setSpacerHeight;
  74113. /** Adds a bar between groups */
  74114. private _addSpacer;
  74115. /** Add a group to the selection panel
  74116. * @param group is the selector group to add
  74117. */
  74118. addGroup(group: SelectorGroup): void;
  74119. /** Remove the group from the given position
  74120. * @param groupNb is the position of the group in the list
  74121. */
  74122. removeGroup(groupNb: number): void;
  74123. /** Change a group header label
  74124. * @param label is the new group header label
  74125. * @param groupNb is the number of the group to relabel
  74126. * */
  74127. setHeaderName(label: string, groupNb: number): void;
  74128. /** Change selector label to the one given
  74129. * @param label is the new selector label
  74130. * @param groupNb is the number of the groupcontaining the selector
  74131. * @param selectorNb is the number of the selector within a group to relabel
  74132. * */
  74133. relabel(label: string, groupNb: number, selectorNb: number): void;
  74134. /** For a given group position remove the selector at the given position
  74135. * @param groupNb is the number of the group to remove the selector from
  74136. * @param selectorNb is the number of the selector within the group
  74137. */
  74138. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  74139. /** For a given group position of correct type add a checkbox button
  74140. * @param groupNb is the number of the group to remove the selector from
  74141. * @param label is the label for the selector
  74142. * @param func is the function called when the Selector is checked
  74143. * @param checked is true when Selector is checked
  74144. */
  74145. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74146. /** For a given group position of correct type add a radio button
  74147. * @param groupNb is the number of the group to remove the selector from
  74148. * @param label is the label for the selector
  74149. * @param func is the function called when the Selector is checked
  74150. * @param checked is true when Selector is checked
  74151. */
  74152. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74153. /**
  74154. * For a given slider group add a slider
  74155. * @param groupNb is the number of the group to add the slider to
  74156. * @param label is the label for the Slider
  74157. * @param func is the function called when the Slider moves
  74158. * @param unit is a string describing the units used, eg degrees or metres
  74159. * @param min is the minimum value for the Slider
  74160. * @param max is the maximum value for the Slider
  74161. * @param value is the start value for the Slider between min and max
  74162. * @param onVal is the function used to format the value displayed, eg radians to degrees
  74163. */
  74164. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  74165. }
  74166. }
  74167. declare module BABYLON.GUI {
  74168. /**
  74169. * Class used to hold a the container for ScrollViewer
  74170. * @hidden
  74171. */
  74172. export class _ScrollViewerWindow extends Container {
  74173. parentClientWidth: number;
  74174. parentClientHeight: number;
  74175. private _freezeControls;
  74176. private _parentMeasure;
  74177. private _oldLeft;
  74178. private _oldTop;
  74179. get freezeControls(): boolean;
  74180. set freezeControls(value: boolean);
  74181. private _bucketWidth;
  74182. private _bucketHeight;
  74183. private _buckets;
  74184. private _bucketLen;
  74185. get bucketWidth(): number;
  74186. get bucketHeight(): number;
  74187. setBucketSizes(width: number, height: number): void;
  74188. private _useBuckets;
  74189. private _makeBuckets;
  74190. private _dispatchInBuckets;
  74191. private _updateMeasures;
  74192. private _updateChildrenMeasures;
  74193. private _restoreMeasures;
  74194. /**
  74195. * Creates a new ScrollViewerWindow
  74196. * @param name of ScrollViewerWindow
  74197. */
  74198. constructor(name?: string);
  74199. protected _getTypeName(): string;
  74200. /** @hidden */
  74201. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74202. /** @hidden */
  74203. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74204. private _scrollChildren;
  74205. private _scrollChildrenWithBuckets;
  74206. /** @hidden */
  74207. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  74208. protected _postMeasure(): void;
  74209. }
  74210. }
  74211. declare module BABYLON.GUI {
  74212. /**
  74213. * Class used to create slider controls
  74214. */
  74215. export class ScrollBar extends BaseSlider {
  74216. name?: string | undefined;
  74217. private _background;
  74218. private _borderColor;
  74219. private _tempMeasure;
  74220. /** Gets or sets border color */
  74221. get borderColor(): string;
  74222. set borderColor(value: string);
  74223. /** Gets or sets background color */
  74224. get background(): string;
  74225. set background(value: string);
  74226. /**
  74227. * Creates a new Slider
  74228. * @param name defines the control name
  74229. */
  74230. constructor(name?: string | undefined);
  74231. protected _getTypeName(): string;
  74232. protected _getThumbThickness(): number;
  74233. _draw(context: CanvasRenderingContext2D): void;
  74234. private _first;
  74235. private _originX;
  74236. private _originY;
  74237. /** @hidden */
  74238. protected _updateValueFromPointer(x: number, y: number): void;
  74239. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74240. }
  74241. }
  74242. declare module BABYLON.GUI {
  74243. /**
  74244. * Class used to create slider controls
  74245. */
  74246. export class ImageScrollBar extends BaseSlider {
  74247. name?: string | undefined;
  74248. private _backgroundBaseImage;
  74249. private _backgroundImage;
  74250. private _thumbImage;
  74251. private _thumbBaseImage;
  74252. private _thumbLength;
  74253. private _thumbHeight;
  74254. private _barImageHeight;
  74255. private _tempMeasure;
  74256. /** Number of 90° rotation to apply on the images when in vertical mode */
  74257. num90RotationInVerticalMode: number;
  74258. /**
  74259. * Gets or sets the image used to render the background for horizontal bar
  74260. */
  74261. get backgroundImage(): Image;
  74262. set backgroundImage(value: Image);
  74263. /**
  74264. * Gets or sets the image used to render the thumb
  74265. */
  74266. get thumbImage(): Image;
  74267. set thumbImage(value: Image);
  74268. /**
  74269. * Gets or sets the length of the thumb
  74270. */
  74271. get thumbLength(): number;
  74272. set thumbLength(value: number);
  74273. /**
  74274. * Gets or sets the height of the thumb
  74275. */
  74276. get thumbHeight(): number;
  74277. set thumbHeight(value: number);
  74278. /**
  74279. * Gets or sets the height of the bar image
  74280. */
  74281. get barImageHeight(): number;
  74282. set barImageHeight(value: number);
  74283. /**
  74284. * Creates a new ImageScrollBar
  74285. * @param name defines the control name
  74286. */
  74287. constructor(name?: string | undefined);
  74288. protected _getTypeName(): string;
  74289. protected _getThumbThickness(): number;
  74290. _draw(context: CanvasRenderingContext2D): void;
  74291. private _first;
  74292. private _originX;
  74293. private _originY;
  74294. /** @hidden */
  74295. protected _updateValueFromPointer(x: number, y: number): void;
  74296. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74297. }
  74298. }
  74299. declare module BABYLON.GUI {
  74300. /**
  74301. * Class used to hold a viewer window and sliders in a grid
  74302. */
  74303. export class ScrollViewer extends Rectangle {
  74304. private _grid;
  74305. private _horizontalBarSpace;
  74306. private _verticalBarSpace;
  74307. private _dragSpace;
  74308. private _horizontalBar;
  74309. private _verticalBar;
  74310. private _barColor;
  74311. private _barBackground;
  74312. private _barImage;
  74313. private _horizontalBarImage;
  74314. private _verticalBarImage;
  74315. private _barBackgroundImage;
  74316. private _horizontalBarBackgroundImage;
  74317. private _verticalBarBackgroundImage;
  74318. private _barSize;
  74319. private _window;
  74320. private _pointerIsOver;
  74321. private _wheelPrecision;
  74322. private _onWheelObserver;
  74323. private _clientWidth;
  74324. private _clientHeight;
  74325. private _useImageBar;
  74326. private _thumbLength;
  74327. private _thumbHeight;
  74328. private _barImageHeight;
  74329. private _horizontalBarImageHeight;
  74330. private _verticalBarImageHeight;
  74331. private _oldWindowContentsWidth;
  74332. private _oldWindowContentsHeight;
  74333. /**
  74334. * Gets the horizontal scrollbar
  74335. */
  74336. get horizontalBar(): ScrollBar | ImageScrollBar;
  74337. /**
  74338. * Gets the vertical scrollbar
  74339. */
  74340. get verticalBar(): ScrollBar | ImageScrollBar;
  74341. /**
  74342. * Adds a new control to the current container
  74343. * @param control defines the control to add
  74344. * @returns the current container
  74345. */
  74346. addControl(control: BABYLON.Nullable<Control>): Container;
  74347. /**
  74348. * Removes a control from the current container
  74349. * @param control defines the control to remove
  74350. * @returns the current container
  74351. */
  74352. removeControl(control: Control): Container;
  74353. /** Gets the list of children */
  74354. get children(): Control[];
  74355. _flagDescendantsAsMatrixDirty(): void;
  74356. /**
  74357. * Freezes or unfreezes the controls in the window.
  74358. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  74359. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  74360. */
  74361. get freezeControls(): boolean;
  74362. set freezeControls(value: boolean);
  74363. /** Gets the bucket width */
  74364. get bucketWidth(): number;
  74365. /** Gets the bucket height */
  74366. get bucketHeight(): number;
  74367. /**
  74368. * Sets the bucket sizes.
  74369. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  74370. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  74371. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  74372. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  74373. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  74374. * used), that's why it is not enabled by default.
  74375. * @param width width of the bucket
  74376. * @param height height of the bucket
  74377. */
  74378. setBucketSizes(width: number, height: number): void;
  74379. private _forceHorizontalBar;
  74380. private _forceVerticalBar;
  74381. /**
  74382. * Forces the horizontal scroll bar to be displayed
  74383. */
  74384. get forceHorizontalBar(): boolean;
  74385. set forceHorizontalBar(value: boolean);
  74386. /**
  74387. * Forces the vertical scroll bar to be displayed
  74388. */
  74389. get forceVerticalBar(): boolean;
  74390. set forceVerticalBar(value: boolean);
  74391. /**
  74392. * Creates a new ScrollViewer
  74393. * @param name of ScrollViewer
  74394. */
  74395. constructor(name?: string, isImageBased?: boolean);
  74396. /** Reset the scroll viewer window to initial size */
  74397. resetWindow(): void;
  74398. protected _getTypeName(): string;
  74399. private _buildClientSizes;
  74400. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74401. protected _postMeasure(): void;
  74402. /**
  74403. * Gets or sets the mouse wheel precision
  74404. * from 0 to 1 with a default value of 0.05
  74405. * */
  74406. get wheelPrecision(): number;
  74407. set wheelPrecision(value: number);
  74408. /** Gets or sets the scroll bar container background color */
  74409. get scrollBackground(): string;
  74410. set scrollBackground(color: string);
  74411. /** Gets or sets the bar color */
  74412. get barColor(): string;
  74413. set barColor(color: string);
  74414. /** Gets or sets the bar image */
  74415. get thumbImage(): Image;
  74416. set thumbImage(value: Image);
  74417. /** Gets or sets the horizontal bar image */
  74418. get horizontalThumbImage(): Image;
  74419. set horizontalThumbImage(value: Image);
  74420. /** Gets or sets the vertical bar image */
  74421. get verticalThumbImage(): Image;
  74422. set verticalThumbImage(value: Image);
  74423. /** Gets or sets the size of the bar */
  74424. get barSize(): number;
  74425. set barSize(value: number);
  74426. /** Gets or sets the length of the thumb */
  74427. get thumbLength(): number;
  74428. set thumbLength(value: number);
  74429. /** Gets or sets the height of the thumb */
  74430. get thumbHeight(): number;
  74431. set thumbHeight(value: number);
  74432. /** Gets or sets the height of the bar image */
  74433. get barImageHeight(): number;
  74434. set barImageHeight(value: number);
  74435. /** Gets or sets the height of the horizontal bar image */
  74436. get horizontalBarImageHeight(): number;
  74437. set horizontalBarImageHeight(value: number);
  74438. /** Gets or sets the height of the vertical bar image */
  74439. get verticalBarImageHeight(): number;
  74440. set verticalBarImageHeight(value: number);
  74441. /** Gets or sets the bar background */
  74442. get barBackground(): string;
  74443. set barBackground(color: string);
  74444. /** Gets or sets the bar background image */
  74445. get barImage(): Image;
  74446. set barImage(value: Image);
  74447. /** Gets or sets the horizontal bar background image */
  74448. get horizontalBarImage(): Image;
  74449. set horizontalBarImage(value: Image);
  74450. /** Gets or sets the vertical bar background image */
  74451. get verticalBarImage(): Image;
  74452. set verticalBarImage(value: Image);
  74453. private _setWindowPosition;
  74454. /** @hidden */
  74455. private _updateScroller;
  74456. _link(host: AdvancedDynamicTexture): void;
  74457. /** @hidden */
  74458. private _addBar;
  74459. /** @hidden */
  74460. private _attachWheel;
  74461. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74462. /** Releases associated resources */
  74463. dispose(): void;
  74464. }
  74465. }
  74466. declare module BABYLON.GUI {
  74467. /** Class used to render a grid */
  74468. export class DisplayGrid extends Control {
  74469. name?: string | undefined;
  74470. private _cellWidth;
  74471. private _cellHeight;
  74472. private _minorLineTickness;
  74473. private _minorLineColor;
  74474. private _majorLineTickness;
  74475. private _majorLineColor;
  74476. private _majorLineFrequency;
  74477. private _background;
  74478. private _displayMajorLines;
  74479. private _displayMinorLines;
  74480. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74481. get displayMinorLines(): boolean;
  74482. set displayMinorLines(value: boolean);
  74483. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74484. get displayMajorLines(): boolean;
  74485. set displayMajorLines(value: boolean);
  74486. /** Gets or sets background color (Black by default) */
  74487. get background(): string;
  74488. set background(value: string);
  74489. /** Gets or sets the width of each cell (20 by default) */
  74490. get cellWidth(): number;
  74491. set cellWidth(value: number);
  74492. /** Gets or sets the height of each cell (20 by default) */
  74493. get cellHeight(): number;
  74494. set cellHeight(value: number);
  74495. /** Gets or sets the tickness of minor lines (1 by default) */
  74496. get minorLineTickness(): number;
  74497. set minorLineTickness(value: number);
  74498. /** Gets or sets the color of minor lines (DarkGray by default) */
  74499. get minorLineColor(): string;
  74500. set minorLineColor(value: string);
  74501. /** Gets or sets the tickness of major lines (2 by default) */
  74502. get majorLineTickness(): number;
  74503. set majorLineTickness(value: number);
  74504. /** Gets or sets the color of major lines (White by default) */
  74505. get majorLineColor(): string;
  74506. set majorLineColor(value: string);
  74507. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74508. get majorLineFrequency(): number;
  74509. set majorLineFrequency(value: number);
  74510. /**
  74511. * Creates a new GridDisplayRectangle
  74512. * @param name defines the control name
  74513. */
  74514. constructor(name?: string | undefined);
  74515. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74516. protected _getTypeName(): string;
  74517. }
  74518. }
  74519. declare module BABYLON.GUI {
  74520. /**
  74521. * Class used to create slider controls based on images
  74522. */
  74523. export class ImageBasedSlider extends BaseSlider {
  74524. name?: string | undefined;
  74525. private _backgroundImage;
  74526. private _thumbImage;
  74527. private _valueBarImage;
  74528. private _tempMeasure;
  74529. get displayThumb(): boolean;
  74530. set displayThumb(value: boolean);
  74531. /**
  74532. * Gets or sets the image used to render the background
  74533. */
  74534. get backgroundImage(): Image;
  74535. set backgroundImage(value: Image);
  74536. /**
  74537. * Gets or sets the image used to render the value bar
  74538. */
  74539. get valueBarImage(): Image;
  74540. set valueBarImage(value: Image);
  74541. /**
  74542. * Gets or sets the image used to render the thumb
  74543. */
  74544. get thumbImage(): Image;
  74545. set thumbImage(value: Image);
  74546. /**
  74547. * Creates a new ImageBasedSlider
  74548. * @param name defines the control name
  74549. */
  74550. constructor(name?: string | undefined);
  74551. protected _getTypeName(): string;
  74552. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74553. }
  74554. }
  74555. declare module BABYLON.GUI {
  74556. /**
  74557. * Forcing an export so that this code will execute
  74558. * @hidden
  74559. */
  74560. const name = "Statics";
  74561. }
  74562. declare module BABYLON.GUI {
  74563. /**
  74564. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74565. */
  74566. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74567. /**
  74568. * Define the instrumented AdvancedDynamicTexture.
  74569. */
  74570. texture: AdvancedDynamicTexture;
  74571. private _captureRenderTime;
  74572. private _renderTime;
  74573. private _captureLayoutTime;
  74574. private _layoutTime;
  74575. private _onBeginRenderObserver;
  74576. private _onEndRenderObserver;
  74577. private _onBeginLayoutObserver;
  74578. private _onEndLayoutObserver;
  74579. /**
  74580. * Gets the perf counter used to capture render time
  74581. */
  74582. get renderTimeCounter(): BABYLON.PerfCounter;
  74583. /**
  74584. * Gets the perf counter used to capture layout time
  74585. */
  74586. get layoutTimeCounter(): BABYLON.PerfCounter;
  74587. /**
  74588. * Enable or disable the render time capture
  74589. */
  74590. get captureRenderTime(): boolean;
  74591. set captureRenderTime(value: boolean);
  74592. /**
  74593. * Enable or disable the layout time capture
  74594. */
  74595. get captureLayoutTime(): boolean;
  74596. set captureLayoutTime(value: boolean);
  74597. /**
  74598. * Instantiates a new advanced dynamic texture instrumentation.
  74599. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74600. * @param texture Defines the AdvancedDynamicTexture to instrument
  74601. */
  74602. constructor(
  74603. /**
  74604. * Define the instrumented AdvancedDynamicTexture.
  74605. */
  74606. texture: AdvancedDynamicTexture);
  74607. /**
  74608. * Dispose and release associated resources.
  74609. */
  74610. dispose(): void;
  74611. }
  74612. }
  74613. declare module BABYLON.GUI {
  74614. /**
  74615. * Class used to load GUI via XML.
  74616. */
  74617. export class XmlLoader {
  74618. private _nodes;
  74619. private _nodeTypes;
  74620. private _isLoaded;
  74621. private _objectAttributes;
  74622. private _parentClass;
  74623. /**
  74624. * Create a new xml loader
  74625. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74626. */
  74627. constructor(parentClass?: null);
  74628. private _getChainElement;
  74629. private _getClassAttribute;
  74630. private _createGuiElement;
  74631. private _parseGrid;
  74632. private _parseElement;
  74633. private _prepareSourceElement;
  74634. private _parseElementsFromSource;
  74635. private _parseXml;
  74636. /**
  74637. * Gets if the loading has finished.
  74638. * @returns whether the loading has finished or not
  74639. */
  74640. isLoaded(): boolean;
  74641. /**
  74642. * Gets a loaded node / control by id.
  74643. * @param id the Controls id set in the xml
  74644. * @returns element of type Control
  74645. */
  74646. getNodeById(id: string): any;
  74647. /**
  74648. * Gets all loaded nodes / controls
  74649. * @returns Array of controls
  74650. */
  74651. getNodes(): any;
  74652. /**
  74653. * Initiates the xml layout loading
  74654. * @param xmlFile defines the xml layout to load
  74655. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74656. * @param callback defines the callback called on layout load.
  74657. */
  74658. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74659. }
  74660. }
  74661. declare module BABYLON.GUI {
  74662. /**
  74663. * Class used to create containers for controls
  74664. */
  74665. export class Container3D extends Control3D {
  74666. private _blockLayout;
  74667. /**
  74668. * Gets the list of child controls
  74669. */
  74670. protected _children: Control3D[];
  74671. /**
  74672. * Gets the list of child controls
  74673. */
  74674. get children(): Array<Control3D>;
  74675. /**
  74676. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74677. * This is helpful to optimize layout operation when adding multiple children in a row
  74678. */
  74679. get blockLayout(): boolean;
  74680. set blockLayout(value: boolean);
  74681. /**
  74682. * Creates a new container
  74683. * @param name defines the container name
  74684. */
  74685. constructor(name?: string);
  74686. /**
  74687. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74688. * @returns the current container
  74689. */
  74690. updateLayout(): Container3D;
  74691. /**
  74692. * Gets a boolean indicating if the given control is in the children of this control
  74693. * @param control defines the control to check
  74694. * @returns true if the control is in the child list
  74695. */
  74696. containsControl(control: Control3D): boolean;
  74697. /**
  74698. * Adds a control to the children of this control
  74699. * @param control defines the control to add
  74700. * @returns the current container
  74701. */
  74702. addControl(control: Control3D): Container3D;
  74703. /**
  74704. * This function will be called everytime a new control is added
  74705. */
  74706. protected _arrangeChildren(): void;
  74707. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74708. /**
  74709. * Removes a control from the children of this control
  74710. * @param control defines the control to remove
  74711. * @returns the current container
  74712. */
  74713. removeControl(control: Control3D): Container3D;
  74714. protected _getTypeName(): string;
  74715. /**
  74716. * Releases all associated resources
  74717. */
  74718. dispose(): void;
  74719. /** Control rotation will remain unchanged */
  74720. static readonly UNSET_ORIENTATION: number;
  74721. /** Control will rotate to make it look at sphere central axis */
  74722. static readonly FACEORIGIN_ORIENTATION: number;
  74723. /** Control will rotate to make it look back at sphere central axis */
  74724. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74725. /** Control will rotate to look at z axis (0, 0, 1) */
  74726. static readonly FACEFORWARD_ORIENTATION: number;
  74727. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74728. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74729. }
  74730. }
  74731. declare module BABYLON.GUI {
  74732. /**
  74733. * Class used to manage 3D user interface
  74734. * @see http://doc.babylonjs.com/how_to/gui3d
  74735. */
  74736. export class GUI3DManager implements BABYLON.IDisposable {
  74737. private _scene;
  74738. private _sceneDisposeObserver;
  74739. private _utilityLayer;
  74740. private _rootContainer;
  74741. private _pointerObserver;
  74742. private _pointerOutObserver;
  74743. /** @hidden */
  74744. _lastPickedControl: Control3D;
  74745. /** @hidden */
  74746. _lastControlOver: {
  74747. [pointerId: number]: Control3D;
  74748. };
  74749. /** @hidden */
  74750. _lastControlDown: {
  74751. [pointerId: number]: Control3D;
  74752. };
  74753. /**
  74754. * BABYLON.Observable raised when the point picked by the pointer events changed
  74755. */
  74756. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74757. /** @hidden */
  74758. _sharedMaterials: {
  74759. [key: string]: BABYLON.Material;
  74760. };
  74761. /** Gets the hosting scene */
  74762. get scene(): BABYLON.Scene;
  74763. /** Gets associated utility layer */
  74764. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74765. /**
  74766. * Creates a new GUI3DManager
  74767. * @param scene
  74768. */
  74769. constructor(scene?: BABYLON.Scene);
  74770. private _handlePointerOut;
  74771. private _doPicking;
  74772. /**
  74773. * Gets the root container
  74774. */
  74775. get rootContainer(): Container3D;
  74776. /**
  74777. * Gets a boolean indicating if the given control is in the root child list
  74778. * @param control defines the control to check
  74779. * @returns true if the control is in the root child list
  74780. */
  74781. containsControl(control: Control3D): boolean;
  74782. /**
  74783. * Adds a control to the root child list
  74784. * @param control defines the control to add
  74785. * @returns the current manager
  74786. */
  74787. addControl(control: Control3D): GUI3DManager;
  74788. /**
  74789. * Removes a control from the root child list
  74790. * @param control defines the control to remove
  74791. * @returns the current container
  74792. */
  74793. removeControl(control: Control3D): GUI3DManager;
  74794. /**
  74795. * Releases all associated resources
  74796. */
  74797. dispose(): void;
  74798. }
  74799. }
  74800. declare module BABYLON.GUI {
  74801. /**
  74802. * Class used to transport BABYLON.Vector3 information for pointer events
  74803. */
  74804. export class Vector3WithInfo extends BABYLON.Vector3 {
  74805. /** defines the current mouse button index */
  74806. buttonIndex: number;
  74807. /**
  74808. * Creates a new Vector3WithInfo
  74809. * @param source defines the vector3 data to transport
  74810. * @param buttonIndex defines the current mouse button index
  74811. */
  74812. constructor(source: BABYLON.Vector3,
  74813. /** defines the current mouse button index */
  74814. buttonIndex?: number);
  74815. }
  74816. }
  74817. declare module BABYLON.GUI {
  74818. /**
  74819. * Class used as base class for controls
  74820. */
  74821. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74822. /** Defines the control name */
  74823. name?: string | undefined;
  74824. /** @hidden */
  74825. _host: GUI3DManager;
  74826. private _node;
  74827. private _downCount;
  74828. private _enterCount;
  74829. private _downPointerIds;
  74830. private _isVisible;
  74831. /** Gets or sets the control position in world space */
  74832. get position(): BABYLON.Vector3;
  74833. set position(value: BABYLON.Vector3);
  74834. /** Gets or sets the control scaling in world space */
  74835. get scaling(): BABYLON.Vector3;
  74836. set scaling(value: BABYLON.Vector3);
  74837. /** Callback used to start pointer enter animation */
  74838. pointerEnterAnimation: () => void;
  74839. /** Callback used to start pointer out animation */
  74840. pointerOutAnimation: () => void;
  74841. /** Callback used to start pointer down animation */
  74842. pointerDownAnimation: () => void;
  74843. /** Callback used to start pointer up animation */
  74844. pointerUpAnimation: () => void;
  74845. /**
  74846. * An event triggered when the pointer move over the control
  74847. */
  74848. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74849. /**
  74850. * An event triggered when the pointer move out of the control
  74851. */
  74852. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74853. /**
  74854. * An event triggered when the pointer taps the control
  74855. */
  74856. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74857. /**
  74858. * An event triggered when pointer is up
  74859. */
  74860. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74861. /**
  74862. * An event triggered when a control is clicked on (with a mouse)
  74863. */
  74864. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74865. /**
  74866. * An event triggered when pointer enters the control
  74867. */
  74868. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74869. /**
  74870. * Gets or sets the parent container
  74871. */
  74872. parent: BABYLON.Nullable<Container3D>;
  74873. private _behaviors;
  74874. /**
  74875. * Gets the list of attached behaviors
  74876. * @see http://doc.babylonjs.com/features/behaviour
  74877. */
  74878. get behaviors(): BABYLON.Behavior<Control3D>[];
  74879. /**
  74880. * Attach a behavior to the control
  74881. * @see http://doc.babylonjs.com/features/behaviour
  74882. * @param behavior defines the behavior to attach
  74883. * @returns the current control
  74884. */
  74885. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74886. /**
  74887. * Remove an attached behavior
  74888. * @see http://doc.babylonjs.com/features/behaviour
  74889. * @param behavior defines the behavior to attach
  74890. * @returns the current control
  74891. */
  74892. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74893. /**
  74894. * Gets an attached behavior by name
  74895. * @param name defines the name of the behavior to look for
  74896. * @see http://doc.babylonjs.com/features/behaviour
  74897. * @returns null if behavior was not found else the requested behavior
  74898. */
  74899. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74900. /** Gets or sets a boolean indicating if the control is visible */
  74901. get isVisible(): boolean;
  74902. set isVisible(value: boolean);
  74903. /**
  74904. * Creates a new control
  74905. * @param name defines the control name
  74906. */
  74907. constructor(
  74908. /** Defines the control name */
  74909. name?: string | undefined);
  74910. /**
  74911. * Gets a string representing the class name
  74912. */
  74913. get typeName(): string;
  74914. /**
  74915. * Get the current class name of the control.
  74916. * @returns current class name
  74917. */
  74918. getClassName(): string;
  74919. protected _getTypeName(): string;
  74920. /**
  74921. * Gets the transform node used by this control
  74922. */
  74923. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74924. /**
  74925. * Gets the mesh used to render this control
  74926. */
  74927. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74928. /**
  74929. * Link the control as child of the given node
  74930. * @param node defines the node to link to. Use null to unlink the control
  74931. * @returns the current control
  74932. */
  74933. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74934. /** @hidden **/
  74935. _prepareNode(scene: BABYLON.Scene): void;
  74936. /**
  74937. * Node creation.
  74938. * Can be overriden by children
  74939. * @param scene defines the scene where the node must be attached
  74940. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74941. */
  74942. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74943. /**
  74944. * Affect a material to the given mesh
  74945. * @param mesh defines the mesh which will represent the control
  74946. */
  74947. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74948. /** @hidden */
  74949. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74950. /** @hidden */
  74951. _onPointerEnter(target: Control3D): boolean;
  74952. /** @hidden */
  74953. _onPointerOut(target: Control3D): void;
  74954. /** @hidden */
  74955. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74956. /** @hidden */
  74957. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74958. /** @hidden */
  74959. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74960. /** @hidden */
  74961. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74962. /** @hidden */
  74963. _disposeNode(): void;
  74964. /**
  74965. * Releases all associated resources
  74966. */
  74967. dispose(): void;
  74968. }
  74969. }
  74970. declare module BABYLON.GUI {
  74971. /**
  74972. * Class used as a root to all buttons
  74973. */
  74974. export class AbstractButton3D extends Control3D {
  74975. /**
  74976. * Creates a new button
  74977. * @param name defines the control name
  74978. */
  74979. constructor(name?: string);
  74980. protected _getTypeName(): string;
  74981. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74982. }
  74983. }
  74984. declare module BABYLON.GUI {
  74985. /**
  74986. * Class used to create a button in 3D
  74987. */
  74988. export class Button3D extends AbstractButton3D {
  74989. /** @hidden */
  74990. protected _currentMaterial: BABYLON.Material;
  74991. private _facadeTexture;
  74992. private _content;
  74993. private _contentResolution;
  74994. private _contentScaleRatio;
  74995. /**
  74996. * Gets or sets the texture resolution used to render content (512 by default)
  74997. */
  74998. get contentResolution(): BABYLON.int;
  74999. set contentResolution(value: BABYLON.int);
  75000. /**
  75001. * Gets or sets the texture scale ratio used to render content (2 by default)
  75002. */
  75003. get contentScaleRatio(): number;
  75004. set contentScaleRatio(value: number);
  75005. protected _disposeFacadeTexture(): void;
  75006. protected _resetContent(): void;
  75007. /**
  75008. * Creates a new button
  75009. * @param name defines the control name
  75010. */
  75011. constructor(name?: string);
  75012. /**
  75013. * Gets or sets the GUI 2D content used to display the button's facade
  75014. */
  75015. get content(): Control;
  75016. set content(value: Control);
  75017. /**
  75018. * Apply the facade texture (created from the content property).
  75019. * This function can be overloaded by child classes
  75020. * @param facadeTexture defines the AdvancedDynamicTexture to use
  75021. */
  75022. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75023. protected _getTypeName(): string;
  75024. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75025. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75026. /**
  75027. * Releases all associated resources
  75028. */
  75029. dispose(): void;
  75030. }
  75031. }
  75032. declare module BABYLON.GUI {
  75033. /**
  75034. * Abstract class used to create a container panel deployed on the surface of a volume
  75035. */
  75036. export abstract class VolumeBasedPanel extends Container3D {
  75037. private _columns;
  75038. private _rows;
  75039. private _rowThenColum;
  75040. private _orientation;
  75041. protected _cellWidth: number;
  75042. protected _cellHeight: number;
  75043. /**
  75044. * Gets or sets the distance between elements
  75045. */
  75046. margin: number;
  75047. /**
  75048. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  75049. * | Value | Type | Description |
  75050. * | ----- | ----------------------------------- | ----------- |
  75051. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  75052. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  75053. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  75054. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  75055. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  75056. */
  75057. get orientation(): number;
  75058. set orientation(value: number);
  75059. /**
  75060. * Gets or sets the number of columns requested (10 by default).
  75061. * The panel will automatically compute the number of rows based on number of child controls.
  75062. */
  75063. get columns(): BABYLON.int;
  75064. set columns(value: BABYLON.int);
  75065. /**
  75066. * Gets or sets a the number of rows requested.
  75067. * The panel will automatically compute the number of columns based on number of child controls.
  75068. */
  75069. get rows(): BABYLON.int;
  75070. set rows(value: BABYLON.int);
  75071. /**
  75072. * Creates new VolumeBasedPanel
  75073. */
  75074. constructor();
  75075. protected _arrangeChildren(): void;
  75076. /** Child classes must implement this function to provide correct control positioning */
  75077. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75078. /** Child classes can implement this function to provide additional processing */
  75079. protected _finalProcessing(): void;
  75080. }
  75081. }
  75082. declare module BABYLON.GUI {
  75083. /**
  75084. * Class used to create a container panel deployed on the surface of a cylinder
  75085. */
  75086. export class CylinderPanel extends VolumeBasedPanel {
  75087. private _radius;
  75088. /**
  75089. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  75090. */
  75091. get radius(): BABYLON.float;
  75092. set radius(value: BABYLON.float);
  75093. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75094. private _cylindricalMapping;
  75095. }
  75096. }
  75097. declare module BABYLON.GUI {
  75098. /** @hidden */
  75099. export var fluentVertexShader: {
  75100. name: string;
  75101. shader: string;
  75102. };
  75103. }
  75104. declare module BABYLON.GUI {
  75105. /** @hidden */
  75106. export var fluentPixelShader: {
  75107. name: string;
  75108. shader: string;
  75109. };
  75110. }
  75111. declare module BABYLON.GUI {
  75112. /** @hidden */
  75113. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  75114. INNERGLOW: boolean;
  75115. BORDER: boolean;
  75116. HOVERLIGHT: boolean;
  75117. TEXTURE: boolean;
  75118. constructor();
  75119. }
  75120. /**
  75121. * Class used to render controls with fluent desgin
  75122. */
  75123. export class FluentMaterial extends BABYLON.PushMaterial {
  75124. /**
  75125. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  75126. */
  75127. innerGlowColorIntensity: number;
  75128. /**
  75129. * Gets or sets the inner glow color (white by default)
  75130. */
  75131. innerGlowColor: BABYLON.Color3;
  75132. /**
  75133. * Gets or sets alpha value (default is 1.0)
  75134. */
  75135. alpha: number;
  75136. /**
  75137. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  75138. */
  75139. albedoColor: BABYLON.Color3;
  75140. /**
  75141. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  75142. */
  75143. renderBorders: boolean;
  75144. /**
  75145. * Gets or sets border width (default is 0.5)
  75146. */
  75147. borderWidth: number;
  75148. /**
  75149. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  75150. */
  75151. edgeSmoothingValue: number;
  75152. /**
  75153. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  75154. */
  75155. borderMinValue: number;
  75156. /**
  75157. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  75158. */
  75159. renderHoverLight: boolean;
  75160. /**
  75161. * Gets or sets the radius used to render the hover light (default is 1.0)
  75162. */
  75163. hoverRadius: number;
  75164. /**
  75165. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  75166. */
  75167. hoverColor: BABYLON.Color4;
  75168. /**
  75169. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  75170. */
  75171. hoverPosition: BABYLON.Vector3;
  75172. private _albedoTexture;
  75173. /** Gets or sets the texture to use for albedo color */
  75174. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75175. /**
  75176. * Creates a new Fluent material
  75177. * @param name defines the name of the material
  75178. * @param scene defines the hosting scene
  75179. */
  75180. constructor(name: string, scene: BABYLON.Scene);
  75181. needAlphaBlending(): boolean;
  75182. needAlphaTesting(): boolean;
  75183. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75184. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75185. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75186. getActiveTextures(): BABYLON.BaseTexture[];
  75187. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75188. dispose(forceDisposeEffect?: boolean): void;
  75189. clone(name: string): FluentMaterial;
  75190. serialize(): any;
  75191. getClassName(): string;
  75192. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  75193. }
  75194. }
  75195. declare module BABYLON.GUI {
  75196. /**
  75197. * Class used to create a holographic button in 3D
  75198. */
  75199. export class HolographicButton extends Button3D {
  75200. private _backPlate;
  75201. private _textPlate;
  75202. private _frontPlate;
  75203. private _text;
  75204. private _imageUrl;
  75205. private _shareMaterials;
  75206. private _frontMaterial;
  75207. private _backMaterial;
  75208. private _plateMaterial;
  75209. private _pickedPointObserver;
  75210. private _tooltipFade;
  75211. private _tooltipTextBlock;
  75212. private _tooltipTexture;
  75213. private _tooltipMesh;
  75214. private _tooltipHoverObserver;
  75215. private _tooltipOutObserver;
  75216. private _disposeTooltip;
  75217. /**
  75218. * Rendering ground id of all the mesh in the button
  75219. */
  75220. set renderingGroupId(id: number);
  75221. get renderingGroupId(): number;
  75222. /**
  75223. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  75224. */
  75225. set tooltipText(text: BABYLON.Nullable<string>);
  75226. get tooltipText(): BABYLON.Nullable<string>;
  75227. /**
  75228. * Gets or sets text for the button
  75229. */
  75230. get text(): string;
  75231. set text(value: string);
  75232. /**
  75233. * Gets or sets the image url for the button
  75234. */
  75235. get imageUrl(): string;
  75236. set imageUrl(value: string);
  75237. /**
  75238. * Gets the back material used by this button
  75239. */
  75240. get backMaterial(): FluentMaterial;
  75241. /**
  75242. * Gets the front material used by this button
  75243. */
  75244. get frontMaterial(): FluentMaterial;
  75245. /**
  75246. * Gets the plate material used by this button
  75247. */
  75248. get plateMaterial(): BABYLON.StandardMaterial;
  75249. /**
  75250. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  75251. */
  75252. get shareMaterials(): boolean;
  75253. /**
  75254. * Creates a new button
  75255. * @param name defines the control name
  75256. */
  75257. constructor(name?: string, shareMaterials?: boolean);
  75258. protected _getTypeName(): string;
  75259. private _rebuildContent;
  75260. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75261. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75262. private _createBackMaterial;
  75263. private _createFrontMaterial;
  75264. private _createPlateMaterial;
  75265. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  75266. /**
  75267. * Releases all associated resources
  75268. */
  75269. dispose(): void;
  75270. }
  75271. }
  75272. declare module BABYLON.GUI {
  75273. /**
  75274. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  75275. */
  75276. export class MeshButton3D extends Button3D {
  75277. /** @hidden */
  75278. protected _currentMesh: BABYLON.Mesh;
  75279. /**
  75280. * Creates a new 3D button based on a mesh
  75281. * @param mesh mesh to become a 3D button
  75282. * @param name defines the control name
  75283. */
  75284. constructor(mesh: BABYLON.Mesh, name?: string);
  75285. protected _getTypeName(): string;
  75286. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75287. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75288. }
  75289. }
  75290. declare module BABYLON.GUI {
  75291. /**
  75292. * Class used to create a container panel deployed on the surface of a plane
  75293. */
  75294. export class PlanePanel extends VolumeBasedPanel {
  75295. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75296. }
  75297. }
  75298. declare module BABYLON.GUI {
  75299. /**
  75300. * Class used to create a container panel where items get randomized planar mapping
  75301. */
  75302. export class ScatterPanel extends VolumeBasedPanel {
  75303. private _iteration;
  75304. /**
  75305. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  75306. */
  75307. get iteration(): BABYLON.float;
  75308. set iteration(value: BABYLON.float);
  75309. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75310. private _scatterMapping;
  75311. protected _finalProcessing(): void;
  75312. }
  75313. }
  75314. declare module BABYLON.GUI {
  75315. /**
  75316. * Class used to create a container panel deployed on the surface of a sphere
  75317. */
  75318. export class SpherePanel extends VolumeBasedPanel {
  75319. private _radius;
  75320. /**
  75321. * Gets or sets the radius of the sphere where to project controls (5 by default)
  75322. */
  75323. get radius(): BABYLON.float;
  75324. set radius(value: BABYLON.float);
  75325. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75326. private _sphericalMapping;
  75327. }
  75328. }
  75329. declare module BABYLON.GUI {
  75330. /**
  75331. * Class used to create a stack panel in 3D on XY plane
  75332. */
  75333. export class StackPanel3D extends Container3D {
  75334. private _isVertical;
  75335. /**
  75336. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  75337. */
  75338. get isVertical(): boolean;
  75339. set isVertical(value: boolean);
  75340. /**
  75341. * Gets or sets the distance between elements
  75342. */
  75343. margin: number;
  75344. /**
  75345. * Creates new StackPanel
  75346. * @param isVertical
  75347. */
  75348. constructor(isVertical?: boolean);
  75349. protected _arrangeChildren(): void;
  75350. }
  75351. }
  75352. declare module BABYLON {
  75353. /**
  75354. * Configuration for glTF validation
  75355. */
  75356. export interface IGLTFValidationConfiguration {
  75357. /**
  75358. * The url of the glTF validator.
  75359. */
  75360. url: string;
  75361. }
  75362. /**
  75363. * glTF validation
  75364. */
  75365. export class GLTFValidation {
  75366. /**
  75367. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  75368. */
  75369. static Configuration: IGLTFValidationConfiguration;
  75370. private static _LoadScriptPromise;
  75371. /**
  75372. * Validate a glTF asset using the glTF-Validator.
  75373. * @param data The JSON of a glTF or the array buffer of a binary glTF
  75374. * @param rootUrl The root url for the glTF
  75375. * @param fileName The file name for the glTF
  75376. * @param getExternalResource The callback to get external resources for the glTF validator
  75377. * @returns A promise that resolves with the glTF validation results once complete
  75378. */
  75379. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  75380. }
  75381. }
  75382. declare module BABYLON {
  75383. /**
  75384. * Mode that determines the coordinate system to use.
  75385. */
  75386. export enum GLTFLoaderCoordinateSystemMode {
  75387. /**
  75388. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  75389. */
  75390. AUTO = 0,
  75391. /**
  75392. * Sets the useRightHandedSystem flag on the scene.
  75393. */
  75394. FORCE_RIGHT_HANDED = 1
  75395. }
  75396. /**
  75397. * Mode that determines what animations will start.
  75398. */
  75399. export enum GLTFLoaderAnimationStartMode {
  75400. /**
  75401. * No animation will start.
  75402. */
  75403. NONE = 0,
  75404. /**
  75405. * The first animation will start.
  75406. */
  75407. FIRST = 1,
  75408. /**
  75409. * All animations will start.
  75410. */
  75411. ALL = 2
  75412. }
  75413. /**
  75414. * Interface that contains the data for the glTF asset.
  75415. */
  75416. export interface IGLTFLoaderData {
  75417. /**
  75418. * The object that represents the glTF JSON.
  75419. */
  75420. json: Object;
  75421. /**
  75422. * The BIN chunk of a binary glTF.
  75423. */
  75424. bin: Nullable<IDataBuffer>;
  75425. }
  75426. /**
  75427. * Interface for extending the loader.
  75428. */
  75429. export interface IGLTFLoaderExtension {
  75430. /**
  75431. * The name of this extension.
  75432. */
  75433. readonly name: string;
  75434. /**
  75435. * Defines whether this extension is enabled.
  75436. */
  75437. enabled: boolean;
  75438. /**
  75439. * Defines the order of this extension.
  75440. * The loader sorts the extensions using these values when loading.
  75441. */
  75442. order?: number;
  75443. }
  75444. /**
  75445. * Loader state.
  75446. */
  75447. export enum GLTFLoaderState {
  75448. /**
  75449. * The asset is loading.
  75450. */
  75451. LOADING = 0,
  75452. /**
  75453. * The asset is ready for rendering.
  75454. */
  75455. READY = 1,
  75456. /**
  75457. * The asset is completely loaded.
  75458. */
  75459. COMPLETE = 2
  75460. }
  75461. /** @hidden */
  75462. export interface IImportMeshAsyncOutput {
  75463. meshes: AbstractMesh[];
  75464. particleSystems: IParticleSystem[];
  75465. skeletons: Skeleton[];
  75466. animationGroups: AnimationGroup[];
  75467. lights: Light[];
  75468. transformNodes: TransformNode[];
  75469. }
  75470. /** @hidden */
  75471. export interface IGLTFLoader extends IDisposable {
  75472. readonly state: Nullable<GLTFLoaderState>;
  75473. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75474. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75475. }
  75476. /**
  75477. * File loader for loading glTF files into a scene.
  75478. */
  75479. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75480. /** @hidden */
  75481. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75482. /** @hidden */
  75483. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75484. /**
  75485. * Raised when the asset has been parsed
  75486. */
  75487. onParsedObservable: Observable<IGLTFLoaderData>;
  75488. private _onParsedObserver;
  75489. /**
  75490. * Raised when the asset has been parsed
  75491. */
  75492. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75493. /**
  75494. * 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.
  75495. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75496. * Defaults to true.
  75497. * @hidden
  75498. */
  75499. static IncrementalLoading: boolean;
  75500. /**
  75501. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75502. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75503. * @hidden
  75504. */
  75505. static HomogeneousCoordinates: boolean;
  75506. /**
  75507. * The coordinate system mode. Defaults to AUTO.
  75508. */
  75509. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75510. /**
  75511. * The animation start mode. Defaults to FIRST.
  75512. */
  75513. animationStartMode: GLTFLoaderAnimationStartMode;
  75514. /**
  75515. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75516. */
  75517. compileMaterials: boolean;
  75518. /**
  75519. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75520. */
  75521. useClipPlane: boolean;
  75522. /**
  75523. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75524. */
  75525. compileShadowGenerators: boolean;
  75526. /**
  75527. * Defines if the Alpha blended materials are only applied as coverage.
  75528. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75529. * If true, no extra effects are applied to transparent pixels.
  75530. */
  75531. transparencyAsCoverage: boolean;
  75532. /**
  75533. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75534. * Enabling will disable offline support and glTF validator.
  75535. * Defaults to false.
  75536. */
  75537. useRangeRequests: boolean;
  75538. /**
  75539. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75540. */
  75541. createInstances: boolean;
  75542. /**
  75543. * Function called before loading a url referenced by the asset.
  75544. */
  75545. preprocessUrlAsync: (url: string) => Promise<string>;
  75546. /**
  75547. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75548. */
  75549. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75550. private _onMeshLoadedObserver;
  75551. /**
  75552. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75553. */
  75554. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75555. /**
  75556. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75557. */
  75558. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75559. private _onTextureLoadedObserver;
  75560. /**
  75561. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75562. */
  75563. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75564. /**
  75565. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75566. */
  75567. readonly onMaterialLoadedObservable: Observable<Material>;
  75568. private _onMaterialLoadedObserver;
  75569. /**
  75570. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75571. */
  75572. set onMaterialLoaded(callback: (material: Material) => void);
  75573. /**
  75574. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75575. */
  75576. readonly onCameraLoadedObservable: Observable<Camera>;
  75577. private _onCameraLoadedObserver;
  75578. /**
  75579. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75580. */
  75581. set onCameraLoaded(callback: (camera: Camera) => void);
  75582. /**
  75583. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75584. * For assets with LODs, raised when all of the LODs are complete.
  75585. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75586. */
  75587. readonly onCompleteObservable: Observable<void>;
  75588. private _onCompleteObserver;
  75589. /**
  75590. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75591. * For assets with LODs, raised when all of the LODs are complete.
  75592. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75593. */
  75594. set onComplete(callback: () => void);
  75595. /**
  75596. * Observable raised when an error occurs.
  75597. */
  75598. readonly onErrorObservable: Observable<any>;
  75599. private _onErrorObserver;
  75600. /**
  75601. * Callback raised when an error occurs.
  75602. */
  75603. set onError(callback: (reason: any) => void);
  75604. /**
  75605. * Observable raised after the loader is disposed.
  75606. */
  75607. readonly onDisposeObservable: Observable<void>;
  75608. private _onDisposeObserver;
  75609. /**
  75610. * Callback raised after the loader is disposed.
  75611. */
  75612. set onDispose(callback: () => void);
  75613. /**
  75614. * Observable raised after a loader extension is created.
  75615. * Set additional options for a loader extension in this event.
  75616. */
  75617. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75618. private _onExtensionLoadedObserver;
  75619. /**
  75620. * Callback raised after a loader extension is created.
  75621. */
  75622. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75623. /**
  75624. * Defines if the loader logging is enabled.
  75625. */
  75626. get loggingEnabled(): boolean;
  75627. set loggingEnabled(value: boolean);
  75628. /**
  75629. * Defines if the loader should capture performance counters.
  75630. */
  75631. get capturePerformanceCounters(): boolean;
  75632. set capturePerformanceCounters(value: boolean);
  75633. /**
  75634. * Defines if the loader should validate the asset.
  75635. */
  75636. validate: boolean;
  75637. /**
  75638. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75639. */
  75640. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75641. private _onValidatedObserver;
  75642. /**
  75643. * Callback raised after a loader extension is created.
  75644. */
  75645. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75646. private _loader;
  75647. /**
  75648. * Name of the loader ("gltf")
  75649. */
  75650. name: string;
  75651. /** @hidden */
  75652. extensions: ISceneLoaderPluginExtensions;
  75653. /**
  75654. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75655. */
  75656. dispose(): void;
  75657. /** @hidden */
  75658. _clear(): void;
  75659. /** @hidden */
  75660. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75661. /** @hidden */
  75662. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75663. /** @hidden */
  75664. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75665. meshes: AbstractMesh[];
  75666. particleSystems: IParticleSystem[];
  75667. skeletons: Skeleton[];
  75668. animationGroups: AnimationGroup[];
  75669. }>;
  75670. /** @hidden */
  75671. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75672. /** @hidden */
  75673. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75674. /** @hidden */
  75675. canDirectLoad(data: string): boolean;
  75676. /** @hidden */
  75677. directLoad(scene: Scene, data: string): any;
  75678. /**
  75679. * The callback that allows custom handling of the root url based on the response url.
  75680. * @param rootUrl the original root url
  75681. * @param responseURL the response url if available
  75682. * @returns the new root url
  75683. */
  75684. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75685. /** @hidden */
  75686. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75687. /**
  75688. * The loader state or null if the loader is not active.
  75689. */
  75690. get loaderState(): Nullable<GLTFLoaderState>;
  75691. /**
  75692. * Returns a promise that resolves when the asset is completely loaded.
  75693. * @returns a promise that resolves when the asset is completely loaded.
  75694. */
  75695. whenCompleteAsync(): Promise<void>;
  75696. private _validate;
  75697. private _getLoader;
  75698. private _parseJson;
  75699. private _unpackBinaryAsync;
  75700. private _unpackBinaryV1Async;
  75701. private _unpackBinaryV2Async;
  75702. private static _parseVersion;
  75703. private static _compareVersion;
  75704. private static readonly _logSpaces;
  75705. private _logIndentLevel;
  75706. private _loggingEnabled;
  75707. /** @hidden */
  75708. _log: (message: string) => void;
  75709. /** @hidden */
  75710. _logOpen(message: string): void;
  75711. /** @hidden */
  75712. _logClose(): void;
  75713. private _logEnabled;
  75714. private _logDisabled;
  75715. private _capturePerformanceCounters;
  75716. /** @hidden */
  75717. _startPerformanceCounter: (counterName: string) => void;
  75718. /** @hidden */
  75719. _endPerformanceCounter: (counterName: string) => void;
  75720. private _startPerformanceCounterEnabled;
  75721. private _startPerformanceCounterDisabled;
  75722. private _endPerformanceCounterEnabled;
  75723. private _endPerformanceCounterDisabled;
  75724. }
  75725. }
  75726. declare module BABYLON.GLTF1 {
  75727. /**
  75728. * Enums
  75729. * @hidden
  75730. */
  75731. export enum EComponentType {
  75732. BYTE = 5120,
  75733. UNSIGNED_BYTE = 5121,
  75734. SHORT = 5122,
  75735. UNSIGNED_SHORT = 5123,
  75736. FLOAT = 5126
  75737. }
  75738. /** @hidden */
  75739. export enum EShaderType {
  75740. FRAGMENT = 35632,
  75741. VERTEX = 35633
  75742. }
  75743. /** @hidden */
  75744. export enum EParameterType {
  75745. BYTE = 5120,
  75746. UNSIGNED_BYTE = 5121,
  75747. SHORT = 5122,
  75748. UNSIGNED_SHORT = 5123,
  75749. INT = 5124,
  75750. UNSIGNED_INT = 5125,
  75751. FLOAT = 5126,
  75752. FLOAT_VEC2 = 35664,
  75753. FLOAT_VEC3 = 35665,
  75754. FLOAT_VEC4 = 35666,
  75755. INT_VEC2 = 35667,
  75756. INT_VEC3 = 35668,
  75757. INT_VEC4 = 35669,
  75758. BOOL = 35670,
  75759. BOOL_VEC2 = 35671,
  75760. BOOL_VEC3 = 35672,
  75761. BOOL_VEC4 = 35673,
  75762. FLOAT_MAT2 = 35674,
  75763. FLOAT_MAT3 = 35675,
  75764. FLOAT_MAT4 = 35676,
  75765. SAMPLER_2D = 35678
  75766. }
  75767. /** @hidden */
  75768. export enum ETextureWrapMode {
  75769. CLAMP_TO_EDGE = 33071,
  75770. MIRRORED_REPEAT = 33648,
  75771. REPEAT = 10497
  75772. }
  75773. /** @hidden */
  75774. export enum ETextureFilterType {
  75775. NEAREST = 9728,
  75776. LINEAR = 9728,
  75777. NEAREST_MIPMAP_NEAREST = 9984,
  75778. LINEAR_MIPMAP_NEAREST = 9985,
  75779. NEAREST_MIPMAP_LINEAR = 9986,
  75780. LINEAR_MIPMAP_LINEAR = 9987
  75781. }
  75782. /** @hidden */
  75783. export enum ETextureFormat {
  75784. ALPHA = 6406,
  75785. RGB = 6407,
  75786. RGBA = 6408,
  75787. LUMINANCE = 6409,
  75788. LUMINANCE_ALPHA = 6410
  75789. }
  75790. /** @hidden */
  75791. export enum ECullingType {
  75792. FRONT = 1028,
  75793. BACK = 1029,
  75794. FRONT_AND_BACK = 1032
  75795. }
  75796. /** @hidden */
  75797. export enum EBlendingFunction {
  75798. ZERO = 0,
  75799. ONE = 1,
  75800. SRC_COLOR = 768,
  75801. ONE_MINUS_SRC_COLOR = 769,
  75802. DST_COLOR = 774,
  75803. ONE_MINUS_DST_COLOR = 775,
  75804. SRC_ALPHA = 770,
  75805. ONE_MINUS_SRC_ALPHA = 771,
  75806. DST_ALPHA = 772,
  75807. ONE_MINUS_DST_ALPHA = 773,
  75808. CONSTANT_COLOR = 32769,
  75809. ONE_MINUS_CONSTANT_COLOR = 32770,
  75810. CONSTANT_ALPHA = 32771,
  75811. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75812. SRC_ALPHA_SATURATE = 776
  75813. }
  75814. /** @hidden */
  75815. export interface IGLTFProperty {
  75816. extensions?: {
  75817. [key: string]: any;
  75818. };
  75819. extras?: Object;
  75820. }
  75821. /** @hidden */
  75822. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75823. name?: string;
  75824. }
  75825. /** @hidden */
  75826. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75827. bufferView: string;
  75828. byteOffset: number;
  75829. byteStride: number;
  75830. count: number;
  75831. type: string;
  75832. componentType: EComponentType;
  75833. max?: number[];
  75834. min?: number[];
  75835. name?: string;
  75836. }
  75837. /** @hidden */
  75838. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75839. buffer: string;
  75840. byteOffset: number;
  75841. byteLength: number;
  75842. byteStride: number;
  75843. target?: number;
  75844. }
  75845. /** @hidden */
  75846. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75847. uri: string;
  75848. byteLength?: number;
  75849. type?: string;
  75850. }
  75851. /** @hidden */
  75852. export interface IGLTFShader extends IGLTFChildRootProperty {
  75853. uri: string;
  75854. type: EShaderType;
  75855. }
  75856. /** @hidden */
  75857. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75858. attributes: string[];
  75859. fragmentShader: string;
  75860. vertexShader: string;
  75861. }
  75862. /** @hidden */
  75863. export interface IGLTFTechniqueParameter {
  75864. type: number;
  75865. count?: number;
  75866. semantic?: string;
  75867. node?: string;
  75868. value?: number | boolean | string | Array<any>;
  75869. source?: string;
  75870. babylonValue?: any;
  75871. }
  75872. /** @hidden */
  75873. export interface IGLTFTechniqueCommonProfile {
  75874. lightingModel: string;
  75875. texcoordBindings: Object;
  75876. parameters?: Array<any>;
  75877. }
  75878. /** @hidden */
  75879. export interface IGLTFTechniqueStatesFunctions {
  75880. blendColor?: number[];
  75881. blendEquationSeparate?: number[];
  75882. blendFuncSeparate?: number[];
  75883. colorMask: boolean[];
  75884. cullFace: number[];
  75885. }
  75886. /** @hidden */
  75887. export interface IGLTFTechniqueStates {
  75888. enable: number[];
  75889. functions: IGLTFTechniqueStatesFunctions;
  75890. }
  75891. /** @hidden */
  75892. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75893. parameters: {
  75894. [key: string]: IGLTFTechniqueParameter;
  75895. };
  75896. program: string;
  75897. attributes: {
  75898. [key: string]: string;
  75899. };
  75900. uniforms: {
  75901. [key: string]: string;
  75902. };
  75903. states: IGLTFTechniqueStates;
  75904. }
  75905. /** @hidden */
  75906. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75907. technique?: string;
  75908. values: string[];
  75909. }
  75910. /** @hidden */
  75911. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75912. attributes: {
  75913. [key: string]: string;
  75914. };
  75915. indices: string;
  75916. material: string;
  75917. mode?: number;
  75918. }
  75919. /** @hidden */
  75920. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75921. primitives: IGLTFMeshPrimitive[];
  75922. }
  75923. /** @hidden */
  75924. export interface IGLTFImage extends IGLTFChildRootProperty {
  75925. uri: string;
  75926. }
  75927. /** @hidden */
  75928. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75929. magFilter?: number;
  75930. minFilter?: number;
  75931. wrapS?: number;
  75932. wrapT?: number;
  75933. }
  75934. /** @hidden */
  75935. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75936. sampler: string;
  75937. source: string;
  75938. format?: ETextureFormat;
  75939. internalFormat?: ETextureFormat;
  75940. target?: number;
  75941. type?: number;
  75942. babylonTexture?: Texture;
  75943. }
  75944. /** @hidden */
  75945. export interface IGLTFAmbienLight {
  75946. color?: number[];
  75947. }
  75948. /** @hidden */
  75949. export interface IGLTFDirectionalLight {
  75950. color?: number[];
  75951. }
  75952. /** @hidden */
  75953. export interface IGLTFPointLight {
  75954. color?: number[];
  75955. constantAttenuation?: number;
  75956. linearAttenuation?: number;
  75957. quadraticAttenuation?: number;
  75958. }
  75959. /** @hidden */
  75960. export interface IGLTFSpotLight {
  75961. color?: number[];
  75962. constantAttenuation?: number;
  75963. fallOfAngle?: number;
  75964. fallOffExponent?: number;
  75965. linearAttenuation?: number;
  75966. quadraticAttenuation?: number;
  75967. }
  75968. /** @hidden */
  75969. export interface IGLTFLight extends IGLTFChildRootProperty {
  75970. type: string;
  75971. }
  75972. /** @hidden */
  75973. export interface IGLTFCameraOrthographic {
  75974. xmag: number;
  75975. ymag: number;
  75976. zfar: number;
  75977. znear: number;
  75978. }
  75979. /** @hidden */
  75980. export interface IGLTFCameraPerspective {
  75981. aspectRatio: number;
  75982. yfov: number;
  75983. zfar: number;
  75984. znear: number;
  75985. }
  75986. /** @hidden */
  75987. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75988. type: string;
  75989. }
  75990. /** @hidden */
  75991. export interface IGLTFAnimationChannelTarget {
  75992. id: string;
  75993. path: string;
  75994. }
  75995. /** @hidden */
  75996. export interface IGLTFAnimationChannel {
  75997. sampler: string;
  75998. target: IGLTFAnimationChannelTarget;
  75999. }
  76000. /** @hidden */
  76001. export interface IGLTFAnimationSampler {
  76002. input: string;
  76003. output: string;
  76004. interpolation?: string;
  76005. }
  76006. /** @hidden */
  76007. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  76008. channels?: IGLTFAnimationChannel[];
  76009. parameters?: {
  76010. [key: string]: string;
  76011. };
  76012. samplers?: {
  76013. [key: string]: IGLTFAnimationSampler;
  76014. };
  76015. }
  76016. /** @hidden */
  76017. export interface IGLTFNodeInstanceSkin {
  76018. skeletons: string[];
  76019. skin: string;
  76020. meshes: string[];
  76021. }
  76022. /** @hidden */
  76023. export interface IGLTFSkins extends IGLTFChildRootProperty {
  76024. bindShapeMatrix: number[];
  76025. inverseBindMatrices: string;
  76026. jointNames: string[];
  76027. babylonSkeleton?: Skeleton;
  76028. }
  76029. /** @hidden */
  76030. export interface IGLTFNode extends IGLTFChildRootProperty {
  76031. camera?: string;
  76032. children: string[];
  76033. skin?: string;
  76034. jointName?: string;
  76035. light?: string;
  76036. matrix: number[];
  76037. mesh?: string;
  76038. meshes?: string[];
  76039. rotation?: number[];
  76040. scale?: number[];
  76041. translation?: number[];
  76042. babylonNode?: Node;
  76043. }
  76044. /** @hidden */
  76045. export interface IGLTFScene extends IGLTFChildRootProperty {
  76046. nodes: string[];
  76047. }
  76048. /** @hidden */
  76049. export interface IGLTFRuntime {
  76050. extensions: {
  76051. [key: string]: any;
  76052. };
  76053. accessors: {
  76054. [key: string]: IGLTFAccessor;
  76055. };
  76056. buffers: {
  76057. [key: string]: IGLTFBuffer;
  76058. };
  76059. bufferViews: {
  76060. [key: string]: IGLTFBufferView;
  76061. };
  76062. meshes: {
  76063. [key: string]: IGLTFMesh;
  76064. };
  76065. lights: {
  76066. [key: string]: IGLTFLight;
  76067. };
  76068. cameras: {
  76069. [key: string]: IGLTFCamera;
  76070. };
  76071. nodes: {
  76072. [key: string]: IGLTFNode;
  76073. };
  76074. images: {
  76075. [key: string]: IGLTFImage;
  76076. };
  76077. textures: {
  76078. [key: string]: IGLTFTexture;
  76079. };
  76080. shaders: {
  76081. [key: string]: IGLTFShader;
  76082. };
  76083. programs: {
  76084. [key: string]: IGLTFProgram;
  76085. };
  76086. samplers: {
  76087. [key: string]: IGLTFSampler;
  76088. };
  76089. techniques: {
  76090. [key: string]: IGLTFTechnique;
  76091. };
  76092. materials: {
  76093. [key: string]: IGLTFMaterial;
  76094. };
  76095. animations: {
  76096. [key: string]: IGLTFAnimation;
  76097. };
  76098. skins: {
  76099. [key: string]: IGLTFSkins;
  76100. };
  76101. currentScene?: Object;
  76102. scenes: {
  76103. [key: string]: IGLTFScene;
  76104. };
  76105. extensionsUsed: string[];
  76106. extensionsRequired?: string[];
  76107. buffersCount: number;
  76108. shaderscount: number;
  76109. scene: Scene;
  76110. rootUrl: string;
  76111. loadedBufferCount: number;
  76112. loadedBufferViews: {
  76113. [name: string]: ArrayBufferView;
  76114. };
  76115. loadedShaderCount: number;
  76116. importOnlyMeshes: boolean;
  76117. importMeshesNames?: string[];
  76118. dummyNodes: Node[];
  76119. forAssetContainer: boolean;
  76120. }
  76121. /** @hidden */
  76122. export interface INodeToRoot {
  76123. bone: Bone;
  76124. node: IGLTFNode;
  76125. id: string;
  76126. }
  76127. /** @hidden */
  76128. export interface IJointNode {
  76129. node: IGLTFNode;
  76130. id: string;
  76131. }
  76132. }
  76133. declare module BABYLON.GLTF1 {
  76134. /**
  76135. * Utils functions for GLTF
  76136. * @hidden
  76137. */
  76138. export class GLTFUtils {
  76139. /**
  76140. * Sets the given "parameter" matrix
  76141. * @param scene: the Scene object
  76142. * @param source: the source node where to pick the matrix
  76143. * @param parameter: the GLTF technique parameter
  76144. * @param uniformName: the name of the shader's uniform
  76145. * @param shaderMaterial: the shader material
  76146. */
  76147. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  76148. /**
  76149. * Sets the given "parameter" matrix
  76150. * @param shaderMaterial: the shader material
  76151. * @param uniform: the name of the shader's uniform
  76152. * @param value: the value of the uniform
  76153. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  76154. */
  76155. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  76156. /**
  76157. * Returns the wrap mode of the texture
  76158. * @param mode: the mode value
  76159. */
  76160. static GetWrapMode(mode: number): number;
  76161. /**
  76162. * Returns the byte stride giving an accessor
  76163. * @param accessor: the GLTF accessor objet
  76164. */
  76165. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  76166. /**
  76167. * Returns the texture filter mode giving a mode value
  76168. * @param mode: the filter mode value
  76169. */
  76170. static GetTextureFilterMode(mode: number): ETextureFilterType;
  76171. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  76172. /**
  76173. * Returns a buffer from its accessor
  76174. * @param gltfRuntime: the GLTF runtime
  76175. * @param accessor: the GLTF accessor
  76176. */
  76177. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  76178. /**
  76179. * Decodes a buffer view into a string
  76180. * @param view: the buffer view
  76181. */
  76182. static DecodeBufferToText(view: ArrayBufferView): string;
  76183. /**
  76184. * Returns the default material of gltf. Related to
  76185. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  76186. * @param scene: the Babylon.js scene
  76187. */
  76188. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  76189. private static _DefaultMaterial;
  76190. }
  76191. }
  76192. declare module BABYLON.GLTF1 {
  76193. /**
  76194. * Implementation of the base glTF spec
  76195. * @hidden
  76196. */
  76197. export class GLTFLoaderBase {
  76198. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  76199. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76200. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  76201. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76202. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  76203. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76204. }
  76205. /**
  76206. * glTF V1 Loader
  76207. * @hidden
  76208. */
  76209. export class GLTFLoader implements IGLTFLoader {
  76210. static Extensions: {
  76211. [name: string]: GLTFLoaderExtension;
  76212. };
  76213. static RegisterExtension(extension: GLTFLoaderExtension): void;
  76214. state: Nullable<GLTFLoaderState>;
  76215. dispose(): void;
  76216. private _importMeshAsync;
  76217. /**
  76218. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  76219. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76220. * @param scene the scene the meshes should be added to
  76221. * @param forAssetContainer defines if the entities must be stored in the scene
  76222. * @param data gltf data containing information of the meshes in a loaded file
  76223. * @param rootUrl root url to load from
  76224. * @param onProgress event that fires when loading progress has occured
  76225. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76226. */
  76227. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  76228. private _loadAsync;
  76229. /**
  76230. * Imports all objects from a loaded gltf file and adds them to the scene
  76231. * @param scene the scene the objects should be added to
  76232. * @param data gltf data containing information of the meshes in a loaded file
  76233. * @param rootUrl root url to load from
  76234. * @param onProgress event that fires when loading progress has occured
  76235. * @returns a promise which completes when objects have been loaded to the scene
  76236. */
  76237. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  76238. private _loadShadersAsync;
  76239. private _loadBuffersAsync;
  76240. private _createNodes;
  76241. }
  76242. /** @hidden */
  76243. export abstract class GLTFLoaderExtension {
  76244. private _name;
  76245. constructor(name: string);
  76246. get name(): string;
  76247. /**
  76248. * Defines an override for loading the runtime
  76249. * Return true to stop further extensions from loading the runtime
  76250. */
  76251. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  76252. /**
  76253. * Defines an onverride for creating gltf runtime
  76254. * Return true to stop further extensions from creating the runtime
  76255. */
  76256. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  76257. /**
  76258. * Defines an override for loading buffers
  76259. * Return true to stop further extensions from loading this buffer
  76260. */
  76261. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  76262. /**
  76263. * Defines an override for loading texture buffers
  76264. * Return true to stop further extensions from loading this texture data
  76265. */
  76266. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76267. /**
  76268. * Defines an override for creating textures
  76269. * Return true to stop further extensions from loading this texture
  76270. */
  76271. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  76272. /**
  76273. * Defines an override for loading shader strings
  76274. * Return true to stop further extensions from loading this shader data
  76275. */
  76276. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76277. /**
  76278. * Defines an override for loading materials
  76279. * Return true to stop further extensions from loading this material
  76280. */
  76281. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76282. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  76283. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  76284. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76285. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76286. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  76287. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76288. private static LoadTextureBufferAsync;
  76289. private static CreateTextureAsync;
  76290. private static ApplyExtensions;
  76291. }
  76292. }
  76293. declare module BABYLON.GLTF1 {
  76294. /** @hidden */
  76295. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  76296. private _bin;
  76297. constructor();
  76298. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  76299. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76300. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76301. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76302. }
  76303. }
  76304. declare module BABYLON.GLTF1 {
  76305. /** @hidden */
  76306. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  76307. constructor();
  76308. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  76309. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76310. private _loadTexture;
  76311. }
  76312. }
  76313. declare module BABYLON.GLTF2.Loader {
  76314. /**
  76315. * Loader interface with an index field.
  76316. */
  76317. export interface IArrayItem {
  76318. /**
  76319. * The index of this item in the array.
  76320. */
  76321. index: number;
  76322. }
  76323. /**
  76324. * Loader interface with additional members.
  76325. */
  76326. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  76327. /** @hidden */
  76328. _data?: Promise<ArrayBufferView>;
  76329. /** @hidden */
  76330. _babylonVertexBuffer?: Promise<VertexBuffer>;
  76331. }
  76332. /**
  76333. * Loader interface with additional members.
  76334. */
  76335. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  76336. }
  76337. /** @hidden */
  76338. export interface _IAnimationSamplerData {
  76339. input: Float32Array;
  76340. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  76341. output: Float32Array;
  76342. }
  76343. /**
  76344. * Loader interface with additional members.
  76345. */
  76346. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  76347. /** @hidden */
  76348. _data?: Promise<_IAnimationSamplerData>;
  76349. }
  76350. /**
  76351. * Loader interface with additional members.
  76352. */
  76353. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  76354. channels: IAnimationChannel[];
  76355. samplers: IAnimationSampler[];
  76356. /** @hidden */
  76357. _babylonAnimationGroup?: AnimationGroup;
  76358. }
  76359. /**
  76360. * Loader interface with additional members.
  76361. */
  76362. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  76363. /** @hidden */
  76364. _data?: Promise<ArrayBufferView>;
  76365. }
  76366. /**
  76367. * Loader interface with additional members.
  76368. */
  76369. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  76370. /** @hidden */
  76371. _data?: Promise<ArrayBufferView>;
  76372. /** @hidden */
  76373. _babylonBuffer?: Promise<Buffer>;
  76374. }
  76375. /**
  76376. * Loader interface with additional members.
  76377. */
  76378. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  76379. }
  76380. /**
  76381. * Loader interface with additional members.
  76382. */
  76383. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  76384. /** @hidden */
  76385. _data?: Promise<ArrayBufferView>;
  76386. }
  76387. /**
  76388. * Loader interface with additional members.
  76389. */
  76390. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  76391. }
  76392. /**
  76393. * Loader interface with additional members.
  76394. */
  76395. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  76396. }
  76397. /**
  76398. * Loader interface with additional members.
  76399. */
  76400. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  76401. baseColorTexture?: ITextureInfo;
  76402. metallicRoughnessTexture?: ITextureInfo;
  76403. }
  76404. /**
  76405. * Loader interface with additional members.
  76406. */
  76407. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  76408. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76409. normalTexture?: IMaterialNormalTextureInfo;
  76410. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76411. emissiveTexture?: ITextureInfo;
  76412. /** @hidden */
  76413. _data?: {
  76414. [babylonDrawMode: number]: {
  76415. babylonMaterial: Material;
  76416. babylonMeshes: AbstractMesh[];
  76417. promise: Promise<void>;
  76418. };
  76419. };
  76420. }
  76421. /**
  76422. * Loader interface with additional members.
  76423. */
  76424. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  76425. primitives: IMeshPrimitive[];
  76426. }
  76427. /**
  76428. * Loader interface with additional members.
  76429. */
  76430. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  76431. /** @hidden */
  76432. _instanceData?: {
  76433. babylonSourceMesh: Mesh;
  76434. promise: Promise<any>;
  76435. };
  76436. }
  76437. /**
  76438. * Loader interface with additional members.
  76439. */
  76440. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76441. /**
  76442. * The parent glTF node.
  76443. */
  76444. parent?: INode;
  76445. /** @hidden */
  76446. _babylonTransformNode?: TransformNode;
  76447. /** @hidden */
  76448. _primitiveBabylonMeshes?: AbstractMesh[];
  76449. /** @hidden */
  76450. _babylonBones?: Bone[];
  76451. /** @hidden */
  76452. _numMorphTargets?: number;
  76453. }
  76454. /** @hidden */
  76455. export interface _ISamplerData {
  76456. noMipMaps: boolean;
  76457. samplingMode: number;
  76458. wrapU: number;
  76459. wrapV: number;
  76460. }
  76461. /**
  76462. * Loader interface with additional members.
  76463. */
  76464. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76465. /** @hidden */
  76466. _data?: _ISamplerData;
  76467. }
  76468. /**
  76469. * Loader interface with additional members.
  76470. */
  76471. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76472. }
  76473. /**
  76474. * Loader interface with additional members.
  76475. */
  76476. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76477. /** @hidden */
  76478. _data?: {
  76479. babylonSkeleton: Skeleton;
  76480. promise: Promise<void>;
  76481. };
  76482. }
  76483. /**
  76484. * Loader interface with additional members.
  76485. */
  76486. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76487. }
  76488. /**
  76489. * Loader interface with additional members.
  76490. */
  76491. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76492. }
  76493. /**
  76494. * Loader interface with additional members.
  76495. */
  76496. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76497. accessors?: IAccessor[];
  76498. animations?: IAnimation[];
  76499. buffers?: IBuffer[];
  76500. bufferViews?: IBufferView[];
  76501. cameras?: ICamera[];
  76502. images?: IImage[];
  76503. materials?: IMaterial[];
  76504. meshes?: IMesh[];
  76505. nodes?: INode[];
  76506. samplers?: ISampler[];
  76507. scenes?: IScene[];
  76508. skins?: ISkin[];
  76509. textures?: ITexture[];
  76510. }
  76511. }
  76512. declare module BABYLON.GLTF2 {
  76513. /**
  76514. * Interface for a glTF loader extension.
  76515. */
  76516. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76517. /**
  76518. * Called after the loader state changes to LOADING.
  76519. */
  76520. onLoading?(): void;
  76521. /**
  76522. * Called after the loader state changes to READY.
  76523. */
  76524. onReady?(): void;
  76525. /**
  76526. * Define this method to modify the default behavior when loading scenes.
  76527. * @param context The context when loading the asset
  76528. * @param scene The glTF scene property
  76529. * @returns A promise that resolves when the load is complete or null if not handled
  76530. */
  76531. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76532. /**
  76533. * Define this method to modify the default behavior when loading nodes.
  76534. * @param context The context when loading the asset
  76535. * @param node The glTF node property
  76536. * @param assign A function called synchronously after parsing the glTF properties
  76537. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76538. */
  76539. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76540. /**
  76541. * Define this method to modify the default behavior when loading cameras.
  76542. * @param context The context when loading the asset
  76543. * @param camera The glTF camera property
  76544. * @param assign A function called synchronously after parsing the glTF properties
  76545. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76546. */
  76547. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76548. /**
  76549. * @hidden
  76550. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76551. * @param context The context when loading the asset
  76552. * @param primitive The glTF mesh primitive property
  76553. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76554. */
  76555. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76556. /**
  76557. * @hidden
  76558. * Define this method to modify the default behavior when loading data for mesh primitives.
  76559. * @param context The context when loading the asset
  76560. * @param name The mesh name when loading the asset
  76561. * @param node The glTF node when loading the asset
  76562. * @param mesh The glTF mesh when loading the asset
  76563. * @param primitive The glTF mesh primitive property
  76564. * @param assign A function called synchronously after parsing the glTF properties
  76565. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76566. */
  76567. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76568. /**
  76569. * @hidden
  76570. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76571. * @param context The context when loading the asset
  76572. * @param material The glTF material property
  76573. * @param assign A function called synchronously after parsing the glTF properties
  76574. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76575. */
  76576. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76577. /**
  76578. * Define this method to modify the default behavior when creating materials.
  76579. * @param context The context when loading the asset
  76580. * @param material The glTF material property
  76581. * @param babylonDrawMode The draw mode for the Babylon material
  76582. * @returns The Babylon material or null if not handled
  76583. */
  76584. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76585. /**
  76586. * Define this method to modify the default behavior when loading material properties.
  76587. * @param context The context when loading the asset
  76588. * @param material The glTF material property
  76589. * @param babylonMaterial The Babylon material
  76590. * @returns A promise that resolves when the load is complete or null if not handled
  76591. */
  76592. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76593. /**
  76594. * Define this method to modify the default behavior when loading texture infos.
  76595. * @param context The context when loading the asset
  76596. * @param textureInfo The glTF texture info property
  76597. * @param assign A function called synchronously after parsing the glTF properties
  76598. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76599. */
  76600. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76601. /**
  76602. * @hidden
  76603. * Define this method to modify the default behavior when loading textures.
  76604. * @param context The context when loading the asset
  76605. * @param texture The glTF texture property
  76606. * @param assign A function called synchronously after parsing the glTF properties
  76607. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76608. */
  76609. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76610. /**
  76611. * Define this method to modify the default behavior when loading animations.
  76612. * @param context The context when loading the asset
  76613. * @param animation The glTF animation property
  76614. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76615. */
  76616. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76617. /**
  76618. * @hidden
  76619. * Define this method to modify the default behavior when loading skins.
  76620. * @param context The context when loading the asset
  76621. * @param node The glTF node property
  76622. * @param skin The glTF skin property
  76623. * @returns A promise that resolves when the load is complete or null if not handled
  76624. */
  76625. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76626. /**
  76627. * @hidden
  76628. * Define this method to modify the default behavior when loading uris.
  76629. * @param context The context when loading the asset
  76630. * @param property The glTF property associated with the uri
  76631. * @param uri The uri to load
  76632. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76633. */
  76634. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76635. /**
  76636. * Define this method to modify the default behavior when loading buffer views.
  76637. * @param context The context when loading the asset
  76638. * @param bufferView The glTF buffer view property
  76639. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76640. */
  76641. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76642. /**
  76643. * Define this method to modify the default behavior when loading buffers.
  76644. * @param context The context when loading the asset
  76645. * @param buffer The glTF buffer property
  76646. * @param byteOffset The byte offset to load
  76647. * @param byteLength The byte length to load
  76648. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76649. */
  76650. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76651. }
  76652. }
  76653. declare module BABYLON.GLTF2 {
  76654. /**
  76655. * Helper class for working with arrays when loading the glTF asset
  76656. */
  76657. export class ArrayItem {
  76658. /**
  76659. * Gets an item from the given array.
  76660. * @param context The context when loading the asset
  76661. * @param array The array to get the item from
  76662. * @param index The index to the array
  76663. * @returns The array item
  76664. */
  76665. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76666. /**
  76667. * Assign an `index` field to each item of the given array.
  76668. * @param array The array of items
  76669. */
  76670. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76671. }
  76672. /**
  76673. * The glTF 2.0 loader
  76674. */
  76675. export class GLTFLoader implements IGLTFLoader {
  76676. /** @hidden */
  76677. _completePromises: Promise<any>[];
  76678. /** @hidden */
  76679. _forAssetContainer: boolean;
  76680. /** Storage */
  76681. _babylonLights: Light[];
  76682. private _disposed;
  76683. private _parent;
  76684. private _state;
  76685. private _extensions;
  76686. private _rootUrl;
  76687. private _fileName;
  76688. private _uniqueRootUrl;
  76689. private _gltf;
  76690. private _bin;
  76691. private _babylonScene;
  76692. private _rootBabylonMesh;
  76693. private _defaultBabylonMaterialData;
  76694. private _progressCallback?;
  76695. private _requests;
  76696. private static _RegisteredExtensions;
  76697. /**
  76698. * The default glTF sampler.
  76699. */
  76700. static readonly DefaultSampler: ISampler;
  76701. /**
  76702. * Registers a loader extension.
  76703. * @param name The name of the loader extension.
  76704. * @param factory The factory function that creates the loader extension.
  76705. */
  76706. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76707. /**
  76708. * Unregisters a loader extension.
  76709. * @param name The name of the loader extension.
  76710. * @returns A boolean indicating whether the extension has been unregistered
  76711. */
  76712. static UnregisterExtension(name: string): boolean;
  76713. /**
  76714. * The loader state.
  76715. */
  76716. get state(): Nullable<GLTFLoaderState>;
  76717. /**
  76718. * The object that represents the glTF JSON.
  76719. */
  76720. get gltf(): IGLTF;
  76721. /**
  76722. * The BIN chunk of a binary glTF.
  76723. */
  76724. get bin(): Nullable<IDataBuffer>;
  76725. /**
  76726. * The parent file loader.
  76727. */
  76728. get parent(): GLTFFileLoader;
  76729. /**
  76730. * The Babylon scene when loading the asset.
  76731. */
  76732. get babylonScene(): Scene;
  76733. /**
  76734. * The root Babylon mesh when loading the asset.
  76735. */
  76736. get rootBabylonMesh(): Mesh;
  76737. /** @hidden */
  76738. constructor(parent: GLTFFileLoader);
  76739. /** @hidden */
  76740. dispose(): void;
  76741. /** @hidden */
  76742. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76743. /** @hidden */
  76744. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76745. private _loadAsync;
  76746. private _loadData;
  76747. private _setupData;
  76748. private _loadExtensions;
  76749. private _checkExtensions;
  76750. private _setState;
  76751. private _createRootNode;
  76752. /**
  76753. * Loads a glTF scene.
  76754. * @param context The context when loading the asset
  76755. * @param scene The glTF scene property
  76756. * @returns A promise that resolves when the load is complete
  76757. */
  76758. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76759. private _forEachPrimitive;
  76760. private _getMeshes;
  76761. private _getTransformNodes;
  76762. private _getSkeletons;
  76763. private _getAnimationGroups;
  76764. private _startAnimations;
  76765. /**
  76766. * Loads a glTF node.
  76767. * @param context The context when loading the asset
  76768. * @param node The glTF node property
  76769. * @param assign A function called synchronously after parsing the glTF properties
  76770. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76771. */
  76772. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76773. private _loadMeshAsync;
  76774. /**
  76775. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76776. * @param context The context when loading the asset
  76777. * @param name The mesh name when loading the asset
  76778. * @param node The glTF node when loading the asset
  76779. * @param mesh The glTF mesh when loading the asset
  76780. * @param primitive The glTF mesh primitive property
  76781. * @param assign A function called synchronously after parsing the glTF properties
  76782. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76783. */
  76784. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76785. private _loadVertexDataAsync;
  76786. private _createMorphTargets;
  76787. private _loadMorphTargetsAsync;
  76788. private _loadMorphTargetVertexDataAsync;
  76789. private static _LoadTransform;
  76790. private _loadSkinAsync;
  76791. private _loadBones;
  76792. private _loadBone;
  76793. private _loadSkinInverseBindMatricesDataAsync;
  76794. private _updateBoneMatrices;
  76795. private _getNodeMatrix;
  76796. /**
  76797. * Loads a glTF camera.
  76798. * @param context The context when loading the asset
  76799. * @param camera The glTF camera property
  76800. * @param assign A function called synchronously after parsing the glTF properties
  76801. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76802. */
  76803. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76804. private _loadAnimationsAsync;
  76805. /**
  76806. * Loads a glTF animation.
  76807. * @param context The context when loading the asset
  76808. * @param animation The glTF animation property
  76809. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76810. */
  76811. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76812. /**
  76813. * @hidden Loads a glTF animation channel.
  76814. * @param context The context when loading the asset
  76815. * @param animationContext The context of the animation when loading the asset
  76816. * @param animation The glTF animation property
  76817. * @param channel The glTF animation channel property
  76818. * @param babylonAnimationGroup The babylon animation group property
  76819. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76820. * @returns A void promise when the channel load is complete
  76821. */
  76822. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76823. private _loadAnimationSamplerAsync;
  76824. private _loadBufferAsync;
  76825. /**
  76826. * Loads a glTF buffer view.
  76827. * @param context The context when loading the asset
  76828. * @param bufferView The glTF buffer view property
  76829. * @returns A promise that resolves with the loaded data when the load is complete
  76830. */
  76831. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76832. private _loadAccessorAsync;
  76833. /** @hidden */
  76834. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76835. private _loadIndicesAccessorAsync;
  76836. private _loadVertexBufferViewAsync;
  76837. private _loadVertexAccessorAsync;
  76838. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76839. /** @hidden */
  76840. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76841. private _createDefaultMaterial;
  76842. /**
  76843. * Creates a Babylon material from a glTF material.
  76844. * @param context The context when loading the asset
  76845. * @param material The glTF material property
  76846. * @param babylonDrawMode The draw mode for the Babylon material
  76847. * @returns The Babylon material
  76848. */
  76849. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76850. /**
  76851. * Loads properties from a glTF material into a Babylon material.
  76852. * @param context The context when loading the asset
  76853. * @param material The glTF material property
  76854. * @param babylonMaterial The Babylon material
  76855. * @returns A promise that resolves when the load is complete
  76856. */
  76857. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76858. /**
  76859. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76860. * @param context The context when loading the asset
  76861. * @param material The glTF material property
  76862. * @param babylonMaterial The Babylon material
  76863. * @returns A promise that resolves when the load is complete
  76864. */
  76865. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76866. /**
  76867. * Loads the alpha properties from a glTF material into a Babylon material.
  76868. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76869. * @param context The context when loading the asset
  76870. * @param material The glTF material property
  76871. * @param babylonMaterial The Babylon material
  76872. */
  76873. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76874. /**
  76875. * Loads a glTF texture info.
  76876. * @param context The context when loading the asset
  76877. * @param textureInfo The glTF texture info property
  76878. * @param assign A function called synchronously after parsing the glTF properties
  76879. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76880. */
  76881. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76882. /** @hidden */
  76883. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76884. /** @hidden */
  76885. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76886. private _loadSampler;
  76887. /**
  76888. * Loads a glTF image.
  76889. * @param context The context when loading the asset
  76890. * @param image The glTF image property
  76891. * @returns A promise that resolves with the loaded data when the load is complete
  76892. */
  76893. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76894. /**
  76895. * Loads a glTF uri.
  76896. * @param context The context when loading the asset
  76897. * @param property The glTF property associated with the uri
  76898. * @param uri The base64 or relative uri
  76899. * @returns A promise that resolves with the loaded data when the load is complete
  76900. */
  76901. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76902. private _onProgress;
  76903. /**
  76904. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76905. * @param babylonObject the Babylon object with metadata
  76906. * @param pointer the JSON pointer
  76907. */
  76908. static AddPointerMetadata(babylonObject: {
  76909. metadata: any;
  76910. }, pointer: string): void;
  76911. private static _GetTextureWrapMode;
  76912. private static _GetTextureSamplingMode;
  76913. private static _GetTypedArrayConstructor;
  76914. private static _GetTypedArray;
  76915. private static _GetNumComponents;
  76916. private static _ValidateUri;
  76917. private static _GetDrawMode;
  76918. private _compileMaterialsAsync;
  76919. private _compileShadowGeneratorsAsync;
  76920. private _forEachExtensions;
  76921. private _applyExtensions;
  76922. private _extensionsOnLoading;
  76923. private _extensionsOnReady;
  76924. private _extensionsLoadSceneAsync;
  76925. private _extensionsLoadNodeAsync;
  76926. private _extensionsLoadCameraAsync;
  76927. private _extensionsLoadVertexDataAsync;
  76928. private _extensionsLoadMeshPrimitiveAsync;
  76929. private _extensionsLoadMaterialAsync;
  76930. private _extensionsCreateMaterial;
  76931. private _extensionsLoadMaterialPropertiesAsync;
  76932. private _extensionsLoadTextureInfoAsync;
  76933. private _extensionsLoadTextureAsync;
  76934. private _extensionsLoadAnimationAsync;
  76935. private _extensionsLoadSkinAsync;
  76936. private _extensionsLoadUriAsync;
  76937. private _extensionsLoadBufferViewAsync;
  76938. private _extensionsLoadBufferAsync;
  76939. /**
  76940. * Helper method called by a loader extension to load an glTF extension.
  76941. * @param context The context when loading the asset
  76942. * @param property The glTF property to load the extension from
  76943. * @param extensionName The name of the extension to load
  76944. * @param actionAsync The action to run
  76945. * @returns The promise returned by actionAsync or null if the extension does not exist
  76946. */
  76947. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76948. /**
  76949. * Helper method called by a loader extension to load a glTF extra.
  76950. * @param context The context when loading the asset
  76951. * @param property The glTF property to load the extra from
  76952. * @param extensionName The name of the extension to load
  76953. * @param actionAsync The action to run
  76954. * @returns The promise returned by actionAsync or null if the extra does not exist
  76955. */
  76956. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76957. /**
  76958. * Checks for presence of an extension.
  76959. * @param name The name of the extension to check
  76960. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76961. */
  76962. isExtensionUsed(name: string): boolean;
  76963. /**
  76964. * Increments the indentation level and logs a message.
  76965. * @param message The message to log
  76966. */
  76967. logOpen(message: string): void;
  76968. /**
  76969. * Decrements the indentation level.
  76970. */
  76971. logClose(): void;
  76972. /**
  76973. * Logs a message
  76974. * @param message The message to log
  76975. */
  76976. log(message: string): void;
  76977. /**
  76978. * Starts a performance counter.
  76979. * @param counterName The name of the performance counter
  76980. */
  76981. startPerformanceCounter(counterName: string): void;
  76982. /**
  76983. * Ends a performance counter.
  76984. * @param counterName The name of the performance counter
  76985. */
  76986. endPerformanceCounter(counterName: string): void;
  76987. }
  76988. }
  76989. declare module BABYLON.GLTF2.Loader.Extensions {
  76990. /**
  76991. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76992. */
  76993. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76994. /**
  76995. * The name of this extension.
  76996. */
  76997. readonly name: string;
  76998. /**
  76999. * Defines whether this extension is enabled.
  77000. */
  77001. enabled: boolean;
  77002. private _loader;
  77003. private _lights?;
  77004. /** @hidden */
  77005. constructor(loader: GLTFLoader);
  77006. /** @hidden */
  77007. dispose(): void;
  77008. /** @hidden */
  77009. onLoading(): void;
  77010. /** @hidden */
  77011. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77012. private _loadLightAsync;
  77013. }
  77014. }
  77015. declare module BABYLON.GLTF2.Loader.Extensions {
  77016. /**
  77017. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  77018. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  77019. * !!! Experimental Extension Subject to Changes !!!
  77020. */
  77021. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  77022. /**
  77023. * The name of this extension.
  77024. */
  77025. readonly name: string;
  77026. /**
  77027. * Defines whether this extension is enabled.
  77028. */
  77029. enabled: boolean;
  77030. private _loader;
  77031. /** @hidden */
  77032. constructor(loader: GLTFLoader);
  77033. /** @hidden */
  77034. dispose(): void;
  77035. /** @hidden */
  77036. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77037. }
  77038. }
  77039. declare module BABYLON.GLTF2.Loader.Extensions {
  77040. /**
  77041. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  77042. */
  77043. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  77044. /**
  77045. * The name of this extension.
  77046. */
  77047. readonly name: string;
  77048. /**
  77049. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  77050. */
  77051. dracoCompression?: DracoCompression;
  77052. /**
  77053. * Defines whether this extension is enabled.
  77054. */
  77055. enabled: boolean;
  77056. private _loader;
  77057. /** @hidden */
  77058. constructor(loader: GLTFLoader);
  77059. /** @hidden */
  77060. dispose(): void;
  77061. /** @hidden */
  77062. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  77063. }
  77064. }
  77065. declare module BABYLON.GLTF2.Loader.Extensions {
  77066. /**
  77067. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  77068. */
  77069. export class KHR_lights implements IGLTFLoaderExtension {
  77070. /**
  77071. * The name of this extension.
  77072. */
  77073. readonly name: string;
  77074. /**
  77075. * Defines whether this extension is enabled.
  77076. */
  77077. enabled: boolean;
  77078. private _loader;
  77079. private _lights?;
  77080. /** @hidden */
  77081. constructor(loader: GLTFLoader);
  77082. /** @hidden */
  77083. dispose(): void;
  77084. /** @hidden */
  77085. onLoading(): void;
  77086. /** @hidden */
  77087. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77088. }
  77089. }
  77090. declare module BABYLON.GLTF2.Loader.Extensions {
  77091. /**
  77092. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  77093. */
  77094. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  77095. /**
  77096. * The name of this extension.
  77097. */
  77098. readonly name: string;
  77099. /**
  77100. * Defines whether this extension is enabled.
  77101. */
  77102. enabled: boolean;
  77103. /**
  77104. * Defines a number that determines the order the extensions are applied.
  77105. */
  77106. order: number;
  77107. private _loader;
  77108. /** @hidden */
  77109. constructor(loader: GLTFLoader);
  77110. /** @hidden */
  77111. dispose(): void;
  77112. /** @hidden */
  77113. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77114. private _loadSpecularGlossinessPropertiesAsync;
  77115. }
  77116. }
  77117. declare module BABYLON.GLTF2.Loader.Extensions {
  77118. /**
  77119. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  77120. */
  77121. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  77122. /**
  77123. * The name of this extension.
  77124. */
  77125. readonly name: string;
  77126. /**
  77127. * Defines whether this extension is enabled.
  77128. */
  77129. enabled: boolean;
  77130. /**
  77131. * Defines a number that determines the order the extensions are applied.
  77132. */
  77133. order: number;
  77134. private _loader;
  77135. /** @hidden */
  77136. constructor(loader: GLTFLoader);
  77137. /** @hidden */
  77138. dispose(): void;
  77139. /** @hidden */
  77140. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77141. private _loadUnlitPropertiesAsync;
  77142. }
  77143. }
  77144. declare module BABYLON.GLTF2.Loader.Extensions {
  77145. /**
  77146. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77147. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  77148. * !!! Experimental Extension Subject to Changes !!!
  77149. */
  77150. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  77151. /**
  77152. * The name of this extension.
  77153. */
  77154. readonly name: string;
  77155. /**
  77156. * Defines whether this extension is enabled.
  77157. */
  77158. enabled: boolean;
  77159. /**
  77160. * Defines a number that determines the order the extensions are applied.
  77161. */
  77162. order: number;
  77163. private _loader;
  77164. /** @hidden */
  77165. constructor(loader: GLTFLoader);
  77166. /** @hidden */
  77167. dispose(): void;
  77168. /** @hidden */
  77169. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77170. private _loadClearCoatPropertiesAsync;
  77171. }
  77172. }
  77173. declare module BABYLON.GLTF2.Loader.Extensions {
  77174. /**
  77175. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  77176. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77177. * !!! Experimental Extension Subject to Changes !!!
  77178. */
  77179. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  77180. /**
  77181. * The name of this extension.
  77182. */
  77183. readonly name: string;
  77184. /**
  77185. * Defines whether this extension is enabled.
  77186. */
  77187. enabled: boolean;
  77188. /**
  77189. * Defines a number that determines the order the extensions are applied.
  77190. */
  77191. order: number;
  77192. private _loader;
  77193. /** @hidden */
  77194. constructor(loader: GLTFLoader);
  77195. /** @hidden */
  77196. dispose(): void;
  77197. /** @hidden */
  77198. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77199. private _loadSheenPropertiesAsync;
  77200. }
  77201. }
  77202. declare module BABYLON.GLTF2.Loader.Extensions {
  77203. /**
  77204. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77205. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77206. * !!! Experimental Extension Subject to Changes !!!
  77207. */
  77208. export class KHR_materials_specular implements IGLTFLoaderExtension {
  77209. /**
  77210. * The name of this extension.
  77211. */
  77212. readonly name: string;
  77213. /**
  77214. * Defines whether this extension is enabled.
  77215. */
  77216. enabled: boolean;
  77217. /**
  77218. * Defines a number that determines the order the extensions are applied.
  77219. */
  77220. order: number;
  77221. private _loader;
  77222. /** @hidden */
  77223. constructor(loader: GLTFLoader);
  77224. /** @hidden */
  77225. dispose(): void;
  77226. /** @hidden */
  77227. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77228. private _loadSpecularPropertiesAsync;
  77229. }
  77230. }
  77231. declare module BABYLON.GLTF2.Loader.Extensions {
  77232. /**
  77233. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  77234. */
  77235. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  77236. /**
  77237. * The name of this extension.
  77238. */
  77239. readonly name: string;
  77240. /**
  77241. * Defines whether this extension is enabled.
  77242. */
  77243. enabled: boolean;
  77244. /** @hidden */
  77245. constructor(loader: GLTFLoader);
  77246. /** @hidden */
  77247. dispose(): void;
  77248. }
  77249. }
  77250. declare module BABYLON.GLTF2.Loader.Extensions {
  77251. /**
  77252. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  77253. * !!! Experimental Extension Subject to Changes !!!
  77254. */
  77255. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  77256. /** The name of this extension. */
  77257. readonly name: string;
  77258. /** Defines whether this extension is enabled. */
  77259. enabled: boolean;
  77260. private _loader;
  77261. /** @hidden */
  77262. constructor(loader: GLTFLoader);
  77263. /** @hidden */
  77264. dispose(): void;
  77265. /** @hidden */
  77266. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77267. }
  77268. }
  77269. declare module BABYLON.GLTF2.Loader.Extensions {
  77270. /**
  77271. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  77272. */
  77273. export class KHR_texture_transform implements IGLTFLoaderExtension {
  77274. /**
  77275. * The name of this extension.
  77276. */
  77277. readonly name: string;
  77278. /**
  77279. * Defines whether this extension is enabled.
  77280. */
  77281. enabled: boolean;
  77282. private _loader;
  77283. /** @hidden */
  77284. constructor(loader: GLTFLoader);
  77285. /** @hidden */
  77286. dispose(): void;
  77287. /** @hidden */
  77288. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77289. }
  77290. }
  77291. declare module BABYLON.GLTF2.Loader.Extensions {
  77292. /**
  77293. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  77294. */
  77295. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  77296. /**
  77297. * The name of this extension.
  77298. */
  77299. readonly name: string;
  77300. /**
  77301. * Defines whether this extension is enabled.
  77302. */
  77303. enabled: boolean;
  77304. private _loader;
  77305. private _clips;
  77306. private _emitters;
  77307. /** @hidden */
  77308. constructor(loader: GLTFLoader);
  77309. /** @hidden */
  77310. dispose(): void;
  77311. /** @hidden */
  77312. onLoading(): void;
  77313. /** @hidden */
  77314. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77315. /** @hidden */
  77316. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77317. /** @hidden */
  77318. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77319. private _loadClipAsync;
  77320. private _loadEmitterAsync;
  77321. private _getEventAction;
  77322. private _loadAnimationEventAsync;
  77323. }
  77324. }
  77325. declare module BABYLON.GLTF2.Loader.Extensions {
  77326. /**
  77327. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  77328. */
  77329. export class MSFT_lod implements IGLTFLoaderExtension {
  77330. /**
  77331. * The name of this extension.
  77332. */
  77333. readonly name: string;
  77334. /**
  77335. * Defines whether this extension is enabled.
  77336. */
  77337. enabled: boolean;
  77338. /**
  77339. * Defines a number that determines the order the extensions are applied.
  77340. */
  77341. order: number;
  77342. /**
  77343. * Maximum number of LODs to load, starting from the lowest LOD.
  77344. */
  77345. maxLODsToLoad: number;
  77346. /**
  77347. * Observable raised when all node LODs of one level are loaded.
  77348. * The event data is the index of the loaded LOD starting from zero.
  77349. * Dispose the loader to cancel the loading of the next level of LODs.
  77350. */
  77351. onNodeLODsLoadedObservable: Observable<number>;
  77352. /**
  77353. * Observable raised when all material LODs of one level are loaded.
  77354. * The event data is the index of the loaded LOD starting from zero.
  77355. * Dispose the loader to cancel the loading of the next level of LODs.
  77356. */
  77357. onMaterialLODsLoadedObservable: Observable<number>;
  77358. private _loader;
  77359. private _nodeIndexLOD;
  77360. private _nodeSignalLODs;
  77361. private _nodePromiseLODs;
  77362. private _materialIndexLOD;
  77363. private _materialSignalLODs;
  77364. private _materialPromiseLODs;
  77365. private _indexLOD;
  77366. private _bufferLODs;
  77367. /** @hidden */
  77368. constructor(loader: GLTFLoader);
  77369. /** @hidden */
  77370. dispose(): void;
  77371. /** @hidden */
  77372. onReady(): void;
  77373. /** @hidden */
  77374. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77375. /** @hidden */
  77376. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77377. /** @hidden */
  77378. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77379. /** @hidden */
  77380. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77381. /** @hidden */
  77382. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77383. private _loadBufferLOD;
  77384. /**
  77385. * Gets an array of LOD properties from lowest to highest.
  77386. */
  77387. private _getLODs;
  77388. private _disposeTransformNode;
  77389. private _disposeMaterials;
  77390. }
  77391. }
  77392. declare module BABYLON.GLTF2.Loader.Extensions {
  77393. /** @hidden */
  77394. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  77395. readonly name: string;
  77396. enabled: boolean;
  77397. private _loader;
  77398. constructor(loader: GLTFLoader);
  77399. dispose(): void;
  77400. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77401. }
  77402. }
  77403. declare module BABYLON.GLTF2.Loader.Extensions {
  77404. /** @hidden */
  77405. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  77406. readonly name: string;
  77407. enabled: boolean;
  77408. private _loader;
  77409. constructor(loader: GLTFLoader);
  77410. dispose(): void;
  77411. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77412. }
  77413. }
  77414. declare module BABYLON.GLTF2.Loader.Extensions {
  77415. /**
  77416. * Store glTF extras (if present) in BJS objects' metadata
  77417. */
  77418. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  77419. /**
  77420. * The name of this extension.
  77421. */
  77422. readonly name: string;
  77423. /**
  77424. * Defines whether this extension is enabled.
  77425. */
  77426. enabled: boolean;
  77427. private _loader;
  77428. private _assignExtras;
  77429. /** @hidden */
  77430. constructor(loader: GLTFLoader);
  77431. /** @hidden */
  77432. dispose(): void;
  77433. /** @hidden */
  77434. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77435. /** @hidden */
  77436. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77437. /** @hidden */
  77438. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77439. }
  77440. }
  77441. declare module BABYLON {
  77442. /**
  77443. * Class reading and parsing the MTL file bundled with the obj file.
  77444. */
  77445. export class MTLFileLoader {
  77446. /**
  77447. * Invert Y-Axis of referenced textures on load
  77448. */
  77449. static INVERT_TEXTURE_Y: boolean;
  77450. /**
  77451. * All material loaded from the mtl will be set here
  77452. */
  77453. materials: StandardMaterial[];
  77454. /**
  77455. * This function will read the mtl file and create each material described inside
  77456. * This function could be improve by adding :
  77457. * -some component missing (Ni, Tf...)
  77458. * -including the specific options available
  77459. *
  77460. * @param scene defines the scene the material will be created in
  77461. * @param data defines the mtl data to parse
  77462. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77463. * @param forAssetContainer defines if the material should be registered in the scene
  77464. */
  77465. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77466. /**
  77467. * Gets the texture for the material.
  77468. *
  77469. * If the material is imported from input file,
  77470. * We sanitize the url to ensure it takes the textre from aside the material.
  77471. *
  77472. * @param rootUrl The root url to load from
  77473. * @param value The value stored in the mtl
  77474. * @return The Texture
  77475. */
  77476. private static _getTexture;
  77477. }
  77478. }
  77479. declare module BABYLON {
  77480. /**
  77481. * Options for loading OBJ/MTL files
  77482. */
  77483. type MeshLoadOptions = {
  77484. /**
  77485. * Defines if UVs are optimized by default during load.
  77486. */
  77487. OptimizeWithUV: boolean;
  77488. /**
  77489. * Defines custom scaling of UV coordinates of loaded meshes.
  77490. */
  77491. UVScaling: Vector2;
  77492. /**
  77493. * Invert model on y-axis (does a model scaling inversion)
  77494. */
  77495. InvertY: boolean;
  77496. /**
  77497. * Invert Y-Axis of referenced textures on load
  77498. */
  77499. InvertTextureY: boolean;
  77500. /**
  77501. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77502. */
  77503. ImportVertexColors: boolean;
  77504. /**
  77505. * Compute the normals for the model, even if normals are present in the file.
  77506. */
  77507. ComputeNormals: boolean;
  77508. /**
  77509. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77510. */
  77511. SkipMaterials: boolean;
  77512. /**
  77513. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77514. */
  77515. MaterialLoadingFailsSilently: boolean;
  77516. };
  77517. /**
  77518. * OBJ file type loader.
  77519. * This is a babylon scene loader plugin.
  77520. */
  77521. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77522. /**
  77523. * Defines if UVs are optimized by default during load.
  77524. */
  77525. static OPTIMIZE_WITH_UV: boolean;
  77526. /**
  77527. * Invert model on y-axis (does a model scaling inversion)
  77528. */
  77529. static INVERT_Y: boolean;
  77530. /**
  77531. * Invert Y-Axis of referenced textures on load
  77532. */
  77533. static get INVERT_TEXTURE_Y(): boolean;
  77534. static set INVERT_TEXTURE_Y(value: boolean);
  77535. /**
  77536. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77537. */
  77538. static IMPORT_VERTEX_COLORS: boolean;
  77539. /**
  77540. * Compute the normals for the model, even if normals are present in the file.
  77541. */
  77542. static COMPUTE_NORMALS: boolean;
  77543. /**
  77544. * Defines custom scaling of UV coordinates of loaded meshes.
  77545. */
  77546. static UV_SCALING: Vector2;
  77547. /**
  77548. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77549. */
  77550. static SKIP_MATERIALS: boolean;
  77551. /**
  77552. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77553. *
  77554. * Defaults to true for backwards compatibility.
  77555. */
  77556. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77557. /**
  77558. * Defines the name of the plugin.
  77559. */
  77560. name: string;
  77561. /**
  77562. * Defines the extension the plugin is able to load.
  77563. */
  77564. extensions: string;
  77565. /** @hidden */
  77566. obj: RegExp;
  77567. /** @hidden */
  77568. group: RegExp;
  77569. /** @hidden */
  77570. mtllib: RegExp;
  77571. /** @hidden */
  77572. usemtl: RegExp;
  77573. /** @hidden */
  77574. smooth: RegExp;
  77575. /** @hidden */
  77576. vertexPattern: RegExp;
  77577. /** @hidden */
  77578. normalPattern: RegExp;
  77579. /** @hidden */
  77580. uvPattern: RegExp;
  77581. /** @hidden */
  77582. facePattern1: RegExp;
  77583. /** @hidden */
  77584. facePattern2: RegExp;
  77585. /** @hidden */
  77586. facePattern3: RegExp;
  77587. /** @hidden */
  77588. facePattern4: RegExp;
  77589. /** @hidden */
  77590. facePattern5: RegExp;
  77591. private _forAssetContainer;
  77592. private _meshLoadOptions;
  77593. /**
  77594. * Creates loader for .OBJ files
  77595. *
  77596. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77597. */
  77598. constructor(meshLoadOptions?: MeshLoadOptions);
  77599. private static get currentMeshLoadOptions();
  77600. /**
  77601. * Calls synchronously the MTL file attached to this obj.
  77602. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77603. * Without this function materials are not displayed in the first frame (but displayed after).
  77604. * In consequence it is impossible to get material information in your HTML file
  77605. *
  77606. * @param url The URL of the MTL file
  77607. * @param rootUrl
  77608. * @param onSuccess Callback function to be called when the MTL file is loaded
  77609. * @private
  77610. */
  77611. private _loadMTL;
  77612. /**
  77613. * Instantiates a OBJ file loader plugin.
  77614. * @returns the created plugin
  77615. */
  77616. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77617. /**
  77618. * If the data string can be loaded directly.
  77619. *
  77620. * @param data string containing the file data
  77621. * @returns if the data can be loaded directly
  77622. */
  77623. canDirectLoad(data: string): boolean;
  77624. /**
  77625. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77626. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77627. * @param scene the scene the meshes should be added to
  77628. * @param data the OBJ data to load
  77629. * @param rootUrl root url to load from
  77630. * @param onProgress event that fires when loading progress has occured
  77631. * @param fileName Defines the name of the file to load
  77632. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77633. */
  77634. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77635. meshes: AbstractMesh[];
  77636. particleSystems: IParticleSystem[];
  77637. skeletons: Skeleton[];
  77638. animationGroups: AnimationGroup[];
  77639. }>;
  77640. /**
  77641. * Imports all objects from the loaded OBJ data and adds them to the scene
  77642. * @param scene the scene the objects should be added to
  77643. * @param data the OBJ data to load
  77644. * @param rootUrl root url to load from
  77645. * @param onProgress event that fires when loading progress has occured
  77646. * @param fileName Defines the name of the file to load
  77647. * @returns a promise which completes when objects have been loaded to the scene
  77648. */
  77649. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77650. /**
  77651. * Load into an asset container.
  77652. * @param scene The scene to load into
  77653. * @param data The data to import
  77654. * @param rootUrl The root url for scene and resources
  77655. * @param onProgress The callback when the load progresses
  77656. * @param fileName Defines the name of the file to load
  77657. * @returns The loaded asset container
  77658. */
  77659. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77660. /**
  77661. * Read the OBJ file and create an Array of meshes.
  77662. * Each mesh contains all information given by the OBJ and the MTL file.
  77663. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77664. *
  77665. * @param meshesNames
  77666. * @param scene Scene The scene where are displayed the data
  77667. * @param data String The content of the obj file
  77668. * @param rootUrl String The path to the folder
  77669. * @returns Array<AbstractMesh>
  77670. * @private
  77671. */
  77672. private _parseSolid;
  77673. }
  77674. }
  77675. declare module BABYLON {
  77676. /**
  77677. * STL file type loader.
  77678. * This is a babylon scene loader plugin.
  77679. */
  77680. export class STLFileLoader implements ISceneLoaderPlugin {
  77681. /** @hidden */
  77682. solidPattern: RegExp;
  77683. /** @hidden */
  77684. facetsPattern: RegExp;
  77685. /** @hidden */
  77686. normalPattern: RegExp;
  77687. /** @hidden */
  77688. vertexPattern: RegExp;
  77689. /**
  77690. * Defines the name of the plugin.
  77691. */
  77692. name: string;
  77693. /**
  77694. * Defines the extensions the stl loader is able to load.
  77695. * force data to come in as an ArrayBuffer
  77696. * we'll convert to string if it looks like it's an ASCII .stl
  77697. */
  77698. extensions: ISceneLoaderPluginExtensions;
  77699. /**
  77700. * Import meshes into a scene.
  77701. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77702. * @param scene The scene to import into
  77703. * @param data The data to import
  77704. * @param rootUrl The root url for scene and resources
  77705. * @param meshes The meshes array to import into
  77706. * @param particleSystems The particle systems array to import into
  77707. * @param skeletons The skeletons array to import into
  77708. * @param onError The callback when import fails
  77709. * @returns True if successful or false otherwise
  77710. */
  77711. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77712. /**
  77713. * Load into a scene.
  77714. * @param scene The scene to load into
  77715. * @param data The data to import
  77716. * @param rootUrl The root url for scene and resources
  77717. * @param onError The callback when import fails
  77718. * @returns true if successful or false otherwise
  77719. */
  77720. load(scene: Scene, data: any, rootUrl: string): boolean;
  77721. /**
  77722. * Load into an asset container.
  77723. * @param scene The scene to load into
  77724. * @param data The data to import
  77725. * @param rootUrl The root url for scene and resources
  77726. * @param onError The callback when import fails
  77727. * @returns The loaded asset container
  77728. */
  77729. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77730. private _isBinary;
  77731. private _parseBinary;
  77732. private _parseASCII;
  77733. }
  77734. }
  77735. declare module BABYLON {
  77736. /**
  77737. * Class for generating OBJ data from a Babylon scene.
  77738. */
  77739. export class OBJExport {
  77740. /**
  77741. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77742. * @param mesh defines the list of meshes to serialize
  77743. * @param materials defines if materials should be exported
  77744. * @param matlibname defines the name of the associated mtl file
  77745. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77746. * @returns the OBJ content
  77747. */
  77748. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77749. /**
  77750. * Exports the material(s) of a mesh in .MTL file format (text)
  77751. * @param mesh defines the mesh to extract the material from
  77752. * @returns the mtl content
  77753. */
  77754. static MTL(mesh: Mesh): string;
  77755. }
  77756. }
  77757. declare module BABYLON {
  77758. /** @hidden */
  77759. export var __IGLTFExporterExtension: number;
  77760. /**
  77761. * Interface for extending the exporter
  77762. * @hidden
  77763. */
  77764. export interface IGLTFExporterExtension {
  77765. /**
  77766. * The name of this extension
  77767. */
  77768. readonly name: string;
  77769. /**
  77770. * Defines whether this extension is enabled
  77771. */
  77772. enabled: boolean;
  77773. /**
  77774. * Defines whether this extension is required
  77775. */
  77776. required: boolean;
  77777. }
  77778. }
  77779. declare module BABYLON.GLTF2.Exporter {
  77780. /** @hidden */
  77781. export var __IGLTFExporterExtensionV2: number;
  77782. /**
  77783. * Interface for a glTF exporter extension
  77784. * @hidden
  77785. */
  77786. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77787. /**
  77788. * Define this method to modify the default behavior before exporting a texture
  77789. * @param context The context when loading the asset
  77790. * @param babylonTexture The Babylon.js texture
  77791. * @param mimeType The mime-type of the generated image
  77792. * @returns A promise that resolves with the exported texture
  77793. */
  77794. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77795. /**
  77796. * Define this method to get notified when a texture info is created
  77797. * @param context The context when loading the asset
  77798. * @param textureInfo The glTF texture info
  77799. * @param babylonTexture The Babylon.js texture
  77800. */
  77801. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77802. /**
  77803. * Define this method to modify the default behavior when exporting texture info
  77804. * @param context The context when loading the asset
  77805. * @param meshPrimitive glTF mesh primitive
  77806. * @param babylonSubMesh Babylon submesh
  77807. * @param binaryWriter glTF serializer binary writer instance
  77808. * @returns nullable IMeshPrimitive promise
  77809. */
  77810. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77811. /**
  77812. * Define this method to modify the default behavior when exporting a node
  77813. * @param context The context when exporting the node
  77814. * @param node glTF node
  77815. * @param babylonNode BabylonJS node
  77816. * @returns nullable INode promise
  77817. */
  77818. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77819. [key: number]: number;
  77820. }): Promise<Nullable<INode>>;
  77821. /**
  77822. * Define this method to modify the default behavior when exporting a material
  77823. * @param material glTF material
  77824. * @param babylonMaterial BabylonJS material
  77825. * @returns nullable IMaterial promise
  77826. */
  77827. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77828. /**
  77829. * Define this method to return additional textures to export from a material
  77830. * @param material glTF material
  77831. * @param babylonMaterial BabylonJS material
  77832. * @returns List of textures
  77833. */
  77834. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77835. /** Gets a boolean indicating that this extension was used */
  77836. wasUsed: boolean;
  77837. /** Gets a boolean indicating that this extension is required for the file to work */
  77838. required: boolean;
  77839. /**
  77840. * Called after the exporter state changes to EXPORTING
  77841. */
  77842. onExporting?(): void;
  77843. }
  77844. }
  77845. declare module BABYLON.GLTF2.Exporter {
  77846. /**
  77847. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77848. * @hidden
  77849. */
  77850. export class _GLTFMaterialExporter {
  77851. /**
  77852. * Represents the dielectric specular values for R, G and B
  77853. */
  77854. private static readonly _DielectricSpecular;
  77855. /**
  77856. * Allows the maximum specular power to be defined for material calculations
  77857. */
  77858. private static readonly _MaxSpecularPower;
  77859. /**
  77860. * Mapping to store textures
  77861. */
  77862. private _textureMap;
  77863. /**
  77864. * Numeric tolerance value
  77865. */
  77866. private static readonly _Epsilon;
  77867. /**
  77868. * Reference to the glTF Exporter
  77869. */
  77870. private _exporter;
  77871. constructor(exporter: _Exporter);
  77872. /**
  77873. * Specifies if two colors are approximately equal in value
  77874. * @param color1 first color to compare to
  77875. * @param color2 second color to compare to
  77876. * @param epsilon threshold value
  77877. */
  77878. private static FuzzyEquals;
  77879. /**
  77880. * Gets the materials from a Babylon scene and converts them to glTF materials
  77881. * @param scene babylonjs scene
  77882. * @param mimeType texture mime type
  77883. * @param images array of images
  77884. * @param textures array of textures
  77885. * @param materials array of materials
  77886. * @param imageData mapping of texture names to base64 textures
  77887. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77888. */
  77889. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77890. /**
  77891. * Makes a copy of the glTF material without the texture parameters
  77892. * @param originalMaterial original glTF material
  77893. * @returns glTF material without texture parameters
  77894. */
  77895. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77896. /**
  77897. * Specifies if the material has any texture parameters present
  77898. * @param material glTF Material
  77899. * @returns boolean specifying if texture parameters are present
  77900. */
  77901. _hasTexturesPresent(material: IMaterial): boolean;
  77902. /**
  77903. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77904. * @param babylonStandardMaterial
  77905. * @returns glTF Metallic Roughness Material representation
  77906. */
  77907. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77908. /**
  77909. * Computes the metallic factor
  77910. * @param diffuse diffused value
  77911. * @param specular specular value
  77912. * @param oneMinusSpecularStrength one minus the specular strength
  77913. * @returns metallic value
  77914. */
  77915. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77916. /**
  77917. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77918. * @param glTFMaterial glTF material
  77919. * @param babylonMaterial Babylon material
  77920. */
  77921. private static _SetAlphaMode;
  77922. /**
  77923. * Converts a Babylon Standard Material to a glTF Material
  77924. * @param babylonStandardMaterial BJS Standard Material
  77925. * @param mimeType mime type to use for the textures
  77926. * @param images array of glTF image interfaces
  77927. * @param textures array of glTF texture interfaces
  77928. * @param materials array of glTF material interfaces
  77929. * @param imageData map of image file name to data
  77930. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77931. */
  77932. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77933. private _finishMaterial;
  77934. /**
  77935. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77936. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77937. * @param mimeType mime type to use for the textures
  77938. * @param images array of glTF image interfaces
  77939. * @param textures array of glTF texture interfaces
  77940. * @param materials array of glTF material interfaces
  77941. * @param imageData map of image file name to data
  77942. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77943. */
  77944. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77945. /**
  77946. * Converts an image typed array buffer to a base64 image
  77947. * @param buffer typed array buffer
  77948. * @param width width of the image
  77949. * @param height height of the image
  77950. * @param mimeType mimetype of the image
  77951. * @returns base64 image string
  77952. */
  77953. private _createBase64FromCanvasAsync;
  77954. /**
  77955. * Generates a white texture based on the specified width and height
  77956. * @param width width of the texture in pixels
  77957. * @param height height of the texture in pixels
  77958. * @param scene babylonjs scene
  77959. * @returns white texture
  77960. */
  77961. private _createWhiteTexture;
  77962. /**
  77963. * 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
  77964. * @param texture1 first texture to resize
  77965. * @param texture2 second texture to resize
  77966. * @param scene babylonjs scene
  77967. * @returns resized textures or null
  77968. */
  77969. private _resizeTexturesToSameDimensions;
  77970. /**
  77971. * Converts an array of pixels to a Float32Array
  77972. * Throws an error if the pixel format is not supported
  77973. * @param pixels - array buffer containing pixel values
  77974. * @returns Float32 of pixels
  77975. */
  77976. private _convertPixelArrayToFloat32;
  77977. /**
  77978. * Convert Specular Glossiness Textures to Metallic Roughness
  77979. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77980. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77981. * @param diffuseTexture texture used to store diffuse information
  77982. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77983. * @param factors specular glossiness material factors
  77984. * @param mimeType the mime type to use for the texture
  77985. * @returns pbr metallic roughness interface or null
  77986. */
  77987. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77988. /**
  77989. * Converts specular glossiness material properties to metallic roughness
  77990. * @param specularGlossiness interface with specular glossiness material properties
  77991. * @returns interface with metallic roughness material properties
  77992. */
  77993. private _convertSpecularGlossinessToMetallicRoughness;
  77994. /**
  77995. * Calculates the surface reflectance, independent of lighting conditions
  77996. * @param color Color source to calculate brightness from
  77997. * @returns number representing the perceived brightness, or zero if color is undefined
  77998. */
  77999. private _getPerceivedBrightness;
  78000. /**
  78001. * Returns the maximum color component value
  78002. * @param color
  78003. * @returns maximum color component value, or zero if color is null or undefined
  78004. */
  78005. private _getMaxComponent;
  78006. /**
  78007. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  78008. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  78009. * @param mimeType mime type to use for the textures
  78010. * @param images array of glTF image interfaces
  78011. * @param textures array of glTF texture interfaces
  78012. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  78013. * @param imageData map of image file name to data
  78014. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  78015. * @returns glTF PBR Metallic Roughness factors
  78016. */
  78017. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  78018. private _getGLTFTextureSampler;
  78019. private _getGLTFTextureWrapMode;
  78020. private _getGLTFTextureWrapModesSampler;
  78021. /**
  78022. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  78023. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  78024. * @param mimeType mime type to use for the textures
  78025. * @param images array of glTF image interfaces
  78026. * @param textures array of glTF texture interfaces
  78027. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  78028. * @param imageData map of image file name to data
  78029. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  78030. * @returns glTF PBR Metallic Roughness factors
  78031. */
  78032. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  78033. /**
  78034. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  78035. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  78036. * @param mimeType mime type to use for the textures
  78037. * @param images array of glTF image interfaces
  78038. * @param textures array of glTF texture interfaces
  78039. * @param materials array of glTF material interfaces
  78040. * @param imageData map of image file name to data
  78041. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  78042. */
  78043. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  78044. private setMetallicRoughnessPbrMaterial;
  78045. private getPixelsFromTexture;
  78046. /**
  78047. * Extracts a texture from a Babylon texture into file data and glTF data
  78048. * @param babylonTexture Babylon texture to extract
  78049. * @param mimeType Mime Type of the babylonTexture
  78050. * @return glTF texture info, or null if the texture format is not supported
  78051. */
  78052. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  78053. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  78054. /**
  78055. * Builds a texture from base64 string
  78056. * @param base64Texture base64 texture string
  78057. * @param baseTextureName Name to use for the texture
  78058. * @param mimeType image mime type for the texture
  78059. * @param images array of images
  78060. * @param textures array of textures
  78061. * @param imageData map of image data
  78062. * @returns glTF texture info, or null if the texture format is not supported
  78063. */
  78064. private _getTextureInfoFromBase64;
  78065. }
  78066. }
  78067. declare module BABYLON {
  78068. /**
  78069. * Class for holding and downloading glTF file data
  78070. */
  78071. export class GLTFData {
  78072. /**
  78073. * Object which contains the file name as the key and its data as the value
  78074. */
  78075. glTFFiles: {
  78076. [fileName: string]: string | Blob;
  78077. };
  78078. /**
  78079. * Initializes the glTF file object
  78080. */
  78081. constructor();
  78082. /**
  78083. * Downloads the glTF data as files based on their names and data
  78084. */
  78085. downloadFiles(): void;
  78086. }
  78087. }
  78088. declare module BABYLON {
  78089. /**
  78090. * Holds a collection of exporter options and parameters
  78091. */
  78092. export interface IExportOptions {
  78093. /**
  78094. * Function which indicates whether a babylon node should be exported or not
  78095. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  78096. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  78097. */
  78098. shouldExportNode?(node: Node): boolean;
  78099. /**
  78100. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  78101. * @param metadata source metadata to read from
  78102. * @returns the data to store to glTF node extras
  78103. */
  78104. metadataSelector?(metadata: any): any;
  78105. /**
  78106. * The sample rate to bake animation curves
  78107. */
  78108. animationSampleRate?: number;
  78109. /**
  78110. * Begin serialization without waiting for the scene to be ready
  78111. */
  78112. exportWithoutWaitingForScene?: boolean;
  78113. /**
  78114. * Indicates if coordinate system swapping root nodes should be included in export
  78115. */
  78116. includeCoordinateSystemConversionNodes?: boolean;
  78117. }
  78118. /**
  78119. * Class for generating glTF data from a Babylon scene.
  78120. */
  78121. export class GLTF2Export {
  78122. /**
  78123. * Exports the geometry of the scene to .gltf file format asynchronously
  78124. * @param scene Babylon scene with scene hierarchy information
  78125. * @param filePrefix File prefix to use when generating the glTF file
  78126. * @param options Exporter options
  78127. * @returns Returns an object with a .gltf file and associates texture names
  78128. * as keys and their data and paths as values
  78129. */
  78130. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78131. private static _PreExportAsync;
  78132. private static _PostExportAsync;
  78133. /**
  78134. * Exports the geometry of the scene to .glb file format asychronously
  78135. * @param scene Babylon scene with scene hierarchy information
  78136. * @param filePrefix File prefix to use when generating glb file
  78137. * @param options Exporter options
  78138. * @returns Returns an object with a .glb filename as key and data as value
  78139. */
  78140. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78141. }
  78142. }
  78143. declare module BABYLON.GLTF2.Exporter {
  78144. /**
  78145. * @hidden
  78146. */
  78147. export class _GLTFUtilities {
  78148. /**
  78149. * Creates a buffer view based on the supplied arguments
  78150. * @param bufferIndex index value of the specified buffer
  78151. * @param byteOffset byte offset value
  78152. * @param byteLength byte length of the bufferView
  78153. * @param byteStride byte distance between conequential elements
  78154. * @param name name of the buffer view
  78155. * @returns bufferView for glTF
  78156. */
  78157. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  78158. /**
  78159. * Creates an accessor based on the supplied arguments
  78160. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  78161. * @param name The name of the accessor
  78162. * @param type The type of the accessor
  78163. * @param componentType The datatype of components in the attribute
  78164. * @param count The number of attributes referenced by this accessor
  78165. * @param byteOffset The offset relative to the start of the bufferView in bytes
  78166. * @param min Minimum value of each component in this attribute
  78167. * @param max Maximum value of each component in this attribute
  78168. * @returns accessor for glTF
  78169. */
  78170. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  78171. /**
  78172. * Calculates the minimum and maximum values of an array of position floats
  78173. * @param positions Positions array of a mesh
  78174. * @param vertexStart Starting vertex offset to calculate min and max values
  78175. * @param vertexCount Number of vertices to check for min and max values
  78176. * @returns min number array and max number array
  78177. */
  78178. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  78179. min: number[];
  78180. max: number[];
  78181. };
  78182. /**
  78183. * Converts a new right-handed Vector3
  78184. * @param vector vector3 array
  78185. * @returns right-handed Vector3
  78186. */
  78187. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  78188. /**
  78189. * Converts a Vector3 to right-handed
  78190. * @param vector Vector3 to convert to right-handed
  78191. */
  78192. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  78193. /**
  78194. * Converts a three element number array to right-handed
  78195. * @param vector number array to convert to right-handed
  78196. */
  78197. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  78198. /**
  78199. * Converts a new right-handed Vector3
  78200. * @param vector vector3 array
  78201. * @returns right-handed Vector3
  78202. */
  78203. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  78204. /**
  78205. * Converts a Vector3 to right-handed
  78206. * @param vector Vector3 to convert to right-handed
  78207. */
  78208. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  78209. /**
  78210. * Converts a three element number array to right-handed
  78211. * @param vector number array to convert to right-handed
  78212. */
  78213. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  78214. /**
  78215. * Converts a Vector4 to right-handed
  78216. * @param vector Vector4 to convert to right-handed
  78217. */
  78218. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  78219. /**
  78220. * Converts a Vector4 to right-handed
  78221. * @param vector Vector4 to convert to right-handed
  78222. */
  78223. static _GetRightHandedArray4FromRef(vector: number[]): void;
  78224. /**
  78225. * Converts a Quaternion to right-handed
  78226. * @param quaternion Source quaternion to convert to right-handed
  78227. */
  78228. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  78229. /**
  78230. * Converts a Quaternion to right-handed
  78231. * @param quaternion Source quaternion to convert to right-handed
  78232. */
  78233. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  78234. static _NormalizeTangentFromRef(tangent: Vector4): void;
  78235. }
  78236. }
  78237. declare module BABYLON.GLTF2.Exporter {
  78238. /**
  78239. * Converts Babylon Scene into glTF 2.0.
  78240. * @hidden
  78241. */
  78242. export class _Exporter {
  78243. /**
  78244. * Stores the glTF to export
  78245. */
  78246. _glTF: IGLTF;
  78247. /**
  78248. * Stores all generated buffer views, which represents views into the main glTF buffer data
  78249. */
  78250. _bufferViews: IBufferView[];
  78251. /**
  78252. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  78253. */
  78254. _accessors: IAccessor[];
  78255. /**
  78256. * Stores all the generated nodes, which contains transform and/or mesh information per node
  78257. */
  78258. _nodes: INode[];
  78259. /**
  78260. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  78261. */
  78262. private _scenes;
  78263. /**
  78264. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  78265. */
  78266. private _meshes;
  78267. /**
  78268. * Stores all the generated material information, which represents the appearance of each primitive
  78269. */
  78270. _materials: IMaterial[];
  78271. _materialMap: {
  78272. [materialID: number]: number;
  78273. };
  78274. /**
  78275. * Stores all the generated texture information, which is referenced by glTF materials
  78276. */
  78277. _textures: ITexture[];
  78278. /**
  78279. * Stores all the generated image information, which is referenced by glTF textures
  78280. */
  78281. _images: IImage[];
  78282. /**
  78283. * Stores all the texture samplers
  78284. */
  78285. _samplers: ISampler[];
  78286. /**
  78287. * Stores all the generated animation samplers, which is referenced by glTF animations
  78288. */
  78289. /**
  78290. * Stores the animations for glTF models
  78291. */
  78292. private _animations;
  78293. /**
  78294. * Stores the total amount of bytes stored in the glTF buffer
  78295. */
  78296. private _totalByteLength;
  78297. /**
  78298. * Stores a reference to the Babylon scene containing the source geometry and material information
  78299. */
  78300. _babylonScene: Scene;
  78301. /**
  78302. * Stores a map of the image data, where the key is the file name and the value
  78303. * is the image data
  78304. */
  78305. _imageData: {
  78306. [fileName: string]: {
  78307. data: Uint8Array;
  78308. mimeType: ImageMimeType;
  78309. };
  78310. };
  78311. /**
  78312. * Stores a map of the unique id of a node to its index in the node array
  78313. */
  78314. _nodeMap: {
  78315. [key: number]: number;
  78316. };
  78317. /**
  78318. * Specifies if the source Babylon scene was left handed, and needed conversion.
  78319. */
  78320. _convertToRightHandedSystem: boolean;
  78321. /**
  78322. * Specifies if a Babylon node should be converted to right-handed on export
  78323. */
  78324. _convertToRightHandedSystemMap: {
  78325. [nodeId: number]: boolean;
  78326. };
  78327. _includeCoordinateSystemConversionNodes: boolean;
  78328. /**
  78329. * Baked animation sample rate
  78330. */
  78331. private _animationSampleRate;
  78332. private _options;
  78333. private _localEngine;
  78334. _glTFMaterialExporter: _GLTFMaterialExporter;
  78335. private _extensions;
  78336. private static _ExtensionNames;
  78337. private static _ExtensionFactories;
  78338. private _applyExtension;
  78339. private _applyExtensions;
  78340. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  78341. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  78342. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78343. [key: number]: number;
  78344. }): Promise<Nullable<INode>>;
  78345. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  78346. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  78347. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78348. private _forEachExtensions;
  78349. private _extensionsOnExporting;
  78350. /**
  78351. * Load glTF serializer extensions
  78352. */
  78353. private _loadExtensions;
  78354. /**
  78355. * Creates a glTF Exporter instance, which can accept optional exporter options
  78356. * @param babylonScene Babylon scene object
  78357. * @param options Options to modify the behavior of the exporter
  78358. */
  78359. constructor(babylonScene: Scene, options?: IExportOptions);
  78360. dispose(): void;
  78361. /**
  78362. * Registers a glTF exporter extension
  78363. * @param name Name of the extension to export
  78364. * @param factory The factory function that creates the exporter extension
  78365. */
  78366. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  78367. /**
  78368. * Un-registers an exporter extension
  78369. * @param name The name fo the exporter extension
  78370. * @returns A boolean indicating whether the extension has been un-registered
  78371. */
  78372. static UnregisterExtension(name: string): boolean;
  78373. /**
  78374. * Lazy load a local engine
  78375. */
  78376. _getLocalEngine(): Engine;
  78377. private reorderIndicesBasedOnPrimitiveMode;
  78378. /**
  78379. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  78380. * clock-wise during export to glTF
  78381. * @param submesh BabylonJS submesh
  78382. * @param primitiveMode Primitive mode of the mesh
  78383. * @param sideOrientation the winding order of the submesh
  78384. * @param vertexBufferKind The type of vertex attribute
  78385. * @param meshAttributeArray The vertex attribute data
  78386. * @param byteOffset The offset to the binary data
  78387. * @param binaryWriter The binary data for the glTF file
  78388. * @param convertToRightHandedSystem Converts the values to right-handed
  78389. */
  78390. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  78391. /**
  78392. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  78393. * clock-wise during export to glTF
  78394. * @param submesh BabylonJS submesh
  78395. * @param primitiveMode Primitive mode of the mesh
  78396. * @param sideOrientation the winding order of the submesh
  78397. * @param vertexBufferKind The type of vertex attribute
  78398. * @param meshAttributeArray The vertex attribute data
  78399. * @param byteOffset The offset to the binary data
  78400. * @param binaryWriter The binary data for the glTF file
  78401. * @param convertToRightHandedSystem Converts the values to right-handed
  78402. */
  78403. private reorderTriangleFillMode;
  78404. /**
  78405. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  78406. * clock-wise during export to glTF
  78407. * @param submesh BabylonJS submesh
  78408. * @param primitiveMode Primitive mode of the mesh
  78409. * @param sideOrientation the winding order of the submesh
  78410. * @param vertexBufferKind The type of vertex attribute
  78411. * @param meshAttributeArray The vertex attribute data
  78412. * @param byteOffset The offset to the binary data
  78413. * @param binaryWriter The binary data for the glTF file
  78414. * @param convertToRightHandedSystem Converts the values to right-handed
  78415. */
  78416. private reorderTriangleStripDrawMode;
  78417. /**
  78418. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  78419. * clock-wise during export to glTF
  78420. * @param submesh BabylonJS submesh
  78421. * @param primitiveMode Primitive mode of the mesh
  78422. * @param sideOrientation the winding order of the submesh
  78423. * @param vertexBufferKind The type of vertex attribute
  78424. * @param meshAttributeArray The vertex attribute data
  78425. * @param byteOffset The offset to the binary data
  78426. * @param binaryWriter The binary data for the glTF file
  78427. * @param convertToRightHandedSystem Converts the values to right-handed
  78428. */
  78429. private reorderTriangleFanMode;
  78430. /**
  78431. * Writes the vertex attribute data to binary
  78432. * @param vertices The vertices to write to the binary writer
  78433. * @param byteOffset The offset into the binary writer to overwrite binary data
  78434. * @param vertexAttributeKind The vertex attribute type
  78435. * @param meshAttributeArray The vertex attribute data
  78436. * @param binaryWriter The writer containing the binary data
  78437. * @param convertToRightHandedSystem Converts the values to right-handed
  78438. */
  78439. private writeVertexAttributeData;
  78440. /**
  78441. * Writes mesh attribute data to a data buffer
  78442. * Returns the bytelength of the data
  78443. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78444. * @param meshAttributeArray Array containing the attribute data
  78445. * @param binaryWriter The buffer to write the binary data to
  78446. * @param indices Used to specify the order of the vertex data
  78447. * @param convertToRightHandedSystem Converts the values to right-handed
  78448. */
  78449. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78450. /**
  78451. * Generates glTF json data
  78452. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78453. * @param glTFPrefix Text to use when prefixing a glTF file
  78454. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78455. * @returns json data as string
  78456. */
  78457. private generateJSON;
  78458. /**
  78459. * Generates data for .gltf and .bin files based on the glTF prefix string
  78460. * @param glTFPrefix Text to use when prefixing a glTF file
  78461. * @param dispose Dispose the exporter
  78462. * @returns GLTFData with glTF file data
  78463. */
  78464. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78465. /**
  78466. * Creates a binary buffer for glTF
  78467. * @returns array buffer for binary data
  78468. */
  78469. private _generateBinaryAsync;
  78470. /**
  78471. * Pads the number to a multiple of 4
  78472. * @param num number to pad
  78473. * @returns padded number
  78474. */
  78475. private _getPadding;
  78476. /**
  78477. * @hidden
  78478. */
  78479. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78480. /**
  78481. * Sets the TRS for each node
  78482. * @param node glTF Node for storing the transformation data
  78483. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78484. * @param convertToRightHandedSystem Converts the values to right-handed
  78485. */
  78486. private setNodeTransformation;
  78487. private getVertexBufferFromMesh;
  78488. /**
  78489. * Creates a bufferview based on the vertices type for the Babylon mesh
  78490. * @param kind Indicates the type of vertices data
  78491. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78492. * @param binaryWriter The buffer to write the bufferview data to
  78493. * @param convertToRightHandedSystem Converts the values to right-handed
  78494. */
  78495. private createBufferViewKind;
  78496. /**
  78497. * The primitive mode of the Babylon mesh
  78498. * @param babylonMesh The BabylonJS mesh
  78499. */
  78500. private getMeshPrimitiveMode;
  78501. /**
  78502. * Sets the primitive mode of the glTF mesh primitive
  78503. * @param meshPrimitive glTF mesh primitive
  78504. * @param primitiveMode The primitive mode
  78505. */
  78506. private setPrimitiveMode;
  78507. /**
  78508. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78509. * @param meshPrimitive glTF mesh primitive
  78510. * @param attributeKind vertex attribute
  78511. * @returns boolean specifying if uv coordinates are present
  78512. */
  78513. private setAttributeKind;
  78514. /**
  78515. * Sets data for the primitive attributes of each submesh
  78516. * @param mesh glTF Mesh object to store the primitive attribute information
  78517. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78518. * @param binaryWriter Buffer to write the attribute data to
  78519. * @param convertToRightHandedSystem Converts the values to right-handed
  78520. */
  78521. private setPrimitiveAttributesAsync;
  78522. /**
  78523. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78524. * @param node The node to check
  78525. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78526. */
  78527. private isBabylonCoordinateSystemConvertingNode;
  78528. /**
  78529. * Creates a glTF scene based on the array of meshes
  78530. * Returns the the total byte offset
  78531. * @param babylonScene Babylon scene to get the mesh data from
  78532. * @param binaryWriter Buffer to write binary data to
  78533. */
  78534. private createSceneAsync;
  78535. /**
  78536. * Creates a mapping of Node unique id to node index and handles animations
  78537. * @param babylonScene Babylon Scene
  78538. * @param nodes Babylon transform nodes
  78539. * @param binaryWriter Buffer to write binary data to
  78540. * @returns Node mapping of unique id to index
  78541. */
  78542. private createNodeMapAndAnimationsAsync;
  78543. /**
  78544. * Creates a glTF node from a Babylon mesh
  78545. * @param babylonMesh Source Babylon mesh
  78546. * @param binaryWriter Buffer for storing geometry data
  78547. * @param convertToRightHandedSystem Converts the values to right-handed
  78548. * @param nodeMap Node mapping of unique id to glTF node index
  78549. * @returns glTF node
  78550. */
  78551. private createNodeAsync;
  78552. }
  78553. /**
  78554. * @hidden
  78555. *
  78556. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78557. */
  78558. export class _BinaryWriter {
  78559. /**
  78560. * Array buffer which stores all binary data
  78561. */
  78562. private _arrayBuffer;
  78563. /**
  78564. * View of the array buffer
  78565. */
  78566. private _dataView;
  78567. /**
  78568. * byte offset of data in array buffer
  78569. */
  78570. private _byteOffset;
  78571. /**
  78572. * Initialize binary writer with an initial byte length
  78573. * @param byteLength Initial byte length of the array buffer
  78574. */
  78575. constructor(byteLength: number);
  78576. /**
  78577. * Resize the array buffer to the specified byte length
  78578. * @param byteLength
  78579. */
  78580. private resizeBuffer;
  78581. /**
  78582. * Get an array buffer with the length of the byte offset
  78583. * @returns ArrayBuffer resized to the byte offset
  78584. */
  78585. getArrayBuffer(): ArrayBuffer;
  78586. /**
  78587. * Get the byte offset of the array buffer
  78588. * @returns byte offset
  78589. */
  78590. getByteOffset(): number;
  78591. /**
  78592. * Stores an UInt8 in the array buffer
  78593. * @param entry
  78594. * @param byteOffset If defined, specifies where to set the value as an offset.
  78595. */
  78596. setUInt8(entry: number, byteOffset?: number): void;
  78597. /**
  78598. * Gets an UInt32 in the array buffer
  78599. * @param entry
  78600. * @param byteOffset If defined, specifies where to set the value as an offset.
  78601. */
  78602. getUInt32(byteOffset: number): number;
  78603. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78604. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78605. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78606. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78607. /**
  78608. * Stores a Float32 in the array buffer
  78609. * @param entry
  78610. */
  78611. setFloat32(entry: number, byteOffset?: number): void;
  78612. /**
  78613. * Stores an UInt32 in the array buffer
  78614. * @param entry
  78615. * @param byteOffset If defined, specifies where to set the value as an offset.
  78616. */
  78617. setUInt32(entry: number, byteOffset?: number): void;
  78618. }
  78619. }
  78620. declare module BABYLON.GLTF2.Exporter {
  78621. /**
  78622. * @hidden
  78623. * Interface to store animation data.
  78624. */
  78625. export interface _IAnimationData {
  78626. /**
  78627. * Keyframe data.
  78628. */
  78629. inputs: number[];
  78630. /**
  78631. * Value data.
  78632. */
  78633. outputs: number[][];
  78634. /**
  78635. * Animation interpolation data.
  78636. */
  78637. samplerInterpolation: AnimationSamplerInterpolation;
  78638. /**
  78639. * Minimum keyframe value.
  78640. */
  78641. inputsMin: number;
  78642. /**
  78643. * Maximum keyframe value.
  78644. */
  78645. inputsMax: number;
  78646. }
  78647. /**
  78648. * @hidden
  78649. */
  78650. export interface _IAnimationInfo {
  78651. /**
  78652. * The target channel for the animation
  78653. */
  78654. animationChannelTargetPath: AnimationChannelTargetPath;
  78655. /**
  78656. * The glTF accessor type for the data.
  78657. */
  78658. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78659. /**
  78660. * Specifies if quaternions should be used.
  78661. */
  78662. useQuaternion: boolean;
  78663. }
  78664. /**
  78665. * @hidden
  78666. * Utility class for generating glTF animation data from BabylonJS.
  78667. */
  78668. export class _GLTFAnimation {
  78669. /**
  78670. * @ignore
  78671. *
  78672. * Creates glTF channel animation from BabylonJS animation.
  78673. * @param babylonTransformNode - BabylonJS mesh.
  78674. * @param animation - animation.
  78675. * @param animationChannelTargetPath - The target animation channel.
  78676. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78677. * @param useQuaternion - Specifies if quaternions are used.
  78678. * @returns nullable IAnimationData
  78679. */
  78680. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78681. private static _DeduceAnimationInfo;
  78682. /**
  78683. * @ignore
  78684. * Create node animations from the transform node animations
  78685. * @param babylonNode
  78686. * @param runtimeGLTFAnimation
  78687. * @param idleGLTFAnimations
  78688. * @param nodeMap
  78689. * @param nodes
  78690. * @param binaryWriter
  78691. * @param bufferViews
  78692. * @param accessors
  78693. * @param convertToRightHandedSystem
  78694. * @param animationSampleRate
  78695. */
  78696. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78697. [key: number]: number;
  78698. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78699. /**
  78700. * @ignore
  78701. * Create node animations from the animation groups
  78702. * @param babylonScene
  78703. * @param glTFAnimations
  78704. * @param nodeMap
  78705. * @param nodes
  78706. * @param binaryWriter
  78707. * @param bufferViews
  78708. * @param accessors
  78709. * @param convertToRightHandedSystemMap
  78710. * @param animationSampleRate
  78711. */
  78712. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78713. [key: number]: number;
  78714. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78715. [nodeId: number]: boolean;
  78716. }, animationSampleRate: number): void;
  78717. private static AddAnimation;
  78718. /**
  78719. * Create a baked animation
  78720. * @param babylonTransformNode BabylonJS mesh
  78721. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78722. * @param animationChannelTargetPath animation target channel
  78723. * @param minFrame minimum animation frame
  78724. * @param maxFrame maximum animation frame
  78725. * @param fps frames per second of the animation
  78726. * @param inputs input key frames of the animation
  78727. * @param outputs output key frame data of the animation
  78728. * @param convertToRightHandedSystem converts the values to right-handed
  78729. * @param useQuaternion specifies if quaternions should be used
  78730. */
  78731. private static _CreateBakedAnimation;
  78732. private static _ConvertFactorToVector3OrQuaternion;
  78733. private static _SetInterpolatedValue;
  78734. /**
  78735. * Creates linear animation from the animation key frames
  78736. * @param babylonTransformNode BabylonJS mesh
  78737. * @param animation BabylonJS animation
  78738. * @param animationChannelTargetPath The target animation channel
  78739. * @param frameDelta The difference between the last and first frame of the animation
  78740. * @param inputs Array to store the key frame times
  78741. * @param outputs Array to store the key frame data
  78742. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78743. * @param useQuaternion Specifies if quaternions are used in the animation
  78744. */
  78745. private static _CreateLinearOrStepAnimation;
  78746. /**
  78747. * Creates cubic spline animation from the animation key frames
  78748. * @param babylonTransformNode BabylonJS mesh
  78749. * @param animation BabylonJS animation
  78750. * @param animationChannelTargetPath The target animation channel
  78751. * @param frameDelta The difference between the last and first frame of the animation
  78752. * @param inputs Array to store the key frame times
  78753. * @param outputs Array to store the key frame data
  78754. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78755. * @param useQuaternion Specifies if quaternions are used in the animation
  78756. */
  78757. private static _CreateCubicSplineAnimation;
  78758. private static _GetBasePositionRotationOrScale;
  78759. /**
  78760. * Adds a key frame value
  78761. * @param keyFrame
  78762. * @param animation
  78763. * @param outputs
  78764. * @param animationChannelTargetPath
  78765. * @param basePositionRotationOrScale
  78766. * @param convertToRightHandedSystem
  78767. * @param useQuaternion
  78768. */
  78769. private static _AddKeyframeValue;
  78770. /**
  78771. * Determine the interpolation based on the key frames
  78772. * @param keyFrames
  78773. * @param animationChannelTargetPath
  78774. * @param useQuaternion
  78775. */
  78776. private static _DeduceInterpolation;
  78777. /**
  78778. * Adds an input tangent or output tangent to the output data
  78779. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78780. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78781. * @param outputs The animation data by keyframe
  78782. * @param animationChannelTargetPath The target animation channel
  78783. * @param interpolation The interpolation type
  78784. * @param keyFrame The key frame with the animation data
  78785. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78786. * @param useQuaternion Specifies if quaternions are used
  78787. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78788. */
  78789. private static AddSplineTangent;
  78790. /**
  78791. * Get the minimum and maximum key frames' frame values
  78792. * @param keyFrames animation key frames
  78793. * @returns the minimum and maximum key frame value
  78794. */
  78795. private static calculateMinMaxKeyFrames;
  78796. }
  78797. }
  78798. declare module BABYLON.GLTF2.Exporter {
  78799. /** @hidden */
  78800. export var textureTransformPixelShader: {
  78801. name: string;
  78802. shader: string;
  78803. };
  78804. }
  78805. declare module BABYLON.GLTF2.Exporter.Extensions {
  78806. /**
  78807. * @hidden
  78808. */
  78809. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78810. private _recordedTextures;
  78811. /** Name of this extension */
  78812. readonly name: string;
  78813. /** Defines whether this extension is enabled */
  78814. enabled: boolean;
  78815. /** Defines whether this extension is required */
  78816. required: boolean;
  78817. /** Reference to the glTF exporter */
  78818. private _wasUsed;
  78819. constructor(exporter: _Exporter);
  78820. dispose(): void;
  78821. /** @hidden */
  78822. get wasUsed(): boolean;
  78823. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78824. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78825. /**
  78826. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78827. * @param babylonTexture
  78828. * @param offset
  78829. * @param rotation
  78830. * @param scale
  78831. * @param scene
  78832. */
  78833. private _textureTransformTextureAsync;
  78834. }
  78835. }
  78836. declare module BABYLON.GLTF2.Exporter.Extensions {
  78837. /**
  78838. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78839. */
  78840. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78841. /** The name of this extension. */
  78842. readonly name: string;
  78843. /** Defines whether this extension is enabled. */
  78844. enabled: boolean;
  78845. /** Defines whether this extension is required */
  78846. required: boolean;
  78847. /** Reference to the glTF exporter */
  78848. private _exporter;
  78849. private _lights;
  78850. /** @hidden */
  78851. constructor(exporter: _Exporter);
  78852. /** @hidden */
  78853. dispose(): void;
  78854. /** @hidden */
  78855. get wasUsed(): boolean;
  78856. /** @hidden */
  78857. onExporting(): void;
  78858. /**
  78859. * Define this method to modify the default behavior when exporting a node
  78860. * @param context The context when exporting the node
  78861. * @param node glTF node
  78862. * @param babylonNode BabylonJS node
  78863. * @param nodeMap Node mapping of unique id to glTF node index
  78864. * @returns nullable INode promise
  78865. */
  78866. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78867. [key: number]: number;
  78868. }): Promise<Nullable<INode>>;
  78869. }
  78870. }
  78871. declare module BABYLON.GLTF2.Exporter.Extensions {
  78872. /**
  78873. * @hidden
  78874. */
  78875. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78876. /** Name of this extension */
  78877. readonly name: string;
  78878. /** Defines whether this extension is enabled */
  78879. enabled: boolean;
  78880. /** Defines whether this extension is required */
  78881. required: boolean;
  78882. /** Reference to the glTF exporter */
  78883. private _textureInfos;
  78884. private _exportedTextures;
  78885. private _wasUsed;
  78886. constructor(exporter: _Exporter);
  78887. dispose(): void;
  78888. /** @hidden */
  78889. get wasUsed(): boolean;
  78890. private _getTextureIndex;
  78891. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78892. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78893. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78894. }
  78895. }
  78896. declare module BABYLON {
  78897. /**
  78898. * Class for generating STL data from a Babylon scene.
  78899. */
  78900. export class STLExport {
  78901. /**
  78902. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78903. * @param meshes list defines the mesh to serialize
  78904. * @param download triggers the automatic download of the file.
  78905. * @param fileName changes the downloads fileName.
  78906. * @param binary changes the STL to a binary type.
  78907. * @param isLittleEndian toggle for binary type exporter.
  78908. * @returns the STL as UTF8 string
  78909. */
  78910. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78911. }
  78912. }
  78913. declare module "babylonjs-gltf2interface" {
  78914. export = BABYLON.GLTF2;
  78915. }
  78916. /**
  78917. * Module for glTF 2.0 Interface
  78918. */
  78919. declare module BABYLON.GLTF2 {
  78920. /**
  78921. * The datatype of the components in the attribute
  78922. */
  78923. const enum AccessorComponentType {
  78924. /**
  78925. * Byte
  78926. */
  78927. BYTE = 5120,
  78928. /**
  78929. * Unsigned Byte
  78930. */
  78931. UNSIGNED_BYTE = 5121,
  78932. /**
  78933. * Short
  78934. */
  78935. SHORT = 5122,
  78936. /**
  78937. * Unsigned Short
  78938. */
  78939. UNSIGNED_SHORT = 5123,
  78940. /**
  78941. * Unsigned Int
  78942. */
  78943. UNSIGNED_INT = 5125,
  78944. /**
  78945. * Float
  78946. */
  78947. FLOAT = 5126,
  78948. }
  78949. /**
  78950. * Specifies if the attirbute is a scalar, vector, or matrix
  78951. */
  78952. const enum AccessorType {
  78953. /**
  78954. * Scalar
  78955. */
  78956. SCALAR = "SCALAR",
  78957. /**
  78958. * Vector2
  78959. */
  78960. VEC2 = "VEC2",
  78961. /**
  78962. * Vector3
  78963. */
  78964. VEC3 = "VEC3",
  78965. /**
  78966. * Vector4
  78967. */
  78968. VEC4 = "VEC4",
  78969. /**
  78970. * Matrix2x2
  78971. */
  78972. MAT2 = "MAT2",
  78973. /**
  78974. * Matrix3x3
  78975. */
  78976. MAT3 = "MAT3",
  78977. /**
  78978. * Matrix4x4
  78979. */
  78980. MAT4 = "MAT4",
  78981. }
  78982. /**
  78983. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78984. */
  78985. const enum AnimationChannelTargetPath {
  78986. /**
  78987. * Translation
  78988. */
  78989. TRANSLATION = "translation",
  78990. /**
  78991. * Rotation
  78992. */
  78993. ROTATION = "rotation",
  78994. /**
  78995. * Scale
  78996. */
  78997. SCALE = "scale",
  78998. /**
  78999. * Weights
  79000. */
  79001. WEIGHTS = "weights",
  79002. }
  79003. /**
  79004. * Interpolation algorithm
  79005. */
  79006. const enum AnimationSamplerInterpolation {
  79007. /**
  79008. * The animated values are linearly interpolated between keyframes
  79009. */
  79010. LINEAR = "LINEAR",
  79011. /**
  79012. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  79013. */
  79014. STEP = "STEP",
  79015. /**
  79016. * The animation's interpolation is computed using a cubic spline with specified tangents
  79017. */
  79018. CUBICSPLINE = "CUBICSPLINE",
  79019. }
  79020. /**
  79021. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79022. */
  79023. const enum CameraType {
  79024. /**
  79025. * A perspective camera containing properties to create a perspective projection matrix
  79026. */
  79027. PERSPECTIVE = "perspective",
  79028. /**
  79029. * An orthographic camera containing properties to create an orthographic projection matrix
  79030. */
  79031. ORTHOGRAPHIC = "orthographic",
  79032. }
  79033. /**
  79034. * The mime-type of the image
  79035. */
  79036. const enum ImageMimeType {
  79037. /**
  79038. * JPEG Mime-type
  79039. */
  79040. JPEG = "image/jpeg",
  79041. /**
  79042. * PNG Mime-type
  79043. */
  79044. PNG = "image/png",
  79045. }
  79046. /**
  79047. * The alpha rendering mode of the material
  79048. */
  79049. const enum MaterialAlphaMode {
  79050. /**
  79051. * The alpha value is ignored and the rendered output is fully opaque
  79052. */
  79053. OPAQUE = "OPAQUE",
  79054. /**
  79055. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  79056. */
  79057. MASK = "MASK",
  79058. /**
  79059. * 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)
  79060. */
  79061. BLEND = "BLEND",
  79062. }
  79063. /**
  79064. * The type of the primitives to render
  79065. */
  79066. const enum MeshPrimitiveMode {
  79067. /**
  79068. * Points
  79069. */
  79070. POINTS = 0,
  79071. /**
  79072. * Lines
  79073. */
  79074. LINES = 1,
  79075. /**
  79076. * Line Loop
  79077. */
  79078. LINE_LOOP = 2,
  79079. /**
  79080. * Line Strip
  79081. */
  79082. LINE_STRIP = 3,
  79083. /**
  79084. * Triangles
  79085. */
  79086. TRIANGLES = 4,
  79087. /**
  79088. * Triangle Strip
  79089. */
  79090. TRIANGLE_STRIP = 5,
  79091. /**
  79092. * Triangle Fan
  79093. */
  79094. TRIANGLE_FAN = 6,
  79095. }
  79096. /**
  79097. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79098. */
  79099. const enum TextureMagFilter {
  79100. /**
  79101. * Nearest
  79102. */
  79103. NEAREST = 9728,
  79104. /**
  79105. * Linear
  79106. */
  79107. LINEAR = 9729,
  79108. }
  79109. /**
  79110. * Minification filter. All valid values correspond to WebGL enums
  79111. */
  79112. const enum TextureMinFilter {
  79113. /**
  79114. * Nearest
  79115. */
  79116. NEAREST = 9728,
  79117. /**
  79118. * Linear
  79119. */
  79120. LINEAR = 9729,
  79121. /**
  79122. * Nearest Mip-Map Nearest
  79123. */
  79124. NEAREST_MIPMAP_NEAREST = 9984,
  79125. /**
  79126. * Linear Mipmap Nearest
  79127. */
  79128. LINEAR_MIPMAP_NEAREST = 9985,
  79129. /**
  79130. * Nearest Mipmap Linear
  79131. */
  79132. NEAREST_MIPMAP_LINEAR = 9986,
  79133. /**
  79134. * Linear Mipmap Linear
  79135. */
  79136. LINEAR_MIPMAP_LINEAR = 9987,
  79137. }
  79138. /**
  79139. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79140. */
  79141. const enum TextureWrapMode {
  79142. /**
  79143. * Clamp to Edge
  79144. */
  79145. CLAMP_TO_EDGE = 33071,
  79146. /**
  79147. * Mirrored Repeat
  79148. */
  79149. MIRRORED_REPEAT = 33648,
  79150. /**
  79151. * Repeat
  79152. */
  79153. REPEAT = 10497,
  79154. }
  79155. /**
  79156. * glTF Property
  79157. */
  79158. interface IProperty {
  79159. /**
  79160. * Dictionary object with extension-specific objects
  79161. */
  79162. extensions?: {
  79163. [key: string]: any;
  79164. };
  79165. /**
  79166. * Application-Specific data
  79167. */
  79168. extras?: any;
  79169. }
  79170. /**
  79171. * glTF Child of Root Property
  79172. */
  79173. interface IChildRootProperty extends IProperty {
  79174. /**
  79175. * The user-defined name of this object
  79176. */
  79177. name?: string;
  79178. }
  79179. /**
  79180. * Indices of those attributes that deviate from their initialization value
  79181. */
  79182. interface IAccessorSparseIndices extends IProperty {
  79183. /**
  79184. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79185. */
  79186. bufferView: number;
  79187. /**
  79188. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79189. */
  79190. byteOffset?: number;
  79191. /**
  79192. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  79193. */
  79194. componentType: AccessorComponentType;
  79195. }
  79196. /**
  79197. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  79198. */
  79199. interface IAccessorSparseValues extends IProperty {
  79200. /**
  79201. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79202. */
  79203. bufferView: number;
  79204. /**
  79205. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79206. */
  79207. byteOffset?: number;
  79208. }
  79209. /**
  79210. * Sparse storage of attributes that deviate from their initialization value
  79211. */
  79212. interface IAccessorSparse extends IProperty {
  79213. /**
  79214. * The number of attributes encoded in this sparse accessor
  79215. */
  79216. count: number;
  79217. /**
  79218. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  79219. */
  79220. indices: IAccessorSparseIndices;
  79221. /**
  79222. * 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
  79223. */
  79224. values: IAccessorSparseValues;
  79225. }
  79226. /**
  79227. * 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
  79228. */
  79229. interface IAccessor extends IChildRootProperty {
  79230. /**
  79231. * The index of the bufferview
  79232. */
  79233. bufferView?: number;
  79234. /**
  79235. * The offset relative to the start of the bufferView in bytes
  79236. */
  79237. byteOffset?: number;
  79238. /**
  79239. * The datatype of components in the attribute
  79240. */
  79241. componentType: AccessorComponentType;
  79242. /**
  79243. * Specifies whether integer data values should be normalized
  79244. */
  79245. normalized?: boolean;
  79246. /**
  79247. * The number of attributes referenced by this accessor
  79248. */
  79249. count: number;
  79250. /**
  79251. * Specifies if the attribute is a scalar, vector, or matrix
  79252. */
  79253. type: AccessorType;
  79254. /**
  79255. * Maximum value of each component in this attribute
  79256. */
  79257. max?: number[];
  79258. /**
  79259. * Minimum value of each component in this attribute
  79260. */
  79261. min?: number[];
  79262. /**
  79263. * Sparse storage of attributes that deviate from their initialization value
  79264. */
  79265. sparse?: IAccessorSparse;
  79266. }
  79267. /**
  79268. * Targets an animation's sampler at a node's property
  79269. */
  79270. interface IAnimationChannel extends IProperty {
  79271. /**
  79272. * The index of a sampler in this animation used to compute the value for the target
  79273. */
  79274. sampler: number;
  79275. /**
  79276. * The index of the node and TRS property to target
  79277. */
  79278. target: IAnimationChannelTarget;
  79279. }
  79280. /**
  79281. * The index of the node and TRS property that an animation channel targets
  79282. */
  79283. interface IAnimationChannelTarget extends IProperty {
  79284. /**
  79285. * The index of the node to target
  79286. */
  79287. node: number;
  79288. /**
  79289. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  79290. */
  79291. path: AnimationChannelTargetPath;
  79292. }
  79293. /**
  79294. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79295. */
  79296. interface IAnimationSampler extends IProperty {
  79297. /**
  79298. * The index of an accessor containing keyframe input values, e.g., time
  79299. */
  79300. input: number;
  79301. /**
  79302. * Interpolation algorithm
  79303. */
  79304. interpolation?: AnimationSamplerInterpolation;
  79305. /**
  79306. * The index of an accessor, containing keyframe output values
  79307. */
  79308. output: number;
  79309. }
  79310. /**
  79311. * A keyframe animation
  79312. */
  79313. interface IAnimation extends IChildRootProperty {
  79314. /**
  79315. * An array of channels, each of which targets an animation's sampler at a node's property
  79316. */
  79317. channels: IAnimationChannel[];
  79318. /**
  79319. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79320. */
  79321. samplers: IAnimationSampler[];
  79322. }
  79323. /**
  79324. * Metadata about the glTF asset
  79325. */
  79326. interface IAsset extends IChildRootProperty {
  79327. /**
  79328. * A copyright message suitable for display to credit the content creator
  79329. */
  79330. copyright?: string;
  79331. /**
  79332. * Tool that generated this glTF model. Useful for debugging
  79333. */
  79334. generator?: string;
  79335. /**
  79336. * The glTF version that this asset targets
  79337. */
  79338. version: string;
  79339. /**
  79340. * The minimum glTF version that this asset targets
  79341. */
  79342. minVersion?: string;
  79343. }
  79344. /**
  79345. * A buffer points to binary geometry, animation, or skins
  79346. */
  79347. interface IBuffer extends IChildRootProperty {
  79348. /**
  79349. * 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
  79350. */
  79351. uri?: string;
  79352. /**
  79353. * The length of the buffer in bytes
  79354. */
  79355. byteLength: number;
  79356. }
  79357. /**
  79358. * A view into a buffer generally representing a subset of the buffer
  79359. */
  79360. interface IBufferView extends IChildRootProperty {
  79361. /**
  79362. * The index of the buffer
  79363. */
  79364. buffer: number;
  79365. /**
  79366. * The offset into the buffer in bytes
  79367. */
  79368. byteOffset?: number;
  79369. /**
  79370. * The lenth of the bufferView in bytes
  79371. */
  79372. byteLength: number;
  79373. /**
  79374. * The stride, in bytes
  79375. */
  79376. byteStride?: number;
  79377. }
  79378. /**
  79379. * An orthographic camera containing properties to create an orthographic projection matrix
  79380. */
  79381. interface ICameraOrthographic extends IProperty {
  79382. /**
  79383. * The floating-point horizontal magnification of the view. Must not be zero
  79384. */
  79385. xmag: number;
  79386. /**
  79387. * The floating-point vertical magnification of the view. Must not be zero
  79388. */
  79389. ymag: number;
  79390. /**
  79391. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  79392. */
  79393. zfar: number;
  79394. /**
  79395. * The floating-point distance to the near clipping plane
  79396. */
  79397. znear: number;
  79398. }
  79399. /**
  79400. * A perspective camera containing properties to create a perspective projection matrix
  79401. */
  79402. interface ICameraPerspective extends IProperty {
  79403. /**
  79404. * The floating-point aspect ratio of the field of view
  79405. */
  79406. aspectRatio?: number;
  79407. /**
  79408. * The floating-point vertical field of view in radians
  79409. */
  79410. yfov: number;
  79411. /**
  79412. * The floating-point distance to the far clipping plane
  79413. */
  79414. zfar?: number;
  79415. /**
  79416. * The floating-point distance to the near clipping plane
  79417. */
  79418. znear: number;
  79419. }
  79420. /**
  79421. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79422. */
  79423. interface ICamera extends IChildRootProperty {
  79424. /**
  79425. * An orthographic camera containing properties to create an orthographic projection matrix
  79426. */
  79427. orthographic?: ICameraOrthographic;
  79428. /**
  79429. * A perspective camera containing properties to create a perspective projection matrix
  79430. */
  79431. perspective?: ICameraPerspective;
  79432. /**
  79433. * Specifies if the camera uses a perspective or orthographic projection
  79434. */
  79435. type: CameraType;
  79436. }
  79437. /**
  79438. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79439. */
  79440. interface IImage extends IChildRootProperty {
  79441. /**
  79442. * 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
  79443. */
  79444. uri?: string;
  79445. /**
  79446. * The image's MIME type
  79447. */
  79448. mimeType?: ImageMimeType;
  79449. /**
  79450. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79451. */
  79452. bufferView?: number;
  79453. }
  79454. /**
  79455. * Material Normal Texture Info
  79456. */
  79457. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79458. /**
  79459. * The scalar multiplier applied to each normal vector of the normal texture
  79460. */
  79461. scale?: number;
  79462. }
  79463. /**
  79464. * Material Occlusion Texture Info
  79465. */
  79466. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79467. /**
  79468. * A scalar multiplier controlling the amount of occlusion applied
  79469. */
  79470. strength?: number;
  79471. }
  79472. /**
  79473. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79474. */
  79475. interface IMaterialPbrMetallicRoughness {
  79476. /**
  79477. * The material's base color factor
  79478. */
  79479. baseColorFactor?: number[];
  79480. /**
  79481. * The base color texture
  79482. */
  79483. baseColorTexture?: ITextureInfo;
  79484. /**
  79485. * The metalness of the material
  79486. */
  79487. metallicFactor?: number;
  79488. /**
  79489. * The roughness of the material
  79490. */
  79491. roughnessFactor?: number;
  79492. /**
  79493. * The metallic-roughness texture
  79494. */
  79495. metallicRoughnessTexture?: ITextureInfo;
  79496. }
  79497. /**
  79498. * The material appearance of a primitive
  79499. */
  79500. interface IMaterial extends IChildRootProperty {
  79501. /**
  79502. * 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
  79503. */
  79504. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79505. /**
  79506. * The normal map texture
  79507. */
  79508. normalTexture?: IMaterialNormalTextureInfo;
  79509. /**
  79510. * The occlusion map texture
  79511. */
  79512. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79513. /**
  79514. * The emissive map texture
  79515. */
  79516. emissiveTexture?: ITextureInfo;
  79517. /**
  79518. * 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
  79519. */
  79520. emissiveFactor?: number[];
  79521. /**
  79522. * The alpha rendering mode of the material
  79523. */
  79524. alphaMode?: MaterialAlphaMode;
  79525. /**
  79526. * The alpha cutoff value of the material
  79527. */
  79528. alphaCutoff?: number;
  79529. /**
  79530. * Specifies whether the material is double sided
  79531. */
  79532. doubleSided?: boolean;
  79533. }
  79534. /**
  79535. * Geometry to be rendered with the given material
  79536. */
  79537. interface IMeshPrimitive extends IProperty {
  79538. /**
  79539. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79540. */
  79541. attributes: {
  79542. [name: string]: number;
  79543. };
  79544. /**
  79545. * The index of the accessor that contains the indices
  79546. */
  79547. indices?: number;
  79548. /**
  79549. * The index of the material to apply to this primitive when rendering
  79550. */
  79551. material?: number;
  79552. /**
  79553. * The type of primitives to render. All valid values correspond to WebGL enums
  79554. */
  79555. mode?: MeshPrimitiveMode;
  79556. /**
  79557. * 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
  79558. */
  79559. targets?: {
  79560. [name: string]: number;
  79561. }[];
  79562. }
  79563. /**
  79564. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79565. */
  79566. interface IMesh extends IChildRootProperty {
  79567. /**
  79568. * An array of primitives, each defining geometry to be rendered with a material
  79569. */
  79570. primitives: IMeshPrimitive[];
  79571. /**
  79572. * Array of weights to be applied to the Morph Targets
  79573. */
  79574. weights?: number[];
  79575. }
  79576. /**
  79577. * A node in the node hierarchy
  79578. */
  79579. interface INode extends IChildRootProperty {
  79580. /**
  79581. * The index of the camera referenced by this node
  79582. */
  79583. camera?: number;
  79584. /**
  79585. * The indices of this node's children
  79586. */
  79587. children?: number[];
  79588. /**
  79589. * The index of the skin referenced by this node
  79590. */
  79591. skin?: number;
  79592. /**
  79593. * A floating-point 4x4 transformation matrix stored in column-major order
  79594. */
  79595. matrix?: number[];
  79596. /**
  79597. * The index of the mesh in this node
  79598. */
  79599. mesh?: number;
  79600. /**
  79601. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79602. */
  79603. rotation?: number[];
  79604. /**
  79605. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79606. */
  79607. scale?: number[];
  79608. /**
  79609. * The node's translation along the x, y, and z axes
  79610. */
  79611. translation?: number[];
  79612. /**
  79613. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79614. */
  79615. weights?: number[];
  79616. }
  79617. /**
  79618. * Texture sampler properties for filtering and wrapping modes
  79619. */
  79620. interface ISampler extends IChildRootProperty {
  79621. /**
  79622. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79623. */
  79624. magFilter?: TextureMagFilter;
  79625. /**
  79626. * Minification filter. All valid values correspond to WebGL enums
  79627. */
  79628. minFilter?: TextureMinFilter;
  79629. /**
  79630. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79631. */
  79632. wrapS?: TextureWrapMode;
  79633. /**
  79634. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79635. */
  79636. wrapT?: TextureWrapMode;
  79637. }
  79638. /**
  79639. * The root nodes of a scene
  79640. */
  79641. interface IScene extends IChildRootProperty {
  79642. /**
  79643. * The indices of each root node
  79644. */
  79645. nodes: number[];
  79646. }
  79647. /**
  79648. * Joints and matrices defining a skin
  79649. */
  79650. interface ISkin extends IChildRootProperty {
  79651. /**
  79652. * 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
  79653. */
  79654. inverseBindMatrices?: number;
  79655. /**
  79656. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79657. */
  79658. skeleton?: number;
  79659. /**
  79660. * 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)
  79661. */
  79662. joints: number[];
  79663. }
  79664. /**
  79665. * A texture and its sampler
  79666. */
  79667. interface ITexture extends IChildRootProperty {
  79668. /**
  79669. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79670. */
  79671. sampler?: number;
  79672. /**
  79673. * The index of the image used by this texture
  79674. */
  79675. source: number;
  79676. }
  79677. /**
  79678. * Reference to a texture
  79679. */
  79680. interface ITextureInfo extends IProperty {
  79681. /**
  79682. * The index of the texture
  79683. */
  79684. index: number;
  79685. /**
  79686. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79687. */
  79688. texCoord?: number;
  79689. }
  79690. /**
  79691. * The root object for a glTF asset
  79692. */
  79693. interface IGLTF extends IProperty {
  79694. /**
  79695. * An array of accessors. An accessor is a typed view into a bufferView
  79696. */
  79697. accessors?: IAccessor[];
  79698. /**
  79699. * An array of keyframe animations
  79700. */
  79701. animations?: IAnimation[];
  79702. /**
  79703. * Metadata about the glTF asset
  79704. */
  79705. asset: IAsset;
  79706. /**
  79707. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79708. */
  79709. buffers?: IBuffer[];
  79710. /**
  79711. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79712. */
  79713. bufferViews?: IBufferView[];
  79714. /**
  79715. * An array of cameras
  79716. */
  79717. cameras?: ICamera[];
  79718. /**
  79719. * Names of glTF extensions used somewhere in this asset
  79720. */
  79721. extensionsUsed?: string[];
  79722. /**
  79723. * Names of glTF extensions required to properly load this asset
  79724. */
  79725. extensionsRequired?: string[];
  79726. /**
  79727. * An array of images. An image defines data used to create a texture
  79728. */
  79729. images?: IImage[];
  79730. /**
  79731. * An array of materials. A material defines the appearance of a primitive
  79732. */
  79733. materials?: IMaterial[];
  79734. /**
  79735. * An array of meshes. A mesh is a set of primitives to be rendered
  79736. */
  79737. meshes?: IMesh[];
  79738. /**
  79739. * An array of nodes
  79740. */
  79741. nodes?: INode[];
  79742. /**
  79743. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79744. */
  79745. samplers?: ISampler[];
  79746. /**
  79747. * The index of the default scene
  79748. */
  79749. scene?: number;
  79750. /**
  79751. * An array of scenes
  79752. */
  79753. scenes?: IScene[];
  79754. /**
  79755. * An array of skins. A skin is defined by joints and matrices
  79756. */
  79757. skins?: ISkin[];
  79758. /**
  79759. * An array of textures
  79760. */
  79761. textures?: ITexture[];
  79762. }
  79763. /**
  79764. * The glTF validation results
  79765. * @ignore
  79766. */
  79767. interface IGLTFValidationResults {
  79768. info: {
  79769. generator: string;
  79770. hasAnimations: boolean;
  79771. hasDefaultScene: boolean;
  79772. hasMaterials: boolean;
  79773. hasMorphTargets: boolean;
  79774. hasSkins: boolean;
  79775. hasTextures: boolean;
  79776. maxAttributesUsed: number;
  79777. primitivesCount: number
  79778. };
  79779. issues: {
  79780. messages: Array<string>;
  79781. numErrors: number;
  79782. numHints: number;
  79783. numInfos: number;
  79784. numWarnings: number;
  79785. truncated: boolean
  79786. };
  79787. mimeType: string;
  79788. uri: string;
  79789. validatedAt: string;
  79790. validatorVersion: string;
  79791. }
  79792. /**
  79793. * The glTF validation options
  79794. */
  79795. interface IGLTFValidationOptions {
  79796. /** Uri to use */
  79797. uri?: string;
  79798. /** Function used to load external resources */
  79799. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79800. /** Boolean indicating that we need to validate accessor data */
  79801. validateAccessorData?: boolean;
  79802. /** max number of issues allowed */
  79803. maxIssues?: number;
  79804. /** Ignored issues */
  79805. ignoredIssues?: Array<string>;
  79806. /** Value to override severy settings */
  79807. severityOverrides?: Object;
  79808. }
  79809. /**
  79810. * The glTF validator object
  79811. * @ignore
  79812. */
  79813. interface IGLTFValidator {
  79814. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79815. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79816. }
  79817. }
  79818. declare module BABYLON {
  79819. /** @hidden */
  79820. export var cellPixelShader: {
  79821. name: string;
  79822. shader: string;
  79823. };
  79824. }
  79825. declare module BABYLON {
  79826. /** @hidden */
  79827. export var cellVertexShader: {
  79828. name: string;
  79829. shader: string;
  79830. };
  79831. }
  79832. declare module BABYLON {
  79833. export class CellMaterial extends BABYLON.PushMaterial {
  79834. private _diffuseTexture;
  79835. diffuseTexture: BABYLON.BaseTexture;
  79836. diffuseColor: BABYLON.Color3;
  79837. _computeHighLevel: boolean;
  79838. computeHighLevel: boolean;
  79839. private _disableLighting;
  79840. disableLighting: boolean;
  79841. private _maxSimultaneousLights;
  79842. maxSimultaneousLights: number;
  79843. constructor(name: string, scene: BABYLON.Scene);
  79844. needAlphaBlending(): boolean;
  79845. needAlphaTesting(): boolean;
  79846. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79847. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79848. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79849. getAnimatables(): BABYLON.IAnimatable[];
  79850. getActiveTextures(): BABYLON.BaseTexture[];
  79851. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79852. dispose(forceDisposeEffect?: boolean): void;
  79853. getClassName(): string;
  79854. clone(name: string): CellMaterial;
  79855. serialize(): any;
  79856. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79857. }
  79858. }
  79859. declare module BABYLON {
  79860. export class CustomShaderStructure {
  79861. FragmentStore: string;
  79862. VertexStore: string;
  79863. constructor();
  79864. }
  79865. export class ShaderSpecialParts {
  79866. constructor();
  79867. Fragment_Begin: string;
  79868. Fragment_Definitions: string;
  79869. Fragment_MainBegin: string;
  79870. Fragment_Custom_Diffuse: string;
  79871. Fragment_Before_Lights: string;
  79872. Fragment_Before_Fog: string;
  79873. Fragment_Custom_Alpha: string;
  79874. Fragment_Before_FragColor: string;
  79875. Vertex_Begin: string;
  79876. Vertex_Definitions: string;
  79877. Vertex_MainBegin: string;
  79878. Vertex_Before_PositionUpdated: string;
  79879. Vertex_Before_NormalUpdated: string;
  79880. Vertex_After_WorldPosComputed: string;
  79881. Vertex_MainEnd: string;
  79882. }
  79883. export class CustomMaterial extends BABYLON.StandardMaterial {
  79884. static ShaderIndexer: number;
  79885. CustomParts: ShaderSpecialParts;
  79886. _isCreatedShader: boolean;
  79887. _createdShaderName: string;
  79888. _customUniform: string[];
  79889. _newUniforms: string[];
  79890. _newUniformInstances: {
  79891. [name: string]: any;
  79892. };
  79893. _newSamplerInstances: {
  79894. [name: string]: BABYLON.Texture;
  79895. };
  79896. _customAttributes: string[];
  79897. FragmentShader: string;
  79898. VertexShader: string;
  79899. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79900. ReviewUniform(name: string, arr: string[]): string[];
  79901. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79902. constructor(name: string, scene: BABYLON.Scene);
  79903. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79904. AddAttribute(name: string): CustomMaterial;
  79905. Fragment_Begin(shaderPart: string): CustomMaterial;
  79906. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79907. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79908. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79909. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79910. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79911. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79912. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79913. Vertex_Begin(shaderPart: string): CustomMaterial;
  79914. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79915. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79916. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79917. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79918. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  79919. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79920. }
  79921. }
  79922. declare module BABYLON {
  79923. export class ShaderAlebdoParts {
  79924. constructor();
  79925. Fragment_Begin: string;
  79926. Fragment_Definitions: string;
  79927. Fragment_MainBegin: string;
  79928. Fragment_Custom_Albedo: string;
  79929. Fragment_Before_Lights: string;
  79930. Fragment_Custom_MetallicRoughness: string;
  79931. Fragment_Custom_MicroSurface: string;
  79932. Fragment_Before_Fog: string;
  79933. Fragment_Custom_Alpha: string;
  79934. Fragment_Before_FragColor: string;
  79935. Vertex_Begin: string;
  79936. Vertex_Definitions: string;
  79937. Vertex_MainBegin: string;
  79938. Vertex_Before_PositionUpdated: string;
  79939. Vertex_Before_NormalUpdated: string;
  79940. Vertex_After_WorldPosComputed: string;
  79941. Vertex_MainEnd: string;
  79942. }
  79943. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79944. static ShaderIndexer: number;
  79945. CustomParts: ShaderAlebdoParts;
  79946. _isCreatedShader: boolean;
  79947. _createdShaderName: string;
  79948. _customUniform: string[];
  79949. _newUniforms: string[];
  79950. _newUniformInstances: {
  79951. [name: string]: any;
  79952. };
  79953. _newSamplerInstances: {
  79954. [name: string]: BABYLON.Texture;
  79955. };
  79956. _customAttributes: string[];
  79957. FragmentShader: string;
  79958. VertexShader: string;
  79959. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79960. ReviewUniform(name: string, arr: string[]): string[];
  79961. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79962. constructor(name: string, scene: BABYLON.Scene);
  79963. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79964. AddAttribute(name: string): PBRCustomMaterial;
  79965. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79966. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79967. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79968. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79969. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79970. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79971. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79972. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79973. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79974. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79975. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79976. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79977. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79978. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79979. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79980. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  79981. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79982. }
  79983. }
  79984. declare module BABYLON {
  79985. /** @hidden */
  79986. export var firePixelShader: {
  79987. name: string;
  79988. shader: string;
  79989. };
  79990. }
  79991. declare module BABYLON {
  79992. /** @hidden */
  79993. export var fireVertexShader: {
  79994. name: string;
  79995. shader: string;
  79996. };
  79997. }
  79998. declare module BABYLON {
  79999. export class FireMaterial extends BABYLON.PushMaterial {
  80000. private _diffuseTexture;
  80001. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80002. private _distortionTexture;
  80003. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80004. private _opacityTexture;
  80005. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80006. diffuseColor: BABYLON.Color3;
  80007. speed: number;
  80008. private _scaledDiffuse;
  80009. private _lastTime;
  80010. constructor(name: string, scene: BABYLON.Scene);
  80011. needAlphaBlending(): boolean;
  80012. needAlphaTesting(): boolean;
  80013. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80014. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80015. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80016. getAnimatables(): BABYLON.IAnimatable[];
  80017. getActiveTextures(): BABYLON.BaseTexture[];
  80018. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80019. getClassName(): string;
  80020. dispose(forceDisposeEffect?: boolean): void;
  80021. clone(name: string): FireMaterial;
  80022. serialize(): any;
  80023. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  80024. }
  80025. }
  80026. declare module BABYLON {
  80027. /** @hidden */
  80028. export var furPixelShader: {
  80029. name: string;
  80030. shader: string;
  80031. };
  80032. }
  80033. declare module BABYLON {
  80034. /** @hidden */
  80035. export var furVertexShader: {
  80036. name: string;
  80037. shader: string;
  80038. };
  80039. }
  80040. declare module BABYLON {
  80041. export class FurMaterial extends BABYLON.PushMaterial {
  80042. private _diffuseTexture;
  80043. diffuseTexture: BABYLON.BaseTexture;
  80044. private _heightTexture;
  80045. heightTexture: BABYLON.BaseTexture;
  80046. diffuseColor: BABYLON.Color3;
  80047. furLength: number;
  80048. furAngle: number;
  80049. furColor: BABYLON.Color3;
  80050. furOffset: number;
  80051. furSpacing: number;
  80052. furGravity: BABYLON.Vector3;
  80053. furSpeed: number;
  80054. furDensity: number;
  80055. furOcclusion: number;
  80056. furTexture: BABYLON.DynamicTexture;
  80057. private _disableLighting;
  80058. disableLighting: boolean;
  80059. private _maxSimultaneousLights;
  80060. maxSimultaneousLights: number;
  80061. highLevelFur: boolean;
  80062. _meshes: BABYLON.AbstractMesh[];
  80063. private _furTime;
  80064. constructor(name: string, scene: BABYLON.Scene);
  80065. get furTime(): number;
  80066. set furTime(furTime: number);
  80067. needAlphaBlending(): boolean;
  80068. needAlphaTesting(): boolean;
  80069. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80070. updateFur(): void;
  80071. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80072. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80073. getAnimatables(): BABYLON.IAnimatable[];
  80074. getActiveTextures(): BABYLON.BaseTexture[];
  80075. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80076. dispose(forceDisposeEffect?: boolean): void;
  80077. clone(name: string): FurMaterial;
  80078. serialize(): any;
  80079. getClassName(): string;
  80080. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  80081. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  80082. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  80083. }
  80084. }
  80085. declare module BABYLON {
  80086. /** @hidden */
  80087. export var gradientPixelShader: {
  80088. name: string;
  80089. shader: string;
  80090. };
  80091. }
  80092. declare module BABYLON {
  80093. /** @hidden */
  80094. export var gradientVertexShader: {
  80095. name: string;
  80096. shader: string;
  80097. };
  80098. }
  80099. declare module BABYLON {
  80100. export class GradientMaterial extends BABYLON.PushMaterial {
  80101. private _maxSimultaneousLights;
  80102. maxSimultaneousLights: number;
  80103. topColor: BABYLON.Color3;
  80104. topColorAlpha: number;
  80105. bottomColor: BABYLON.Color3;
  80106. bottomColorAlpha: number;
  80107. offset: number;
  80108. scale: number;
  80109. smoothness: number;
  80110. private _disableLighting;
  80111. disableLighting: boolean;
  80112. constructor(name: string, scene: BABYLON.Scene);
  80113. needAlphaBlending(): boolean;
  80114. needAlphaTesting(): boolean;
  80115. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80116. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80117. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80118. getAnimatables(): BABYLON.IAnimatable[];
  80119. dispose(forceDisposeEffect?: boolean): void;
  80120. clone(name: string): GradientMaterial;
  80121. serialize(): any;
  80122. getClassName(): string;
  80123. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  80124. }
  80125. }
  80126. declare module BABYLON {
  80127. /** @hidden */
  80128. export var gridPixelShader: {
  80129. name: string;
  80130. shader: string;
  80131. };
  80132. }
  80133. declare module BABYLON {
  80134. /** @hidden */
  80135. export var gridVertexShader: {
  80136. name: string;
  80137. shader: string;
  80138. };
  80139. }
  80140. declare module BABYLON {
  80141. /**
  80142. * The grid materials allows you to wrap any shape with a grid.
  80143. * Colors are customizable.
  80144. */
  80145. export class GridMaterial extends BABYLON.PushMaterial {
  80146. /**
  80147. * Main color of the grid (e.g. between lines)
  80148. */
  80149. mainColor: BABYLON.Color3;
  80150. /**
  80151. * Color of the grid lines.
  80152. */
  80153. lineColor: BABYLON.Color3;
  80154. /**
  80155. * The scale of the grid compared to unit.
  80156. */
  80157. gridRatio: number;
  80158. /**
  80159. * Allows setting an offset for the grid lines.
  80160. */
  80161. gridOffset: BABYLON.Vector3;
  80162. /**
  80163. * The frequency of thicker lines.
  80164. */
  80165. majorUnitFrequency: number;
  80166. /**
  80167. * The visibility of minor units in the grid.
  80168. */
  80169. minorUnitVisibility: number;
  80170. /**
  80171. * The grid opacity outside of the lines.
  80172. */
  80173. opacity: number;
  80174. /**
  80175. * Determine RBG output is premultiplied by alpha value.
  80176. */
  80177. preMultiplyAlpha: boolean;
  80178. private _opacityTexture;
  80179. opacityTexture: BABYLON.BaseTexture;
  80180. private _gridControl;
  80181. /**
  80182. * constructor
  80183. * @param name The name given to the material in order to identify it afterwards.
  80184. * @param scene The scene the material is used in.
  80185. */
  80186. constructor(name: string, scene: BABYLON.Scene);
  80187. /**
  80188. * Returns wehter or not the grid requires alpha blending.
  80189. */
  80190. needAlphaBlending(): boolean;
  80191. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80192. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80193. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80194. /**
  80195. * Dispose the material and its associated resources.
  80196. * @param forceDisposeEffect will also dispose the used effect when true
  80197. */
  80198. dispose(forceDisposeEffect?: boolean): void;
  80199. clone(name: string): GridMaterial;
  80200. serialize(): any;
  80201. getClassName(): string;
  80202. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  80203. }
  80204. }
  80205. declare module BABYLON {
  80206. /** @hidden */
  80207. export var lavaPixelShader: {
  80208. name: string;
  80209. shader: string;
  80210. };
  80211. }
  80212. declare module BABYLON {
  80213. /** @hidden */
  80214. export var lavaVertexShader: {
  80215. name: string;
  80216. shader: string;
  80217. };
  80218. }
  80219. declare module BABYLON {
  80220. export class LavaMaterial extends BABYLON.PushMaterial {
  80221. private _diffuseTexture;
  80222. diffuseTexture: BABYLON.BaseTexture;
  80223. noiseTexture: BABYLON.BaseTexture;
  80224. fogColor: BABYLON.Color3;
  80225. speed: number;
  80226. movingSpeed: number;
  80227. lowFrequencySpeed: number;
  80228. fogDensity: number;
  80229. private _lastTime;
  80230. diffuseColor: BABYLON.Color3;
  80231. private _disableLighting;
  80232. disableLighting: boolean;
  80233. private _unlit;
  80234. unlit: boolean;
  80235. private _maxSimultaneousLights;
  80236. maxSimultaneousLights: number;
  80237. private _scaledDiffuse;
  80238. constructor(name: string, scene: BABYLON.Scene);
  80239. needAlphaBlending(): boolean;
  80240. needAlphaTesting(): boolean;
  80241. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80242. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80243. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80244. getAnimatables(): BABYLON.IAnimatable[];
  80245. getActiveTextures(): BABYLON.BaseTexture[];
  80246. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80247. dispose(forceDisposeEffect?: boolean): void;
  80248. clone(name: string): LavaMaterial;
  80249. serialize(): any;
  80250. getClassName(): string;
  80251. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  80252. }
  80253. }
  80254. declare module BABYLON {
  80255. /** @hidden */
  80256. export var mixPixelShader: {
  80257. name: string;
  80258. shader: string;
  80259. };
  80260. }
  80261. declare module BABYLON {
  80262. /** @hidden */
  80263. export var mixVertexShader: {
  80264. name: string;
  80265. shader: string;
  80266. };
  80267. }
  80268. declare module BABYLON {
  80269. export class MixMaterial extends BABYLON.PushMaterial {
  80270. /**
  80271. * Mix textures
  80272. */
  80273. private _mixTexture1;
  80274. mixTexture1: BABYLON.BaseTexture;
  80275. private _mixTexture2;
  80276. mixTexture2: BABYLON.BaseTexture;
  80277. /**
  80278. * Diffuse textures
  80279. */
  80280. private _diffuseTexture1;
  80281. diffuseTexture1: BABYLON.Texture;
  80282. private _diffuseTexture2;
  80283. diffuseTexture2: BABYLON.Texture;
  80284. private _diffuseTexture3;
  80285. diffuseTexture3: BABYLON.Texture;
  80286. private _diffuseTexture4;
  80287. diffuseTexture4: BABYLON.Texture;
  80288. private _diffuseTexture5;
  80289. diffuseTexture5: BABYLON.Texture;
  80290. private _diffuseTexture6;
  80291. diffuseTexture6: BABYLON.Texture;
  80292. private _diffuseTexture7;
  80293. diffuseTexture7: BABYLON.Texture;
  80294. private _diffuseTexture8;
  80295. diffuseTexture8: BABYLON.Texture;
  80296. /**
  80297. * Uniforms
  80298. */
  80299. diffuseColor: BABYLON.Color3;
  80300. specularColor: BABYLON.Color3;
  80301. specularPower: number;
  80302. private _disableLighting;
  80303. disableLighting: boolean;
  80304. private _maxSimultaneousLights;
  80305. maxSimultaneousLights: number;
  80306. constructor(name: string, scene: BABYLON.Scene);
  80307. needAlphaBlending(): boolean;
  80308. needAlphaTesting(): boolean;
  80309. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80310. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80311. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80312. getAnimatables(): BABYLON.IAnimatable[];
  80313. getActiveTextures(): BABYLON.BaseTexture[];
  80314. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80315. dispose(forceDisposeEffect?: boolean): void;
  80316. clone(name: string): MixMaterial;
  80317. serialize(): any;
  80318. getClassName(): string;
  80319. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  80320. }
  80321. }
  80322. declare module BABYLON {
  80323. /** @hidden */
  80324. export var normalPixelShader: {
  80325. name: string;
  80326. shader: string;
  80327. };
  80328. }
  80329. declare module BABYLON {
  80330. /** @hidden */
  80331. export var normalVertexShader: {
  80332. name: string;
  80333. shader: string;
  80334. };
  80335. }
  80336. declare module BABYLON {
  80337. export class NormalMaterial extends BABYLON.PushMaterial {
  80338. private _diffuseTexture;
  80339. diffuseTexture: BABYLON.BaseTexture;
  80340. diffuseColor: BABYLON.Color3;
  80341. private _disableLighting;
  80342. disableLighting: boolean;
  80343. private _maxSimultaneousLights;
  80344. maxSimultaneousLights: number;
  80345. constructor(name: string, scene: BABYLON.Scene);
  80346. needAlphaBlending(): boolean;
  80347. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80348. needAlphaTesting(): boolean;
  80349. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80350. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80351. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80352. getAnimatables(): BABYLON.IAnimatable[];
  80353. getActiveTextures(): BABYLON.BaseTexture[];
  80354. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80355. dispose(forceDisposeEffect?: boolean): void;
  80356. clone(name: string): NormalMaterial;
  80357. serialize(): any;
  80358. getClassName(): string;
  80359. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  80360. }
  80361. }
  80362. declare module BABYLON {
  80363. /** @hidden */
  80364. export var shadowOnlyPixelShader: {
  80365. name: string;
  80366. shader: string;
  80367. };
  80368. }
  80369. declare module BABYLON {
  80370. /** @hidden */
  80371. export var shadowOnlyVertexShader: {
  80372. name: string;
  80373. shader: string;
  80374. };
  80375. }
  80376. declare module BABYLON {
  80377. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  80378. private _activeLight;
  80379. constructor(name: string, scene: BABYLON.Scene);
  80380. shadowColor: BABYLON.Color3;
  80381. needAlphaBlending(): boolean;
  80382. needAlphaTesting(): boolean;
  80383. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80384. get activeLight(): BABYLON.IShadowLight;
  80385. set activeLight(light: BABYLON.IShadowLight);
  80386. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80387. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80388. clone(name: string): ShadowOnlyMaterial;
  80389. serialize(): any;
  80390. getClassName(): string;
  80391. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  80392. }
  80393. }
  80394. declare module BABYLON {
  80395. /** @hidden */
  80396. export var simplePixelShader: {
  80397. name: string;
  80398. shader: string;
  80399. };
  80400. }
  80401. declare module BABYLON {
  80402. /** @hidden */
  80403. export var simpleVertexShader: {
  80404. name: string;
  80405. shader: string;
  80406. };
  80407. }
  80408. declare module BABYLON {
  80409. export class SimpleMaterial extends BABYLON.PushMaterial {
  80410. private _diffuseTexture;
  80411. diffuseTexture: BABYLON.BaseTexture;
  80412. diffuseColor: BABYLON.Color3;
  80413. private _disableLighting;
  80414. disableLighting: boolean;
  80415. private _maxSimultaneousLights;
  80416. maxSimultaneousLights: number;
  80417. constructor(name: string, scene: BABYLON.Scene);
  80418. needAlphaBlending(): boolean;
  80419. needAlphaTesting(): boolean;
  80420. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80421. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80422. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80423. getAnimatables(): BABYLON.IAnimatable[];
  80424. getActiveTextures(): BABYLON.BaseTexture[];
  80425. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80426. dispose(forceDisposeEffect?: boolean): void;
  80427. clone(name: string): SimpleMaterial;
  80428. serialize(): any;
  80429. getClassName(): string;
  80430. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  80431. }
  80432. }
  80433. declare module BABYLON {
  80434. /** @hidden */
  80435. export var skyPixelShader: {
  80436. name: string;
  80437. shader: string;
  80438. };
  80439. }
  80440. declare module BABYLON {
  80441. /** @hidden */
  80442. export var skyVertexShader: {
  80443. name: string;
  80444. shader: string;
  80445. };
  80446. }
  80447. declare module BABYLON {
  80448. /**
  80449. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80450. * @see https://doc.babylonjs.com/extensions/sky
  80451. */
  80452. export class SkyMaterial extends BABYLON.PushMaterial {
  80453. /**
  80454. * Defines the overall luminance of sky in interval ]0, 1[.
  80455. */
  80456. luminance: number;
  80457. /**
  80458. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80459. */
  80460. turbidity: number;
  80461. /**
  80462. * Defines the sky appearance (light intensity).
  80463. */
  80464. rayleigh: number;
  80465. /**
  80466. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80467. */
  80468. mieCoefficient: number;
  80469. /**
  80470. * Defines the amount of haze particles following the Mie scattering theory.
  80471. */
  80472. mieDirectionalG: number;
  80473. /**
  80474. * Defines the distance of the sun according to the active scene camera.
  80475. */
  80476. distance: number;
  80477. /**
  80478. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80479. * "inclined".
  80480. */
  80481. inclination: number;
  80482. /**
  80483. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80484. * an object direction and a reference direction.
  80485. */
  80486. azimuth: number;
  80487. /**
  80488. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80489. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80490. */
  80491. sunPosition: BABYLON.Vector3;
  80492. /**
  80493. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80494. * .sunPosition property.
  80495. */
  80496. useSunPosition: boolean;
  80497. /**
  80498. * Defines an offset vector used to get a horizon offset.
  80499. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80500. */
  80501. cameraOffset: BABYLON.Vector3;
  80502. private _cameraPosition;
  80503. /**
  80504. * Instantiates a new sky material.
  80505. * This material allows to create dynamic and texture free
  80506. * effects for skyboxes by taking care of the atmosphere state.
  80507. * @see https://doc.babylonjs.com/extensions/sky
  80508. * @param name Define the name of the material in the scene
  80509. * @param scene Define the scene the material belong to
  80510. */
  80511. constructor(name: string, scene: BABYLON.Scene);
  80512. /**
  80513. * Specifies if the material will require alpha blending
  80514. * @returns a boolean specifying if alpha blending is needed
  80515. */
  80516. needAlphaBlending(): boolean;
  80517. /**
  80518. * Specifies if this material should be rendered in alpha test mode
  80519. * @returns false as the sky material doesn't need alpha testing.
  80520. */
  80521. needAlphaTesting(): boolean;
  80522. /**
  80523. * Get the texture used for alpha test purpose.
  80524. * @returns null as the sky material has no texture.
  80525. */
  80526. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80527. /**
  80528. * Get if the submesh is ready to be used and all its information available.
  80529. * Child classes can use it to update shaders
  80530. * @param mesh defines the mesh to check
  80531. * @param subMesh defines which submesh to check
  80532. * @param useInstances specifies that instances should be used
  80533. * @returns a boolean indicating that the submesh is ready or not
  80534. */
  80535. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80536. /**
  80537. * Binds the submesh to this material by preparing the effect and shader to draw
  80538. * @param world defines the world transformation matrix
  80539. * @param mesh defines the mesh containing the submesh
  80540. * @param subMesh defines the submesh to bind the material to
  80541. */
  80542. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80543. /**
  80544. * Get the list of animatables in the material.
  80545. * @returns the list of animatables object used in the material
  80546. */
  80547. getAnimatables(): BABYLON.IAnimatable[];
  80548. /**
  80549. * Disposes the material
  80550. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80551. */
  80552. dispose(forceDisposeEffect?: boolean): void;
  80553. /**
  80554. * Makes a duplicate of the material, and gives it a new name
  80555. * @param name defines the new name for the duplicated material
  80556. * @returns the cloned material
  80557. */
  80558. clone(name: string): SkyMaterial;
  80559. /**
  80560. * Serializes this material in a JSON representation
  80561. * @returns the serialized material object
  80562. */
  80563. serialize(): any;
  80564. /**
  80565. * Gets the current class name of the material e.g. "SkyMaterial"
  80566. * Mainly use in serialization.
  80567. * @returns the class name
  80568. */
  80569. getClassName(): string;
  80570. /**
  80571. * Creates a sky material from parsed material data
  80572. * @param source defines the JSON representation of the material
  80573. * @param scene defines the hosting scene
  80574. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80575. * @returns a new sky material
  80576. */
  80577. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80578. }
  80579. }
  80580. declare module BABYLON {
  80581. /** @hidden */
  80582. export var terrainPixelShader: {
  80583. name: string;
  80584. shader: string;
  80585. };
  80586. }
  80587. declare module BABYLON {
  80588. /** @hidden */
  80589. export var terrainVertexShader: {
  80590. name: string;
  80591. shader: string;
  80592. };
  80593. }
  80594. declare module BABYLON {
  80595. export class TerrainMaterial extends BABYLON.PushMaterial {
  80596. private _mixTexture;
  80597. mixTexture: BABYLON.BaseTexture;
  80598. private _diffuseTexture1;
  80599. diffuseTexture1: BABYLON.Texture;
  80600. private _diffuseTexture2;
  80601. diffuseTexture2: BABYLON.Texture;
  80602. private _diffuseTexture3;
  80603. diffuseTexture3: BABYLON.Texture;
  80604. private _bumpTexture1;
  80605. bumpTexture1: BABYLON.Texture;
  80606. private _bumpTexture2;
  80607. bumpTexture2: BABYLON.Texture;
  80608. private _bumpTexture3;
  80609. bumpTexture3: BABYLON.Texture;
  80610. diffuseColor: BABYLON.Color3;
  80611. specularColor: BABYLON.Color3;
  80612. specularPower: number;
  80613. private _disableLighting;
  80614. disableLighting: boolean;
  80615. private _maxSimultaneousLights;
  80616. maxSimultaneousLights: number;
  80617. constructor(name: string, scene: BABYLON.Scene);
  80618. needAlphaBlending(): boolean;
  80619. needAlphaTesting(): boolean;
  80620. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80621. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80622. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80623. getAnimatables(): BABYLON.IAnimatable[];
  80624. getActiveTextures(): BABYLON.BaseTexture[];
  80625. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80626. dispose(forceDisposeEffect?: boolean): void;
  80627. clone(name: string): TerrainMaterial;
  80628. serialize(): any;
  80629. getClassName(): string;
  80630. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80631. }
  80632. }
  80633. declare module BABYLON {
  80634. /** @hidden */
  80635. export var triplanarPixelShader: {
  80636. name: string;
  80637. shader: string;
  80638. };
  80639. }
  80640. declare module BABYLON {
  80641. /** @hidden */
  80642. export var triplanarVertexShader: {
  80643. name: string;
  80644. shader: string;
  80645. };
  80646. }
  80647. declare module BABYLON {
  80648. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80649. mixTexture: BABYLON.BaseTexture;
  80650. private _diffuseTextureX;
  80651. diffuseTextureX: BABYLON.BaseTexture;
  80652. private _diffuseTextureY;
  80653. diffuseTextureY: BABYLON.BaseTexture;
  80654. private _diffuseTextureZ;
  80655. diffuseTextureZ: BABYLON.BaseTexture;
  80656. private _normalTextureX;
  80657. normalTextureX: BABYLON.BaseTexture;
  80658. private _normalTextureY;
  80659. normalTextureY: BABYLON.BaseTexture;
  80660. private _normalTextureZ;
  80661. normalTextureZ: BABYLON.BaseTexture;
  80662. tileSize: number;
  80663. diffuseColor: BABYLON.Color3;
  80664. specularColor: BABYLON.Color3;
  80665. specularPower: number;
  80666. private _disableLighting;
  80667. disableLighting: boolean;
  80668. private _maxSimultaneousLights;
  80669. maxSimultaneousLights: number;
  80670. constructor(name: string, scene: BABYLON.Scene);
  80671. needAlphaBlending(): boolean;
  80672. needAlphaTesting(): boolean;
  80673. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80674. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80675. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80676. getAnimatables(): BABYLON.IAnimatable[];
  80677. getActiveTextures(): BABYLON.BaseTexture[];
  80678. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80679. dispose(forceDisposeEffect?: boolean): void;
  80680. clone(name: string): TriPlanarMaterial;
  80681. serialize(): any;
  80682. getClassName(): string;
  80683. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80684. }
  80685. }
  80686. declare module BABYLON {
  80687. /** @hidden */
  80688. export var waterPixelShader: {
  80689. name: string;
  80690. shader: string;
  80691. };
  80692. }
  80693. declare module BABYLON {
  80694. /** @hidden */
  80695. export var waterVertexShader: {
  80696. name: string;
  80697. shader: string;
  80698. };
  80699. }
  80700. declare module BABYLON {
  80701. export class WaterMaterial extends BABYLON.PushMaterial {
  80702. renderTargetSize: BABYLON.Vector2;
  80703. private _bumpTexture;
  80704. bumpTexture: BABYLON.BaseTexture;
  80705. diffuseColor: BABYLON.Color3;
  80706. specularColor: BABYLON.Color3;
  80707. specularPower: number;
  80708. private _disableLighting;
  80709. disableLighting: boolean;
  80710. private _maxSimultaneousLights;
  80711. maxSimultaneousLights: number;
  80712. /**
  80713. * @param {number}: Represents the wind force
  80714. */
  80715. windForce: number;
  80716. /**
  80717. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80718. */
  80719. windDirection: BABYLON.Vector2;
  80720. /**
  80721. * @param {number}: Wave height, represents the height of the waves
  80722. */
  80723. waveHeight: number;
  80724. /**
  80725. * @param {number}: Bump height, represents the bump height related to the bump map
  80726. */
  80727. bumpHeight: number;
  80728. /**
  80729. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80730. */
  80731. private _bumpSuperimpose;
  80732. bumpSuperimpose: boolean;
  80733. /**
  80734. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80735. */
  80736. private _fresnelSeparate;
  80737. fresnelSeparate: boolean;
  80738. /**
  80739. * @param {boolean}: bump Waves modify the reflection.
  80740. */
  80741. private _bumpAffectsReflection;
  80742. bumpAffectsReflection: boolean;
  80743. /**
  80744. * @param {number}: The water color blended with the refraction (near)
  80745. */
  80746. waterColor: BABYLON.Color3;
  80747. /**
  80748. * @param {number}: The blend factor related to the water color
  80749. */
  80750. colorBlendFactor: number;
  80751. /**
  80752. * @param {number}: The water color blended with the reflection (far)
  80753. */
  80754. waterColor2: BABYLON.Color3;
  80755. /**
  80756. * @param {number}: The blend factor related to the water color (reflection, far)
  80757. */
  80758. colorBlendFactor2: number;
  80759. /**
  80760. * @param {number}: Represents the maximum length of a wave
  80761. */
  80762. waveLength: number;
  80763. /**
  80764. * @param {number}: Defines the waves speed
  80765. */
  80766. waveSpeed: number;
  80767. /**
  80768. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80769. * will avoid calculating useless pixels in the pixel shader of the water material.
  80770. */
  80771. disableClipPlane: boolean;
  80772. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80773. private _mesh;
  80774. private _refractionRTT;
  80775. private _reflectionRTT;
  80776. private _reflectionTransform;
  80777. private _lastTime;
  80778. private _lastDeltaTime;
  80779. private _useLogarithmicDepth;
  80780. private _waitingRenderList;
  80781. private _imageProcessingConfiguration;
  80782. private _imageProcessingObserver;
  80783. /**
  80784. * Gets a boolean indicating that current material needs to register RTT
  80785. */
  80786. get hasRenderTargetTextures(): boolean;
  80787. /**
  80788. * Constructor
  80789. */
  80790. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80791. get useLogarithmicDepth(): boolean;
  80792. set useLogarithmicDepth(value: boolean);
  80793. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80794. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80795. addToRenderList(node: any): void;
  80796. enableRenderTargets(enable: boolean): void;
  80797. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80798. get renderTargetsEnabled(): boolean;
  80799. needAlphaBlending(): boolean;
  80800. needAlphaTesting(): boolean;
  80801. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80802. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80803. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80804. private _createRenderTargets;
  80805. getAnimatables(): BABYLON.IAnimatable[];
  80806. getActiveTextures(): BABYLON.BaseTexture[];
  80807. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80808. dispose(forceDisposeEffect?: boolean): void;
  80809. clone(name: string): WaterMaterial;
  80810. serialize(): any;
  80811. getClassName(): string;
  80812. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80813. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80814. }
  80815. }
  80816. declare module BABYLON {
  80817. /** @hidden */
  80818. export var asciiartPixelShader: {
  80819. name: string;
  80820. shader: string;
  80821. };
  80822. }
  80823. declare module BABYLON {
  80824. /**
  80825. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80826. *
  80827. * It basically takes care rendering the font front the given font size to a texture.
  80828. * This is used later on in the postprocess.
  80829. */
  80830. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80831. private _font;
  80832. private _text;
  80833. private _charSize;
  80834. /**
  80835. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80836. */
  80837. get charSize(): number;
  80838. /**
  80839. * Create a new instance of the Ascii Art FontTexture class
  80840. * @param name the name of the texture
  80841. * @param font the font to use, use the W3C CSS notation
  80842. * @param text the caracter set to use in the rendering.
  80843. * @param scene the scene that owns the texture
  80844. */
  80845. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80846. /**
  80847. * Gets the max char width of a font.
  80848. * @param font the font to use, use the W3C CSS notation
  80849. * @return the max char width
  80850. */
  80851. private getFontWidth;
  80852. /**
  80853. * Gets the max char height of a font.
  80854. * @param font the font to use, use the W3C CSS notation
  80855. * @return the max char height
  80856. */
  80857. private getFontHeight;
  80858. /**
  80859. * Clones the current AsciiArtTexture.
  80860. * @return the clone of the texture.
  80861. */
  80862. clone(): AsciiArtFontTexture;
  80863. /**
  80864. * Parses a json object representing the texture and returns an instance of it.
  80865. * @param source the source JSON representation
  80866. * @param scene the scene to create the texture for
  80867. * @return the parsed texture
  80868. */
  80869. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80870. }
  80871. /**
  80872. * Option available in the Ascii Art Post Process.
  80873. */
  80874. export interface IAsciiArtPostProcessOptions {
  80875. /**
  80876. * The font to use following the w3c font definition.
  80877. */
  80878. font?: string;
  80879. /**
  80880. * The character set to use in the postprocess.
  80881. */
  80882. characterSet?: string;
  80883. /**
  80884. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80885. * This number is defined between 0 and 1;
  80886. */
  80887. mixToTile?: number;
  80888. /**
  80889. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80890. * This number is defined between 0 and 1;
  80891. */
  80892. mixToNormal?: number;
  80893. }
  80894. /**
  80895. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80896. *
  80897. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80898. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80899. */
  80900. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80901. /**
  80902. * The font texture used to render the char in the post process.
  80903. */
  80904. private _asciiArtFontTexture;
  80905. /**
  80906. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80907. * This number is defined between 0 and 1;
  80908. */
  80909. mixToTile: number;
  80910. /**
  80911. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80912. * This number is defined between 0 and 1;
  80913. */
  80914. mixToNormal: number;
  80915. /**
  80916. * Instantiates a new Ascii Art Post Process.
  80917. * @param name the name to give to the postprocess
  80918. * @camera the camera to apply the post process to.
  80919. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80920. */
  80921. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80922. }
  80923. }
  80924. declare module BABYLON {
  80925. /** @hidden */
  80926. export var digitalrainPixelShader: {
  80927. name: string;
  80928. shader: string;
  80929. };
  80930. }
  80931. declare module BABYLON {
  80932. /**
  80933. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80934. *
  80935. * It basically takes care rendering the font front the given font size to a texture.
  80936. * This is used later on in the postprocess.
  80937. */
  80938. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80939. private _font;
  80940. private _text;
  80941. private _charSize;
  80942. /**
  80943. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80944. */
  80945. get charSize(): number;
  80946. /**
  80947. * Create a new instance of the Digital Rain FontTexture class
  80948. * @param name the name of the texture
  80949. * @param font the font to use, use the W3C CSS notation
  80950. * @param text the caracter set to use in the rendering.
  80951. * @param scene the scene that owns the texture
  80952. */
  80953. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80954. /**
  80955. * Gets the max char width of a font.
  80956. * @param font the font to use, use the W3C CSS notation
  80957. * @return the max char width
  80958. */
  80959. private getFontWidth;
  80960. /**
  80961. * Gets the max char height of a font.
  80962. * @param font the font to use, use the W3C CSS notation
  80963. * @return the max char height
  80964. */
  80965. private getFontHeight;
  80966. /**
  80967. * Clones the current DigitalRainFontTexture.
  80968. * @return the clone of the texture.
  80969. */
  80970. clone(): DigitalRainFontTexture;
  80971. /**
  80972. * Parses a json object representing the texture and returns an instance of it.
  80973. * @param source the source JSON representation
  80974. * @param scene the scene to create the texture for
  80975. * @return the parsed texture
  80976. */
  80977. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80978. }
  80979. /**
  80980. * Option available in the Digital Rain Post Process.
  80981. */
  80982. export interface IDigitalRainPostProcessOptions {
  80983. /**
  80984. * The font to use following the w3c font definition.
  80985. */
  80986. font?: string;
  80987. /**
  80988. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80989. * This number is defined between 0 and 1;
  80990. */
  80991. mixToTile?: number;
  80992. /**
  80993. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80994. * This number is defined between 0 and 1;
  80995. */
  80996. mixToNormal?: number;
  80997. }
  80998. /**
  80999. * DigitalRainPostProcess helps rendering everithing in digital rain.
  81000. *
  81001. * Simmply add it to your scene and let the nerd that lives in you have fun.
  81002. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  81003. */
  81004. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  81005. /**
  81006. * The font texture used to render the char in the post process.
  81007. */
  81008. private _digitalRainFontTexture;
  81009. /**
  81010. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  81011. * This number is defined between 0 and 1;
  81012. */
  81013. mixToTile: number;
  81014. /**
  81015. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  81016. * This number is defined between 0 and 1;
  81017. */
  81018. mixToNormal: number;
  81019. /**
  81020. * Instantiates a new Digital Rain Post Process.
  81021. * @param name the name to give to the postprocess
  81022. * @camera the camera to apply the post process to.
  81023. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  81024. */
  81025. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  81026. }
  81027. }
  81028. declare module BABYLON {
  81029. /** @hidden */
  81030. export var brickProceduralTexturePixelShader: {
  81031. name: string;
  81032. shader: string;
  81033. };
  81034. }
  81035. declare module BABYLON {
  81036. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  81037. private _numberOfBricksHeight;
  81038. private _numberOfBricksWidth;
  81039. private _jointColor;
  81040. private _brickColor;
  81041. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81042. updateShaderUniforms(): void;
  81043. get numberOfBricksHeight(): number;
  81044. set numberOfBricksHeight(value: number);
  81045. get numberOfBricksWidth(): number;
  81046. set numberOfBricksWidth(value: number);
  81047. get jointColor(): BABYLON.Color3;
  81048. set jointColor(value: BABYLON.Color3);
  81049. get brickColor(): BABYLON.Color3;
  81050. set brickColor(value: BABYLON.Color3);
  81051. /**
  81052. * Serializes this brick procedural texture
  81053. * @returns a serialized brick procedural texture object
  81054. */
  81055. serialize(): any;
  81056. /**
  81057. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  81058. * @param parsedTexture defines parsed texture data
  81059. * @param scene defines the current scene
  81060. * @param rootUrl defines the root URL containing brick procedural texture information
  81061. * @returns a parsed Brick Procedural BABYLON.Texture
  81062. */
  81063. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  81064. }
  81065. }
  81066. declare module BABYLON {
  81067. /** @hidden */
  81068. export var cloudProceduralTexturePixelShader: {
  81069. name: string;
  81070. shader: string;
  81071. };
  81072. }
  81073. declare module BABYLON {
  81074. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  81075. private _skyColor;
  81076. private _cloudColor;
  81077. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81078. updateShaderUniforms(): void;
  81079. get skyColor(): BABYLON.Color4;
  81080. set skyColor(value: BABYLON.Color4);
  81081. get cloudColor(): BABYLON.Color4;
  81082. set cloudColor(value: BABYLON.Color4);
  81083. /**
  81084. * Serializes this cloud procedural texture
  81085. * @returns a serialized cloud procedural texture object
  81086. */
  81087. serialize(): any;
  81088. /**
  81089. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  81090. * @param parsedTexture defines parsed texture data
  81091. * @param scene defines the current scene
  81092. * @param rootUrl defines the root URL containing cloud procedural texture information
  81093. * @returns a parsed Cloud Procedural BABYLON.Texture
  81094. */
  81095. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  81096. }
  81097. }
  81098. declare module BABYLON {
  81099. /** @hidden */
  81100. export var fireProceduralTexturePixelShader: {
  81101. name: string;
  81102. shader: string;
  81103. };
  81104. }
  81105. declare module BABYLON {
  81106. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  81107. private _time;
  81108. private _speed;
  81109. private _autoGenerateTime;
  81110. private _fireColors;
  81111. private _alphaThreshold;
  81112. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81113. updateShaderUniforms(): void;
  81114. render(useCameraPostProcess?: boolean): void;
  81115. static get PurpleFireColors(): BABYLON.Color3[];
  81116. static get GreenFireColors(): BABYLON.Color3[];
  81117. static get RedFireColors(): BABYLON.Color3[];
  81118. static get BlueFireColors(): BABYLON.Color3[];
  81119. get autoGenerateTime(): boolean;
  81120. set autoGenerateTime(value: boolean);
  81121. get fireColors(): BABYLON.Color3[];
  81122. set fireColors(value: BABYLON.Color3[]);
  81123. get time(): number;
  81124. set time(value: number);
  81125. get speed(): BABYLON.Vector2;
  81126. set speed(value: BABYLON.Vector2);
  81127. get alphaThreshold(): number;
  81128. set alphaThreshold(value: number);
  81129. /**
  81130. * Serializes this fire procedural texture
  81131. * @returns a serialized fire procedural texture object
  81132. */
  81133. serialize(): any;
  81134. /**
  81135. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  81136. * @param parsedTexture defines parsed texture data
  81137. * @param scene defines the current scene
  81138. * @param rootUrl defines the root URL containing fire procedural texture information
  81139. * @returns a parsed Fire Procedural BABYLON.Texture
  81140. */
  81141. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  81142. }
  81143. }
  81144. declare module BABYLON {
  81145. /** @hidden */
  81146. export var grassProceduralTexturePixelShader: {
  81147. name: string;
  81148. shader: string;
  81149. };
  81150. }
  81151. declare module BABYLON {
  81152. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  81153. private _grassColors;
  81154. private _groundColor;
  81155. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81156. updateShaderUniforms(): void;
  81157. get grassColors(): BABYLON.Color3[];
  81158. set grassColors(value: BABYLON.Color3[]);
  81159. get groundColor(): BABYLON.Color3;
  81160. set groundColor(value: BABYLON.Color3);
  81161. /**
  81162. * Serializes this grass procedural texture
  81163. * @returns a serialized grass procedural texture object
  81164. */
  81165. serialize(): any;
  81166. /**
  81167. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  81168. * @param parsedTexture defines parsed texture data
  81169. * @param scene defines the current scene
  81170. * @param rootUrl defines the root URL containing grass procedural texture information
  81171. * @returns a parsed Grass Procedural BABYLON.Texture
  81172. */
  81173. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  81174. }
  81175. }
  81176. declare module BABYLON {
  81177. /** @hidden */
  81178. export var marbleProceduralTexturePixelShader: {
  81179. name: string;
  81180. shader: string;
  81181. };
  81182. }
  81183. declare module BABYLON {
  81184. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  81185. private _numberOfTilesHeight;
  81186. private _numberOfTilesWidth;
  81187. private _amplitude;
  81188. private _jointColor;
  81189. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81190. updateShaderUniforms(): void;
  81191. get numberOfTilesHeight(): number;
  81192. set numberOfTilesHeight(value: number);
  81193. get amplitude(): number;
  81194. set amplitude(value: number);
  81195. get numberOfTilesWidth(): number;
  81196. set numberOfTilesWidth(value: number);
  81197. get jointColor(): BABYLON.Color3;
  81198. set jointColor(value: BABYLON.Color3);
  81199. /**
  81200. * Serializes this marble procedural texture
  81201. * @returns a serialized marble procedural texture object
  81202. */
  81203. serialize(): any;
  81204. /**
  81205. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  81206. * @param parsedTexture defines parsed texture data
  81207. * @param scene defines the current scene
  81208. * @param rootUrl defines the root URL containing marble procedural texture information
  81209. * @returns a parsed Marble Procedural BABYLON.Texture
  81210. */
  81211. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  81212. }
  81213. }
  81214. declare module BABYLON {
  81215. /** @hidden */
  81216. export var normalMapProceduralTexturePixelShader: {
  81217. name: string;
  81218. shader: string;
  81219. };
  81220. }
  81221. declare module BABYLON {
  81222. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  81223. private _baseTexture;
  81224. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81225. updateShaderUniforms(): void;
  81226. render(useCameraPostProcess?: boolean): void;
  81227. resize(size: any, generateMipMaps: any): void;
  81228. get baseTexture(): BABYLON.Texture;
  81229. set baseTexture(texture: BABYLON.Texture);
  81230. /**
  81231. * Serializes this normal map procedural texture
  81232. * @returns a serialized normal map procedural texture object
  81233. */
  81234. serialize(): any;
  81235. /**
  81236. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  81237. * @param parsedTexture defines parsed texture data
  81238. * @param scene defines the current scene
  81239. * @param rootUrl defines the root URL containing normal map procedural texture information
  81240. * @returns a parsed Normal Map Procedural BABYLON.Texture
  81241. */
  81242. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  81243. }
  81244. }
  81245. declare module BABYLON {
  81246. /** @hidden */
  81247. export var perlinNoiseProceduralTexturePixelShader: {
  81248. name: string;
  81249. shader: string;
  81250. };
  81251. }
  81252. declare module BABYLON {
  81253. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  81254. time: number;
  81255. timeScale: number;
  81256. translationSpeed: number;
  81257. private _currentTranslation;
  81258. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81259. updateShaderUniforms(): void;
  81260. render(useCameraPostProcess?: boolean): void;
  81261. resize(size: any, generateMipMaps: any): void;
  81262. /**
  81263. * Serializes this perlin noise procedural texture
  81264. * @returns a serialized perlin noise procedural texture object
  81265. */
  81266. serialize(): any;
  81267. /**
  81268. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  81269. * @param parsedTexture defines parsed texture data
  81270. * @param scene defines the current scene
  81271. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  81272. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  81273. */
  81274. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  81275. }
  81276. }
  81277. declare module BABYLON {
  81278. /** @hidden */
  81279. export var roadProceduralTexturePixelShader: {
  81280. name: string;
  81281. shader: string;
  81282. };
  81283. }
  81284. declare module BABYLON {
  81285. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  81286. private _roadColor;
  81287. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81288. updateShaderUniforms(): void;
  81289. get roadColor(): BABYLON.Color3;
  81290. set roadColor(value: BABYLON.Color3);
  81291. /**
  81292. * Serializes this road procedural texture
  81293. * @returns a serialized road procedural texture object
  81294. */
  81295. serialize(): any;
  81296. /**
  81297. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  81298. * @param parsedTexture defines parsed texture data
  81299. * @param scene defines the current scene
  81300. * @param rootUrl defines the root URL containing road procedural texture information
  81301. * @returns a parsed Road Procedural BABYLON.Texture
  81302. */
  81303. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  81304. }
  81305. }
  81306. declare module BABYLON {
  81307. /** @hidden */
  81308. export var starfieldProceduralTexturePixelShader: {
  81309. name: string;
  81310. shader: string;
  81311. };
  81312. }
  81313. declare module BABYLON {
  81314. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  81315. private _time;
  81316. private _alpha;
  81317. private _beta;
  81318. private _zoom;
  81319. private _formuparam;
  81320. private _stepsize;
  81321. private _tile;
  81322. private _brightness;
  81323. private _darkmatter;
  81324. private _distfading;
  81325. private _saturation;
  81326. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81327. updateShaderUniforms(): void;
  81328. get time(): number;
  81329. set time(value: number);
  81330. get alpha(): number;
  81331. set alpha(value: number);
  81332. get beta(): number;
  81333. set beta(value: number);
  81334. get formuparam(): number;
  81335. set formuparam(value: number);
  81336. get stepsize(): number;
  81337. set stepsize(value: number);
  81338. get zoom(): number;
  81339. set zoom(value: number);
  81340. get tile(): number;
  81341. set tile(value: number);
  81342. get brightness(): number;
  81343. set brightness(value: number);
  81344. get darkmatter(): number;
  81345. set darkmatter(value: number);
  81346. get distfading(): number;
  81347. set distfading(value: number);
  81348. get saturation(): number;
  81349. set saturation(value: number);
  81350. /**
  81351. * Serializes this starfield procedural texture
  81352. * @returns a serialized starfield procedural texture object
  81353. */
  81354. serialize(): any;
  81355. /**
  81356. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  81357. * @param parsedTexture defines parsed texture data
  81358. * @param scene defines the current scene
  81359. * @param rootUrl defines the root URL containing startfield procedural texture information
  81360. * @returns a parsed Starfield Procedural BABYLON.Texture
  81361. */
  81362. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  81363. }
  81364. }
  81365. declare module BABYLON {
  81366. /** @hidden */
  81367. export var woodProceduralTexturePixelShader: {
  81368. name: string;
  81369. shader: string;
  81370. };
  81371. }
  81372. declare module BABYLON {
  81373. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  81374. private _ampScale;
  81375. private _woodColor;
  81376. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81377. updateShaderUniforms(): void;
  81378. get ampScale(): number;
  81379. set ampScale(value: number);
  81380. get woodColor(): BABYLON.Color3;
  81381. set woodColor(value: BABYLON.Color3);
  81382. /**
  81383. * Serializes this wood procedural texture
  81384. * @returns a serialized wood procedural texture object
  81385. */
  81386. serialize(): any;
  81387. /**
  81388. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  81389. * @param parsedTexture defines parsed texture data
  81390. * @param scene defines the current scene
  81391. * @param rootUrl defines the root URL containing wood procedural texture information
  81392. * @returns a parsed Wood Procedural BABYLON.Texture
  81393. */
  81394. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  81395. }
  81396. }