documentation.d.ts 3.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503
  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 particles are enabled on this scene
  36142. */
  36143. particlesEnabled: boolean;
  36144. /**
  36145. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36146. */
  36147. spritesEnabled: boolean;
  36148. private _skeletonsEnabled;
  36149. /**
  36150. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36151. */
  36152. set skeletonsEnabled(value: boolean);
  36153. get skeletonsEnabled(): boolean;
  36154. /**
  36155. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36156. */
  36157. lensFlaresEnabled: boolean;
  36158. /**
  36159. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36161. */
  36162. collisionsEnabled: boolean;
  36163. private _collisionCoordinator;
  36164. /** @hidden */
  36165. get collisionCoordinator(): ICollisionCoordinator;
  36166. /**
  36167. * Defines the gravity applied to this scene (used only for collisions)
  36168. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36169. */
  36170. gravity: Vector3;
  36171. /**
  36172. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36173. */
  36174. postProcessesEnabled: boolean;
  36175. /**
  36176. * The list of postprocesses added to the scene
  36177. */
  36178. postProcesses: PostProcess[];
  36179. /**
  36180. * Gets the current postprocess manager
  36181. */
  36182. postProcessManager: PostProcessManager;
  36183. /**
  36184. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36185. */
  36186. renderTargetsEnabled: boolean;
  36187. /**
  36188. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36189. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36190. */
  36191. dumpNextRenderTargets: boolean;
  36192. /**
  36193. * The list of user defined render targets added to the scene
  36194. */
  36195. customRenderTargets: RenderTargetTexture[];
  36196. /**
  36197. * Defines if texture loading must be delayed
  36198. * If true, textures will only be loaded when they need to be rendered
  36199. */
  36200. useDelayedTextureLoading: boolean;
  36201. /**
  36202. * Gets the list of meshes imported to the scene through SceneLoader
  36203. */
  36204. importedMeshesFiles: String[];
  36205. /**
  36206. * Gets or sets a boolean indicating if probes are enabled on this scene
  36207. */
  36208. probesEnabled: boolean;
  36209. /**
  36210. * Gets or sets the current offline provider to use to store scene data
  36211. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36212. */
  36213. offlineProvider: IOfflineProvider;
  36214. /**
  36215. * Gets or sets the action manager associated with the scene
  36216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36217. */
  36218. actionManager: AbstractActionManager;
  36219. private _meshesForIntersections;
  36220. /**
  36221. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36222. */
  36223. proceduralTexturesEnabled: boolean;
  36224. private _engine;
  36225. private _totalVertices;
  36226. /** @hidden */
  36227. _activeIndices: PerfCounter;
  36228. /** @hidden */
  36229. _activeParticles: PerfCounter;
  36230. /** @hidden */
  36231. _activeBones: PerfCounter;
  36232. private _animationRatio;
  36233. /** @hidden */
  36234. _animationTimeLast: number;
  36235. /** @hidden */
  36236. _animationTime: number;
  36237. /**
  36238. * Gets or sets a general scale for animation speed
  36239. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36240. */
  36241. animationTimeScale: number;
  36242. /** @hidden */
  36243. _cachedMaterial: Nullable<Material>;
  36244. /** @hidden */
  36245. _cachedEffect: Nullable<Effect>;
  36246. /** @hidden */
  36247. _cachedVisibility: Nullable<number>;
  36248. private _renderId;
  36249. private _frameId;
  36250. private _executeWhenReadyTimeoutId;
  36251. private _intermediateRendering;
  36252. private _viewUpdateFlag;
  36253. private _projectionUpdateFlag;
  36254. /** @hidden */
  36255. _toBeDisposed: Nullable<IDisposable>[];
  36256. private _activeRequests;
  36257. /** @hidden */
  36258. _pendingData: any[];
  36259. private _isDisposed;
  36260. /**
  36261. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36262. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36263. */
  36264. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36265. private _activeMeshes;
  36266. private _processedMaterials;
  36267. private _renderTargets;
  36268. /** @hidden */
  36269. _activeParticleSystems: SmartArray<IParticleSystem>;
  36270. private _activeSkeletons;
  36271. private _softwareSkinnedMeshes;
  36272. private _renderingManager;
  36273. /** @hidden */
  36274. _activeAnimatables: Animatable[];
  36275. private _transformMatrix;
  36276. private _sceneUbo;
  36277. /** @hidden */
  36278. _viewMatrix: Matrix;
  36279. private _projectionMatrix;
  36280. /** @hidden */
  36281. _forcedViewPosition: Nullable<Vector3>;
  36282. /** @hidden */
  36283. _frustumPlanes: Plane[];
  36284. /**
  36285. * Gets the list of frustum planes (built from the active camera)
  36286. */
  36287. get frustumPlanes(): Plane[];
  36288. /**
  36289. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36290. * This is useful if there are more lights that the maximum simulteanous authorized
  36291. */
  36292. requireLightSorting: boolean;
  36293. /** @hidden */
  36294. readonly useMaterialMeshMap: boolean;
  36295. /** @hidden */
  36296. readonly useClonedMeshMap: boolean;
  36297. private _externalData;
  36298. private _uid;
  36299. /**
  36300. * @hidden
  36301. * Backing store of defined scene components.
  36302. */
  36303. _components: ISceneComponent[];
  36304. /**
  36305. * @hidden
  36306. * Backing store of defined scene components.
  36307. */
  36308. _serializableComponents: ISceneSerializableComponent[];
  36309. /**
  36310. * List of components to register on the next registration step.
  36311. */
  36312. private _transientComponents;
  36313. /**
  36314. * Registers the transient components if needed.
  36315. */
  36316. private _registerTransientComponents;
  36317. /**
  36318. * @hidden
  36319. * Add a component to the scene.
  36320. * Note that the ccomponent could be registered on th next frame if this is called after
  36321. * the register component stage.
  36322. * @param component Defines the component to add to the scene
  36323. */
  36324. _addComponent(component: ISceneComponent): void;
  36325. /**
  36326. * @hidden
  36327. * Gets a component from the scene.
  36328. * @param name defines the name of the component to retrieve
  36329. * @returns the component or null if not present
  36330. */
  36331. _getComponent(name: string): Nullable<ISceneComponent>;
  36332. /**
  36333. * @hidden
  36334. * Defines the actions happening before camera updates.
  36335. */
  36336. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36337. /**
  36338. * @hidden
  36339. * Defines the actions happening before clear the canvas.
  36340. */
  36341. _beforeClearStage: Stage<SimpleStageAction>;
  36342. /**
  36343. * @hidden
  36344. * Defines the actions when collecting render targets for the frame.
  36345. */
  36346. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36347. /**
  36348. * @hidden
  36349. * Defines the actions happening for one camera in the frame.
  36350. */
  36351. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36352. /**
  36353. * @hidden
  36354. * Defines the actions happening during the per mesh ready checks.
  36355. */
  36356. _isReadyForMeshStage: Stage<MeshStageAction>;
  36357. /**
  36358. * @hidden
  36359. * Defines the actions happening before evaluate active mesh checks.
  36360. */
  36361. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36362. /**
  36363. * @hidden
  36364. * Defines the actions happening during the evaluate sub mesh checks.
  36365. */
  36366. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36367. /**
  36368. * @hidden
  36369. * Defines the actions happening during the active mesh stage.
  36370. */
  36371. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36372. /**
  36373. * @hidden
  36374. * Defines the actions happening during the per camera render target step.
  36375. */
  36376. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36377. /**
  36378. * @hidden
  36379. * Defines the actions happening just before the active camera is drawing.
  36380. */
  36381. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36382. /**
  36383. * @hidden
  36384. * Defines the actions happening just before a render target is drawing.
  36385. */
  36386. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36387. /**
  36388. * @hidden
  36389. * Defines the actions happening just before a rendering group is drawing.
  36390. */
  36391. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36392. /**
  36393. * @hidden
  36394. * Defines the actions happening just before a mesh is drawing.
  36395. */
  36396. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36397. /**
  36398. * @hidden
  36399. * Defines the actions happening just after a mesh has been drawn.
  36400. */
  36401. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36402. /**
  36403. * @hidden
  36404. * Defines the actions happening just after a rendering group has been drawn.
  36405. */
  36406. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36407. /**
  36408. * @hidden
  36409. * Defines the actions happening just after the active camera has been drawn.
  36410. */
  36411. _afterCameraDrawStage: Stage<CameraStageAction>;
  36412. /**
  36413. * @hidden
  36414. * Defines the actions happening just after a render target has been drawn.
  36415. */
  36416. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36417. /**
  36418. * @hidden
  36419. * Defines the actions happening just after rendering all cameras and computing intersections.
  36420. */
  36421. _afterRenderStage: Stage<SimpleStageAction>;
  36422. /**
  36423. * @hidden
  36424. * Defines the actions happening when a pointer move event happens.
  36425. */
  36426. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36427. /**
  36428. * @hidden
  36429. * Defines the actions happening when a pointer down event happens.
  36430. */
  36431. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36432. /**
  36433. * @hidden
  36434. * Defines the actions happening when a pointer up event happens.
  36435. */
  36436. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36437. /**
  36438. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36439. */
  36440. private geometriesByUniqueId;
  36441. /**
  36442. * Creates a new Scene
  36443. * @param engine defines the engine to use to render this scene
  36444. * @param options defines the scene options
  36445. */
  36446. constructor(engine: Engine, options?: SceneOptions);
  36447. /**
  36448. * Gets a string idenfifying the name of the class
  36449. * @returns "Scene" string
  36450. */
  36451. getClassName(): string;
  36452. private _defaultMeshCandidates;
  36453. /**
  36454. * @hidden
  36455. */
  36456. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36457. private _defaultSubMeshCandidates;
  36458. /**
  36459. * @hidden
  36460. */
  36461. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36462. /**
  36463. * Sets the default candidate providers for the scene.
  36464. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36465. * and getCollidingSubMeshCandidates to their default function
  36466. */
  36467. setDefaultCandidateProviders(): void;
  36468. /**
  36469. * Gets the mesh that is currently under the pointer
  36470. */
  36471. get meshUnderPointer(): Nullable<AbstractMesh>;
  36472. /**
  36473. * Gets or sets the current on-screen X position of the pointer
  36474. */
  36475. get pointerX(): number;
  36476. set pointerX(value: number);
  36477. /**
  36478. * Gets or sets the current on-screen Y position of the pointer
  36479. */
  36480. get pointerY(): number;
  36481. set pointerY(value: number);
  36482. /**
  36483. * Gets the cached material (ie. the latest rendered one)
  36484. * @returns the cached material
  36485. */
  36486. getCachedMaterial(): Nullable<Material>;
  36487. /**
  36488. * Gets the cached effect (ie. the latest rendered one)
  36489. * @returns the cached effect
  36490. */
  36491. getCachedEffect(): Nullable<Effect>;
  36492. /**
  36493. * Gets the cached visibility state (ie. the latest rendered one)
  36494. * @returns the cached visibility state
  36495. */
  36496. getCachedVisibility(): Nullable<number>;
  36497. /**
  36498. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36499. * @param material defines the current material
  36500. * @param effect defines the current effect
  36501. * @param visibility defines the current visibility state
  36502. * @returns true if one parameter is not cached
  36503. */
  36504. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36505. /**
  36506. * Gets the engine associated with the scene
  36507. * @returns an Engine
  36508. */
  36509. getEngine(): Engine;
  36510. /**
  36511. * Gets the total number of vertices rendered per frame
  36512. * @returns the total number of vertices rendered per frame
  36513. */
  36514. getTotalVertices(): number;
  36515. /**
  36516. * Gets the performance counter for total vertices
  36517. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36518. */
  36519. get totalVerticesPerfCounter(): PerfCounter;
  36520. /**
  36521. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36522. * @returns the total number of active indices rendered per frame
  36523. */
  36524. getActiveIndices(): number;
  36525. /**
  36526. * Gets the performance counter for active indices
  36527. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36528. */
  36529. get totalActiveIndicesPerfCounter(): PerfCounter;
  36530. /**
  36531. * Gets the total number of active particles rendered per frame
  36532. * @returns the total number of active particles rendered per frame
  36533. */
  36534. getActiveParticles(): number;
  36535. /**
  36536. * Gets the performance counter for active particles
  36537. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36538. */
  36539. get activeParticlesPerfCounter(): PerfCounter;
  36540. /**
  36541. * Gets the total number of active bones rendered per frame
  36542. * @returns the total number of active bones rendered per frame
  36543. */
  36544. getActiveBones(): number;
  36545. /**
  36546. * Gets the performance counter for active bones
  36547. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36548. */
  36549. get activeBonesPerfCounter(): PerfCounter;
  36550. /**
  36551. * Gets the array of active meshes
  36552. * @returns an array of AbstractMesh
  36553. */
  36554. getActiveMeshes(): SmartArray<AbstractMesh>;
  36555. /**
  36556. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36557. * @returns a number
  36558. */
  36559. getAnimationRatio(): number;
  36560. /**
  36561. * Gets an unique Id for the current render phase
  36562. * @returns a number
  36563. */
  36564. getRenderId(): number;
  36565. /**
  36566. * Gets an unique Id for the current frame
  36567. * @returns a number
  36568. */
  36569. getFrameId(): number;
  36570. /** Call this function if you want to manually increment the render Id*/
  36571. incrementRenderId(): void;
  36572. private _createUbo;
  36573. /**
  36574. * Use this method to simulate a pointer move on a mesh
  36575. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36576. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36577. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36578. * @returns the current scene
  36579. */
  36580. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36581. /**
  36582. * Use this method to simulate a pointer down on a mesh
  36583. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36584. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36585. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36586. * @returns the current scene
  36587. */
  36588. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36589. /**
  36590. * Use this method to simulate a pointer up on a mesh
  36591. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36592. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36593. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36594. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36595. * @returns the current scene
  36596. */
  36597. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36598. /**
  36599. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36600. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36601. * @returns true if the pointer was captured
  36602. */
  36603. isPointerCaptured(pointerId?: number): boolean;
  36604. /**
  36605. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36606. * @param attachUp defines if you want to attach events to pointerup
  36607. * @param attachDown defines if you want to attach events to pointerdown
  36608. * @param attachMove defines if you want to attach events to pointermove
  36609. */
  36610. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36611. /** Detaches all event handlers*/
  36612. detachControl(): void;
  36613. /**
  36614. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36615. * Delay loaded resources are not taking in account
  36616. * @return true if all required resources are ready
  36617. */
  36618. isReady(): boolean;
  36619. /** Resets all cached information relative to material (including effect and visibility) */
  36620. resetCachedMaterial(): void;
  36621. /**
  36622. * Registers a function to be called before every frame render
  36623. * @param func defines the function to register
  36624. */
  36625. registerBeforeRender(func: () => void): void;
  36626. /**
  36627. * Unregisters a function called before every frame render
  36628. * @param func defines the function to unregister
  36629. */
  36630. unregisterBeforeRender(func: () => void): void;
  36631. /**
  36632. * Registers a function to be called after every frame render
  36633. * @param func defines the function to register
  36634. */
  36635. registerAfterRender(func: () => void): void;
  36636. /**
  36637. * Unregisters a function called after every frame render
  36638. * @param func defines the function to unregister
  36639. */
  36640. unregisterAfterRender(func: () => void): void;
  36641. private _executeOnceBeforeRender;
  36642. /**
  36643. * The provided function will run before render once and will be disposed afterwards.
  36644. * A timeout delay can be provided so that the function will be executed in N ms.
  36645. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36646. * @param func The function to be executed.
  36647. * @param timeout optional delay in ms
  36648. */
  36649. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36650. /** @hidden */
  36651. _addPendingData(data: any): void;
  36652. /** @hidden */
  36653. _removePendingData(data: any): void;
  36654. /**
  36655. * Returns the number of items waiting to be loaded
  36656. * @returns the number of items waiting to be loaded
  36657. */
  36658. getWaitingItemsCount(): number;
  36659. /**
  36660. * Returns a boolean indicating if the scene is still loading data
  36661. */
  36662. get isLoading(): boolean;
  36663. /**
  36664. * Registers a function to be executed when the scene is ready
  36665. * @param {Function} func - the function to be executed
  36666. */
  36667. executeWhenReady(func: () => void): void;
  36668. /**
  36669. * Returns a promise that resolves when the scene is ready
  36670. * @returns A promise that resolves when the scene is ready
  36671. */
  36672. whenReadyAsync(): Promise<void>;
  36673. /** @hidden */
  36674. _checkIsReady(): void;
  36675. /**
  36676. * Gets all animatable attached to the scene
  36677. */
  36678. get animatables(): Animatable[];
  36679. /**
  36680. * Resets the last animation time frame.
  36681. * Useful to override when animations start running when loading a scene for the first time.
  36682. */
  36683. resetLastAnimationTimeFrame(): void;
  36684. /**
  36685. * Gets the current view matrix
  36686. * @returns a Matrix
  36687. */
  36688. getViewMatrix(): Matrix;
  36689. /**
  36690. * Gets the current projection matrix
  36691. * @returns a Matrix
  36692. */
  36693. getProjectionMatrix(): Matrix;
  36694. /**
  36695. * Gets the current transform matrix
  36696. * @returns a Matrix made of View * Projection
  36697. */
  36698. getTransformMatrix(): Matrix;
  36699. /**
  36700. * Sets the current transform matrix
  36701. * @param viewL defines the View matrix to use
  36702. * @param projectionL defines the Projection matrix to use
  36703. * @param viewR defines the right View matrix to use (if provided)
  36704. * @param projectionR defines the right Projection matrix to use (if provided)
  36705. */
  36706. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36707. /**
  36708. * Gets the uniform buffer used to store scene data
  36709. * @returns a UniformBuffer
  36710. */
  36711. getSceneUniformBuffer(): UniformBuffer;
  36712. /**
  36713. * Gets an unique (relatively to the current scene) Id
  36714. * @returns an unique number for the scene
  36715. */
  36716. getUniqueId(): number;
  36717. /**
  36718. * Add a mesh to the list of scene's meshes
  36719. * @param newMesh defines the mesh to add
  36720. * @param recursive if all child meshes should also be added to the scene
  36721. */
  36722. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36723. /**
  36724. * Remove a mesh for the list of scene's meshes
  36725. * @param toRemove defines the mesh to remove
  36726. * @param recursive if all child meshes should also be removed from the scene
  36727. * @returns the index where the mesh was in the mesh list
  36728. */
  36729. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36730. /**
  36731. * Add a transform node to the list of scene's transform nodes
  36732. * @param newTransformNode defines the transform node to add
  36733. */
  36734. addTransformNode(newTransformNode: TransformNode): void;
  36735. /**
  36736. * Remove a transform node for the list of scene's transform nodes
  36737. * @param toRemove defines the transform node to remove
  36738. * @returns the index where the transform node was in the transform node list
  36739. */
  36740. removeTransformNode(toRemove: TransformNode): number;
  36741. /**
  36742. * Remove a skeleton for the list of scene's skeletons
  36743. * @param toRemove defines the skeleton to remove
  36744. * @returns the index where the skeleton was in the skeleton list
  36745. */
  36746. removeSkeleton(toRemove: Skeleton): number;
  36747. /**
  36748. * Remove a morph target for the list of scene's morph targets
  36749. * @param toRemove defines the morph target to remove
  36750. * @returns the index where the morph target was in the morph target list
  36751. */
  36752. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36753. /**
  36754. * Remove a light for the list of scene's lights
  36755. * @param toRemove defines the light to remove
  36756. * @returns the index where the light was in the light list
  36757. */
  36758. removeLight(toRemove: Light): number;
  36759. /**
  36760. * Remove a camera for the list of scene's cameras
  36761. * @param toRemove defines the camera to remove
  36762. * @returns the index where the camera was in the camera list
  36763. */
  36764. removeCamera(toRemove: Camera): number;
  36765. /**
  36766. * Remove a particle system for the list of scene's particle systems
  36767. * @param toRemove defines the particle system to remove
  36768. * @returns the index where the particle system was in the particle system list
  36769. */
  36770. removeParticleSystem(toRemove: IParticleSystem): number;
  36771. /**
  36772. * Remove a animation for the list of scene's animations
  36773. * @param toRemove defines the animation to remove
  36774. * @returns the index where the animation was in the animation list
  36775. */
  36776. removeAnimation(toRemove: Animation): number;
  36777. /**
  36778. * Will stop the animation of the given target
  36779. * @param target - the target
  36780. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36781. * @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)
  36782. */
  36783. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36784. /**
  36785. * Removes the given animation group from this scene.
  36786. * @param toRemove The animation group to remove
  36787. * @returns The index of the removed animation group
  36788. */
  36789. removeAnimationGroup(toRemove: AnimationGroup): number;
  36790. /**
  36791. * Removes the given multi-material from this scene.
  36792. * @param toRemove The multi-material to remove
  36793. * @returns The index of the removed multi-material
  36794. */
  36795. removeMultiMaterial(toRemove: MultiMaterial): number;
  36796. /**
  36797. * Removes the given material from this scene.
  36798. * @param toRemove The material to remove
  36799. * @returns The index of the removed material
  36800. */
  36801. removeMaterial(toRemove: Material): number;
  36802. /**
  36803. * Removes the given action manager from this scene.
  36804. * @param toRemove The action manager to remove
  36805. * @returns The index of the removed action manager
  36806. */
  36807. removeActionManager(toRemove: AbstractActionManager): number;
  36808. /**
  36809. * Removes the given texture from this scene.
  36810. * @param toRemove The texture to remove
  36811. * @returns The index of the removed texture
  36812. */
  36813. removeTexture(toRemove: BaseTexture): number;
  36814. /**
  36815. * Adds the given light to this scene
  36816. * @param newLight The light to add
  36817. */
  36818. addLight(newLight: Light): void;
  36819. /**
  36820. * Sorts the list list based on light priorities
  36821. */
  36822. sortLightsByPriority(): void;
  36823. /**
  36824. * Adds the given camera to this scene
  36825. * @param newCamera The camera to add
  36826. */
  36827. addCamera(newCamera: Camera): void;
  36828. /**
  36829. * Adds the given skeleton to this scene
  36830. * @param newSkeleton The skeleton to add
  36831. */
  36832. addSkeleton(newSkeleton: Skeleton): void;
  36833. /**
  36834. * Adds the given particle system to this scene
  36835. * @param newParticleSystem The particle system to add
  36836. */
  36837. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36838. /**
  36839. * Adds the given animation to this scene
  36840. * @param newAnimation The animation to add
  36841. */
  36842. addAnimation(newAnimation: Animation): void;
  36843. /**
  36844. * Adds the given animation group to this scene.
  36845. * @param newAnimationGroup The animation group to add
  36846. */
  36847. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36848. /**
  36849. * Adds the given multi-material to this scene
  36850. * @param newMultiMaterial The multi-material to add
  36851. */
  36852. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36853. /**
  36854. * Adds the given material to this scene
  36855. * @param newMaterial The material to add
  36856. */
  36857. addMaterial(newMaterial: Material): void;
  36858. /**
  36859. * Adds the given morph target to this scene
  36860. * @param newMorphTargetManager The morph target to add
  36861. */
  36862. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36863. /**
  36864. * Adds the given geometry to this scene
  36865. * @param newGeometry The geometry to add
  36866. */
  36867. addGeometry(newGeometry: Geometry): void;
  36868. /**
  36869. * Adds the given action manager to this scene
  36870. * @param newActionManager The action manager to add
  36871. */
  36872. addActionManager(newActionManager: AbstractActionManager): void;
  36873. /**
  36874. * Adds the given texture to this scene.
  36875. * @param newTexture The texture to add
  36876. */
  36877. addTexture(newTexture: BaseTexture): void;
  36878. /**
  36879. * Switch active camera
  36880. * @param newCamera defines the new active camera
  36881. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36882. */
  36883. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36884. /**
  36885. * sets the active camera of the scene using its ID
  36886. * @param id defines the camera's ID
  36887. * @return the new active camera or null if none found.
  36888. */
  36889. setActiveCameraByID(id: string): Nullable<Camera>;
  36890. /**
  36891. * sets the active camera of the scene using its name
  36892. * @param name defines the camera's name
  36893. * @returns the new active camera or null if none found.
  36894. */
  36895. setActiveCameraByName(name: string): Nullable<Camera>;
  36896. /**
  36897. * get an animation group using its name
  36898. * @param name defines the material's name
  36899. * @return the animation group or null if none found.
  36900. */
  36901. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36902. /**
  36903. * Get a material using its unique id
  36904. * @param uniqueId defines the material's unique id
  36905. * @return the material or null if none found.
  36906. */
  36907. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36908. /**
  36909. * get a material using its id
  36910. * @param id defines the material's ID
  36911. * @return the material or null if none found.
  36912. */
  36913. getMaterialByID(id: string): Nullable<Material>;
  36914. /**
  36915. * Gets a the last added material using a given id
  36916. * @param id defines the material's ID
  36917. * @return the last material with the given id or null if none found.
  36918. */
  36919. getLastMaterialByID(id: string): Nullable<Material>;
  36920. /**
  36921. * Gets a material using its name
  36922. * @param name defines the material's name
  36923. * @return the material or null if none found.
  36924. */
  36925. getMaterialByName(name: string): Nullable<Material>;
  36926. /**
  36927. * Get a texture using its unique id
  36928. * @param uniqueId defines the texture's unique id
  36929. * @return the texture or null if none found.
  36930. */
  36931. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36932. /**
  36933. * Gets a camera using its id
  36934. * @param id defines the id to look for
  36935. * @returns the camera or null if not found
  36936. */
  36937. getCameraByID(id: string): Nullable<Camera>;
  36938. /**
  36939. * Gets a camera using its unique id
  36940. * @param uniqueId defines the unique id to look for
  36941. * @returns the camera or null if not found
  36942. */
  36943. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36944. /**
  36945. * Gets a camera using its name
  36946. * @param name defines the camera's name
  36947. * @return the camera or null if none found.
  36948. */
  36949. getCameraByName(name: string): Nullable<Camera>;
  36950. /**
  36951. * Gets a bone using its id
  36952. * @param id defines the bone's id
  36953. * @return the bone or null if not found
  36954. */
  36955. getBoneByID(id: string): Nullable<Bone>;
  36956. /**
  36957. * Gets a bone using its id
  36958. * @param name defines the bone's name
  36959. * @return the bone or null if not found
  36960. */
  36961. getBoneByName(name: string): Nullable<Bone>;
  36962. /**
  36963. * Gets a light node using its name
  36964. * @param name defines the the light's name
  36965. * @return the light or null if none found.
  36966. */
  36967. getLightByName(name: string): Nullable<Light>;
  36968. /**
  36969. * Gets a light node using its id
  36970. * @param id defines the light's id
  36971. * @return the light or null if none found.
  36972. */
  36973. getLightByID(id: string): Nullable<Light>;
  36974. /**
  36975. * Gets a light node using its scene-generated unique ID
  36976. * @param uniqueId defines the light's unique id
  36977. * @return the light or null if none found.
  36978. */
  36979. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36980. /**
  36981. * Gets a particle system by id
  36982. * @param id defines the particle system id
  36983. * @return the corresponding system or null if none found
  36984. */
  36985. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36986. /**
  36987. * Gets a geometry using its ID
  36988. * @param id defines the geometry's id
  36989. * @return the geometry or null if none found.
  36990. */
  36991. getGeometryByID(id: string): Nullable<Geometry>;
  36992. private _getGeometryByUniqueID;
  36993. /**
  36994. * Add a new geometry to this scene
  36995. * @param geometry defines the geometry to be added to the scene.
  36996. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36997. * @return a boolean defining if the geometry was added or not
  36998. */
  36999. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37000. /**
  37001. * Removes an existing geometry
  37002. * @param geometry defines the geometry to be removed from the scene
  37003. * @return a boolean defining if the geometry was removed or not
  37004. */
  37005. removeGeometry(geometry: Geometry): boolean;
  37006. /**
  37007. * Gets the list of geometries attached to the scene
  37008. * @returns an array of Geometry
  37009. */
  37010. getGeometries(): Geometry[];
  37011. /**
  37012. * Gets the first added mesh found of a given ID
  37013. * @param id defines the id to search for
  37014. * @return the mesh found or null if not found at all
  37015. */
  37016. getMeshByID(id: string): Nullable<AbstractMesh>;
  37017. /**
  37018. * Gets a list of meshes using their id
  37019. * @param id defines the id to search for
  37020. * @returns a list of meshes
  37021. */
  37022. getMeshesByID(id: string): Array<AbstractMesh>;
  37023. /**
  37024. * Gets the first added transform node found of a given ID
  37025. * @param id defines the id to search for
  37026. * @return the found transform node or null if not found at all.
  37027. */
  37028. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37029. /**
  37030. * Gets a transform node with its auto-generated unique id
  37031. * @param uniqueId efines the unique id to search for
  37032. * @return the found transform node or null if not found at all.
  37033. */
  37034. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37035. /**
  37036. * Gets a list of transform nodes using their id
  37037. * @param id defines the id to search for
  37038. * @returns a list of transform nodes
  37039. */
  37040. getTransformNodesByID(id: string): Array<TransformNode>;
  37041. /**
  37042. * Gets a mesh with its auto-generated unique id
  37043. * @param uniqueId defines the unique id to search for
  37044. * @return the found mesh or null if not found at all.
  37045. */
  37046. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37047. /**
  37048. * Gets a the last added mesh using a given id
  37049. * @param id defines the id to search for
  37050. * @return the found mesh or null if not found at all.
  37051. */
  37052. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37053. /**
  37054. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37055. * @param id defines the id to search for
  37056. * @return the found node or null if not found at all
  37057. */
  37058. getLastEntryByID(id: string): Nullable<Node>;
  37059. /**
  37060. * Gets a node (Mesh, Camera, Light) using a given id
  37061. * @param id defines the id to search for
  37062. * @return the found node or null if not found at all
  37063. */
  37064. getNodeByID(id: string): Nullable<Node>;
  37065. /**
  37066. * Gets a node (Mesh, Camera, Light) using a given name
  37067. * @param name defines the name to search for
  37068. * @return the found node or null if not found at all.
  37069. */
  37070. getNodeByName(name: string): Nullable<Node>;
  37071. /**
  37072. * Gets a mesh using a given name
  37073. * @param name defines the name to search for
  37074. * @return the found mesh or null if not found at all.
  37075. */
  37076. getMeshByName(name: string): Nullable<AbstractMesh>;
  37077. /**
  37078. * Gets a transform node using a given name
  37079. * @param name defines the name to search for
  37080. * @return the found transform node or null if not found at all.
  37081. */
  37082. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37083. /**
  37084. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37085. * @param id defines the id to search for
  37086. * @return the found skeleton or null if not found at all.
  37087. */
  37088. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37089. /**
  37090. * Gets a skeleton using a given auto generated unique id
  37091. * @param uniqueId defines the unique id to search for
  37092. * @return the found skeleton or null if not found at all.
  37093. */
  37094. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37095. /**
  37096. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37097. * @param id defines the id to search for
  37098. * @return the found skeleton or null if not found at all.
  37099. */
  37100. getSkeletonById(id: string): Nullable<Skeleton>;
  37101. /**
  37102. * Gets a skeleton using a given name
  37103. * @param name defines the name to search for
  37104. * @return the found skeleton or null if not found at all.
  37105. */
  37106. getSkeletonByName(name: string): Nullable<Skeleton>;
  37107. /**
  37108. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37109. * @param id defines the id to search for
  37110. * @return the found morph target manager or null if not found at all.
  37111. */
  37112. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37113. /**
  37114. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37115. * @param id defines the id to search for
  37116. * @return the found morph target or null if not found at all.
  37117. */
  37118. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37119. /**
  37120. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37121. * @param name defines the name to search for
  37122. * @return the found morph target or null if not found at all.
  37123. */
  37124. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37125. /**
  37126. * Gets a boolean indicating if the given mesh is active
  37127. * @param mesh defines the mesh to look for
  37128. * @returns true if the mesh is in the active list
  37129. */
  37130. isActiveMesh(mesh: AbstractMesh): boolean;
  37131. /**
  37132. * Return a unique id as a string which can serve as an identifier for the scene
  37133. */
  37134. get uid(): string;
  37135. /**
  37136. * Add an externaly attached data from its key.
  37137. * This method call will fail and return false, if such key already exists.
  37138. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37139. * @param key the unique key that identifies the data
  37140. * @param data the data object to associate to the key for this Engine instance
  37141. * @return true if no such key were already present and the data was added successfully, false otherwise
  37142. */
  37143. addExternalData<T>(key: string, data: T): boolean;
  37144. /**
  37145. * Get an externaly attached data from its key
  37146. * @param key the unique key that identifies the data
  37147. * @return the associated data, if present (can be null), or undefined if not present
  37148. */
  37149. getExternalData<T>(key: string): Nullable<T>;
  37150. /**
  37151. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37152. * @param key the unique key that identifies the data
  37153. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37154. * @return the associated data, can be null if the factory returned null.
  37155. */
  37156. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37157. /**
  37158. * Remove an externaly attached data from the Engine instance
  37159. * @param key the unique key that identifies the data
  37160. * @return true if the data was successfully removed, false if it doesn't exist
  37161. */
  37162. removeExternalData(key: string): boolean;
  37163. private _evaluateSubMesh;
  37164. /**
  37165. * Clear the processed materials smart array preventing retention point in material dispose.
  37166. */
  37167. freeProcessedMaterials(): void;
  37168. private _preventFreeActiveMeshesAndRenderingGroups;
  37169. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37170. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37171. * when disposing several meshes in a row or a hierarchy of meshes.
  37172. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37173. */
  37174. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37175. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37176. /**
  37177. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37178. */
  37179. freeActiveMeshes(): void;
  37180. /**
  37181. * Clear the info related to rendering groups preventing retention points during dispose.
  37182. */
  37183. freeRenderingGroups(): void;
  37184. /** @hidden */
  37185. _isInIntermediateRendering(): boolean;
  37186. /**
  37187. * Lambda returning the list of potentially active meshes.
  37188. */
  37189. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37190. /**
  37191. * Lambda returning the list of potentially active sub meshes.
  37192. */
  37193. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37194. /**
  37195. * Lambda returning the list of potentially intersecting sub meshes.
  37196. */
  37197. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37198. /**
  37199. * Lambda returning the list of potentially colliding sub meshes.
  37200. */
  37201. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37202. private _activeMeshesFrozen;
  37203. private _skipEvaluateActiveMeshesCompletely;
  37204. /**
  37205. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37206. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37207. * @returns the current scene
  37208. */
  37209. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37210. /**
  37211. * Use this function to restart evaluating active meshes on every frame
  37212. * @returns the current scene
  37213. */
  37214. unfreezeActiveMeshes(): Scene;
  37215. private _evaluateActiveMeshes;
  37216. private _activeMesh;
  37217. /**
  37218. * Update the transform matrix to update from the current active camera
  37219. * @param force defines a boolean used to force the update even if cache is up to date
  37220. */
  37221. updateTransformMatrix(force?: boolean): void;
  37222. private _bindFrameBuffer;
  37223. /** @hidden */
  37224. _allowPostProcessClearColor: boolean;
  37225. /** @hidden */
  37226. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37227. private _processSubCameras;
  37228. private _checkIntersections;
  37229. /** @hidden */
  37230. _advancePhysicsEngineStep(step: number): void;
  37231. /**
  37232. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37233. */
  37234. getDeterministicFrameTime: () => number;
  37235. /** @hidden */
  37236. _animate(): void;
  37237. /** Execute all animations (for a frame) */
  37238. animate(): void;
  37239. /**
  37240. * Render the scene
  37241. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37242. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37243. */
  37244. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37245. /**
  37246. * Freeze all materials
  37247. * A frozen material will not be updatable but should be faster to render
  37248. */
  37249. freezeMaterials(): void;
  37250. /**
  37251. * Unfreeze all materials
  37252. * A frozen material will not be updatable but should be faster to render
  37253. */
  37254. unfreezeMaterials(): void;
  37255. /**
  37256. * Releases all held ressources
  37257. */
  37258. dispose(): void;
  37259. /**
  37260. * Gets if the scene is already disposed
  37261. */
  37262. get isDisposed(): boolean;
  37263. /**
  37264. * Call this function to reduce memory footprint of the scene.
  37265. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37266. */
  37267. clearCachedVertexData(): void;
  37268. /**
  37269. * This function will remove the local cached buffer data from texture.
  37270. * It will save memory but will prevent the texture from being rebuilt
  37271. */
  37272. cleanCachedTextureBuffer(): void;
  37273. /**
  37274. * Get the world extend vectors with an optional filter
  37275. *
  37276. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37277. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37278. */
  37279. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37280. min: Vector3;
  37281. max: Vector3;
  37282. };
  37283. /**
  37284. * Creates a ray that can be used to pick in the scene
  37285. * @param x defines the x coordinate of the origin (on-screen)
  37286. * @param y defines the y coordinate of the origin (on-screen)
  37287. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37288. * @param camera defines the camera to use for the picking
  37289. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37290. * @returns a Ray
  37291. */
  37292. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37293. /**
  37294. * Creates a ray that can be used to pick in the scene
  37295. * @param x defines the x coordinate of the origin (on-screen)
  37296. * @param y defines the y coordinate of the origin (on-screen)
  37297. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37298. * @param result defines the ray where to store the picking ray
  37299. * @param camera defines the camera to use for the picking
  37300. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37301. * @returns the current scene
  37302. */
  37303. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37304. /**
  37305. * Creates a ray that can be used to pick in the scene
  37306. * @param x defines the x coordinate of the origin (on-screen)
  37307. * @param y defines the y coordinate of the origin (on-screen)
  37308. * @param camera defines the camera to use for the picking
  37309. * @returns a Ray
  37310. */
  37311. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37312. /**
  37313. * Creates a ray that can be used to pick in the scene
  37314. * @param x defines the x coordinate of the origin (on-screen)
  37315. * @param y defines the y coordinate of the origin (on-screen)
  37316. * @param result defines the ray where to store the picking ray
  37317. * @param camera defines the camera to use for the picking
  37318. * @returns the current scene
  37319. */
  37320. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37321. /** Launch a ray to try to pick a mesh in the scene
  37322. * @param x position on screen
  37323. * @param y position on screen
  37324. * @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
  37325. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37326. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37327. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37328. * @returns a PickingInfo
  37329. */
  37330. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37331. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  37332. * @param x position on screen
  37333. * @param y position on screen
  37334. * @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
  37335. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37336. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37337. * @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)
  37338. */
  37339. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  37340. /** Use the given ray to pick a mesh in the scene
  37341. * @param ray The ray to use to pick meshes
  37342. * @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
  37343. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37344. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37345. * @returns a PickingInfo
  37346. */
  37347. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37348. /**
  37349. * Launch a ray to try to pick a mesh in the scene
  37350. * @param x X position on screen
  37351. * @param y Y position on screen
  37352. * @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
  37353. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37354. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37355. * @returns an array of PickingInfo
  37356. */
  37357. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37358. /**
  37359. * Launch a ray to try to pick a mesh in the scene
  37360. * @param ray Ray to use
  37361. * @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
  37362. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37363. * @returns an array of PickingInfo
  37364. */
  37365. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37366. /**
  37367. * Force the value of meshUnderPointer
  37368. * @param mesh defines the mesh to use
  37369. */
  37370. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37371. /**
  37372. * Gets the mesh under the pointer
  37373. * @returns a Mesh or null if no mesh is under the pointer
  37374. */
  37375. getPointerOverMesh(): Nullable<AbstractMesh>;
  37376. /** @hidden */
  37377. _rebuildGeometries(): void;
  37378. /** @hidden */
  37379. _rebuildTextures(): void;
  37380. private _getByTags;
  37381. /**
  37382. * Get a list of meshes by tags
  37383. * @param tagsQuery defines the tags query to use
  37384. * @param forEach defines a predicate used to filter results
  37385. * @returns an array of Mesh
  37386. */
  37387. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37388. /**
  37389. * Get a list of cameras by tags
  37390. * @param tagsQuery defines the tags query to use
  37391. * @param forEach defines a predicate used to filter results
  37392. * @returns an array of Camera
  37393. */
  37394. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37395. /**
  37396. * Get a list of lights by tags
  37397. * @param tagsQuery defines the tags query to use
  37398. * @param forEach defines a predicate used to filter results
  37399. * @returns an array of Light
  37400. */
  37401. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37402. /**
  37403. * Get a list of materials by tags
  37404. * @param tagsQuery defines the tags query to use
  37405. * @param forEach defines a predicate used to filter results
  37406. * @returns an array of Material
  37407. */
  37408. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37409. /**
  37410. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37411. * This allowed control for front to back rendering or reversly depending of the special needs.
  37412. *
  37413. * @param renderingGroupId The rendering group id corresponding to its index
  37414. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37415. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37416. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37417. */
  37418. 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;
  37419. /**
  37420. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37421. *
  37422. * @param renderingGroupId The rendering group id corresponding to its index
  37423. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37424. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37425. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37426. */
  37427. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37428. /**
  37429. * Gets the current auto clear configuration for one rendering group of the rendering
  37430. * manager.
  37431. * @param index the rendering group index to get the information for
  37432. * @returns The auto clear setup for the requested rendering group
  37433. */
  37434. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37435. private _blockMaterialDirtyMechanism;
  37436. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37437. get blockMaterialDirtyMechanism(): boolean;
  37438. set blockMaterialDirtyMechanism(value: boolean);
  37439. /**
  37440. * Will flag all materials as dirty to trigger new shader compilation
  37441. * @param flag defines the flag used to specify which material part must be marked as dirty
  37442. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37443. */
  37444. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37445. /** @hidden */
  37446. _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;
  37447. /** @hidden */
  37448. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37449. /** @hidden */
  37450. _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;
  37451. /** @hidden */
  37452. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37453. /** @hidden */
  37454. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37455. /** @hidden */
  37456. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37457. }
  37458. }
  37459. declare module BABYLON {
  37460. /**
  37461. * Set of assets to keep when moving a scene into an asset container.
  37462. */
  37463. export class KeepAssets extends AbstractScene {
  37464. }
  37465. /**
  37466. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37467. */
  37468. export class InstantiatedEntries {
  37469. /**
  37470. * List of new root nodes (eg. nodes with no parent)
  37471. */
  37472. rootNodes: TransformNode[];
  37473. /**
  37474. * List of new skeletons
  37475. */
  37476. skeletons: Skeleton[];
  37477. /**
  37478. * List of new animation groups
  37479. */
  37480. animationGroups: AnimationGroup[];
  37481. }
  37482. /**
  37483. * Container with a set of assets that can be added or removed from a scene.
  37484. */
  37485. export class AssetContainer extends AbstractScene {
  37486. private _wasAddedToScene;
  37487. /**
  37488. * The scene the AssetContainer belongs to.
  37489. */
  37490. scene: Scene;
  37491. /**
  37492. * Instantiates an AssetContainer.
  37493. * @param scene The scene the AssetContainer belongs to.
  37494. */
  37495. constructor(scene: Scene);
  37496. /**
  37497. * Instantiate or clone all meshes and add the new ones to the scene.
  37498. * Skeletons and animation groups will all be cloned
  37499. * @param nameFunction defines an optional function used to get new names for clones
  37500. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37501. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37502. */
  37503. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37504. /**
  37505. * Adds all the assets from the container to the scene.
  37506. */
  37507. addAllToScene(): void;
  37508. /**
  37509. * Removes all the assets in the container from the scene
  37510. */
  37511. removeAllFromScene(): void;
  37512. /**
  37513. * Disposes all the assets in the container
  37514. */
  37515. dispose(): void;
  37516. private _moveAssets;
  37517. /**
  37518. * Removes all the assets contained in the scene and adds them to the container.
  37519. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37520. */
  37521. moveAllFromScene(keepAssets?: KeepAssets): void;
  37522. /**
  37523. * 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.
  37524. * @returns the root mesh
  37525. */
  37526. createRootMesh(): Mesh;
  37527. /**
  37528. * Merge animations (direct and animation groups) from this asset container into a scene
  37529. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37530. * @param animatables set of animatables to retarget to a node from the scene
  37531. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37532. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  37533. */
  37534. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  37535. }
  37536. }
  37537. declare module BABYLON {
  37538. /**
  37539. * Defines how the parser contract is defined.
  37540. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37541. */
  37542. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37543. /**
  37544. * Defines how the individual parser contract is defined.
  37545. * These parser can parse an individual asset
  37546. */
  37547. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37548. /**
  37549. * Base class of the scene acting as a container for the different elements composing a scene.
  37550. * This class is dynamically extended by the different components of the scene increasing
  37551. * flexibility and reducing coupling
  37552. */
  37553. export abstract class AbstractScene {
  37554. /**
  37555. * Stores the list of available parsers in the application.
  37556. */
  37557. private static _BabylonFileParsers;
  37558. /**
  37559. * Stores the list of available individual parsers in the application.
  37560. */
  37561. private static _IndividualBabylonFileParsers;
  37562. /**
  37563. * Adds a parser in the list of available ones
  37564. * @param name Defines the name of the parser
  37565. * @param parser Defines the parser to add
  37566. */
  37567. static AddParser(name: string, parser: BabylonFileParser): void;
  37568. /**
  37569. * Gets a general parser from the list of avaialble ones
  37570. * @param name Defines the name of the parser
  37571. * @returns the requested parser or null
  37572. */
  37573. static GetParser(name: string): Nullable<BabylonFileParser>;
  37574. /**
  37575. * Adds n individual parser in the list of available ones
  37576. * @param name Defines the name of the parser
  37577. * @param parser Defines the parser to add
  37578. */
  37579. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37580. /**
  37581. * Gets an individual parser from the list of avaialble ones
  37582. * @param name Defines the name of the parser
  37583. * @returns the requested parser or null
  37584. */
  37585. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37586. /**
  37587. * Parser json data and populate both a scene and its associated container object
  37588. * @param jsonData Defines the data to parse
  37589. * @param scene Defines the scene to parse the data for
  37590. * @param container Defines the container attached to the parsing sequence
  37591. * @param rootUrl Defines the root url of the data
  37592. */
  37593. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37594. /**
  37595. * Gets the list of root nodes (ie. nodes with no parent)
  37596. */
  37597. rootNodes: Node[];
  37598. /** All of the cameras added to this scene
  37599. * @see http://doc.babylonjs.com/babylon101/cameras
  37600. */
  37601. cameras: Camera[];
  37602. /**
  37603. * All of the lights added to this scene
  37604. * @see http://doc.babylonjs.com/babylon101/lights
  37605. */
  37606. lights: Light[];
  37607. /**
  37608. * All of the (abstract) meshes added to this scene
  37609. */
  37610. meshes: AbstractMesh[];
  37611. /**
  37612. * The list of skeletons added to the scene
  37613. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37614. */
  37615. skeletons: Skeleton[];
  37616. /**
  37617. * All of the particle systems added to this scene
  37618. * @see http://doc.babylonjs.com/babylon101/particles
  37619. */
  37620. particleSystems: IParticleSystem[];
  37621. /**
  37622. * Gets a list of Animations associated with the scene
  37623. */
  37624. animations: Animation[];
  37625. /**
  37626. * All of the animation groups added to this scene
  37627. * @see http://doc.babylonjs.com/how_to/group
  37628. */
  37629. animationGroups: AnimationGroup[];
  37630. /**
  37631. * All of the multi-materials added to this scene
  37632. * @see http://doc.babylonjs.com/how_to/multi_materials
  37633. */
  37634. multiMaterials: MultiMaterial[];
  37635. /**
  37636. * All of the materials added to this scene
  37637. * In the context of a Scene, it is not supposed to be modified manually.
  37638. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37639. * Note also that the order of the Material within the array is not significant and might change.
  37640. * @see http://doc.babylonjs.com/babylon101/materials
  37641. */
  37642. materials: Material[];
  37643. /**
  37644. * The list of morph target managers added to the scene
  37645. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37646. */
  37647. morphTargetManagers: MorphTargetManager[];
  37648. /**
  37649. * The list of geometries used in the scene.
  37650. */
  37651. geometries: Geometry[];
  37652. /**
  37653. * All of the tranform nodes added to this scene
  37654. * In the context of a Scene, it is not supposed to be modified manually.
  37655. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37656. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37657. * @see http://doc.babylonjs.com/how_to/transformnode
  37658. */
  37659. transformNodes: TransformNode[];
  37660. /**
  37661. * ActionManagers available on the scene.
  37662. */
  37663. actionManagers: AbstractActionManager[];
  37664. /**
  37665. * Textures to keep.
  37666. */
  37667. textures: BaseTexture[];
  37668. /**
  37669. * Environment texture for the scene
  37670. */
  37671. environmentTexture: Nullable<BaseTexture>;
  37672. /**
  37673. * @returns all meshes, lights, cameras, transformNodes and bones
  37674. */
  37675. getNodes(): Array<Node>;
  37676. }
  37677. }
  37678. declare module BABYLON {
  37679. /**
  37680. * Interface used to define options for Sound class
  37681. */
  37682. export interface ISoundOptions {
  37683. /**
  37684. * Does the sound autoplay once loaded.
  37685. */
  37686. autoplay?: boolean;
  37687. /**
  37688. * Does the sound loop after it finishes playing once.
  37689. */
  37690. loop?: boolean;
  37691. /**
  37692. * Sound's volume
  37693. */
  37694. volume?: number;
  37695. /**
  37696. * Is it a spatial sound?
  37697. */
  37698. spatialSound?: boolean;
  37699. /**
  37700. * Maximum distance to hear that sound
  37701. */
  37702. maxDistance?: number;
  37703. /**
  37704. * Uses user defined attenuation function
  37705. */
  37706. useCustomAttenuation?: boolean;
  37707. /**
  37708. * Define the roll off factor of spatial sounds.
  37709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37710. */
  37711. rolloffFactor?: number;
  37712. /**
  37713. * Define the reference distance the sound should be heard perfectly.
  37714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37715. */
  37716. refDistance?: number;
  37717. /**
  37718. * Define the distance attenuation model the sound will follow.
  37719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37720. */
  37721. distanceModel?: string;
  37722. /**
  37723. * Defines the playback speed (1 by default)
  37724. */
  37725. playbackRate?: number;
  37726. /**
  37727. * Defines if the sound is from a streaming source
  37728. */
  37729. streaming?: boolean;
  37730. /**
  37731. * Defines an optional length (in seconds) inside the sound file
  37732. */
  37733. length?: number;
  37734. /**
  37735. * Defines an optional offset (in seconds) inside the sound file
  37736. */
  37737. offset?: number;
  37738. /**
  37739. * If true, URLs will not be required to state the audio file codec to use.
  37740. */
  37741. skipCodecCheck?: boolean;
  37742. }
  37743. /**
  37744. * Defines a sound that can be played in the application.
  37745. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37747. */
  37748. export class Sound {
  37749. /**
  37750. * The name of the sound in the scene.
  37751. */
  37752. name: string;
  37753. /**
  37754. * Does the sound autoplay once loaded.
  37755. */
  37756. autoplay: boolean;
  37757. /**
  37758. * Does the sound loop after it finishes playing once.
  37759. */
  37760. loop: boolean;
  37761. /**
  37762. * Does the sound use a custom attenuation curve to simulate the falloff
  37763. * happening when the source gets further away from the camera.
  37764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37765. */
  37766. useCustomAttenuation: boolean;
  37767. /**
  37768. * The sound track id this sound belongs to.
  37769. */
  37770. soundTrackId: number;
  37771. /**
  37772. * Is this sound currently played.
  37773. */
  37774. isPlaying: boolean;
  37775. /**
  37776. * Is this sound currently paused.
  37777. */
  37778. isPaused: boolean;
  37779. /**
  37780. * Does this sound enables spatial sound.
  37781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37782. */
  37783. spatialSound: boolean;
  37784. /**
  37785. * Define the reference distance the sound should be heard perfectly.
  37786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37787. */
  37788. refDistance: number;
  37789. /**
  37790. * Define the roll off factor of spatial sounds.
  37791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37792. */
  37793. rolloffFactor: number;
  37794. /**
  37795. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37797. */
  37798. maxDistance: number;
  37799. /**
  37800. * Define the distance attenuation model the sound will follow.
  37801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37802. */
  37803. distanceModel: string;
  37804. /**
  37805. * @hidden
  37806. * Back Compat
  37807. **/
  37808. onended: () => any;
  37809. /**
  37810. * Observable event when the current playing sound finishes.
  37811. */
  37812. onEndedObservable: Observable<Sound>;
  37813. private _panningModel;
  37814. private _playbackRate;
  37815. private _streaming;
  37816. private _startTime;
  37817. private _startOffset;
  37818. private _position;
  37819. /** @hidden */
  37820. _positionInEmitterSpace: boolean;
  37821. private _localDirection;
  37822. private _volume;
  37823. private _isReadyToPlay;
  37824. private _isDirectional;
  37825. private _readyToPlayCallback;
  37826. private _audioBuffer;
  37827. private _soundSource;
  37828. private _streamingSource;
  37829. private _soundPanner;
  37830. private _soundGain;
  37831. private _inputAudioNode;
  37832. private _outputAudioNode;
  37833. private _coneInnerAngle;
  37834. private _coneOuterAngle;
  37835. private _coneOuterGain;
  37836. private _scene;
  37837. private _connectedTransformNode;
  37838. private _customAttenuationFunction;
  37839. private _registerFunc;
  37840. private _isOutputConnected;
  37841. private _htmlAudioElement;
  37842. private _urlType;
  37843. private _length?;
  37844. private _offset?;
  37845. /** @hidden */
  37846. static _SceneComponentInitialization: (scene: Scene) => void;
  37847. /**
  37848. * Create a sound and attach it to a scene
  37849. * @param name Name of your sound
  37850. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37851. * @param scene defines the scene the sound belongs to
  37852. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37853. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37854. */
  37855. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37856. /**
  37857. * Release the sound and its associated resources
  37858. */
  37859. dispose(): void;
  37860. /**
  37861. * Gets if the sounds is ready to be played or not.
  37862. * @returns true if ready, otherwise false
  37863. */
  37864. isReady(): boolean;
  37865. private _soundLoaded;
  37866. /**
  37867. * Sets the data of the sound from an audiobuffer
  37868. * @param audioBuffer The audioBuffer containing the data
  37869. */
  37870. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37871. /**
  37872. * Updates the current sounds options such as maxdistance, loop...
  37873. * @param options A JSON object containing values named as the object properties
  37874. */
  37875. updateOptions(options: ISoundOptions): void;
  37876. private _createSpatialParameters;
  37877. private _updateSpatialParameters;
  37878. /**
  37879. * Switch the panning model to HRTF:
  37880. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37882. */
  37883. switchPanningModelToHRTF(): void;
  37884. /**
  37885. * Switch the panning model to Equal Power:
  37886. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37888. */
  37889. switchPanningModelToEqualPower(): void;
  37890. private _switchPanningModel;
  37891. /**
  37892. * Connect this sound to a sound track audio node like gain...
  37893. * @param soundTrackAudioNode the sound track audio node to connect to
  37894. */
  37895. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37896. /**
  37897. * Transform this sound into a directional source
  37898. * @param coneInnerAngle Size of the inner cone in degree
  37899. * @param coneOuterAngle Size of the outer cone in degree
  37900. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37901. */
  37902. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37903. /**
  37904. * Gets or sets the inner angle for the directional cone.
  37905. */
  37906. get directionalConeInnerAngle(): number;
  37907. /**
  37908. * Gets or sets the inner angle for the directional cone.
  37909. */
  37910. set directionalConeInnerAngle(value: number);
  37911. /**
  37912. * Gets or sets the outer angle for the directional cone.
  37913. */
  37914. get directionalConeOuterAngle(): number;
  37915. /**
  37916. * Gets or sets the outer angle for the directional cone.
  37917. */
  37918. set directionalConeOuterAngle(value: number);
  37919. /**
  37920. * Sets the position of the emitter if spatial sound is enabled
  37921. * @param newPosition Defines the new posisiton
  37922. */
  37923. setPosition(newPosition: Vector3): void;
  37924. /**
  37925. * Sets the local direction of the emitter if spatial sound is enabled
  37926. * @param newLocalDirection Defines the new local direction
  37927. */
  37928. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37929. private _updateDirection;
  37930. /** @hidden */
  37931. updateDistanceFromListener(): void;
  37932. /**
  37933. * Sets a new custom attenuation function for the sound.
  37934. * @param callback Defines the function used for the attenuation
  37935. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37936. */
  37937. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37938. /**
  37939. * Play the sound
  37940. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37941. * @param offset (optional) Start the sound at a specific time in seconds
  37942. * @param length (optional) Sound duration (in seconds)
  37943. */
  37944. play(time?: number, offset?: number, length?: number): void;
  37945. private _onended;
  37946. /**
  37947. * Stop the sound
  37948. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37949. */
  37950. stop(time?: number): void;
  37951. /**
  37952. * Put the sound in pause
  37953. */
  37954. pause(): void;
  37955. /**
  37956. * Sets a dedicated volume for this sounds
  37957. * @param newVolume Define the new volume of the sound
  37958. * @param time Define time for gradual change to new volume
  37959. */
  37960. setVolume(newVolume: number, time?: number): void;
  37961. /**
  37962. * Set the sound play back rate
  37963. * @param newPlaybackRate Define the playback rate the sound should be played at
  37964. */
  37965. setPlaybackRate(newPlaybackRate: number): void;
  37966. /**
  37967. * Gets the volume of the sound.
  37968. * @returns the volume of the sound
  37969. */
  37970. getVolume(): number;
  37971. /**
  37972. * Attach the sound to a dedicated mesh
  37973. * @param transformNode The transform node to connect the sound with
  37974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37975. */
  37976. attachToMesh(transformNode: TransformNode): void;
  37977. /**
  37978. * Detach the sound from the previously attached mesh
  37979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37980. */
  37981. detachFromMesh(): void;
  37982. private _onRegisterAfterWorldMatrixUpdate;
  37983. /**
  37984. * Clone the current sound in the scene.
  37985. * @returns the new sound clone
  37986. */
  37987. clone(): Nullable<Sound>;
  37988. /**
  37989. * Gets the current underlying audio buffer containing the data
  37990. * @returns the audio buffer
  37991. */
  37992. getAudioBuffer(): Nullable<AudioBuffer>;
  37993. /**
  37994. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37995. * @returns the source node
  37996. */
  37997. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37998. /**
  37999. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38000. * @returns the gain node
  38001. */
  38002. getSoundGain(): Nullable<GainNode>;
  38003. /**
  38004. * Serializes the Sound in a JSON representation
  38005. * @returns the JSON representation of the sound
  38006. */
  38007. serialize(): any;
  38008. /**
  38009. * Parse a JSON representation of a sound to innstantiate in a given scene
  38010. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38011. * @param scene Define the scene the new parsed sound should be created in
  38012. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38013. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38014. * @returns the newly parsed sound
  38015. */
  38016. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38017. }
  38018. }
  38019. declare module BABYLON {
  38020. /**
  38021. * This defines an action helpful to play a defined sound on a triggered action.
  38022. */
  38023. export class PlaySoundAction extends Action {
  38024. private _sound;
  38025. /**
  38026. * Instantiate the action
  38027. * @param triggerOptions defines the trigger options
  38028. * @param sound defines the sound to play
  38029. * @param condition defines the trigger related conditions
  38030. */
  38031. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38032. /** @hidden */
  38033. _prepare(): void;
  38034. /**
  38035. * Execute the action and play the sound.
  38036. */
  38037. execute(): void;
  38038. /**
  38039. * Serializes the actions and its related information.
  38040. * @param parent defines the object to serialize in
  38041. * @returns the serialized object
  38042. */
  38043. serialize(parent: any): any;
  38044. }
  38045. /**
  38046. * This defines an action helpful to stop a defined sound on a triggered action.
  38047. */
  38048. export class StopSoundAction extends Action {
  38049. private _sound;
  38050. /**
  38051. * Instantiate the action
  38052. * @param triggerOptions defines the trigger options
  38053. * @param sound defines the sound to stop
  38054. * @param condition defines the trigger related conditions
  38055. */
  38056. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38057. /** @hidden */
  38058. _prepare(): void;
  38059. /**
  38060. * Execute the action and stop the sound.
  38061. */
  38062. execute(): void;
  38063. /**
  38064. * Serializes the actions and its related information.
  38065. * @param parent defines the object to serialize in
  38066. * @returns the serialized object
  38067. */
  38068. serialize(parent: any): any;
  38069. }
  38070. }
  38071. declare module BABYLON {
  38072. /**
  38073. * This defines an action responsible to change the value of a property
  38074. * by interpolating between its current value and the newly set one once triggered.
  38075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38076. */
  38077. export class InterpolateValueAction extends Action {
  38078. /**
  38079. * Defines the path of the property where the value should be interpolated
  38080. */
  38081. propertyPath: string;
  38082. /**
  38083. * Defines the target value at the end of the interpolation.
  38084. */
  38085. value: any;
  38086. /**
  38087. * Defines the time it will take for the property to interpolate to the value.
  38088. */
  38089. duration: number;
  38090. /**
  38091. * Defines if the other scene animations should be stopped when the action has been triggered
  38092. */
  38093. stopOtherAnimations?: boolean;
  38094. /**
  38095. * Defines a callback raised once the interpolation animation has been done.
  38096. */
  38097. onInterpolationDone?: () => void;
  38098. /**
  38099. * Observable triggered once the interpolation animation has been done.
  38100. */
  38101. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38102. private _target;
  38103. private _effectiveTarget;
  38104. private _property;
  38105. /**
  38106. * Instantiate the action
  38107. * @param triggerOptions defines the trigger options
  38108. * @param target defines the object containing the value to interpolate
  38109. * @param propertyPath defines the path to the property in the target object
  38110. * @param value defines the target value at the end of the interpolation
  38111. * @param duration deines the time it will take for the property to interpolate to the value.
  38112. * @param condition defines the trigger related conditions
  38113. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38114. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38115. */
  38116. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38117. /** @hidden */
  38118. _prepare(): void;
  38119. /**
  38120. * Execute the action starts the value interpolation.
  38121. */
  38122. execute(): void;
  38123. /**
  38124. * Serializes the actions and its related information.
  38125. * @param parent defines the object to serialize in
  38126. * @returns the serialized object
  38127. */
  38128. serialize(parent: any): any;
  38129. }
  38130. }
  38131. declare module BABYLON {
  38132. /**
  38133. * Options allowed during the creation of a sound track.
  38134. */
  38135. export interface ISoundTrackOptions {
  38136. /**
  38137. * The volume the sound track should take during creation
  38138. */
  38139. volume?: number;
  38140. /**
  38141. * Define if the sound track is the main sound track of the scene
  38142. */
  38143. mainTrack?: boolean;
  38144. }
  38145. /**
  38146. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38147. * It will be also used in a future release to apply effects on a specific track.
  38148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38149. */
  38150. export class SoundTrack {
  38151. /**
  38152. * The unique identifier of the sound track in the scene.
  38153. */
  38154. id: number;
  38155. /**
  38156. * The list of sounds included in the sound track.
  38157. */
  38158. soundCollection: Array<Sound>;
  38159. private _outputAudioNode;
  38160. private _scene;
  38161. private _connectedAnalyser;
  38162. private _options;
  38163. private _isInitialized;
  38164. /**
  38165. * Creates a new sound track.
  38166. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38167. * @param scene Define the scene the sound track belongs to
  38168. * @param options
  38169. */
  38170. constructor(scene: Scene, options?: ISoundTrackOptions);
  38171. private _initializeSoundTrackAudioGraph;
  38172. /**
  38173. * Release the sound track and its associated resources
  38174. */
  38175. dispose(): void;
  38176. /**
  38177. * Adds a sound to this sound track
  38178. * @param sound define the cound to add
  38179. * @ignoreNaming
  38180. */
  38181. AddSound(sound: Sound): void;
  38182. /**
  38183. * Removes a sound to this sound track
  38184. * @param sound define the cound to remove
  38185. * @ignoreNaming
  38186. */
  38187. RemoveSound(sound: Sound): void;
  38188. /**
  38189. * Set a global volume for the full sound track.
  38190. * @param newVolume Define the new volume of the sound track
  38191. */
  38192. setVolume(newVolume: number): void;
  38193. /**
  38194. * Switch the panning model to HRTF:
  38195. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38197. */
  38198. switchPanningModelToHRTF(): void;
  38199. /**
  38200. * Switch the panning model to Equal Power:
  38201. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38203. */
  38204. switchPanningModelToEqualPower(): void;
  38205. /**
  38206. * Connect the sound track to an audio analyser allowing some amazing
  38207. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38209. * @param analyser The analyser to connect to the engine
  38210. */
  38211. connectToAnalyser(analyser: Analyser): void;
  38212. }
  38213. }
  38214. declare module BABYLON {
  38215. interface AbstractScene {
  38216. /**
  38217. * The list of sounds used in the scene.
  38218. */
  38219. sounds: Nullable<Array<Sound>>;
  38220. }
  38221. interface Scene {
  38222. /**
  38223. * @hidden
  38224. * Backing field
  38225. */
  38226. _mainSoundTrack: SoundTrack;
  38227. /**
  38228. * The main sound track played by the scene.
  38229. * It cotains your primary collection of sounds.
  38230. */
  38231. mainSoundTrack: SoundTrack;
  38232. /**
  38233. * The list of sound tracks added to the scene
  38234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38235. */
  38236. soundTracks: Nullable<Array<SoundTrack>>;
  38237. /**
  38238. * Gets a sound using a given name
  38239. * @param name defines the name to search for
  38240. * @return the found sound or null if not found at all.
  38241. */
  38242. getSoundByName(name: string): Nullable<Sound>;
  38243. /**
  38244. * Gets or sets if audio support is enabled
  38245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38246. */
  38247. audioEnabled: boolean;
  38248. /**
  38249. * Gets or sets if audio will be output to headphones
  38250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38251. */
  38252. headphone: boolean;
  38253. /**
  38254. * Gets or sets custom audio listener position provider
  38255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38256. */
  38257. audioListenerPositionProvider: Nullable<() => Vector3>;
  38258. /**
  38259. * Gets or sets a refresh rate when using 3D audio positioning
  38260. */
  38261. audioPositioningRefreshRate: number;
  38262. }
  38263. /**
  38264. * Defines the sound scene component responsible to manage any sounds
  38265. * in a given scene.
  38266. */
  38267. export class AudioSceneComponent implements ISceneSerializableComponent {
  38268. /**
  38269. * The component name helpfull to identify the component in the list of scene components.
  38270. */
  38271. readonly name: string;
  38272. /**
  38273. * The scene the component belongs to.
  38274. */
  38275. scene: Scene;
  38276. private _audioEnabled;
  38277. /**
  38278. * Gets whether audio is enabled or not.
  38279. * Please use related enable/disable method to switch state.
  38280. */
  38281. get audioEnabled(): boolean;
  38282. private _headphone;
  38283. /**
  38284. * Gets whether audio is outputing to headphone or not.
  38285. * Please use the according Switch methods to change output.
  38286. */
  38287. get headphone(): boolean;
  38288. /**
  38289. * Gets or sets a refresh rate when using 3D audio positioning
  38290. */
  38291. audioPositioningRefreshRate: number;
  38292. private _audioListenerPositionProvider;
  38293. /**
  38294. * Gets the current audio listener position provider
  38295. */
  38296. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38297. /**
  38298. * Sets a custom listener position for all sounds in the scene
  38299. * By default, this is the position of the first active camera
  38300. */
  38301. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38302. /**
  38303. * Creates a new instance of the component for the given scene
  38304. * @param scene Defines the scene to register the component in
  38305. */
  38306. constructor(scene: Scene);
  38307. /**
  38308. * Registers the component in a given scene
  38309. */
  38310. register(): void;
  38311. /**
  38312. * Rebuilds the elements related to this component in case of
  38313. * context lost for instance.
  38314. */
  38315. rebuild(): void;
  38316. /**
  38317. * Serializes the component data to the specified json object
  38318. * @param serializationObject The object to serialize to
  38319. */
  38320. serialize(serializationObject: any): void;
  38321. /**
  38322. * Adds all the elements from the container to the scene
  38323. * @param container the container holding the elements
  38324. */
  38325. addFromContainer(container: AbstractScene): void;
  38326. /**
  38327. * Removes all the elements in the container from the scene
  38328. * @param container contains the elements to remove
  38329. * @param dispose if the removed element should be disposed (default: false)
  38330. */
  38331. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38332. /**
  38333. * Disposes the component and the associated ressources.
  38334. */
  38335. dispose(): void;
  38336. /**
  38337. * Disables audio in the associated scene.
  38338. */
  38339. disableAudio(): void;
  38340. /**
  38341. * Enables audio in the associated scene.
  38342. */
  38343. enableAudio(): void;
  38344. /**
  38345. * Switch audio to headphone output.
  38346. */
  38347. switchAudioModeForHeadphones(): void;
  38348. /**
  38349. * Switch audio to normal speakers.
  38350. */
  38351. switchAudioModeForNormalSpeakers(): void;
  38352. private _cachedCameraDirection;
  38353. private _cachedCameraPosition;
  38354. private _lastCheck;
  38355. private _afterRender;
  38356. }
  38357. }
  38358. declare module BABYLON {
  38359. /**
  38360. * Wraps one or more Sound objects and selects one with random weight for playback.
  38361. */
  38362. export class WeightedSound {
  38363. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38364. loop: boolean;
  38365. private _coneInnerAngle;
  38366. private _coneOuterAngle;
  38367. private _volume;
  38368. /** A Sound is currently playing. */
  38369. isPlaying: boolean;
  38370. /** A Sound is currently paused. */
  38371. isPaused: boolean;
  38372. private _sounds;
  38373. private _weights;
  38374. private _currentIndex?;
  38375. /**
  38376. * Creates a new WeightedSound from the list of sounds given.
  38377. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38378. * @param sounds Array of Sounds that will be selected from.
  38379. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38380. */
  38381. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38382. /**
  38383. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38384. */
  38385. get directionalConeInnerAngle(): number;
  38386. /**
  38387. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38388. */
  38389. set directionalConeInnerAngle(value: number);
  38390. /**
  38391. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38392. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38393. */
  38394. get directionalConeOuterAngle(): number;
  38395. /**
  38396. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38397. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38398. */
  38399. set directionalConeOuterAngle(value: number);
  38400. /**
  38401. * Playback volume.
  38402. */
  38403. get volume(): number;
  38404. /**
  38405. * Playback volume.
  38406. */
  38407. set volume(value: number);
  38408. private _onended;
  38409. /**
  38410. * Suspend playback
  38411. */
  38412. pause(): void;
  38413. /**
  38414. * Stop playback
  38415. */
  38416. stop(): void;
  38417. /**
  38418. * Start playback.
  38419. * @param startOffset Position the clip head at a specific time in seconds.
  38420. */
  38421. play(startOffset?: number): void;
  38422. }
  38423. }
  38424. declare module BABYLON {
  38425. /**
  38426. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38427. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38428. */
  38429. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38430. /**
  38431. * Gets the name of the behavior.
  38432. */
  38433. get name(): string;
  38434. /**
  38435. * The easing function used by animations
  38436. */
  38437. static EasingFunction: BackEase;
  38438. /**
  38439. * The easing mode used by animations
  38440. */
  38441. static EasingMode: number;
  38442. /**
  38443. * The duration of the animation, in milliseconds
  38444. */
  38445. transitionDuration: number;
  38446. /**
  38447. * Length of the distance animated by the transition when lower radius is reached
  38448. */
  38449. lowerRadiusTransitionRange: number;
  38450. /**
  38451. * Length of the distance animated by the transition when upper radius is reached
  38452. */
  38453. upperRadiusTransitionRange: number;
  38454. private _autoTransitionRange;
  38455. /**
  38456. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38457. */
  38458. get autoTransitionRange(): boolean;
  38459. /**
  38460. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38461. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38462. */
  38463. set autoTransitionRange(value: boolean);
  38464. private _attachedCamera;
  38465. private _onAfterCheckInputsObserver;
  38466. private _onMeshTargetChangedObserver;
  38467. /**
  38468. * Initializes the behavior.
  38469. */
  38470. init(): void;
  38471. /**
  38472. * Attaches the behavior to its arc rotate camera.
  38473. * @param camera Defines the camera to attach the behavior to
  38474. */
  38475. attach(camera: ArcRotateCamera): void;
  38476. /**
  38477. * Detaches the behavior from its current arc rotate camera.
  38478. */
  38479. detach(): void;
  38480. private _radiusIsAnimating;
  38481. private _radiusBounceTransition;
  38482. private _animatables;
  38483. private _cachedWheelPrecision;
  38484. /**
  38485. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38486. * @param radiusLimit The limit to check against.
  38487. * @return Bool to indicate if at limit.
  38488. */
  38489. private _isRadiusAtLimit;
  38490. /**
  38491. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38492. * @param radiusDelta The delta by which to animate to. Can be negative.
  38493. */
  38494. private _applyBoundRadiusAnimation;
  38495. /**
  38496. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38497. */
  38498. protected _clearAnimationLocks(): void;
  38499. /**
  38500. * Stops and removes all animations that have been applied to the camera
  38501. */
  38502. stopAllAnimations(): void;
  38503. }
  38504. }
  38505. declare module BABYLON {
  38506. /**
  38507. * 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.
  38508. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38509. */
  38510. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38511. /**
  38512. * Gets the name of the behavior.
  38513. */
  38514. get name(): string;
  38515. private _mode;
  38516. private _radiusScale;
  38517. private _positionScale;
  38518. private _defaultElevation;
  38519. private _elevationReturnTime;
  38520. private _elevationReturnWaitTime;
  38521. private _zoomStopsAnimation;
  38522. private _framingTime;
  38523. /**
  38524. * The easing function used by animations
  38525. */
  38526. static EasingFunction: ExponentialEase;
  38527. /**
  38528. * The easing mode used by animations
  38529. */
  38530. static EasingMode: number;
  38531. /**
  38532. * Sets the current mode used by the behavior
  38533. */
  38534. set mode(mode: number);
  38535. /**
  38536. * Gets current mode used by the behavior.
  38537. */
  38538. get mode(): number;
  38539. /**
  38540. * Sets the scale applied to the radius (1 by default)
  38541. */
  38542. set radiusScale(radius: number);
  38543. /**
  38544. * Gets the scale applied to the radius
  38545. */
  38546. get radiusScale(): number;
  38547. /**
  38548. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38549. */
  38550. set positionScale(scale: number);
  38551. /**
  38552. * Gets 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. get positionScale(): number;
  38555. /**
  38556. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38557. * behaviour is triggered, in radians.
  38558. */
  38559. set defaultElevation(elevation: number);
  38560. /**
  38561. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38562. * behaviour is triggered, in radians.
  38563. */
  38564. get defaultElevation(): number;
  38565. /**
  38566. * Sets the time (in milliseconds) taken to return to the default beta position.
  38567. * Negative value indicates camera should not return to default.
  38568. */
  38569. set elevationReturnTime(speed: number);
  38570. /**
  38571. * Gets the time (in milliseconds) taken to return to the default beta position.
  38572. * Negative value indicates camera should not return to default.
  38573. */
  38574. get elevationReturnTime(): number;
  38575. /**
  38576. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38577. */
  38578. set elevationReturnWaitTime(time: number);
  38579. /**
  38580. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38581. */
  38582. get elevationReturnWaitTime(): number;
  38583. /**
  38584. * Sets the flag that indicates if user zooming should stop animation.
  38585. */
  38586. set zoomStopsAnimation(flag: boolean);
  38587. /**
  38588. * Gets the flag that indicates if user zooming should stop animation.
  38589. */
  38590. get zoomStopsAnimation(): boolean;
  38591. /**
  38592. * Sets the transition time when framing the mesh, in milliseconds
  38593. */
  38594. set framingTime(time: number);
  38595. /**
  38596. * Gets the transition time when framing the mesh, in milliseconds
  38597. */
  38598. get framingTime(): number;
  38599. /**
  38600. * Define if the behavior should automatically change the configured
  38601. * camera limits and sensibilities.
  38602. */
  38603. autoCorrectCameraLimitsAndSensibility: boolean;
  38604. private _onPrePointerObservableObserver;
  38605. private _onAfterCheckInputsObserver;
  38606. private _onMeshTargetChangedObserver;
  38607. private _attachedCamera;
  38608. private _isPointerDown;
  38609. private _lastInteractionTime;
  38610. /**
  38611. * Initializes the behavior.
  38612. */
  38613. init(): void;
  38614. /**
  38615. * Attaches the behavior to its arc rotate camera.
  38616. * @param camera Defines the camera to attach the behavior to
  38617. */
  38618. attach(camera: ArcRotateCamera): void;
  38619. /**
  38620. * Detaches the behavior from its current arc rotate camera.
  38621. */
  38622. detach(): void;
  38623. private _animatables;
  38624. private _betaIsAnimating;
  38625. private _betaTransition;
  38626. private _radiusTransition;
  38627. private _vectorTransition;
  38628. /**
  38629. * Targets the given mesh and updates zoom level accordingly.
  38630. * @param mesh The mesh to target.
  38631. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38632. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38633. */
  38634. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38635. /**
  38636. * Targets the given mesh with its children and updates zoom level accordingly.
  38637. * @param mesh The mesh to target.
  38638. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38639. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38640. */
  38641. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38642. /**
  38643. * Targets the given meshes with their children and updates zoom level accordingly.
  38644. * @param meshes The mesh to target.
  38645. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38646. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38647. */
  38648. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38649. /**
  38650. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38651. * @param minimumWorld Determines the smaller position of the bounding box extend
  38652. * @param maximumWorld Determines the bigger position of the bounding box extend
  38653. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38654. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38655. */
  38656. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38657. /**
  38658. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38659. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38660. * frustum width.
  38661. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38662. * to fully enclose the mesh in the viewing frustum.
  38663. */
  38664. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38665. /**
  38666. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38667. * is automatically returned to its default position (expected to be above ground plane).
  38668. */
  38669. private _maintainCameraAboveGround;
  38670. /**
  38671. * Returns the frustum slope based on the canvas ratio and camera FOV
  38672. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38673. */
  38674. private _getFrustumSlope;
  38675. /**
  38676. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38677. */
  38678. private _clearAnimationLocks;
  38679. /**
  38680. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38681. */
  38682. private _applyUserInteraction;
  38683. /**
  38684. * Stops and removes all animations that have been applied to the camera
  38685. */
  38686. stopAllAnimations(): void;
  38687. /**
  38688. * Gets a value indicating if the user is moving the camera
  38689. */
  38690. get isUserIsMoving(): boolean;
  38691. /**
  38692. * The camera can move all the way towards the mesh.
  38693. */
  38694. static IgnoreBoundsSizeMode: number;
  38695. /**
  38696. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38697. */
  38698. static FitFrustumSidesMode: number;
  38699. }
  38700. }
  38701. declare module BABYLON {
  38702. /**
  38703. * Base class for Camera Pointer Inputs.
  38704. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38705. * for example usage.
  38706. */
  38707. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38708. /**
  38709. * Defines the camera the input is attached to.
  38710. */
  38711. abstract camera: Camera;
  38712. /**
  38713. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38714. */
  38715. protected _altKey: boolean;
  38716. protected _ctrlKey: boolean;
  38717. protected _metaKey: boolean;
  38718. protected _shiftKey: boolean;
  38719. /**
  38720. * Which mouse buttons were pressed at time of last mouse event.
  38721. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38722. */
  38723. protected _buttonsPressed: number;
  38724. /**
  38725. * Defines the buttons associated with the input to handle camera move.
  38726. */
  38727. buttons: number[];
  38728. /**
  38729. * Attach the input controls to a specific dom element to get the input from.
  38730. * @param element Defines the element the controls should be listened from
  38731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38732. */
  38733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38734. /**
  38735. * Detach the current controls from the specified dom element.
  38736. * @param element Defines the element to stop listening the inputs from
  38737. */
  38738. detachControl(element: Nullable<HTMLElement>): void;
  38739. /**
  38740. * Gets the class name of the current input.
  38741. * @returns the class name
  38742. */
  38743. getClassName(): string;
  38744. /**
  38745. * Get the friendly name associated with the input class.
  38746. * @returns the input friendly name
  38747. */
  38748. getSimpleName(): string;
  38749. /**
  38750. * Called on pointer POINTERDOUBLETAP event.
  38751. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38752. */
  38753. protected onDoubleTap(type: string): void;
  38754. /**
  38755. * Called on pointer POINTERMOVE event if only a single touch is active.
  38756. * Override this method to provide functionality.
  38757. */
  38758. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38759. /**
  38760. * Called on pointer POINTERMOVE event if multiple touches are active.
  38761. * Override this method to provide functionality.
  38762. */
  38763. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38764. /**
  38765. * Called on JS contextmenu event.
  38766. * Override this method to provide functionality.
  38767. */
  38768. protected onContextMenu(evt: PointerEvent): void;
  38769. /**
  38770. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38771. * press.
  38772. * Override this method to provide functionality.
  38773. */
  38774. protected onButtonDown(evt: PointerEvent): void;
  38775. /**
  38776. * Called each time a new POINTERUP event occurs. Ie, for each button
  38777. * release.
  38778. * Override this method to provide functionality.
  38779. */
  38780. protected onButtonUp(evt: PointerEvent): void;
  38781. /**
  38782. * Called when window becomes inactive.
  38783. * Override this method to provide functionality.
  38784. */
  38785. protected onLostFocus(): void;
  38786. private _pointerInput;
  38787. private _observer;
  38788. private _onLostFocus;
  38789. private pointA;
  38790. private pointB;
  38791. }
  38792. }
  38793. declare module BABYLON {
  38794. /**
  38795. * Manage the pointers inputs to control an arc rotate camera.
  38796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38797. */
  38798. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38799. /**
  38800. * Defines the camera the input is attached to.
  38801. */
  38802. camera: ArcRotateCamera;
  38803. /**
  38804. * Gets the class name of the current input.
  38805. * @returns the class name
  38806. */
  38807. getClassName(): string;
  38808. /**
  38809. * Defines the buttons associated with the input to handle camera move.
  38810. */
  38811. buttons: number[];
  38812. /**
  38813. * Defines the pointer angular sensibility along the X axis or how fast is
  38814. * the camera rotating.
  38815. */
  38816. angularSensibilityX: number;
  38817. /**
  38818. * Defines the pointer angular sensibility along the Y axis or how fast is
  38819. * the camera rotating.
  38820. */
  38821. angularSensibilityY: number;
  38822. /**
  38823. * Defines the pointer pinch precision or how fast is the camera zooming.
  38824. */
  38825. pinchPrecision: number;
  38826. /**
  38827. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38828. * from 0.
  38829. * It defines the percentage of current camera.radius to use as delta when
  38830. * pinch zoom is used.
  38831. */
  38832. pinchDeltaPercentage: number;
  38833. /**
  38834. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38835. * that any object in the plane at the camera's target point will scale
  38836. * perfectly with finger motion.
  38837. * Overrides pinchDeltaPercentage and pinchPrecision.
  38838. */
  38839. useNaturalPinchZoom: boolean;
  38840. /**
  38841. * Defines the pointer panning sensibility or how fast is the camera moving.
  38842. */
  38843. panningSensibility: number;
  38844. /**
  38845. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38846. */
  38847. multiTouchPanning: boolean;
  38848. /**
  38849. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38850. * zoom (pinch) through multitouch.
  38851. */
  38852. multiTouchPanAndZoom: boolean;
  38853. /**
  38854. * Revers pinch action direction.
  38855. */
  38856. pinchInwards: boolean;
  38857. private _isPanClick;
  38858. private _twoFingerActivityCount;
  38859. private _isPinching;
  38860. /**
  38861. * Called on pointer POINTERMOVE event if only a single touch is active.
  38862. */
  38863. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38864. /**
  38865. * Called on pointer POINTERDOUBLETAP event.
  38866. */
  38867. protected onDoubleTap(type: string): void;
  38868. /**
  38869. * Called on pointer POINTERMOVE event if multiple touches are active.
  38870. */
  38871. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38872. /**
  38873. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38874. * press.
  38875. */
  38876. protected onButtonDown(evt: PointerEvent): void;
  38877. /**
  38878. * Called each time a new POINTERUP event occurs. Ie, for each button
  38879. * release.
  38880. */
  38881. protected onButtonUp(evt: PointerEvent): void;
  38882. /**
  38883. * Called when window becomes inactive.
  38884. */
  38885. protected onLostFocus(): void;
  38886. }
  38887. }
  38888. declare module BABYLON {
  38889. /**
  38890. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38891. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38892. */
  38893. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38894. /**
  38895. * Defines the camera the input is attached to.
  38896. */
  38897. camera: ArcRotateCamera;
  38898. /**
  38899. * Defines the list of key codes associated with the up action (increase alpha)
  38900. */
  38901. keysUp: number[];
  38902. /**
  38903. * Defines the list of key codes associated with the down action (decrease alpha)
  38904. */
  38905. keysDown: number[];
  38906. /**
  38907. * Defines the list of key codes associated with the left action (increase beta)
  38908. */
  38909. keysLeft: number[];
  38910. /**
  38911. * Defines the list of key codes associated with the right action (decrease beta)
  38912. */
  38913. keysRight: number[];
  38914. /**
  38915. * Defines the list of key codes associated with the reset action.
  38916. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38917. */
  38918. keysReset: number[];
  38919. /**
  38920. * Defines the panning sensibility of the inputs.
  38921. * (How fast is the camera panning)
  38922. */
  38923. panningSensibility: number;
  38924. /**
  38925. * Defines the zooming sensibility of the inputs.
  38926. * (How fast is the camera zooming)
  38927. */
  38928. zoomingSensibility: number;
  38929. /**
  38930. * Defines whether maintaining the alt key down switch the movement mode from
  38931. * orientation to zoom.
  38932. */
  38933. useAltToZoom: boolean;
  38934. /**
  38935. * Rotation speed of the camera
  38936. */
  38937. angularSpeed: number;
  38938. private _keys;
  38939. private _ctrlPressed;
  38940. private _altPressed;
  38941. private _onCanvasBlurObserver;
  38942. private _onKeyboardObserver;
  38943. private _engine;
  38944. private _scene;
  38945. /**
  38946. * Attach the input controls to a specific dom element to get the input from.
  38947. * @param element Defines the element the controls should be listened from
  38948. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38949. */
  38950. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38951. /**
  38952. * Detach the current controls from the specified dom element.
  38953. * @param element Defines the element to stop listening the inputs from
  38954. */
  38955. detachControl(element: Nullable<HTMLElement>): void;
  38956. /**
  38957. * Update the current camera state depending on the inputs that have been used this frame.
  38958. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38959. */
  38960. checkInputs(): void;
  38961. /**
  38962. * Gets the class name of the current intput.
  38963. * @returns the class name
  38964. */
  38965. getClassName(): string;
  38966. /**
  38967. * Get the friendly name associated with the input class.
  38968. * @returns the input friendly name
  38969. */
  38970. getSimpleName(): string;
  38971. }
  38972. }
  38973. declare module BABYLON {
  38974. /**
  38975. * Manage the mouse wheel inputs to control an arc rotate camera.
  38976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38977. */
  38978. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38979. /**
  38980. * Defines the camera the input is attached to.
  38981. */
  38982. camera: ArcRotateCamera;
  38983. /**
  38984. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38985. */
  38986. wheelPrecision: number;
  38987. /**
  38988. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38989. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38990. */
  38991. wheelDeltaPercentage: number;
  38992. private _wheel;
  38993. private _observer;
  38994. private computeDeltaFromMouseWheelLegacyEvent;
  38995. /**
  38996. * Attach the input controls to a specific dom element to get the input from.
  38997. * @param element Defines the element the controls should be listened from
  38998. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38999. */
  39000. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39001. /**
  39002. * Detach the current controls from the specified dom element.
  39003. * @param element Defines the element to stop listening the inputs from
  39004. */
  39005. detachControl(element: Nullable<HTMLElement>): void;
  39006. /**
  39007. * Gets the class name of the current intput.
  39008. * @returns the class name
  39009. */
  39010. getClassName(): string;
  39011. /**
  39012. * Get the friendly name associated with the input class.
  39013. * @returns the input friendly name
  39014. */
  39015. getSimpleName(): string;
  39016. }
  39017. }
  39018. declare module BABYLON {
  39019. /**
  39020. * Default Inputs manager for the ArcRotateCamera.
  39021. * It groups all the default supported inputs for ease of use.
  39022. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39023. */
  39024. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39025. /**
  39026. * Instantiates a new ArcRotateCameraInputsManager.
  39027. * @param camera Defines the camera the inputs belong to
  39028. */
  39029. constructor(camera: ArcRotateCamera);
  39030. /**
  39031. * Add mouse wheel input support to the input manager.
  39032. * @returns the current input manager
  39033. */
  39034. addMouseWheel(): ArcRotateCameraInputsManager;
  39035. /**
  39036. * Add pointers input support to the input manager.
  39037. * @returns the current input manager
  39038. */
  39039. addPointers(): ArcRotateCameraInputsManager;
  39040. /**
  39041. * Add keyboard input support to the input manager.
  39042. * @returns the current input manager
  39043. */
  39044. addKeyboard(): ArcRotateCameraInputsManager;
  39045. }
  39046. }
  39047. declare module BABYLON {
  39048. /**
  39049. * This represents an orbital type of camera.
  39050. *
  39051. * 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.
  39052. * 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.
  39053. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39054. */
  39055. export class ArcRotateCamera extends TargetCamera {
  39056. /**
  39057. * Defines the rotation angle of the camera along the longitudinal axis.
  39058. */
  39059. alpha: number;
  39060. /**
  39061. * Defines the rotation angle of the camera along the latitudinal axis.
  39062. */
  39063. beta: number;
  39064. /**
  39065. * Defines the radius of the camera from it s target point.
  39066. */
  39067. radius: number;
  39068. protected _target: Vector3;
  39069. protected _targetHost: Nullable<AbstractMesh>;
  39070. /**
  39071. * Defines the target point of the camera.
  39072. * The camera looks towards it form the radius distance.
  39073. */
  39074. get target(): Vector3;
  39075. set target(value: Vector3);
  39076. /**
  39077. * Define the current local position of the camera in the scene
  39078. */
  39079. get position(): Vector3;
  39080. set position(newPosition: Vector3);
  39081. protected _upVector: Vector3;
  39082. protected _upToYMatrix: Matrix;
  39083. protected _YToUpMatrix: Matrix;
  39084. /**
  39085. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39086. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39087. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39088. */
  39089. set upVector(vec: Vector3);
  39090. get upVector(): Vector3;
  39091. /**
  39092. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39093. */
  39094. setMatUp(): void;
  39095. /**
  39096. * Current inertia value on the longitudinal axis.
  39097. * The bigger this number the longer it will take for the camera to stop.
  39098. */
  39099. inertialAlphaOffset: number;
  39100. /**
  39101. * Current inertia value on the latitudinal axis.
  39102. * The bigger this number the longer it will take for the camera to stop.
  39103. */
  39104. inertialBetaOffset: number;
  39105. /**
  39106. * Current inertia value on the radius axis.
  39107. * The bigger this number the longer it will take for the camera to stop.
  39108. */
  39109. inertialRadiusOffset: number;
  39110. /**
  39111. * Minimum allowed angle on the longitudinal axis.
  39112. * This can help limiting how the Camera is able to move in the scene.
  39113. */
  39114. lowerAlphaLimit: Nullable<number>;
  39115. /**
  39116. * Maximum allowed angle on the longitudinal axis.
  39117. * This can help limiting how the Camera is able to move in the scene.
  39118. */
  39119. upperAlphaLimit: Nullable<number>;
  39120. /**
  39121. * Minimum allowed angle on the latitudinal axis.
  39122. * This can help limiting how the Camera is able to move in the scene.
  39123. */
  39124. lowerBetaLimit: number;
  39125. /**
  39126. * Maximum allowed angle on the latitudinal axis.
  39127. * This can help limiting how the Camera is able to move in the scene.
  39128. */
  39129. upperBetaLimit: number;
  39130. /**
  39131. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39132. * This can help limiting how the Camera is able to move in the scene.
  39133. */
  39134. lowerRadiusLimit: Nullable<number>;
  39135. /**
  39136. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39137. * This can help limiting how the Camera is able to move in the scene.
  39138. */
  39139. upperRadiusLimit: Nullable<number>;
  39140. /**
  39141. * Defines the current inertia value used during panning of the camera along the X axis.
  39142. */
  39143. inertialPanningX: number;
  39144. /**
  39145. * Defines the current inertia value used during panning of the camera along the Y axis.
  39146. */
  39147. inertialPanningY: number;
  39148. /**
  39149. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39150. * Basically if your fingers moves away from more than this distance you will be considered
  39151. * in pinch mode.
  39152. */
  39153. pinchToPanMaxDistance: number;
  39154. /**
  39155. * Defines the maximum distance the camera can pan.
  39156. * This could help keeping the cammera always in your scene.
  39157. */
  39158. panningDistanceLimit: Nullable<number>;
  39159. /**
  39160. * Defines the target of the camera before paning.
  39161. */
  39162. panningOriginTarget: Vector3;
  39163. /**
  39164. * Defines the value of the inertia used during panning.
  39165. * 0 would mean stop inertia and one would mean no decelleration at all.
  39166. */
  39167. panningInertia: number;
  39168. /**
  39169. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39170. */
  39171. get angularSensibilityX(): number;
  39172. set angularSensibilityX(value: number);
  39173. /**
  39174. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39175. */
  39176. get angularSensibilityY(): number;
  39177. set angularSensibilityY(value: number);
  39178. /**
  39179. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39180. */
  39181. get pinchPrecision(): number;
  39182. set pinchPrecision(value: number);
  39183. /**
  39184. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39185. * It will be used instead of pinchDeltaPrecision if different from 0.
  39186. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39187. */
  39188. get pinchDeltaPercentage(): number;
  39189. set pinchDeltaPercentage(value: number);
  39190. /**
  39191. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39192. * and pinch delta percentage.
  39193. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39194. * that any object in the plane at the camera's target point will scale
  39195. * perfectly with finger motion.
  39196. */
  39197. get useNaturalPinchZoom(): boolean;
  39198. set useNaturalPinchZoom(value: boolean);
  39199. /**
  39200. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39201. */
  39202. get panningSensibility(): number;
  39203. set panningSensibility(value: number);
  39204. /**
  39205. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39206. */
  39207. get keysUp(): number[];
  39208. set keysUp(value: number[]);
  39209. /**
  39210. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39211. */
  39212. get keysDown(): number[];
  39213. set keysDown(value: number[]);
  39214. /**
  39215. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39216. */
  39217. get keysLeft(): number[];
  39218. set keysLeft(value: number[]);
  39219. /**
  39220. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39221. */
  39222. get keysRight(): number[];
  39223. set keysRight(value: number[]);
  39224. /**
  39225. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39226. */
  39227. get wheelPrecision(): number;
  39228. set wheelPrecision(value: number);
  39229. /**
  39230. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39231. * It will be used instead of pinchDeltaPrecision if different from 0.
  39232. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39233. */
  39234. get wheelDeltaPercentage(): number;
  39235. set wheelDeltaPercentage(value: number);
  39236. /**
  39237. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39238. */
  39239. zoomOnFactor: number;
  39240. /**
  39241. * Defines a screen offset for the camera position.
  39242. */
  39243. targetScreenOffset: Vector2;
  39244. /**
  39245. * Allows the camera to be completely reversed.
  39246. * If false the camera can not arrive upside down.
  39247. */
  39248. allowUpsideDown: boolean;
  39249. /**
  39250. * Define if double tap/click is used to restore the previously saved state of the camera.
  39251. */
  39252. useInputToRestoreState: boolean;
  39253. /** @hidden */
  39254. _viewMatrix: Matrix;
  39255. /** @hidden */
  39256. _useCtrlForPanning: boolean;
  39257. /** @hidden */
  39258. _panningMouseButton: number;
  39259. /**
  39260. * Defines the input associated to the camera.
  39261. */
  39262. inputs: ArcRotateCameraInputsManager;
  39263. /** @hidden */
  39264. _reset: () => void;
  39265. /**
  39266. * Defines the allowed panning axis.
  39267. */
  39268. panningAxis: Vector3;
  39269. protected _localDirection: Vector3;
  39270. protected _transformedDirection: Vector3;
  39271. private _bouncingBehavior;
  39272. /**
  39273. * Gets the bouncing behavior of the camera if it has been enabled.
  39274. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39275. */
  39276. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39277. /**
  39278. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39279. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39280. */
  39281. get useBouncingBehavior(): boolean;
  39282. set useBouncingBehavior(value: boolean);
  39283. private _framingBehavior;
  39284. /**
  39285. * Gets the framing behavior of the camera if it has been enabled.
  39286. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39287. */
  39288. get framingBehavior(): Nullable<FramingBehavior>;
  39289. /**
  39290. * Defines if the framing behavior of the camera is enabled on the camera.
  39291. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39292. */
  39293. get useFramingBehavior(): boolean;
  39294. set useFramingBehavior(value: boolean);
  39295. private _autoRotationBehavior;
  39296. /**
  39297. * Gets the auto rotation behavior of the camera if it has been enabled.
  39298. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39299. */
  39300. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39301. /**
  39302. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39303. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39304. */
  39305. get useAutoRotationBehavior(): boolean;
  39306. set useAutoRotationBehavior(value: boolean);
  39307. /**
  39308. * Observable triggered when the mesh target has been changed on the camera.
  39309. */
  39310. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39311. /**
  39312. * Event raised when the camera is colliding with a mesh.
  39313. */
  39314. onCollide: (collidedMesh: AbstractMesh) => void;
  39315. /**
  39316. * Defines whether the camera should check collision with the objects oh the scene.
  39317. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39318. */
  39319. checkCollisions: boolean;
  39320. /**
  39321. * Defines the collision radius of the camera.
  39322. * This simulates a sphere around the camera.
  39323. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39324. */
  39325. collisionRadius: Vector3;
  39326. protected _collider: Collider;
  39327. protected _previousPosition: Vector3;
  39328. protected _collisionVelocity: Vector3;
  39329. protected _newPosition: Vector3;
  39330. protected _previousAlpha: number;
  39331. protected _previousBeta: number;
  39332. protected _previousRadius: number;
  39333. protected _collisionTriggered: boolean;
  39334. protected _targetBoundingCenter: Nullable<Vector3>;
  39335. private _computationVector;
  39336. /**
  39337. * Instantiates a new ArcRotateCamera in a given scene
  39338. * @param name Defines the name of the camera
  39339. * @param alpha Defines the camera rotation along the logitudinal axis
  39340. * @param beta Defines the camera rotation along the latitudinal axis
  39341. * @param radius Defines the camera distance from its target
  39342. * @param target Defines the camera target
  39343. * @param scene Defines the scene the camera belongs to
  39344. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39345. */
  39346. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39347. /** @hidden */
  39348. _initCache(): void;
  39349. /** @hidden */
  39350. _updateCache(ignoreParentClass?: boolean): void;
  39351. protected _getTargetPosition(): Vector3;
  39352. private _storedAlpha;
  39353. private _storedBeta;
  39354. private _storedRadius;
  39355. private _storedTarget;
  39356. private _storedTargetScreenOffset;
  39357. /**
  39358. * Stores the current state of the camera (alpha, beta, radius and target)
  39359. * @returns the camera itself
  39360. */
  39361. storeState(): Camera;
  39362. /**
  39363. * @hidden
  39364. * Restored camera state. You must call storeState() first
  39365. */
  39366. _restoreStateValues(): boolean;
  39367. /** @hidden */
  39368. _isSynchronizedViewMatrix(): boolean;
  39369. /**
  39370. * Attached controls to the current camera.
  39371. * @param element Defines the element the controls should be listened from
  39372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39373. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39374. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39375. */
  39376. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39377. /**
  39378. * Detach the current controls from the camera.
  39379. * The camera will stop reacting to inputs.
  39380. * @param element Defines the element to stop listening the inputs from
  39381. */
  39382. detachControl(element: HTMLElement): void;
  39383. /** @hidden */
  39384. _checkInputs(): void;
  39385. protected _checkLimits(): void;
  39386. /**
  39387. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39388. */
  39389. rebuildAnglesAndRadius(): void;
  39390. /**
  39391. * Use a position to define the current camera related information like alpha, beta and radius
  39392. * @param position Defines the position to set the camera at
  39393. */
  39394. setPosition(position: Vector3): void;
  39395. /**
  39396. * Defines the target the camera should look at.
  39397. * This will automatically adapt alpha beta and radius to fit within the new target.
  39398. * @param target Defines the new target as a Vector or a mesh
  39399. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39400. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39401. */
  39402. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39403. /** @hidden */
  39404. _getViewMatrix(): Matrix;
  39405. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39406. /**
  39407. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39408. * @param meshes Defines the mesh to zoom on
  39409. * @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)
  39410. */
  39411. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39412. /**
  39413. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39414. * The target will be changed but the radius
  39415. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39416. * @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)
  39417. */
  39418. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39419. min: Vector3;
  39420. max: Vector3;
  39421. distance: number;
  39422. }, doNotUpdateMaxZ?: boolean): void;
  39423. /**
  39424. * @override
  39425. * Override Camera.createRigCamera
  39426. */
  39427. createRigCamera(name: string, cameraIndex: number): Camera;
  39428. /**
  39429. * @hidden
  39430. * @override
  39431. * Override Camera._updateRigCameras
  39432. */
  39433. _updateRigCameras(): void;
  39434. /**
  39435. * Destroy the camera and release the current resources hold by it.
  39436. */
  39437. dispose(): void;
  39438. /**
  39439. * Gets the current object class name.
  39440. * @return the class name
  39441. */
  39442. getClassName(): string;
  39443. }
  39444. }
  39445. declare module BABYLON {
  39446. /**
  39447. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39448. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39449. */
  39450. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39451. /**
  39452. * Gets the name of the behavior.
  39453. */
  39454. get name(): string;
  39455. private _zoomStopsAnimation;
  39456. private _idleRotationSpeed;
  39457. private _idleRotationWaitTime;
  39458. private _idleRotationSpinupTime;
  39459. /**
  39460. * Sets the flag that indicates if user zooming should stop animation.
  39461. */
  39462. set zoomStopsAnimation(flag: boolean);
  39463. /**
  39464. * Gets the flag that indicates if user zooming should stop animation.
  39465. */
  39466. get zoomStopsAnimation(): boolean;
  39467. /**
  39468. * Sets the default speed at which the camera rotates around the model.
  39469. */
  39470. set idleRotationSpeed(speed: number);
  39471. /**
  39472. * Gets the default speed at which the camera rotates around the model.
  39473. */
  39474. get idleRotationSpeed(): number;
  39475. /**
  39476. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39477. */
  39478. set idleRotationWaitTime(time: number);
  39479. /**
  39480. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39481. */
  39482. get idleRotationWaitTime(): number;
  39483. /**
  39484. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39485. */
  39486. set idleRotationSpinupTime(time: number);
  39487. /**
  39488. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39489. */
  39490. get idleRotationSpinupTime(): number;
  39491. /**
  39492. * Gets a value indicating if the camera is currently rotating because of this behavior
  39493. */
  39494. get rotationInProgress(): boolean;
  39495. private _onPrePointerObservableObserver;
  39496. private _onAfterCheckInputsObserver;
  39497. private _attachedCamera;
  39498. private _isPointerDown;
  39499. private _lastFrameTime;
  39500. private _lastInteractionTime;
  39501. private _cameraRotationSpeed;
  39502. /**
  39503. * Initializes the behavior.
  39504. */
  39505. init(): void;
  39506. /**
  39507. * Attaches the behavior to its arc rotate camera.
  39508. * @param camera Defines the camera to attach the behavior to
  39509. */
  39510. attach(camera: ArcRotateCamera): void;
  39511. /**
  39512. * Detaches the behavior from its current arc rotate camera.
  39513. */
  39514. detach(): void;
  39515. /**
  39516. * Returns true if user is scrolling.
  39517. * @return true if user is scrolling.
  39518. */
  39519. private _userIsZooming;
  39520. private _lastFrameRadius;
  39521. private _shouldAnimationStopForInteraction;
  39522. /**
  39523. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39524. */
  39525. private _applyUserInteraction;
  39526. private _userIsMoving;
  39527. }
  39528. }
  39529. declare module BABYLON {
  39530. /**
  39531. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39532. */
  39533. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39534. private ui;
  39535. /**
  39536. * The name of the behavior
  39537. */
  39538. name: string;
  39539. /**
  39540. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39541. */
  39542. distanceAwayFromFace: number;
  39543. /**
  39544. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39545. */
  39546. distanceAwayFromBottomOfFace: number;
  39547. private _faceVectors;
  39548. private _target;
  39549. private _scene;
  39550. private _onRenderObserver;
  39551. private _tmpMatrix;
  39552. private _tmpVector;
  39553. /**
  39554. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39555. * @param ui The transform node that should be attched to the mesh
  39556. */
  39557. constructor(ui: TransformNode);
  39558. /**
  39559. * Initializes the behavior
  39560. */
  39561. init(): void;
  39562. private _closestFace;
  39563. private _zeroVector;
  39564. private _lookAtTmpMatrix;
  39565. private _lookAtToRef;
  39566. /**
  39567. * Attaches the AttachToBoxBehavior to the passed in mesh
  39568. * @param target The mesh that the specified node will be attached to
  39569. */
  39570. attach(target: Mesh): void;
  39571. /**
  39572. * Detaches the behavior from the mesh
  39573. */
  39574. detach(): void;
  39575. }
  39576. }
  39577. declare module BABYLON {
  39578. /**
  39579. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39580. */
  39581. export class FadeInOutBehavior implements Behavior<Mesh> {
  39582. /**
  39583. * Time in milliseconds to delay before fading in (Default: 0)
  39584. */
  39585. delay: number;
  39586. /**
  39587. * Time in milliseconds for the mesh to fade in (Default: 300)
  39588. */
  39589. fadeInTime: number;
  39590. private _millisecondsPerFrame;
  39591. private _hovered;
  39592. private _hoverValue;
  39593. private _ownerNode;
  39594. /**
  39595. * Instatiates the FadeInOutBehavior
  39596. */
  39597. constructor();
  39598. /**
  39599. * The name of the behavior
  39600. */
  39601. get name(): string;
  39602. /**
  39603. * Initializes the behavior
  39604. */
  39605. init(): void;
  39606. /**
  39607. * Attaches the fade behavior on the passed in mesh
  39608. * @param ownerNode The mesh that will be faded in/out once attached
  39609. */
  39610. attach(ownerNode: Mesh): void;
  39611. /**
  39612. * Detaches the behavior from the mesh
  39613. */
  39614. detach(): void;
  39615. /**
  39616. * Triggers the mesh to begin fading in or out
  39617. * @param value if the object should fade in or out (true to fade in)
  39618. */
  39619. fadeIn(value: boolean): void;
  39620. private _update;
  39621. private _setAllVisibility;
  39622. }
  39623. }
  39624. declare module BABYLON {
  39625. /**
  39626. * Class containing a set of static utilities functions for managing Pivots
  39627. * @hidden
  39628. */
  39629. export class PivotTools {
  39630. private static _PivotCached;
  39631. private static _OldPivotPoint;
  39632. private static _PivotTranslation;
  39633. private static _PivotTmpVector;
  39634. /** @hidden */
  39635. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39636. /** @hidden */
  39637. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39638. }
  39639. }
  39640. declare module BABYLON {
  39641. /**
  39642. * Class containing static functions to help procedurally build meshes
  39643. */
  39644. export class PlaneBuilder {
  39645. /**
  39646. * Creates a plane mesh
  39647. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39648. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39649. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39651. * * 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
  39652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39653. * @param name defines the name of the mesh
  39654. * @param options defines the options used to create the mesh
  39655. * @param scene defines the hosting scene
  39656. * @returns the plane mesh
  39657. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39658. */
  39659. static CreatePlane(name: string, options: {
  39660. size?: number;
  39661. width?: number;
  39662. height?: number;
  39663. sideOrientation?: number;
  39664. frontUVs?: Vector4;
  39665. backUVs?: Vector4;
  39666. updatable?: boolean;
  39667. sourcePlane?: Plane;
  39668. }, scene?: Nullable<Scene>): Mesh;
  39669. }
  39670. }
  39671. declare module BABYLON {
  39672. /**
  39673. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39674. */
  39675. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39676. private static _AnyMouseID;
  39677. /**
  39678. * Abstract mesh the behavior is set on
  39679. */
  39680. attachedNode: AbstractMesh;
  39681. private _dragPlane;
  39682. private _scene;
  39683. private _pointerObserver;
  39684. private _beforeRenderObserver;
  39685. private static _planeScene;
  39686. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39687. /**
  39688. * 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)
  39689. */
  39690. maxDragAngle: number;
  39691. /**
  39692. * @hidden
  39693. */
  39694. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39695. /**
  39696. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39697. */
  39698. currentDraggingPointerID: number;
  39699. /**
  39700. * The last position where the pointer hit the drag plane in world space
  39701. */
  39702. lastDragPosition: Vector3;
  39703. /**
  39704. * If the behavior is currently in a dragging state
  39705. */
  39706. dragging: boolean;
  39707. /**
  39708. * 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)
  39709. */
  39710. dragDeltaRatio: number;
  39711. /**
  39712. * If the drag plane orientation should be updated during the dragging (Default: true)
  39713. */
  39714. updateDragPlane: boolean;
  39715. private _debugMode;
  39716. private _moving;
  39717. /**
  39718. * Fires each time the attached mesh is dragged with the pointer
  39719. * * delta between last drag position and current drag position in world space
  39720. * * dragDistance along the drag axis
  39721. * * dragPlaneNormal normal of the current drag plane used during the drag
  39722. * * dragPlanePoint in world space where the drag intersects the drag plane
  39723. */
  39724. onDragObservable: Observable<{
  39725. delta: Vector3;
  39726. dragPlanePoint: Vector3;
  39727. dragPlaneNormal: Vector3;
  39728. dragDistance: number;
  39729. pointerId: number;
  39730. }>;
  39731. /**
  39732. * Fires each time a drag begins (eg. mouse down on mesh)
  39733. */
  39734. onDragStartObservable: Observable<{
  39735. dragPlanePoint: Vector3;
  39736. pointerId: number;
  39737. }>;
  39738. /**
  39739. * Fires each time a drag ends (eg. mouse release after drag)
  39740. */
  39741. onDragEndObservable: Observable<{
  39742. dragPlanePoint: Vector3;
  39743. pointerId: number;
  39744. }>;
  39745. /**
  39746. * If the attached mesh should be moved when dragged
  39747. */
  39748. moveAttached: boolean;
  39749. /**
  39750. * If the drag behavior will react to drag events (Default: true)
  39751. */
  39752. enabled: boolean;
  39753. /**
  39754. * If pointer events should start and release the drag (Default: true)
  39755. */
  39756. startAndReleaseDragOnPointerEvents: boolean;
  39757. /**
  39758. * If camera controls should be detached during the drag
  39759. */
  39760. detachCameraControls: boolean;
  39761. /**
  39762. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39763. */
  39764. useObjectOrientationForDragging: boolean;
  39765. private _options;
  39766. /**
  39767. * Gets the options used by the behavior
  39768. */
  39769. get options(): {
  39770. dragAxis?: Vector3;
  39771. dragPlaneNormal?: Vector3;
  39772. };
  39773. /**
  39774. * Sets the options used by the behavior
  39775. */
  39776. set options(options: {
  39777. dragAxis?: Vector3;
  39778. dragPlaneNormal?: Vector3;
  39779. });
  39780. /**
  39781. * Creates a pointer drag behavior that can be attached to a mesh
  39782. * @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)
  39783. */
  39784. constructor(options?: {
  39785. dragAxis?: Vector3;
  39786. dragPlaneNormal?: Vector3;
  39787. });
  39788. /**
  39789. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39790. */
  39791. validateDrag: (targetPosition: Vector3) => boolean;
  39792. /**
  39793. * The name of the behavior
  39794. */
  39795. get name(): string;
  39796. /**
  39797. * Initializes the behavior
  39798. */
  39799. init(): void;
  39800. private _tmpVector;
  39801. private _alternatePickedPoint;
  39802. private _worldDragAxis;
  39803. private _targetPosition;
  39804. private _attachedElement;
  39805. /**
  39806. * Attaches the drag behavior the passed in mesh
  39807. * @param ownerNode The mesh that will be dragged around once attached
  39808. * @param predicate Predicate to use for pick filtering
  39809. */
  39810. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39811. /**
  39812. * Force relase the drag action by code.
  39813. */
  39814. releaseDrag(): void;
  39815. private _startDragRay;
  39816. private _lastPointerRay;
  39817. /**
  39818. * Simulates the start of a pointer drag event on the behavior
  39819. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39820. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39821. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39822. */
  39823. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39824. private _startDrag;
  39825. private _dragDelta;
  39826. private _moveDrag;
  39827. private _pickWithRayOnDragPlane;
  39828. private _pointA;
  39829. private _pointB;
  39830. private _pointC;
  39831. private _lineA;
  39832. private _lineB;
  39833. private _localAxis;
  39834. private _lookAt;
  39835. private _updateDragPlanePosition;
  39836. /**
  39837. * Detaches the behavior from the mesh
  39838. */
  39839. detach(): void;
  39840. }
  39841. }
  39842. declare module BABYLON {
  39843. /**
  39844. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39845. */
  39846. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39847. private _dragBehaviorA;
  39848. private _dragBehaviorB;
  39849. private _startDistance;
  39850. private _initialScale;
  39851. private _targetScale;
  39852. private _ownerNode;
  39853. private _sceneRenderObserver;
  39854. /**
  39855. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39856. */
  39857. constructor();
  39858. /**
  39859. * The name of the behavior
  39860. */
  39861. get name(): string;
  39862. /**
  39863. * Initializes the behavior
  39864. */
  39865. init(): void;
  39866. private _getCurrentDistance;
  39867. /**
  39868. * Attaches the scale behavior the passed in mesh
  39869. * @param ownerNode The mesh that will be scaled around once attached
  39870. */
  39871. attach(ownerNode: Mesh): void;
  39872. /**
  39873. * Detaches the behavior from the mesh
  39874. */
  39875. detach(): void;
  39876. }
  39877. }
  39878. declare module BABYLON {
  39879. /**
  39880. * 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
  39881. */
  39882. export class SixDofDragBehavior implements Behavior<Mesh> {
  39883. private static _virtualScene;
  39884. private _ownerNode;
  39885. private _sceneRenderObserver;
  39886. private _scene;
  39887. private _targetPosition;
  39888. private _virtualOriginMesh;
  39889. private _virtualDragMesh;
  39890. private _pointerObserver;
  39891. private _moving;
  39892. private _startingOrientation;
  39893. private _attachedElement;
  39894. /**
  39895. * 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)
  39896. */
  39897. private zDragFactor;
  39898. /**
  39899. * If the object should rotate to face the drag origin
  39900. */
  39901. rotateDraggedObject: boolean;
  39902. /**
  39903. * If the behavior is currently in a dragging state
  39904. */
  39905. dragging: boolean;
  39906. /**
  39907. * 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)
  39908. */
  39909. dragDeltaRatio: number;
  39910. /**
  39911. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39912. */
  39913. currentDraggingPointerID: number;
  39914. /**
  39915. * If camera controls should be detached during the drag
  39916. */
  39917. detachCameraControls: boolean;
  39918. /**
  39919. * Fires each time a drag starts
  39920. */
  39921. onDragStartObservable: Observable<{}>;
  39922. /**
  39923. * Fires each time a drag ends (eg. mouse release after drag)
  39924. */
  39925. onDragEndObservable: Observable<{}>;
  39926. /**
  39927. * 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
  39928. */
  39929. constructor();
  39930. /**
  39931. * The name of the behavior
  39932. */
  39933. get name(): string;
  39934. /**
  39935. * Initializes the behavior
  39936. */
  39937. init(): void;
  39938. /**
  39939. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39940. */
  39941. private get _pointerCamera();
  39942. /**
  39943. * Attaches the scale behavior the passed in mesh
  39944. * @param ownerNode The mesh that will be scaled around once attached
  39945. */
  39946. attach(ownerNode: Mesh): void;
  39947. /**
  39948. * Detaches the behavior from the mesh
  39949. */
  39950. detach(): void;
  39951. }
  39952. }
  39953. declare module BABYLON {
  39954. /**
  39955. * Class used to apply inverse kinematics to bones
  39956. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39957. */
  39958. export class BoneIKController {
  39959. private static _tmpVecs;
  39960. private static _tmpQuat;
  39961. private static _tmpMats;
  39962. /**
  39963. * Gets or sets the target mesh
  39964. */
  39965. targetMesh: AbstractMesh;
  39966. /** Gets or sets the mesh used as pole */
  39967. poleTargetMesh: AbstractMesh;
  39968. /**
  39969. * Gets or sets the bone used as pole
  39970. */
  39971. poleTargetBone: Nullable<Bone>;
  39972. /**
  39973. * Gets or sets the target position
  39974. */
  39975. targetPosition: Vector3;
  39976. /**
  39977. * Gets or sets the pole target position
  39978. */
  39979. poleTargetPosition: Vector3;
  39980. /**
  39981. * Gets or sets the pole target local offset
  39982. */
  39983. poleTargetLocalOffset: Vector3;
  39984. /**
  39985. * Gets or sets the pole angle
  39986. */
  39987. poleAngle: number;
  39988. /**
  39989. * Gets or sets the mesh associated with the controller
  39990. */
  39991. mesh: AbstractMesh;
  39992. /**
  39993. * 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)
  39994. */
  39995. slerpAmount: number;
  39996. private _bone1Quat;
  39997. private _bone1Mat;
  39998. private _bone2Ang;
  39999. private _bone1;
  40000. private _bone2;
  40001. private _bone1Length;
  40002. private _bone2Length;
  40003. private _maxAngle;
  40004. private _maxReach;
  40005. private _rightHandedSystem;
  40006. private _bendAxis;
  40007. private _slerping;
  40008. private _adjustRoll;
  40009. /**
  40010. * Gets or sets maximum allowed angle
  40011. */
  40012. get maxAngle(): number;
  40013. set maxAngle(value: number);
  40014. /**
  40015. * Creates a new BoneIKController
  40016. * @param mesh defines the mesh to control
  40017. * @param bone defines the bone to control
  40018. * @param options defines options to set up the controller
  40019. */
  40020. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40021. targetMesh?: AbstractMesh;
  40022. poleTargetMesh?: AbstractMesh;
  40023. poleTargetBone?: Bone;
  40024. poleTargetLocalOffset?: Vector3;
  40025. poleAngle?: number;
  40026. bendAxis?: Vector3;
  40027. maxAngle?: number;
  40028. slerpAmount?: number;
  40029. });
  40030. private _setMaxAngle;
  40031. /**
  40032. * Force the controller to update the bones
  40033. */
  40034. update(): void;
  40035. }
  40036. }
  40037. declare module BABYLON {
  40038. /**
  40039. * Class used to make a bone look toward a point in space
  40040. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40041. */
  40042. export class BoneLookController {
  40043. private static _tmpVecs;
  40044. private static _tmpQuat;
  40045. private static _tmpMats;
  40046. /**
  40047. * The target Vector3 that the bone will look at
  40048. */
  40049. target: Vector3;
  40050. /**
  40051. * The mesh that the bone is attached to
  40052. */
  40053. mesh: AbstractMesh;
  40054. /**
  40055. * The bone that will be looking to the target
  40056. */
  40057. bone: Bone;
  40058. /**
  40059. * The up axis of the coordinate system that is used when the bone is rotated
  40060. */
  40061. upAxis: Vector3;
  40062. /**
  40063. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40064. */
  40065. upAxisSpace: Space;
  40066. /**
  40067. * Used to make an adjustment to the yaw of the bone
  40068. */
  40069. adjustYaw: number;
  40070. /**
  40071. * Used to make an adjustment to the pitch of the bone
  40072. */
  40073. adjustPitch: number;
  40074. /**
  40075. * Used to make an adjustment to the roll of the bone
  40076. */
  40077. adjustRoll: number;
  40078. /**
  40079. * 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)
  40080. */
  40081. slerpAmount: number;
  40082. private _minYaw;
  40083. private _maxYaw;
  40084. private _minPitch;
  40085. private _maxPitch;
  40086. private _minYawSin;
  40087. private _minYawCos;
  40088. private _maxYawSin;
  40089. private _maxYawCos;
  40090. private _midYawConstraint;
  40091. private _minPitchTan;
  40092. private _maxPitchTan;
  40093. private _boneQuat;
  40094. private _slerping;
  40095. private _transformYawPitch;
  40096. private _transformYawPitchInv;
  40097. private _firstFrameSkipped;
  40098. private _yawRange;
  40099. private _fowardAxis;
  40100. /**
  40101. * Gets or sets the minimum yaw angle that the bone can look to
  40102. */
  40103. get minYaw(): number;
  40104. set minYaw(value: number);
  40105. /**
  40106. * Gets or sets the maximum yaw angle that the bone can look to
  40107. */
  40108. get maxYaw(): number;
  40109. set maxYaw(value: number);
  40110. /**
  40111. * Gets or sets the minimum pitch angle that the bone can look to
  40112. */
  40113. get minPitch(): number;
  40114. set minPitch(value: number);
  40115. /**
  40116. * Gets or sets the maximum pitch angle that the bone can look to
  40117. */
  40118. get maxPitch(): number;
  40119. set maxPitch(value: number);
  40120. /**
  40121. * Create a BoneLookController
  40122. * @param mesh the mesh that the bone belongs to
  40123. * @param bone the bone that will be looking to the target
  40124. * @param target the target Vector3 to look at
  40125. * @param options optional settings:
  40126. * * maxYaw: the maximum angle the bone will yaw to
  40127. * * minYaw: the minimum angle the bone will yaw to
  40128. * * maxPitch: the maximum angle the bone will pitch to
  40129. * * minPitch: the minimum angle the bone will yaw to
  40130. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40131. * * upAxis: the up axis of the coordinate system
  40132. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40133. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40134. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40135. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40136. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40137. * * adjustRoll: used to make an adjustment to the roll of the bone
  40138. **/
  40139. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40140. maxYaw?: number;
  40141. minYaw?: number;
  40142. maxPitch?: number;
  40143. minPitch?: number;
  40144. slerpAmount?: number;
  40145. upAxis?: Vector3;
  40146. upAxisSpace?: Space;
  40147. yawAxis?: Vector3;
  40148. pitchAxis?: Vector3;
  40149. adjustYaw?: number;
  40150. adjustPitch?: number;
  40151. adjustRoll?: number;
  40152. });
  40153. /**
  40154. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40155. */
  40156. update(): void;
  40157. private _getAngleDiff;
  40158. private _getAngleBetween;
  40159. private _isAngleBetween;
  40160. }
  40161. }
  40162. declare module BABYLON {
  40163. /**
  40164. * Manage the gamepad inputs to control an arc rotate camera.
  40165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40166. */
  40167. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40168. /**
  40169. * Defines the camera the input is attached to.
  40170. */
  40171. camera: ArcRotateCamera;
  40172. /**
  40173. * Defines the gamepad the input is gathering event from.
  40174. */
  40175. gamepad: Nullable<Gamepad>;
  40176. /**
  40177. * Defines the gamepad rotation sensiblity.
  40178. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40179. */
  40180. gamepadRotationSensibility: number;
  40181. /**
  40182. * Defines the gamepad move sensiblity.
  40183. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40184. */
  40185. gamepadMoveSensibility: number;
  40186. private _yAxisScale;
  40187. /**
  40188. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40189. */
  40190. get invertYAxis(): boolean;
  40191. set invertYAxis(value: boolean);
  40192. private _onGamepadConnectedObserver;
  40193. private _onGamepadDisconnectedObserver;
  40194. /**
  40195. * Attach the input controls to a specific dom element to get the input from.
  40196. * @param element Defines the element the controls should be listened from
  40197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40198. */
  40199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40200. /**
  40201. * Detach the current controls from the specified dom element.
  40202. * @param element Defines the element to stop listening the inputs from
  40203. */
  40204. detachControl(element: Nullable<HTMLElement>): void;
  40205. /**
  40206. * Update the current camera state depending on the inputs that have been used this frame.
  40207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40208. */
  40209. checkInputs(): void;
  40210. /**
  40211. * Gets the class name of the current intput.
  40212. * @returns the class name
  40213. */
  40214. getClassName(): string;
  40215. /**
  40216. * Get the friendly name associated with the input class.
  40217. * @returns the input friendly name
  40218. */
  40219. getSimpleName(): string;
  40220. }
  40221. }
  40222. declare module BABYLON {
  40223. interface ArcRotateCameraInputsManager {
  40224. /**
  40225. * Add orientation input support to the input manager.
  40226. * @returns the current input manager
  40227. */
  40228. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40229. }
  40230. /**
  40231. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40233. */
  40234. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40235. /**
  40236. * Defines the camera the input is attached to.
  40237. */
  40238. camera: ArcRotateCamera;
  40239. /**
  40240. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40241. */
  40242. alphaCorrection: number;
  40243. /**
  40244. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40245. */
  40246. gammaCorrection: number;
  40247. private _alpha;
  40248. private _gamma;
  40249. private _dirty;
  40250. private _deviceOrientationHandler;
  40251. /**
  40252. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40253. */
  40254. constructor();
  40255. /**
  40256. * Attach the input controls to a specific dom element to get the input from.
  40257. * @param element Defines the element the controls should be listened from
  40258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40259. */
  40260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40261. /** @hidden */
  40262. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40263. /**
  40264. * Update the current camera state depending on the inputs that have been used this frame.
  40265. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40266. */
  40267. checkInputs(): void;
  40268. /**
  40269. * Detach the current controls from the specified dom element.
  40270. * @param element Defines the element to stop listening the inputs from
  40271. */
  40272. detachControl(element: Nullable<HTMLElement>): void;
  40273. /**
  40274. * Gets the class name of the current intput.
  40275. * @returns the class name
  40276. */
  40277. getClassName(): string;
  40278. /**
  40279. * Get the friendly name associated with the input class.
  40280. * @returns the input friendly name
  40281. */
  40282. getSimpleName(): string;
  40283. }
  40284. }
  40285. declare module BABYLON {
  40286. /**
  40287. * Listen to mouse events to control the camera.
  40288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40289. */
  40290. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40291. /**
  40292. * Defines the camera the input is attached to.
  40293. */
  40294. camera: FlyCamera;
  40295. /**
  40296. * Defines if touch is enabled. (Default is true.)
  40297. */
  40298. touchEnabled: boolean;
  40299. /**
  40300. * Defines the buttons associated with the input to handle camera rotation.
  40301. */
  40302. buttons: number[];
  40303. /**
  40304. * Assign buttons for Yaw control.
  40305. */
  40306. buttonsYaw: number[];
  40307. /**
  40308. * Assign buttons for Pitch control.
  40309. */
  40310. buttonsPitch: number[];
  40311. /**
  40312. * Assign buttons for Roll control.
  40313. */
  40314. buttonsRoll: number[];
  40315. /**
  40316. * Detect if any button is being pressed while mouse is moved.
  40317. * -1 = Mouse locked.
  40318. * 0 = Left button.
  40319. * 1 = Middle Button.
  40320. * 2 = Right Button.
  40321. */
  40322. activeButton: number;
  40323. /**
  40324. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40325. * Higher values reduce its sensitivity.
  40326. */
  40327. angularSensibility: number;
  40328. private _mousemoveCallback;
  40329. private _observer;
  40330. private _rollObserver;
  40331. private previousPosition;
  40332. private noPreventDefault;
  40333. private element;
  40334. /**
  40335. * Listen to mouse events to control the camera.
  40336. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40338. */
  40339. constructor(touchEnabled?: boolean);
  40340. /**
  40341. * Attach the mouse control to the HTML DOM element.
  40342. * @param element Defines the element that listens to the input events.
  40343. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40344. */
  40345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40346. /**
  40347. * Detach the current controls from the specified dom element.
  40348. * @param element Defines the element to stop listening the inputs from
  40349. */
  40350. detachControl(element: Nullable<HTMLElement>): void;
  40351. /**
  40352. * Gets the class name of the current input.
  40353. * @returns the class name.
  40354. */
  40355. getClassName(): string;
  40356. /**
  40357. * Get the friendly name associated with the input class.
  40358. * @returns the input's friendly name.
  40359. */
  40360. getSimpleName(): string;
  40361. private _pointerInput;
  40362. private _onMouseMove;
  40363. /**
  40364. * Rotate camera by mouse offset.
  40365. */
  40366. private rotateCamera;
  40367. }
  40368. }
  40369. declare module BABYLON {
  40370. /**
  40371. * Default Inputs manager for the FlyCamera.
  40372. * It groups all the default supported inputs for ease of use.
  40373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40374. */
  40375. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40376. /**
  40377. * Instantiates a new FlyCameraInputsManager.
  40378. * @param camera Defines the camera the inputs belong to.
  40379. */
  40380. constructor(camera: FlyCamera);
  40381. /**
  40382. * Add keyboard input support to the input manager.
  40383. * @returns the new FlyCameraKeyboardMoveInput().
  40384. */
  40385. addKeyboard(): FlyCameraInputsManager;
  40386. /**
  40387. * Add mouse input support to the input manager.
  40388. * @param touchEnabled Enable touch screen support.
  40389. * @returns the new FlyCameraMouseInput().
  40390. */
  40391. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40392. }
  40393. }
  40394. declare module BABYLON {
  40395. /**
  40396. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40397. * such as in a 3D Space Shooter or a Flight Simulator.
  40398. */
  40399. export class FlyCamera extends TargetCamera {
  40400. /**
  40401. * Define the collision ellipsoid of the camera.
  40402. * This is helpful for simulating a camera body, like a player's body.
  40403. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40404. */
  40405. ellipsoid: Vector3;
  40406. /**
  40407. * Define an offset for the position of the ellipsoid around the camera.
  40408. * This can be helpful if the camera is attached away from the player's body center,
  40409. * such as at its head.
  40410. */
  40411. ellipsoidOffset: Vector3;
  40412. /**
  40413. * Enable or disable collisions of the camera with the rest of the scene objects.
  40414. */
  40415. checkCollisions: boolean;
  40416. /**
  40417. * Enable or disable gravity on the camera.
  40418. */
  40419. applyGravity: boolean;
  40420. /**
  40421. * Define the current direction the camera is moving to.
  40422. */
  40423. cameraDirection: Vector3;
  40424. /**
  40425. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40426. * This overrides and empties cameraRotation.
  40427. */
  40428. rotationQuaternion: Quaternion;
  40429. /**
  40430. * Track Roll to maintain the wanted Rolling when looking around.
  40431. */
  40432. _trackRoll: number;
  40433. /**
  40434. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40435. */
  40436. rollCorrect: number;
  40437. /**
  40438. * Mimic a banked turn, Rolling the camera when Yawing.
  40439. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40440. */
  40441. bankedTurn: boolean;
  40442. /**
  40443. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40444. */
  40445. bankedTurnLimit: number;
  40446. /**
  40447. * Value of 0 disables the banked Roll.
  40448. * Value of 1 is equal to the Yaw angle in radians.
  40449. */
  40450. bankedTurnMultiplier: number;
  40451. /**
  40452. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40453. */
  40454. inputs: FlyCameraInputsManager;
  40455. /**
  40456. * Gets the input sensibility for mouse input.
  40457. * Higher values reduce sensitivity.
  40458. */
  40459. get angularSensibility(): number;
  40460. /**
  40461. * Sets the input sensibility for a mouse input.
  40462. * Higher values reduce sensitivity.
  40463. */
  40464. set angularSensibility(value: number);
  40465. /**
  40466. * Get the keys for camera movement forward.
  40467. */
  40468. get keysForward(): number[];
  40469. /**
  40470. * Set the keys for camera movement forward.
  40471. */
  40472. set keysForward(value: number[]);
  40473. /**
  40474. * Get the keys for camera movement backward.
  40475. */
  40476. get keysBackward(): number[];
  40477. set keysBackward(value: number[]);
  40478. /**
  40479. * Get the keys for camera movement up.
  40480. */
  40481. get keysUp(): number[];
  40482. /**
  40483. * Set the keys for camera movement up.
  40484. */
  40485. set keysUp(value: number[]);
  40486. /**
  40487. * Get the keys for camera movement down.
  40488. */
  40489. get keysDown(): number[];
  40490. /**
  40491. * Set the keys for camera movement down.
  40492. */
  40493. set keysDown(value: number[]);
  40494. /**
  40495. * Get the keys for camera movement left.
  40496. */
  40497. get keysLeft(): number[];
  40498. /**
  40499. * Set the keys for camera movement left.
  40500. */
  40501. set keysLeft(value: number[]);
  40502. /**
  40503. * Set the keys for camera movement right.
  40504. */
  40505. get keysRight(): number[];
  40506. /**
  40507. * Set the keys for camera movement right.
  40508. */
  40509. set keysRight(value: number[]);
  40510. /**
  40511. * Event raised when the camera collides with a mesh in the scene.
  40512. */
  40513. onCollide: (collidedMesh: AbstractMesh) => void;
  40514. private _collider;
  40515. private _needMoveForGravity;
  40516. private _oldPosition;
  40517. private _diffPosition;
  40518. private _newPosition;
  40519. /** @hidden */
  40520. _localDirection: Vector3;
  40521. /** @hidden */
  40522. _transformedDirection: Vector3;
  40523. /**
  40524. * Instantiates a FlyCamera.
  40525. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40526. * such as in a 3D Space Shooter or a Flight Simulator.
  40527. * @param name Define the name of the camera in the scene.
  40528. * @param position Define the starting position of the camera in the scene.
  40529. * @param scene Define the scene the camera belongs to.
  40530. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40531. */
  40532. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40533. /**
  40534. * Attach a control to the HTML DOM element.
  40535. * @param element Defines the element that listens to the input events.
  40536. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40537. */
  40538. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40539. /**
  40540. * Detach a control from the HTML DOM element.
  40541. * The camera will stop reacting to that input.
  40542. * @param element Defines the element that listens to the input events.
  40543. */
  40544. detachControl(element: HTMLElement): void;
  40545. private _collisionMask;
  40546. /**
  40547. * Get the mask that the camera ignores in collision events.
  40548. */
  40549. get collisionMask(): number;
  40550. /**
  40551. * Set the mask that the camera ignores in collision events.
  40552. */
  40553. set collisionMask(mask: number);
  40554. /** @hidden */
  40555. _collideWithWorld(displacement: Vector3): void;
  40556. /** @hidden */
  40557. private _onCollisionPositionChange;
  40558. /** @hidden */
  40559. _checkInputs(): void;
  40560. /** @hidden */
  40561. _decideIfNeedsToMove(): boolean;
  40562. /** @hidden */
  40563. _updatePosition(): void;
  40564. /**
  40565. * Restore the Roll to its target value at the rate specified.
  40566. * @param rate - Higher means slower restoring.
  40567. * @hidden
  40568. */
  40569. restoreRoll(rate: number): void;
  40570. /**
  40571. * Destroy the camera and release the current resources held by it.
  40572. */
  40573. dispose(): void;
  40574. /**
  40575. * Get the current object class name.
  40576. * @returns the class name.
  40577. */
  40578. getClassName(): string;
  40579. }
  40580. }
  40581. declare module BABYLON {
  40582. /**
  40583. * Listen to keyboard events to control the camera.
  40584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40585. */
  40586. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40587. /**
  40588. * Defines the camera the input is attached to.
  40589. */
  40590. camera: FlyCamera;
  40591. /**
  40592. * The list of keyboard keys used to control the forward move of the camera.
  40593. */
  40594. keysForward: number[];
  40595. /**
  40596. * The list of keyboard keys used to control the backward move of the camera.
  40597. */
  40598. keysBackward: number[];
  40599. /**
  40600. * The list of keyboard keys used to control the forward move of the camera.
  40601. */
  40602. keysUp: number[];
  40603. /**
  40604. * The list of keyboard keys used to control the backward move of the camera.
  40605. */
  40606. keysDown: number[];
  40607. /**
  40608. * The list of keyboard keys used to control the right strafe move of the camera.
  40609. */
  40610. keysRight: number[];
  40611. /**
  40612. * The list of keyboard keys used to control the left strafe move of the camera.
  40613. */
  40614. keysLeft: number[];
  40615. private _keys;
  40616. private _onCanvasBlurObserver;
  40617. private _onKeyboardObserver;
  40618. private _engine;
  40619. private _scene;
  40620. /**
  40621. * Attach the input controls to a specific dom element to get the input from.
  40622. * @param element Defines the element the controls should be listened from
  40623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40624. */
  40625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40626. /**
  40627. * Detach the current controls from the specified dom element.
  40628. * @param element Defines the element to stop listening the inputs from
  40629. */
  40630. detachControl(element: Nullable<HTMLElement>): void;
  40631. /**
  40632. * Gets the class name of the current intput.
  40633. * @returns the class name
  40634. */
  40635. getClassName(): string;
  40636. /** @hidden */
  40637. _onLostFocus(e: FocusEvent): void;
  40638. /**
  40639. * Get the friendly name associated with the input class.
  40640. * @returns the input friendly name
  40641. */
  40642. getSimpleName(): string;
  40643. /**
  40644. * Update the current camera state depending on the inputs that have been used this frame.
  40645. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40646. */
  40647. checkInputs(): void;
  40648. }
  40649. }
  40650. declare module BABYLON {
  40651. /**
  40652. * Manage the mouse wheel inputs to control a follow camera.
  40653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40654. */
  40655. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40656. /**
  40657. * Defines the camera the input is attached to.
  40658. */
  40659. camera: FollowCamera;
  40660. /**
  40661. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40662. */
  40663. axisControlRadius: boolean;
  40664. /**
  40665. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40666. */
  40667. axisControlHeight: boolean;
  40668. /**
  40669. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40670. */
  40671. axisControlRotation: boolean;
  40672. /**
  40673. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40674. * relation to mouseWheel events.
  40675. */
  40676. wheelPrecision: number;
  40677. /**
  40678. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40679. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40680. */
  40681. wheelDeltaPercentage: number;
  40682. private _wheel;
  40683. private _observer;
  40684. /**
  40685. * Attach the input controls to a specific dom element to get the input from.
  40686. * @param element Defines the element the controls should be listened from
  40687. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40688. */
  40689. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40690. /**
  40691. * Detach the current controls from the specified dom element.
  40692. * @param element Defines the element to stop listening the inputs from
  40693. */
  40694. detachControl(element: Nullable<HTMLElement>): void;
  40695. /**
  40696. * Gets the class name of the current intput.
  40697. * @returns the class name
  40698. */
  40699. getClassName(): string;
  40700. /**
  40701. * Get the friendly name associated with the input class.
  40702. * @returns the input friendly name
  40703. */
  40704. getSimpleName(): string;
  40705. }
  40706. }
  40707. declare module BABYLON {
  40708. /**
  40709. * Manage the pointers inputs to control an follow camera.
  40710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40711. */
  40712. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40713. /**
  40714. * Defines the camera the input is attached to.
  40715. */
  40716. camera: FollowCamera;
  40717. /**
  40718. * Gets the class name of the current input.
  40719. * @returns the class name
  40720. */
  40721. getClassName(): string;
  40722. /**
  40723. * Defines the pointer angular sensibility along the X axis or how fast is
  40724. * the camera rotating.
  40725. * A negative number will reverse the axis direction.
  40726. */
  40727. angularSensibilityX: number;
  40728. /**
  40729. * Defines the pointer angular sensibility along the Y axis or how fast is
  40730. * the camera rotating.
  40731. * A negative number will reverse the axis direction.
  40732. */
  40733. angularSensibilityY: number;
  40734. /**
  40735. * Defines the pointer pinch precision or how fast is the camera zooming.
  40736. * A negative number will reverse the axis direction.
  40737. */
  40738. pinchPrecision: number;
  40739. /**
  40740. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40741. * from 0.
  40742. * It defines the percentage of current camera.radius to use as delta when
  40743. * pinch zoom is used.
  40744. */
  40745. pinchDeltaPercentage: number;
  40746. /**
  40747. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40748. */
  40749. axisXControlRadius: boolean;
  40750. /**
  40751. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40752. */
  40753. axisXControlHeight: boolean;
  40754. /**
  40755. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40756. */
  40757. axisXControlRotation: boolean;
  40758. /**
  40759. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40760. */
  40761. axisYControlRadius: boolean;
  40762. /**
  40763. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40764. */
  40765. axisYControlHeight: boolean;
  40766. /**
  40767. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40768. */
  40769. axisYControlRotation: boolean;
  40770. /**
  40771. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40772. */
  40773. axisPinchControlRadius: boolean;
  40774. /**
  40775. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40776. */
  40777. axisPinchControlHeight: boolean;
  40778. /**
  40779. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40780. */
  40781. axisPinchControlRotation: boolean;
  40782. /**
  40783. * Log error messages if basic misconfiguration has occurred.
  40784. */
  40785. warningEnable: boolean;
  40786. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40787. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40788. private _warningCounter;
  40789. private _warning;
  40790. }
  40791. }
  40792. declare module BABYLON {
  40793. /**
  40794. * Default Inputs manager for the FollowCamera.
  40795. * It groups all the default supported inputs for ease of use.
  40796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40797. */
  40798. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40799. /**
  40800. * Instantiates a new FollowCameraInputsManager.
  40801. * @param camera Defines the camera the inputs belong to
  40802. */
  40803. constructor(camera: FollowCamera);
  40804. /**
  40805. * Add keyboard input support to the input manager.
  40806. * @returns the current input manager
  40807. */
  40808. addKeyboard(): FollowCameraInputsManager;
  40809. /**
  40810. * Add mouse wheel input support to the input manager.
  40811. * @returns the current input manager
  40812. */
  40813. addMouseWheel(): FollowCameraInputsManager;
  40814. /**
  40815. * Add pointers input support to the input manager.
  40816. * @returns the current input manager
  40817. */
  40818. addPointers(): FollowCameraInputsManager;
  40819. /**
  40820. * Add orientation input support to the input manager.
  40821. * @returns the current input manager
  40822. */
  40823. addVRDeviceOrientation(): FollowCameraInputsManager;
  40824. }
  40825. }
  40826. declare module BABYLON {
  40827. /**
  40828. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40829. * an arc rotate version arcFollowCamera are available.
  40830. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40831. */
  40832. export class FollowCamera extends TargetCamera {
  40833. /**
  40834. * Distance the follow camera should follow an object at
  40835. */
  40836. radius: number;
  40837. /**
  40838. * Minimum allowed distance of the camera to the axis of rotation
  40839. * (The camera can not get closer).
  40840. * This can help limiting how the Camera is able to move in the scene.
  40841. */
  40842. lowerRadiusLimit: Nullable<number>;
  40843. /**
  40844. * Maximum allowed distance of the camera to the axis of rotation
  40845. * (The camera can not get further).
  40846. * This can help limiting how the Camera is able to move in the scene.
  40847. */
  40848. upperRadiusLimit: Nullable<number>;
  40849. /**
  40850. * Define a rotation offset between the camera and the object it follows
  40851. */
  40852. rotationOffset: number;
  40853. /**
  40854. * Minimum allowed angle to camera position relative to target object.
  40855. * This can help limiting how the Camera is able to move in the scene.
  40856. */
  40857. lowerRotationOffsetLimit: Nullable<number>;
  40858. /**
  40859. * Maximum allowed angle to camera position relative to target object.
  40860. * This can help limiting how the Camera is able to move in the scene.
  40861. */
  40862. upperRotationOffsetLimit: Nullable<number>;
  40863. /**
  40864. * Define a height offset between the camera and the object it follows.
  40865. * It can help following an object from the top (like a car chaing a plane)
  40866. */
  40867. heightOffset: number;
  40868. /**
  40869. * Minimum allowed height of camera position relative to target object.
  40870. * This can help limiting how the Camera is able to move in the scene.
  40871. */
  40872. lowerHeightOffsetLimit: Nullable<number>;
  40873. /**
  40874. * Maximum allowed height of camera position relative to target object.
  40875. * This can help limiting how the Camera is able to move in the scene.
  40876. */
  40877. upperHeightOffsetLimit: Nullable<number>;
  40878. /**
  40879. * Define how fast the camera can accelerate to follow it s target.
  40880. */
  40881. cameraAcceleration: number;
  40882. /**
  40883. * Define the speed limit of the camera following an object.
  40884. */
  40885. maxCameraSpeed: number;
  40886. /**
  40887. * Define the target of the camera.
  40888. */
  40889. lockedTarget: Nullable<AbstractMesh>;
  40890. /**
  40891. * Defines the input associated with the camera.
  40892. */
  40893. inputs: FollowCameraInputsManager;
  40894. /**
  40895. * Instantiates the follow camera.
  40896. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40897. * @param name Define the name of the camera in the scene
  40898. * @param position Define the position of the camera
  40899. * @param scene Define the scene the camera belong to
  40900. * @param lockedTarget Define the target of the camera
  40901. */
  40902. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40903. private _follow;
  40904. /**
  40905. * Attached controls to the current camera.
  40906. * @param element Defines the element the controls should be listened from
  40907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40908. */
  40909. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40910. /**
  40911. * Detach the current controls from the camera.
  40912. * The camera will stop reacting to inputs.
  40913. * @param element Defines the element to stop listening the inputs from
  40914. */
  40915. detachControl(element: HTMLElement): void;
  40916. /** @hidden */
  40917. _checkInputs(): void;
  40918. private _checkLimits;
  40919. /**
  40920. * Gets the camera class name.
  40921. * @returns the class name
  40922. */
  40923. getClassName(): string;
  40924. }
  40925. /**
  40926. * Arc Rotate version of the follow camera.
  40927. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40928. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40929. */
  40930. export class ArcFollowCamera extends TargetCamera {
  40931. /** The longitudinal angle of the camera */
  40932. alpha: number;
  40933. /** The latitudinal angle of the camera */
  40934. beta: number;
  40935. /** The radius of the camera from its target */
  40936. radius: number;
  40937. /** Define the camera target (the messh it should follow) */
  40938. target: Nullable<AbstractMesh>;
  40939. private _cartesianCoordinates;
  40940. /**
  40941. * Instantiates a new ArcFollowCamera
  40942. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40943. * @param name Define the name of the camera
  40944. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40945. * @param beta Define the rotation angle of the camera around the elevation axis
  40946. * @param radius Define the radius of the camera from its target point
  40947. * @param target Define the target of the camera
  40948. * @param scene Define the scene the camera belongs to
  40949. */
  40950. constructor(name: string,
  40951. /** The longitudinal angle of the camera */
  40952. alpha: number,
  40953. /** The latitudinal angle of the camera */
  40954. beta: number,
  40955. /** The radius of the camera from its target */
  40956. radius: number,
  40957. /** Define the camera target (the messh it should follow) */
  40958. target: Nullable<AbstractMesh>, scene: Scene);
  40959. private _follow;
  40960. /** @hidden */
  40961. _checkInputs(): void;
  40962. /**
  40963. * Returns the class name of the object.
  40964. * It is mostly used internally for serialization purposes.
  40965. */
  40966. getClassName(): string;
  40967. }
  40968. }
  40969. declare module BABYLON {
  40970. /**
  40971. * Manage the keyboard inputs to control the movement of a follow camera.
  40972. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40973. */
  40974. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40975. /**
  40976. * Defines the camera the input is attached to.
  40977. */
  40978. camera: FollowCamera;
  40979. /**
  40980. * Defines the list of key codes associated with the up action (increase heightOffset)
  40981. */
  40982. keysHeightOffsetIncr: number[];
  40983. /**
  40984. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40985. */
  40986. keysHeightOffsetDecr: number[];
  40987. /**
  40988. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40989. */
  40990. keysHeightOffsetModifierAlt: boolean;
  40991. /**
  40992. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40993. */
  40994. keysHeightOffsetModifierCtrl: boolean;
  40995. /**
  40996. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40997. */
  40998. keysHeightOffsetModifierShift: boolean;
  40999. /**
  41000. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41001. */
  41002. keysRotationOffsetIncr: number[];
  41003. /**
  41004. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41005. */
  41006. keysRotationOffsetDecr: number[];
  41007. /**
  41008. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41009. */
  41010. keysRotationOffsetModifierAlt: boolean;
  41011. /**
  41012. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41013. */
  41014. keysRotationOffsetModifierCtrl: boolean;
  41015. /**
  41016. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41017. */
  41018. keysRotationOffsetModifierShift: boolean;
  41019. /**
  41020. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41021. */
  41022. keysRadiusIncr: number[];
  41023. /**
  41024. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41025. */
  41026. keysRadiusDecr: number[];
  41027. /**
  41028. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41029. */
  41030. keysRadiusModifierAlt: boolean;
  41031. /**
  41032. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41033. */
  41034. keysRadiusModifierCtrl: boolean;
  41035. /**
  41036. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41037. */
  41038. keysRadiusModifierShift: boolean;
  41039. /**
  41040. * Defines the rate of change of heightOffset.
  41041. */
  41042. heightSensibility: number;
  41043. /**
  41044. * Defines the rate of change of rotationOffset.
  41045. */
  41046. rotationSensibility: number;
  41047. /**
  41048. * Defines the rate of change of radius.
  41049. */
  41050. radiusSensibility: number;
  41051. private _keys;
  41052. private _ctrlPressed;
  41053. private _altPressed;
  41054. private _shiftPressed;
  41055. private _onCanvasBlurObserver;
  41056. private _onKeyboardObserver;
  41057. private _engine;
  41058. private _scene;
  41059. /**
  41060. * Attach the input controls to a specific dom element to get the input from.
  41061. * @param element Defines the element the controls should be listened from
  41062. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41063. */
  41064. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41065. /**
  41066. * Detach the current controls from the specified dom element.
  41067. * @param element Defines the element to stop listening the inputs from
  41068. */
  41069. detachControl(element: Nullable<HTMLElement>): void;
  41070. /**
  41071. * Update the current camera state depending on the inputs that have been used this frame.
  41072. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41073. */
  41074. checkInputs(): void;
  41075. /**
  41076. * Gets the class name of the current input.
  41077. * @returns the class name
  41078. */
  41079. getClassName(): string;
  41080. /**
  41081. * Get the friendly name associated with the input class.
  41082. * @returns the input friendly name
  41083. */
  41084. getSimpleName(): string;
  41085. /**
  41086. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41087. * allow modification of the heightOffset value.
  41088. */
  41089. private _modifierHeightOffset;
  41090. /**
  41091. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41092. * allow modification of the rotationOffset value.
  41093. */
  41094. private _modifierRotationOffset;
  41095. /**
  41096. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41097. * allow modification of the radius value.
  41098. */
  41099. private _modifierRadius;
  41100. }
  41101. }
  41102. declare module BABYLON {
  41103. interface FreeCameraInputsManager {
  41104. /**
  41105. * @hidden
  41106. */
  41107. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41108. /**
  41109. * Add orientation input support to the input manager.
  41110. * @returns the current input manager
  41111. */
  41112. addDeviceOrientation(): FreeCameraInputsManager;
  41113. }
  41114. /**
  41115. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41116. * Screen rotation is taken into account.
  41117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41118. */
  41119. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41120. private _camera;
  41121. private _screenOrientationAngle;
  41122. private _constantTranform;
  41123. private _screenQuaternion;
  41124. private _alpha;
  41125. private _beta;
  41126. private _gamma;
  41127. /**
  41128. * Can be used to detect if a device orientation sensor is available on a device
  41129. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41130. * @returns a promise that will resolve on orientation change
  41131. */
  41132. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41133. /**
  41134. * @hidden
  41135. */
  41136. _onDeviceOrientationChangedObservable: Observable<void>;
  41137. /**
  41138. * Instantiates a new input
  41139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41140. */
  41141. constructor();
  41142. /**
  41143. * Define the camera controlled by the input.
  41144. */
  41145. get camera(): FreeCamera;
  41146. set camera(camera: FreeCamera);
  41147. /**
  41148. * Attach the input controls to a specific dom element to get the input from.
  41149. * @param element Defines the element the controls should be listened from
  41150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41151. */
  41152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41153. private _orientationChanged;
  41154. private _deviceOrientation;
  41155. /**
  41156. * Detach the current controls from the specified dom element.
  41157. * @param element Defines the element to stop listening the inputs from
  41158. */
  41159. detachControl(element: Nullable<HTMLElement>): void;
  41160. /**
  41161. * Update the current camera state depending on the inputs that have been used this frame.
  41162. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41163. */
  41164. checkInputs(): void;
  41165. /**
  41166. * Gets the class name of the current intput.
  41167. * @returns the class name
  41168. */
  41169. getClassName(): string;
  41170. /**
  41171. * Get the friendly name associated with the input class.
  41172. * @returns the input friendly name
  41173. */
  41174. getSimpleName(): string;
  41175. }
  41176. }
  41177. declare module BABYLON {
  41178. /**
  41179. * Manage the gamepad inputs to control a free camera.
  41180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41181. */
  41182. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41183. /**
  41184. * Define the camera the input is attached to.
  41185. */
  41186. camera: FreeCamera;
  41187. /**
  41188. * Define the Gamepad controlling the input
  41189. */
  41190. gamepad: Nullable<Gamepad>;
  41191. /**
  41192. * Defines the gamepad rotation sensiblity.
  41193. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41194. */
  41195. gamepadAngularSensibility: number;
  41196. /**
  41197. * Defines the gamepad move sensiblity.
  41198. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41199. */
  41200. gamepadMoveSensibility: number;
  41201. private _yAxisScale;
  41202. /**
  41203. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41204. */
  41205. get invertYAxis(): boolean;
  41206. set invertYAxis(value: boolean);
  41207. private _onGamepadConnectedObserver;
  41208. private _onGamepadDisconnectedObserver;
  41209. private _cameraTransform;
  41210. private _deltaTransform;
  41211. private _vector3;
  41212. private _vector2;
  41213. /**
  41214. * Attach the input controls to a specific dom element to get the input from.
  41215. * @param element Defines the element the controls should be listened from
  41216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41217. */
  41218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41219. /**
  41220. * Detach the current controls from the specified dom element.
  41221. * @param element Defines the element to stop listening the inputs from
  41222. */
  41223. detachControl(element: Nullable<HTMLElement>): void;
  41224. /**
  41225. * Update the current camera state depending on the inputs that have been used this frame.
  41226. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41227. */
  41228. checkInputs(): void;
  41229. /**
  41230. * Gets the class name of the current intput.
  41231. * @returns the class name
  41232. */
  41233. getClassName(): string;
  41234. /**
  41235. * Get the friendly name associated with the input class.
  41236. * @returns the input friendly name
  41237. */
  41238. getSimpleName(): string;
  41239. }
  41240. }
  41241. declare module BABYLON {
  41242. /**
  41243. * Defines the potential axis of a Joystick
  41244. */
  41245. export enum JoystickAxis {
  41246. /** X axis */
  41247. X = 0,
  41248. /** Y axis */
  41249. Y = 1,
  41250. /** Z axis */
  41251. Z = 2
  41252. }
  41253. /**
  41254. * Class used to define virtual joystick (used in touch mode)
  41255. */
  41256. export class VirtualJoystick {
  41257. /**
  41258. * Gets or sets a boolean indicating that left and right values must be inverted
  41259. */
  41260. reverseLeftRight: boolean;
  41261. /**
  41262. * Gets or sets a boolean indicating that up and down values must be inverted
  41263. */
  41264. reverseUpDown: boolean;
  41265. /**
  41266. * Gets the offset value for the position (ie. the change of the position value)
  41267. */
  41268. deltaPosition: Vector3;
  41269. /**
  41270. * Gets a boolean indicating if the virtual joystick was pressed
  41271. */
  41272. pressed: boolean;
  41273. /**
  41274. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41275. */
  41276. static Canvas: Nullable<HTMLCanvasElement>;
  41277. private static _globalJoystickIndex;
  41278. private static vjCanvasContext;
  41279. private static vjCanvasWidth;
  41280. private static vjCanvasHeight;
  41281. private static halfWidth;
  41282. private _action;
  41283. private _axisTargetedByLeftAndRight;
  41284. private _axisTargetedByUpAndDown;
  41285. private _joystickSensibility;
  41286. private _inversedSensibility;
  41287. private _joystickPointerID;
  41288. private _joystickColor;
  41289. private _joystickPointerPos;
  41290. private _joystickPreviousPointerPos;
  41291. private _joystickPointerStartPos;
  41292. private _deltaJoystickVector;
  41293. private _leftJoystick;
  41294. private _touches;
  41295. private _onPointerDownHandlerRef;
  41296. private _onPointerMoveHandlerRef;
  41297. private _onPointerUpHandlerRef;
  41298. private _onResize;
  41299. /**
  41300. * Creates a new virtual joystick
  41301. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41302. */
  41303. constructor(leftJoystick?: boolean);
  41304. /**
  41305. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41306. * @param newJoystickSensibility defines the new sensibility
  41307. */
  41308. setJoystickSensibility(newJoystickSensibility: number): void;
  41309. private _onPointerDown;
  41310. private _onPointerMove;
  41311. private _onPointerUp;
  41312. /**
  41313. * Change the color of the virtual joystick
  41314. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41315. */
  41316. setJoystickColor(newColor: string): void;
  41317. /**
  41318. * Defines a callback to call when the joystick is touched
  41319. * @param action defines the callback
  41320. */
  41321. setActionOnTouch(action: () => any): void;
  41322. /**
  41323. * Defines which axis you'd like to control for left & right
  41324. * @param axis defines the axis to use
  41325. */
  41326. setAxisForLeftRight(axis: JoystickAxis): void;
  41327. /**
  41328. * Defines which axis you'd like to control for up & down
  41329. * @param axis defines the axis to use
  41330. */
  41331. setAxisForUpDown(axis: JoystickAxis): void;
  41332. private _drawVirtualJoystick;
  41333. /**
  41334. * Release internal HTML canvas
  41335. */
  41336. releaseCanvas(): void;
  41337. }
  41338. }
  41339. declare module BABYLON {
  41340. interface FreeCameraInputsManager {
  41341. /**
  41342. * Add virtual joystick input support to the input manager.
  41343. * @returns the current input manager
  41344. */
  41345. addVirtualJoystick(): FreeCameraInputsManager;
  41346. }
  41347. /**
  41348. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41350. */
  41351. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41352. /**
  41353. * Defines the camera the input is attached to.
  41354. */
  41355. camera: FreeCamera;
  41356. private _leftjoystick;
  41357. private _rightjoystick;
  41358. /**
  41359. * Gets the left stick of the virtual joystick.
  41360. * @returns The virtual Joystick
  41361. */
  41362. getLeftJoystick(): VirtualJoystick;
  41363. /**
  41364. * Gets the right stick of the virtual joystick.
  41365. * @returns The virtual Joystick
  41366. */
  41367. getRightJoystick(): VirtualJoystick;
  41368. /**
  41369. * Update the current camera state depending on the inputs that have been used this frame.
  41370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41371. */
  41372. checkInputs(): void;
  41373. /**
  41374. * Attach the input controls to a specific dom element to get the input from.
  41375. * @param element Defines the element the controls should be listened from
  41376. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41377. */
  41378. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41379. /**
  41380. * Detach the current controls from the specified dom element.
  41381. * @param element Defines the element to stop listening the inputs from
  41382. */
  41383. detachControl(element: Nullable<HTMLElement>): void;
  41384. /**
  41385. * Gets the class name of the current intput.
  41386. * @returns the class name
  41387. */
  41388. getClassName(): string;
  41389. /**
  41390. * Get the friendly name associated with the input class.
  41391. * @returns the input friendly name
  41392. */
  41393. getSimpleName(): string;
  41394. }
  41395. }
  41396. declare module BABYLON {
  41397. /**
  41398. * This represents a FPS type of camera controlled by touch.
  41399. * This is like a universal camera minus the Gamepad controls.
  41400. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41401. */
  41402. export class TouchCamera extends FreeCamera {
  41403. /**
  41404. * Defines the touch sensibility for rotation.
  41405. * The higher the faster.
  41406. */
  41407. get touchAngularSensibility(): number;
  41408. set touchAngularSensibility(value: number);
  41409. /**
  41410. * Defines the touch sensibility for move.
  41411. * The higher the faster.
  41412. */
  41413. get touchMoveSensibility(): number;
  41414. set touchMoveSensibility(value: number);
  41415. /**
  41416. * Instantiates a new touch camera.
  41417. * This represents a FPS type of camera controlled by touch.
  41418. * This is like a universal camera minus the Gamepad controls.
  41419. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41420. * @param name Define the name of the camera in the scene
  41421. * @param position Define the start position of the camera in the scene
  41422. * @param scene Define the scene the camera belongs to
  41423. */
  41424. constructor(name: string, position: Vector3, scene: Scene);
  41425. /**
  41426. * Gets the current object class name.
  41427. * @return the class name
  41428. */
  41429. getClassName(): string;
  41430. /** @hidden */
  41431. _setupInputs(): void;
  41432. }
  41433. }
  41434. declare module BABYLON {
  41435. /**
  41436. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41437. * being tilted forward or back and left or right.
  41438. */
  41439. export class DeviceOrientationCamera extends FreeCamera {
  41440. private _initialQuaternion;
  41441. private _quaternionCache;
  41442. private _tmpDragQuaternion;
  41443. private _disablePointerInputWhenUsingDeviceOrientation;
  41444. /**
  41445. * Creates a new device orientation camera
  41446. * @param name The name of the camera
  41447. * @param position The start position camera
  41448. * @param scene The scene the camera belongs to
  41449. */
  41450. constructor(name: string, position: Vector3, scene: Scene);
  41451. /**
  41452. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41453. */
  41454. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41455. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41456. private _dragFactor;
  41457. /**
  41458. * Enabled turning on the y axis when the orientation sensor is active
  41459. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41460. */
  41461. enableHorizontalDragging(dragFactor?: number): void;
  41462. /**
  41463. * Gets the current instance class name ("DeviceOrientationCamera").
  41464. * This helps avoiding instanceof at run time.
  41465. * @returns the class name
  41466. */
  41467. getClassName(): string;
  41468. /**
  41469. * @hidden
  41470. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41471. */
  41472. _checkInputs(): void;
  41473. /**
  41474. * Reset the camera to its default orientation on the specified axis only.
  41475. * @param axis The axis to reset
  41476. */
  41477. resetToCurrentRotation(axis?: Axis): void;
  41478. }
  41479. }
  41480. declare module BABYLON {
  41481. /**
  41482. * Defines supported buttons for XBox360 compatible gamepads
  41483. */
  41484. export enum Xbox360Button {
  41485. /** A */
  41486. A = 0,
  41487. /** B */
  41488. B = 1,
  41489. /** X */
  41490. X = 2,
  41491. /** Y */
  41492. Y = 3,
  41493. /** Left button */
  41494. LB = 4,
  41495. /** Right button */
  41496. RB = 5,
  41497. /** Back */
  41498. Back = 8,
  41499. /** Start */
  41500. Start = 9,
  41501. /** Left stick */
  41502. LeftStick = 10,
  41503. /** Right stick */
  41504. RightStick = 11
  41505. }
  41506. /** Defines values for XBox360 DPad */
  41507. export enum Xbox360Dpad {
  41508. /** Up */
  41509. Up = 12,
  41510. /** Down */
  41511. Down = 13,
  41512. /** Left */
  41513. Left = 14,
  41514. /** Right */
  41515. Right = 15
  41516. }
  41517. /**
  41518. * Defines a XBox360 gamepad
  41519. */
  41520. export class Xbox360Pad extends Gamepad {
  41521. private _leftTrigger;
  41522. private _rightTrigger;
  41523. private _onlefttriggerchanged;
  41524. private _onrighttriggerchanged;
  41525. private _onbuttondown;
  41526. private _onbuttonup;
  41527. private _ondpaddown;
  41528. private _ondpadup;
  41529. /** Observable raised when a button is pressed */
  41530. onButtonDownObservable: Observable<Xbox360Button>;
  41531. /** Observable raised when a button is released */
  41532. onButtonUpObservable: Observable<Xbox360Button>;
  41533. /** Observable raised when a pad is pressed */
  41534. onPadDownObservable: Observable<Xbox360Dpad>;
  41535. /** Observable raised when a pad is released */
  41536. onPadUpObservable: Observable<Xbox360Dpad>;
  41537. private _buttonA;
  41538. private _buttonB;
  41539. private _buttonX;
  41540. private _buttonY;
  41541. private _buttonBack;
  41542. private _buttonStart;
  41543. private _buttonLB;
  41544. private _buttonRB;
  41545. private _buttonLeftStick;
  41546. private _buttonRightStick;
  41547. private _dPadUp;
  41548. private _dPadDown;
  41549. private _dPadLeft;
  41550. private _dPadRight;
  41551. private _isXboxOnePad;
  41552. /**
  41553. * Creates a new XBox360 gamepad object
  41554. * @param id defines the id of this gamepad
  41555. * @param index defines its index
  41556. * @param gamepad defines the internal HTML gamepad object
  41557. * @param xboxOne defines if it is a XBox One gamepad
  41558. */
  41559. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41560. /**
  41561. * Defines the callback to call when left trigger is pressed
  41562. * @param callback defines the callback to use
  41563. */
  41564. onlefttriggerchanged(callback: (value: number) => void): void;
  41565. /**
  41566. * Defines the callback to call when right trigger is pressed
  41567. * @param callback defines the callback to use
  41568. */
  41569. onrighttriggerchanged(callback: (value: number) => void): void;
  41570. /**
  41571. * Gets the left trigger value
  41572. */
  41573. get leftTrigger(): number;
  41574. /**
  41575. * Sets the left trigger value
  41576. */
  41577. set leftTrigger(newValue: number);
  41578. /**
  41579. * Gets the right trigger value
  41580. */
  41581. get rightTrigger(): number;
  41582. /**
  41583. * Sets the right trigger value
  41584. */
  41585. set rightTrigger(newValue: number);
  41586. /**
  41587. * Defines the callback to call when a button is pressed
  41588. * @param callback defines the callback to use
  41589. */
  41590. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41591. /**
  41592. * Defines the callback to call when a button is released
  41593. * @param callback defines the callback to use
  41594. */
  41595. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41596. /**
  41597. * Defines the callback to call when a pad is pressed
  41598. * @param callback defines the callback to use
  41599. */
  41600. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41601. /**
  41602. * Defines the callback to call when a pad is released
  41603. * @param callback defines the callback to use
  41604. */
  41605. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41606. private _setButtonValue;
  41607. private _setDPadValue;
  41608. /**
  41609. * Gets the value of the `A` button
  41610. */
  41611. get buttonA(): number;
  41612. /**
  41613. * Sets the value of the `A` button
  41614. */
  41615. set buttonA(value: number);
  41616. /**
  41617. * Gets the value of the `B` button
  41618. */
  41619. get buttonB(): number;
  41620. /**
  41621. * Sets the value of the `B` button
  41622. */
  41623. set buttonB(value: number);
  41624. /**
  41625. * Gets the value of the `X` button
  41626. */
  41627. get buttonX(): number;
  41628. /**
  41629. * Sets the value of the `X` button
  41630. */
  41631. set buttonX(value: number);
  41632. /**
  41633. * Gets the value of the `Y` button
  41634. */
  41635. get buttonY(): number;
  41636. /**
  41637. * Sets the value of the `Y` button
  41638. */
  41639. set buttonY(value: number);
  41640. /**
  41641. * Gets the value of the `Start` button
  41642. */
  41643. get buttonStart(): number;
  41644. /**
  41645. * Sets the value of the `Start` button
  41646. */
  41647. set buttonStart(value: number);
  41648. /**
  41649. * Gets the value of the `Back` button
  41650. */
  41651. get buttonBack(): number;
  41652. /**
  41653. * Sets the value of the `Back` button
  41654. */
  41655. set buttonBack(value: number);
  41656. /**
  41657. * Gets the value of the `Left` button
  41658. */
  41659. get buttonLB(): number;
  41660. /**
  41661. * Sets the value of the `Left` button
  41662. */
  41663. set buttonLB(value: number);
  41664. /**
  41665. * Gets the value of the `Right` button
  41666. */
  41667. get buttonRB(): number;
  41668. /**
  41669. * Sets the value of the `Right` button
  41670. */
  41671. set buttonRB(value: number);
  41672. /**
  41673. * Gets the value of the Left joystick
  41674. */
  41675. get buttonLeftStick(): number;
  41676. /**
  41677. * Sets the value of the Left joystick
  41678. */
  41679. set buttonLeftStick(value: number);
  41680. /**
  41681. * Gets the value of the Right joystick
  41682. */
  41683. get buttonRightStick(): number;
  41684. /**
  41685. * Sets the value of the Right joystick
  41686. */
  41687. set buttonRightStick(value: number);
  41688. /**
  41689. * Gets the value of D-pad up
  41690. */
  41691. get dPadUp(): number;
  41692. /**
  41693. * Sets the value of D-pad up
  41694. */
  41695. set dPadUp(value: number);
  41696. /**
  41697. * Gets the value of D-pad down
  41698. */
  41699. get dPadDown(): number;
  41700. /**
  41701. * Sets the value of D-pad down
  41702. */
  41703. set dPadDown(value: number);
  41704. /**
  41705. * Gets the value of D-pad left
  41706. */
  41707. get dPadLeft(): number;
  41708. /**
  41709. * Sets the value of D-pad left
  41710. */
  41711. set dPadLeft(value: number);
  41712. /**
  41713. * Gets the value of D-pad right
  41714. */
  41715. get dPadRight(): number;
  41716. /**
  41717. * Sets the value of D-pad right
  41718. */
  41719. set dPadRight(value: number);
  41720. /**
  41721. * Force the gamepad to synchronize with device values
  41722. */
  41723. update(): void;
  41724. /**
  41725. * Disposes the gamepad
  41726. */
  41727. dispose(): void;
  41728. }
  41729. }
  41730. declare module BABYLON {
  41731. /**
  41732. * Defines supported buttons for DualShock compatible gamepads
  41733. */
  41734. export enum DualShockButton {
  41735. /** Cross */
  41736. Cross = 0,
  41737. /** Circle */
  41738. Circle = 1,
  41739. /** Square */
  41740. Square = 2,
  41741. /** Triangle */
  41742. Triangle = 3,
  41743. /** L1 */
  41744. L1 = 4,
  41745. /** R1 */
  41746. R1 = 5,
  41747. /** Share */
  41748. Share = 8,
  41749. /** Options */
  41750. Options = 9,
  41751. /** Left stick */
  41752. LeftStick = 10,
  41753. /** Right stick */
  41754. RightStick = 11
  41755. }
  41756. /** Defines values for DualShock DPad */
  41757. export enum DualShockDpad {
  41758. /** Up */
  41759. Up = 12,
  41760. /** Down */
  41761. Down = 13,
  41762. /** Left */
  41763. Left = 14,
  41764. /** Right */
  41765. Right = 15
  41766. }
  41767. /**
  41768. * Defines a DualShock gamepad
  41769. */
  41770. export class DualShockPad extends Gamepad {
  41771. private _leftTrigger;
  41772. private _rightTrigger;
  41773. private _onlefttriggerchanged;
  41774. private _onrighttriggerchanged;
  41775. private _onbuttondown;
  41776. private _onbuttonup;
  41777. private _ondpaddown;
  41778. private _ondpadup;
  41779. /** Observable raised when a button is pressed */
  41780. onButtonDownObservable: Observable<DualShockButton>;
  41781. /** Observable raised when a button is released */
  41782. onButtonUpObservable: Observable<DualShockButton>;
  41783. /** Observable raised when a pad is pressed */
  41784. onPadDownObservable: Observable<DualShockDpad>;
  41785. /** Observable raised when a pad is released */
  41786. onPadUpObservable: Observable<DualShockDpad>;
  41787. private _buttonCross;
  41788. private _buttonCircle;
  41789. private _buttonSquare;
  41790. private _buttonTriangle;
  41791. private _buttonShare;
  41792. private _buttonOptions;
  41793. private _buttonL1;
  41794. private _buttonR1;
  41795. private _buttonLeftStick;
  41796. private _buttonRightStick;
  41797. private _dPadUp;
  41798. private _dPadDown;
  41799. private _dPadLeft;
  41800. private _dPadRight;
  41801. /**
  41802. * Creates a new DualShock gamepad object
  41803. * @param id defines the id of this gamepad
  41804. * @param index defines its index
  41805. * @param gamepad defines the internal HTML gamepad object
  41806. */
  41807. constructor(id: string, index: number, gamepad: any);
  41808. /**
  41809. * Defines the callback to call when left trigger is pressed
  41810. * @param callback defines the callback to use
  41811. */
  41812. onlefttriggerchanged(callback: (value: number) => void): void;
  41813. /**
  41814. * Defines the callback to call when right trigger is pressed
  41815. * @param callback defines the callback to use
  41816. */
  41817. onrighttriggerchanged(callback: (value: number) => void): void;
  41818. /**
  41819. * Gets the left trigger value
  41820. */
  41821. get leftTrigger(): number;
  41822. /**
  41823. * Sets the left trigger value
  41824. */
  41825. set leftTrigger(newValue: number);
  41826. /**
  41827. * Gets the right trigger value
  41828. */
  41829. get rightTrigger(): number;
  41830. /**
  41831. * Sets the right trigger value
  41832. */
  41833. set rightTrigger(newValue: number);
  41834. /**
  41835. * Defines the callback to call when a button is pressed
  41836. * @param callback defines the callback to use
  41837. */
  41838. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41839. /**
  41840. * Defines the callback to call when a button is released
  41841. * @param callback defines the callback to use
  41842. */
  41843. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41844. /**
  41845. * Defines the callback to call when a pad is pressed
  41846. * @param callback defines the callback to use
  41847. */
  41848. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41849. /**
  41850. * Defines the callback to call when a pad is released
  41851. * @param callback defines the callback to use
  41852. */
  41853. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41854. private _setButtonValue;
  41855. private _setDPadValue;
  41856. /**
  41857. * Gets the value of the `Cross` button
  41858. */
  41859. get buttonCross(): number;
  41860. /**
  41861. * Sets the value of the `Cross` button
  41862. */
  41863. set buttonCross(value: number);
  41864. /**
  41865. * Gets the value of the `Circle` button
  41866. */
  41867. get buttonCircle(): number;
  41868. /**
  41869. * Sets the value of the `Circle` button
  41870. */
  41871. set buttonCircle(value: number);
  41872. /**
  41873. * Gets the value of the `Square` button
  41874. */
  41875. get buttonSquare(): number;
  41876. /**
  41877. * Sets the value of the `Square` button
  41878. */
  41879. set buttonSquare(value: number);
  41880. /**
  41881. * Gets the value of the `Triangle` button
  41882. */
  41883. get buttonTriangle(): number;
  41884. /**
  41885. * Sets the value of the `Triangle` button
  41886. */
  41887. set buttonTriangle(value: number);
  41888. /**
  41889. * Gets the value of the `Options` button
  41890. */
  41891. get buttonOptions(): number;
  41892. /**
  41893. * Sets the value of the `Options` button
  41894. */
  41895. set buttonOptions(value: number);
  41896. /**
  41897. * Gets the value of the `Share` button
  41898. */
  41899. get buttonShare(): number;
  41900. /**
  41901. * Sets the value of the `Share` button
  41902. */
  41903. set buttonShare(value: number);
  41904. /**
  41905. * Gets the value of the `L1` button
  41906. */
  41907. get buttonL1(): number;
  41908. /**
  41909. * Sets the value of the `L1` button
  41910. */
  41911. set buttonL1(value: number);
  41912. /**
  41913. * Gets the value of the `R1` button
  41914. */
  41915. get buttonR1(): number;
  41916. /**
  41917. * Sets the value of the `R1` button
  41918. */
  41919. set buttonR1(value: number);
  41920. /**
  41921. * Gets the value of the Left joystick
  41922. */
  41923. get buttonLeftStick(): number;
  41924. /**
  41925. * Sets the value of the Left joystick
  41926. */
  41927. set buttonLeftStick(value: number);
  41928. /**
  41929. * Gets the value of the Right joystick
  41930. */
  41931. get buttonRightStick(): number;
  41932. /**
  41933. * Sets the value of the Right joystick
  41934. */
  41935. set buttonRightStick(value: number);
  41936. /**
  41937. * Gets the value of D-pad up
  41938. */
  41939. get dPadUp(): number;
  41940. /**
  41941. * Sets the value of D-pad up
  41942. */
  41943. set dPadUp(value: number);
  41944. /**
  41945. * Gets the value of D-pad down
  41946. */
  41947. get dPadDown(): number;
  41948. /**
  41949. * Sets the value of D-pad down
  41950. */
  41951. set dPadDown(value: number);
  41952. /**
  41953. * Gets the value of D-pad left
  41954. */
  41955. get dPadLeft(): number;
  41956. /**
  41957. * Sets the value of D-pad left
  41958. */
  41959. set dPadLeft(value: number);
  41960. /**
  41961. * Gets the value of D-pad right
  41962. */
  41963. get dPadRight(): number;
  41964. /**
  41965. * Sets the value of D-pad right
  41966. */
  41967. set dPadRight(value: number);
  41968. /**
  41969. * Force the gamepad to synchronize with device values
  41970. */
  41971. update(): void;
  41972. /**
  41973. * Disposes the gamepad
  41974. */
  41975. dispose(): void;
  41976. }
  41977. }
  41978. declare module BABYLON {
  41979. /**
  41980. * Manager for handling gamepads
  41981. */
  41982. export class GamepadManager {
  41983. private _scene?;
  41984. private _babylonGamepads;
  41985. private _oneGamepadConnected;
  41986. /** @hidden */
  41987. _isMonitoring: boolean;
  41988. private _gamepadEventSupported;
  41989. private _gamepadSupport?;
  41990. /**
  41991. * observable to be triggered when the gamepad controller has been connected
  41992. */
  41993. onGamepadConnectedObservable: Observable<Gamepad>;
  41994. /**
  41995. * observable to be triggered when the gamepad controller has been disconnected
  41996. */
  41997. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41998. private _onGamepadConnectedEvent;
  41999. private _onGamepadDisconnectedEvent;
  42000. /**
  42001. * Initializes the gamepad manager
  42002. * @param _scene BabylonJS scene
  42003. */
  42004. constructor(_scene?: Scene | undefined);
  42005. /**
  42006. * The gamepads in the game pad manager
  42007. */
  42008. get gamepads(): Gamepad[];
  42009. /**
  42010. * Get the gamepad controllers based on type
  42011. * @param type The type of gamepad controller
  42012. * @returns Nullable gamepad
  42013. */
  42014. getGamepadByType(type?: number): Nullable<Gamepad>;
  42015. /**
  42016. * Disposes the gamepad manager
  42017. */
  42018. dispose(): void;
  42019. private _addNewGamepad;
  42020. private _startMonitoringGamepads;
  42021. private _stopMonitoringGamepads;
  42022. /** @hidden */
  42023. _checkGamepadsStatus(): void;
  42024. private _updateGamepadObjects;
  42025. }
  42026. }
  42027. declare module BABYLON {
  42028. interface Scene {
  42029. /** @hidden */
  42030. _gamepadManager: Nullable<GamepadManager>;
  42031. /**
  42032. * Gets the gamepad manager associated with the scene
  42033. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42034. */
  42035. gamepadManager: GamepadManager;
  42036. }
  42037. /**
  42038. * Interface representing a free camera inputs manager
  42039. */
  42040. interface FreeCameraInputsManager {
  42041. /**
  42042. * Adds gamepad input support to the FreeCameraInputsManager.
  42043. * @returns the FreeCameraInputsManager
  42044. */
  42045. addGamepad(): FreeCameraInputsManager;
  42046. }
  42047. /**
  42048. * Interface representing an arc rotate camera inputs manager
  42049. */
  42050. interface ArcRotateCameraInputsManager {
  42051. /**
  42052. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42053. * @returns the camera inputs manager
  42054. */
  42055. addGamepad(): ArcRotateCameraInputsManager;
  42056. }
  42057. /**
  42058. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42059. */
  42060. export class GamepadSystemSceneComponent implements ISceneComponent {
  42061. /**
  42062. * The component name helpfull to identify the component in the list of scene components.
  42063. */
  42064. readonly name: string;
  42065. /**
  42066. * The scene the component belongs to.
  42067. */
  42068. scene: Scene;
  42069. /**
  42070. * Creates a new instance of the component for the given scene
  42071. * @param scene Defines the scene to register the component in
  42072. */
  42073. constructor(scene: Scene);
  42074. /**
  42075. * Registers the component in a given scene
  42076. */
  42077. register(): void;
  42078. /**
  42079. * Rebuilds the elements related to this component in case of
  42080. * context lost for instance.
  42081. */
  42082. rebuild(): void;
  42083. /**
  42084. * Disposes the component and the associated ressources
  42085. */
  42086. dispose(): void;
  42087. private _beforeCameraUpdate;
  42088. }
  42089. }
  42090. declare module BABYLON {
  42091. /**
  42092. * 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,
  42093. * which still works and will still be found in many Playgrounds.
  42094. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42095. */
  42096. export class UniversalCamera extends TouchCamera {
  42097. /**
  42098. * Defines the gamepad rotation sensiblity.
  42099. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42100. */
  42101. get gamepadAngularSensibility(): number;
  42102. set gamepadAngularSensibility(value: number);
  42103. /**
  42104. * Defines the gamepad move sensiblity.
  42105. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42106. */
  42107. get gamepadMoveSensibility(): number;
  42108. set gamepadMoveSensibility(value: number);
  42109. /**
  42110. * 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,
  42111. * which still works and will still be found in many Playgrounds.
  42112. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42113. * @param name Define the name of the camera in the scene
  42114. * @param position Define the start position of the camera in the scene
  42115. * @param scene Define the scene the camera belongs to
  42116. */
  42117. constructor(name: string, position: Vector3, scene: Scene);
  42118. /**
  42119. * Gets the current object class name.
  42120. * @return the class name
  42121. */
  42122. getClassName(): string;
  42123. }
  42124. }
  42125. declare module BABYLON {
  42126. /**
  42127. * This represents a FPS type of camera. This is only here for back compat purpose.
  42128. * Please use the UniversalCamera instead as both are identical.
  42129. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42130. */
  42131. export class GamepadCamera extends UniversalCamera {
  42132. /**
  42133. * Instantiates a new Gamepad Camera
  42134. * This represents a FPS type of camera. This is only here for back compat purpose.
  42135. * Please use the UniversalCamera instead as both are identical.
  42136. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42137. * @param name Define the name of the camera in the scene
  42138. * @param position Define the start position of the camera in the scene
  42139. * @param scene Define the scene the camera belongs to
  42140. */
  42141. constructor(name: string, position: Vector3, scene: Scene);
  42142. /**
  42143. * Gets the current object class name.
  42144. * @return the class name
  42145. */
  42146. getClassName(): string;
  42147. }
  42148. }
  42149. declare module BABYLON {
  42150. /** @hidden */
  42151. export var passPixelShader: {
  42152. name: string;
  42153. shader: string;
  42154. };
  42155. }
  42156. declare module BABYLON {
  42157. /** @hidden */
  42158. export var passCubePixelShader: {
  42159. name: string;
  42160. shader: string;
  42161. };
  42162. }
  42163. declare module BABYLON {
  42164. /**
  42165. * PassPostProcess which produces an output the same as it's input
  42166. */
  42167. export class PassPostProcess extends PostProcess {
  42168. /**
  42169. * Creates the PassPostProcess
  42170. * @param name The name of the effect.
  42171. * @param options The required width/height ratio to downsize to before computing the render pass.
  42172. * @param camera The camera to apply the render pass to.
  42173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42174. * @param engine The engine which the post process will be applied. (default: current engine)
  42175. * @param reusable If the post process can be reused on the same frame. (default: false)
  42176. * @param textureType The type of texture to be used when performing the post processing.
  42177. * @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)
  42178. */
  42179. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42180. }
  42181. /**
  42182. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42183. */
  42184. export class PassCubePostProcess extends PostProcess {
  42185. private _face;
  42186. /**
  42187. * Gets or sets the cube face to display.
  42188. * * 0 is +X
  42189. * * 1 is -X
  42190. * * 2 is +Y
  42191. * * 3 is -Y
  42192. * * 4 is +Z
  42193. * * 5 is -Z
  42194. */
  42195. get face(): number;
  42196. set face(value: number);
  42197. /**
  42198. * Creates the PassCubePostProcess
  42199. * @param name The name of the effect.
  42200. * @param options The required width/height ratio to downsize to before computing the render pass.
  42201. * @param camera The camera to apply the render pass to.
  42202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42203. * @param engine The engine which the post process will be applied. (default: current engine)
  42204. * @param reusable If the post process can be reused on the same frame. (default: false)
  42205. * @param textureType The type of texture to be used when performing the post processing.
  42206. * @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)
  42207. */
  42208. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42209. }
  42210. }
  42211. declare module BABYLON {
  42212. /** @hidden */
  42213. export var anaglyphPixelShader: {
  42214. name: string;
  42215. shader: string;
  42216. };
  42217. }
  42218. declare module BABYLON {
  42219. /**
  42220. * Postprocess used to generate anaglyphic rendering
  42221. */
  42222. export class AnaglyphPostProcess extends PostProcess {
  42223. private _passedProcess;
  42224. /**
  42225. * Creates a new AnaglyphPostProcess
  42226. * @param name defines postprocess name
  42227. * @param options defines creation options or target ratio scale
  42228. * @param rigCameras defines cameras using this postprocess
  42229. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42230. * @param engine defines hosting engine
  42231. * @param reusable defines if the postprocess will be reused multiple times per frame
  42232. */
  42233. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42234. }
  42235. }
  42236. declare module BABYLON {
  42237. /**
  42238. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42239. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42240. */
  42241. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42242. /**
  42243. * Creates a new AnaglyphArcRotateCamera
  42244. * @param name defines camera name
  42245. * @param alpha defines alpha angle (in radians)
  42246. * @param beta defines beta angle (in radians)
  42247. * @param radius defines radius
  42248. * @param target defines camera target
  42249. * @param interaxialDistance defines distance between each color axis
  42250. * @param scene defines the hosting scene
  42251. */
  42252. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42253. /**
  42254. * Gets camera class name
  42255. * @returns AnaglyphArcRotateCamera
  42256. */
  42257. getClassName(): string;
  42258. }
  42259. }
  42260. declare module BABYLON {
  42261. /**
  42262. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42263. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42264. */
  42265. export class AnaglyphFreeCamera extends FreeCamera {
  42266. /**
  42267. * Creates a new AnaglyphFreeCamera
  42268. * @param name defines camera name
  42269. * @param position defines initial position
  42270. * @param interaxialDistance defines distance between each color axis
  42271. * @param scene defines the hosting scene
  42272. */
  42273. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42274. /**
  42275. * Gets camera class name
  42276. * @returns AnaglyphFreeCamera
  42277. */
  42278. getClassName(): string;
  42279. }
  42280. }
  42281. declare module BABYLON {
  42282. /**
  42283. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42284. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42285. */
  42286. export class AnaglyphGamepadCamera extends GamepadCamera {
  42287. /**
  42288. * Creates a new AnaglyphGamepadCamera
  42289. * @param name defines camera name
  42290. * @param position defines initial position
  42291. * @param interaxialDistance defines distance between each color axis
  42292. * @param scene defines the hosting scene
  42293. */
  42294. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42295. /**
  42296. * Gets camera class name
  42297. * @returns AnaglyphGamepadCamera
  42298. */
  42299. getClassName(): string;
  42300. }
  42301. }
  42302. declare module BABYLON {
  42303. /**
  42304. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42305. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42306. */
  42307. export class AnaglyphUniversalCamera extends UniversalCamera {
  42308. /**
  42309. * Creates a new AnaglyphUniversalCamera
  42310. * @param name defines camera name
  42311. * @param position defines initial position
  42312. * @param interaxialDistance defines distance between each color axis
  42313. * @param scene defines the hosting scene
  42314. */
  42315. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42316. /**
  42317. * Gets camera class name
  42318. * @returns AnaglyphUniversalCamera
  42319. */
  42320. getClassName(): string;
  42321. }
  42322. }
  42323. declare module BABYLON {
  42324. /**
  42325. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42326. * @see http://doc.babylonjs.com/features/cameras
  42327. */
  42328. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42329. /**
  42330. * Creates a new StereoscopicArcRotateCamera
  42331. * @param name defines camera name
  42332. * @param alpha defines alpha angle (in radians)
  42333. * @param beta defines beta angle (in radians)
  42334. * @param radius defines radius
  42335. * @param target defines camera target
  42336. * @param interaxialDistance defines distance between each color axis
  42337. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42338. * @param scene defines the hosting scene
  42339. */
  42340. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42341. /**
  42342. * Gets camera class name
  42343. * @returns StereoscopicArcRotateCamera
  42344. */
  42345. getClassName(): string;
  42346. }
  42347. }
  42348. declare module BABYLON {
  42349. /**
  42350. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42351. * @see http://doc.babylonjs.com/features/cameras
  42352. */
  42353. export class StereoscopicFreeCamera extends FreeCamera {
  42354. /**
  42355. * Creates a new StereoscopicFreeCamera
  42356. * @param name defines camera name
  42357. * @param position defines initial position
  42358. * @param interaxialDistance defines distance between each color axis
  42359. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42360. * @param scene defines the hosting scene
  42361. */
  42362. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42363. /**
  42364. * Gets camera class name
  42365. * @returns StereoscopicFreeCamera
  42366. */
  42367. getClassName(): string;
  42368. }
  42369. }
  42370. declare module BABYLON {
  42371. /**
  42372. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42373. * @see http://doc.babylonjs.com/features/cameras
  42374. */
  42375. export class StereoscopicGamepadCamera extends GamepadCamera {
  42376. /**
  42377. * Creates a new StereoscopicGamepadCamera
  42378. * @param name defines camera name
  42379. * @param position defines initial position
  42380. * @param interaxialDistance defines distance between each color axis
  42381. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42382. * @param scene defines the hosting scene
  42383. */
  42384. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42385. /**
  42386. * Gets camera class name
  42387. * @returns StereoscopicGamepadCamera
  42388. */
  42389. getClassName(): string;
  42390. }
  42391. }
  42392. declare module BABYLON {
  42393. /**
  42394. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42395. * @see http://doc.babylonjs.com/features/cameras
  42396. */
  42397. export class StereoscopicUniversalCamera extends UniversalCamera {
  42398. /**
  42399. * Creates a new StereoscopicUniversalCamera
  42400. * @param name defines camera name
  42401. * @param position defines initial position
  42402. * @param interaxialDistance defines distance between each color axis
  42403. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42404. * @param scene defines the hosting scene
  42405. */
  42406. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42407. /**
  42408. * Gets camera class name
  42409. * @returns StereoscopicUniversalCamera
  42410. */
  42411. getClassName(): string;
  42412. }
  42413. }
  42414. declare module BABYLON {
  42415. /**
  42416. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42417. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42418. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42419. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42420. */
  42421. export class VirtualJoysticksCamera extends FreeCamera {
  42422. /**
  42423. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42424. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42425. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42426. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42427. * @param name Define the name of the camera in the scene
  42428. * @param position Define the start position of the camera in the scene
  42429. * @param scene Define the scene the camera belongs to
  42430. */
  42431. constructor(name: string, position: Vector3, scene: Scene);
  42432. /**
  42433. * Gets the current object class name.
  42434. * @return the class name
  42435. */
  42436. getClassName(): string;
  42437. }
  42438. }
  42439. declare module BABYLON {
  42440. /**
  42441. * This represents all the required metrics to create a VR camera.
  42442. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42443. */
  42444. export class VRCameraMetrics {
  42445. /**
  42446. * Define the horizontal resolution off the screen.
  42447. */
  42448. hResolution: number;
  42449. /**
  42450. * Define the vertical resolution off the screen.
  42451. */
  42452. vResolution: number;
  42453. /**
  42454. * Define the horizontal screen size.
  42455. */
  42456. hScreenSize: number;
  42457. /**
  42458. * Define the vertical screen size.
  42459. */
  42460. vScreenSize: number;
  42461. /**
  42462. * Define the vertical screen center position.
  42463. */
  42464. vScreenCenter: number;
  42465. /**
  42466. * Define the distance of the eyes to the screen.
  42467. */
  42468. eyeToScreenDistance: number;
  42469. /**
  42470. * Define the distance between both lenses
  42471. */
  42472. lensSeparationDistance: number;
  42473. /**
  42474. * Define the distance between both viewer's eyes.
  42475. */
  42476. interpupillaryDistance: number;
  42477. /**
  42478. * Define the distortion factor of the VR postprocess.
  42479. * Please, touch with care.
  42480. */
  42481. distortionK: number[];
  42482. /**
  42483. * Define the chromatic aberration correction factors for the VR post process.
  42484. */
  42485. chromaAbCorrection: number[];
  42486. /**
  42487. * Define the scale factor of the post process.
  42488. * The smaller the better but the slower.
  42489. */
  42490. postProcessScaleFactor: number;
  42491. /**
  42492. * Define an offset for the lens center.
  42493. */
  42494. lensCenterOffset: number;
  42495. /**
  42496. * Define if the current vr camera should compensate the distortion of the lense or not.
  42497. */
  42498. compensateDistortion: boolean;
  42499. /**
  42500. * Defines if multiview should be enabled when rendering (Default: false)
  42501. */
  42502. multiviewEnabled: boolean;
  42503. /**
  42504. * Gets the rendering aspect ratio based on the provided resolutions.
  42505. */
  42506. get aspectRatio(): number;
  42507. /**
  42508. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42509. */
  42510. get aspectRatioFov(): number;
  42511. /**
  42512. * @hidden
  42513. */
  42514. get leftHMatrix(): Matrix;
  42515. /**
  42516. * @hidden
  42517. */
  42518. get rightHMatrix(): Matrix;
  42519. /**
  42520. * @hidden
  42521. */
  42522. get leftPreViewMatrix(): Matrix;
  42523. /**
  42524. * @hidden
  42525. */
  42526. get rightPreViewMatrix(): Matrix;
  42527. /**
  42528. * Get the default VRMetrics based on the most generic setup.
  42529. * @returns the default vr metrics
  42530. */
  42531. static GetDefault(): VRCameraMetrics;
  42532. }
  42533. }
  42534. declare module BABYLON {
  42535. /** @hidden */
  42536. export var vrDistortionCorrectionPixelShader: {
  42537. name: string;
  42538. shader: string;
  42539. };
  42540. }
  42541. declare module BABYLON {
  42542. /**
  42543. * VRDistortionCorrectionPostProcess used for mobile VR
  42544. */
  42545. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42546. private _isRightEye;
  42547. private _distortionFactors;
  42548. private _postProcessScaleFactor;
  42549. private _lensCenterOffset;
  42550. private _scaleIn;
  42551. private _scaleFactor;
  42552. private _lensCenter;
  42553. /**
  42554. * Initializes the VRDistortionCorrectionPostProcess
  42555. * @param name The name of the effect.
  42556. * @param camera The camera to apply the render pass to.
  42557. * @param isRightEye If this is for the right eye distortion
  42558. * @param vrMetrics All the required metrics for the VR camera
  42559. */
  42560. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42561. }
  42562. }
  42563. declare module BABYLON {
  42564. /**
  42565. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42566. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42567. */
  42568. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42569. /**
  42570. * Creates a new VRDeviceOrientationArcRotateCamera
  42571. * @param name defines camera name
  42572. * @param alpha defines the camera rotation along the logitudinal axis
  42573. * @param beta defines the camera rotation along the latitudinal axis
  42574. * @param radius defines the camera distance from its target
  42575. * @param target defines the camera target
  42576. * @param scene defines the scene the camera belongs to
  42577. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42578. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42579. */
  42580. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42581. /**
  42582. * Gets camera class name
  42583. * @returns VRDeviceOrientationArcRotateCamera
  42584. */
  42585. getClassName(): string;
  42586. }
  42587. }
  42588. declare module BABYLON {
  42589. /**
  42590. * Camera used to simulate VR rendering (based on FreeCamera)
  42591. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42592. */
  42593. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42594. /**
  42595. * Creates a new VRDeviceOrientationFreeCamera
  42596. * @param name defines camera name
  42597. * @param position defines the start position of the camera
  42598. * @param scene defines the scene the camera belongs to
  42599. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42600. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42601. */
  42602. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42603. /**
  42604. * Gets camera class name
  42605. * @returns VRDeviceOrientationFreeCamera
  42606. */
  42607. getClassName(): string;
  42608. }
  42609. }
  42610. declare module BABYLON {
  42611. /**
  42612. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42613. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42614. */
  42615. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42616. /**
  42617. * Creates a new VRDeviceOrientationGamepadCamera
  42618. * @param name defines camera name
  42619. * @param position defines the start position of the camera
  42620. * @param scene defines the scene the camera belongs to
  42621. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42622. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42623. */
  42624. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42625. /**
  42626. * Gets camera class name
  42627. * @returns VRDeviceOrientationGamepadCamera
  42628. */
  42629. getClassName(): string;
  42630. }
  42631. }
  42632. declare module BABYLON {
  42633. /** @hidden */
  42634. export var imageProcessingPixelShader: {
  42635. name: string;
  42636. shader: string;
  42637. };
  42638. }
  42639. declare module BABYLON {
  42640. /**
  42641. * ImageProcessingPostProcess
  42642. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42643. */
  42644. export class ImageProcessingPostProcess extends PostProcess {
  42645. /**
  42646. * Default configuration related to image processing available in the PBR Material.
  42647. */
  42648. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42649. /**
  42650. * Gets the image processing configuration used either in this material.
  42651. */
  42652. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42653. /**
  42654. * Sets the Default image processing configuration used either in the this material.
  42655. *
  42656. * If sets to null, the scene one is in use.
  42657. */
  42658. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42659. /**
  42660. * Keep track of the image processing observer to allow dispose and replace.
  42661. */
  42662. private _imageProcessingObserver;
  42663. /**
  42664. * Attaches a new image processing configuration to the PBR Material.
  42665. * @param configuration
  42666. */
  42667. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42668. /**
  42669. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42670. */
  42671. get colorCurves(): Nullable<ColorCurves>;
  42672. /**
  42673. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42674. */
  42675. set colorCurves(value: Nullable<ColorCurves>);
  42676. /**
  42677. * Gets wether the color curves effect is enabled.
  42678. */
  42679. get colorCurvesEnabled(): boolean;
  42680. /**
  42681. * Sets wether the color curves effect is enabled.
  42682. */
  42683. set colorCurvesEnabled(value: boolean);
  42684. /**
  42685. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42686. */
  42687. get colorGradingTexture(): Nullable<BaseTexture>;
  42688. /**
  42689. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42690. */
  42691. set colorGradingTexture(value: Nullable<BaseTexture>);
  42692. /**
  42693. * Gets wether the color grading effect is enabled.
  42694. */
  42695. get colorGradingEnabled(): boolean;
  42696. /**
  42697. * Gets wether the color grading effect is enabled.
  42698. */
  42699. set colorGradingEnabled(value: boolean);
  42700. /**
  42701. * Gets exposure used in the effect.
  42702. */
  42703. get exposure(): number;
  42704. /**
  42705. * Sets exposure used in the effect.
  42706. */
  42707. set exposure(value: number);
  42708. /**
  42709. * Gets wether tonemapping is enabled or not.
  42710. */
  42711. get toneMappingEnabled(): boolean;
  42712. /**
  42713. * Sets wether tonemapping is enabled or not
  42714. */
  42715. set toneMappingEnabled(value: boolean);
  42716. /**
  42717. * Gets the type of tone mapping effect.
  42718. */
  42719. get toneMappingType(): number;
  42720. /**
  42721. * Sets the type of tone mapping effect.
  42722. */
  42723. set toneMappingType(value: number);
  42724. /**
  42725. * Gets contrast used in the effect.
  42726. */
  42727. get contrast(): number;
  42728. /**
  42729. * Sets contrast used in the effect.
  42730. */
  42731. set contrast(value: number);
  42732. /**
  42733. * Gets Vignette stretch size.
  42734. */
  42735. get vignetteStretch(): number;
  42736. /**
  42737. * Sets Vignette stretch size.
  42738. */
  42739. set vignetteStretch(value: number);
  42740. /**
  42741. * Gets Vignette centre X Offset.
  42742. */
  42743. get vignetteCentreX(): number;
  42744. /**
  42745. * Sets Vignette centre X Offset.
  42746. */
  42747. set vignetteCentreX(value: number);
  42748. /**
  42749. * Gets Vignette centre Y Offset.
  42750. */
  42751. get vignetteCentreY(): number;
  42752. /**
  42753. * Sets Vignette centre Y Offset.
  42754. */
  42755. set vignetteCentreY(value: number);
  42756. /**
  42757. * Gets Vignette weight or intensity of the vignette effect.
  42758. */
  42759. get vignetteWeight(): number;
  42760. /**
  42761. * Sets Vignette weight or intensity of the vignette effect.
  42762. */
  42763. set vignetteWeight(value: number);
  42764. /**
  42765. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42766. * if vignetteEnabled is set to true.
  42767. */
  42768. get vignetteColor(): Color4;
  42769. /**
  42770. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42771. * if vignetteEnabled is set to true.
  42772. */
  42773. set vignetteColor(value: Color4);
  42774. /**
  42775. * Gets Camera field of view used by the Vignette effect.
  42776. */
  42777. get vignetteCameraFov(): number;
  42778. /**
  42779. * Sets Camera field of view used by the Vignette effect.
  42780. */
  42781. set vignetteCameraFov(value: number);
  42782. /**
  42783. * Gets the vignette blend mode allowing different kind of effect.
  42784. */
  42785. get vignetteBlendMode(): number;
  42786. /**
  42787. * Sets the vignette blend mode allowing different kind of effect.
  42788. */
  42789. set vignetteBlendMode(value: number);
  42790. /**
  42791. * Gets wether the vignette effect is enabled.
  42792. */
  42793. get vignetteEnabled(): boolean;
  42794. /**
  42795. * Sets wether the vignette effect is enabled.
  42796. */
  42797. set vignetteEnabled(value: boolean);
  42798. private _fromLinearSpace;
  42799. /**
  42800. * Gets wether the input of the processing is in Gamma or Linear Space.
  42801. */
  42802. get fromLinearSpace(): boolean;
  42803. /**
  42804. * Sets wether the input of the processing is in Gamma or Linear Space.
  42805. */
  42806. set fromLinearSpace(value: boolean);
  42807. /**
  42808. * Defines cache preventing GC.
  42809. */
  42810. private _defines;
  42811. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42812. /**
  42813. * "ImageProcessingPostProcess"
  42814. * @returns "ImageProcessingPostProcess"
  42815. */
  42816. getClassName(): string;
  42817. protected _updateParameters(): void;
  42818. dispose(camera?: Camera): void;
  42819. }
  42820. }
  42821. declare module BABYLON {
  42822. /**
  42823. * Class containing static functions to help procedurally build meshes
  42824. */
  42825. export class GroundBuilder {
  42826. /**
  42827. * Creates a ground mesh
  42828. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42829. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42831. * @param name defines the name of the mesh
  42832. * @param options defines the options used to create the mesh
  42833. * @param scene defines the hosting scene
  42834. * @returns the ground mesh
  42835. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42836. */
  42837. static CreateGround(name: string, options: {
  42838. width?: number;
  42839. height?: number;
  42840. subdivisions?: number;
  42841. subdivisionsX?: number;
  42842. subdivisionsY?: number;
  42843. updatable?: boolean;
  42844. }, scene: any): Mesh;
  42845. /**
  42846. * Creates a tiled ground mesh
  42847. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42848. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42849. * * 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
  42850. * * 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
  42851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42852. * @param name defines the name of the mesh
  42853. * @param options defines the options used to create the mesh
  42854. * @param scene defines the hosting scene
  42855. * @returns the tiled ground mesh
  42856. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42857. */
  42858. static CreateTiledGround(name: string, options: {
  42859. xmin: number;
  42860. zmin: number;
  42861. xmax: number;
  42862. zmax: number;
  42863. subdivisions?: {
  42864. w: number;
  42865. h: number;
  42866. };
  42867. precision?: {
  42868. w: number;
  42869. h: number;
  42870. };
  42871. updatable?: boolean;
  42872. }, scene?: Nullable<Scene>): Mesh;
  42873. /**
  42874. * Creates a ground mesh from a height map
  42875. * * The parameter `url` sets the URL of the height map image resource.
  42876. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42877. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42878. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42879. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42880. * * 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.
  42881. * * 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).
  42882. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42884. * @param name defines the name of the mesh
  42885. * @param url defines the url to the height map
  42886. * @param options defines the options used to create the mesh
  42887. * @param scene defines the hosting scene
  42888. * @returns the ground mesh
  42889. * @see https://doc.babylonjs.com/babylon101/height_map
  42890. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42891. */
  42892. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42893. width?: number;
  42894. height?: number;
  42895. subdivisions?: number;
  42896. minHeight?: number;
  42897. maxHeight?: number;
  42898. colorFilter?: Color3;
  42899. alphaFilter?: number;
  42900. updatable?: boolean;
  42901. onReady?: (mesh: GroundMesh) => void;
  42902. }, scene?: Nullable<Scene>): GroundMesh;
  42903. }
  42904. }
  42905. declare module BABYLON {
  42906. /**
  42907. * Class containing static functions to help procedurally build meshes
  42908. */
  42909. export class TorusBuilder {
  42910. /**
  42911. * Creates a torus mesh
  42912. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42913. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42914. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42916. * * 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
  42917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42918. * @param name defines the name of the mesh
  42919. * @param options defines the options used to create the mesh
  42920. * @param scene defines the hosting scene
  42921. * @returns the torus mesh
  42922. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42923. */
  42924. static CreateTorus(name: string, options: {
  42925. diameter?: number;
  42926. thickness?: number;
  42927. tessellation?: number;
  42928. updatable?: boolean;
  42929. sideOrientation?: number;
  42930. frontUVs?: Vector4;
  42931. backUVs?: Vector4;
  42932. }, scene: any): Mesh;
  42933. }
  42934. }
  42935. declare module BABYLON {
  42936. /**
  42937. * Class containing static functions to help procedurally build meshes
  42938. */
  42939. export class CylinderBuilder {
  42940. /**
  42941. * Creates a cylinder or a cone mesh
  42942. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42943. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42944. * * 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.
  42945. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42946. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42947. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42948. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42949. * * 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).
  42950. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42951. * * 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).
  42952. * * 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
  42953. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42954. * * 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
  42955. * * 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.
  42956. * * If `enclose` is false, a ring surface is one element.
  42957. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42958. * * 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
  42959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42960. * * 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
  42961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42962. * @param name defines the name of the mesh
  42963. * @param options defines the options used to create the mesh
  42964. * @param scene defines the hosting scene
  42965. * @returns the cylinder mesh
  42966. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42967. */
  42968. static CreateCylinder(name: string, options: {
  42969. height?: number;
  42970. diameterTop?: number;
  42971. diameterBottom?: number;
  42972. diameter?: number;
  42973. tessellation?: number;
  42974. subdivisions?: number;
  42975. arc?: number;
  42976. faceColors?: Color4[];
  42977. faceUV?: Vector4[];
  42978. updatable?: boolean;
  42979. hasRings?: boolean;
  42980. enclose?: boolean;
  42981. cap?: number;
  42982. sideOrientation?: number;
  42983. frontUVs?: Vector4;
  42984. backUVs?: Vector4;
  42985. }, scene: any): Mesh;
  42986. }
  42987. }
  42988. declare module BABYLON {
  42989. /**
  42990. * States of the webXR experience
  42991. */
  42992. export enum WebXRState {
  42993. /**
  42994. * Transitioning to being in XR mode
  42995. */
  42996. ENTERING_XR = 0,
  42997. /**
  42998. * Transitioning to non XR mode
  42999. */
  43000. EXITING_XR = 1,
  43001. /**
  43002. * In XR mode and presenting
  43003. */
  43004. IN_XR = 2,
  43005. /**
  43006. * Not entered XR mode
  43007. */
  43008. NOT_IN_XR = 3
  43009. }
  43010. /**
  43011. * Abstraction of the XR render target
  43012. */
  43013. export interface WebXRRenderTarget extends IDisposable {
  43014. /**
  43015. * xrpresent context of the canvas which can be used to display/mirror xr content
  43016. */
  43017. canvasContext: WebGLRenderingContext;
  43018. /**
  43019. * xr layer for the canvas
  43020. */
  43021. xrLayer: Nullable<XRWebGLLayer>;
  43022. /**
  43023. * Initializes the xr layer for the session
  43024. * @param xrSession xr session
  43025. * @returns a promise that will resolve once the XR Layer has been created
  43026. */
  43027. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43028. }
  43029. }
  43030. declare module BABYLON {
  43031. /**
  43032. * COnfiguration object for WebXR output canvas
  43033. */
  43034. export class WebXRManagedOutputCanvasOptions {
  43035. /**
  43036. * An optional canvas in case you wish to create it yourself and provide it here.
  43037. * If not provided, a new canvas will be created
  43038. */
  43039. canvasElement?: HTMLCanvasElement;
  43040. /**
  43041. * Options for this XR Layer output
  43042. */
  43043. canvasOptions?: XRWebGLLayerOptions;
  43044. /**
  43045. * CSS styling for a newly created canvas (if not provided)
  43046. */
  43047. newCanvasCssStyle?: string;
  43048. /**
  43049. * Get the default values of the configuration object
  43050. * @returns default values of this configuration object
  43051. */
  43052. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43053. }
  43054. /**
  43055. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43056. */
  43057. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43058. private _options;
  43059. private _canvas;
  43060. private _engine;
  43061. /**
  43062. * Rendering context of the canvas which can be used to display/mirror xr content
  43063. */
  43064. canvasContext: WebGLRenderingContext;
  43065. /**
  43066. * xr layer for the canvas
  43067. */
  43068. xrLayer: Nullable<XRWebGLLayer>;
  43069. /**
  43070. * Initializes the canvas to be added/removed upon entering/exiting xr
  43071. * @param _xrSessionManager The XR Session manager
  43072. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43073. */
  43074. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43075. /**
  43076. * Disposes of the object
  43077. */
  43078. dispose(): void;
  43079. /**
  43080. * Initializes the xr layer for the session
  43081. * @param xrSession xr session
  43082. * @returns a promise that will resolve once the XR Layer has been created
  43083. */
  43084. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43085. private _addCanvas;
  43086. private _removeCanvas;
  43087. private _setManagedOutputCanvas;
  43088. }
  43089. }
  43090. declare module BABYLON {
  43091. /**
  43092. * Manages an XRSession to work with Babylon's engine
  43093. * @see https://doc.babylonjs.com/how_to/webxr
  43094. */
  43095. export class WebXRSessionManager implements IDisposable {
  43096. /** The scene which the session should be created for */
  43097. scene: Scene;
  43098. private _referenceSpace;
  43099. private _rttProvider;
  43100. private _sessionEnded;
  43101. private _xrNavigator;
  43102. private baseLayer;
  43103. /**
  43104. * The base reference space from which the session started. good if you want to reset your
  43105. * reference space
  43106. */
  43107. baseReferenceSpace: XRReferenceSpace;
  43108. /**
  43109. * Current XR frame
  43110. */
  43111. currentFrame: Nullable<XRFrame>;
  43112. /** WebXR timestamp updated every frame */
  43113. currentTimestamp: number;
  43114. /**
  43115. * Used just in case of a failure to initialize an immersive session.
  43116. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43117. */
  43118. defaultHeightCompensation: number;
  43119. /**
  43120. * Fires every time a new xrFrame arrives which can be used to update the camera
  43121. */
  43122. onXRFrameObservable: Observable<XRFrame>;
  43123. /**
  43124. * Fires when the reference space changed
  43125. */
  43126. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43127. /**
  43128. * Fires when the xr session is ended either by the device or manually done
  43129. */
  43130. onXRSessionEnded: Observable<any>;
  43131. /**
  43132. * Fires when the xr session is ended either by the device or manually done
  43133. */
  43134. onXRSessionInit: Observable<XRSession>;
  43135. /**
  43136. * Underlying xr session
  43137. */
  43138. session: XRSession;
  43139. /**
  43140. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43141. * or get the offset the player is currently at.
  43142. */
  43143. viewerReferenceSpace: XRReferenceSpace;
  43144. /**
  43145. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43146. * @param scene The scene which the session should be created for
  43147. */
  43148. constructor(
  43149. /** The scene which the session should be created for */
  43150. scene: Scene);
  43151. /**
  43152. * The current reference space used in this session. This reference space can constantly change!
  43153. * It is mainly used to offset the camera's position.
  43154. */
  43155. get referenceSpace(): XRReferenceSpace;
  43156. /**
  43157. * Set a new reference space and triggers the observable
  43158. */
  43159. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43160. /**
  43161. * Disposes of the session manager
  43162. */
  43163. dispose(): void;
  43164. /**
  43165. * Stops the xrSession and restores the render loop
  43166. * @returns Promise which resolves after it exits XR
  43167. */
  43168. exitXRAsync(): Promise<void>;
  43169. /**
  43170. * Gets the correct render target texture to be rendered this frame for this eye
  43171. * @param eye the eye for which to get the render target
  43172. * @returns the render target for the specified eye
  43173. */
  43174. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43175. /**
  43176. * Creates a WebXRRenderTarget object for the XR session
  43177. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43178. * @param options optional options to provide when creating a new render target
  43179. * @returns a WebXR render target to which the session can render
  43180. */
  43181. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43182. /**
  43183. * Initializes the manager
  43184. * After initialization enterXR can be called to start an XR session
  43185. * @returns Promise which resolves after it is initialized
  43186. */
  43187. initializeAsync(): Promise<void>;
  43188. /**
  43189. * Initializes an xr session
  43190. * @param xrSessionMode mode to initialize
  43191. * @param xrSessionInit defines optional and required values to pass to the session builder
  43192. * @returns a promise which will resolve once the session has been initialized
  43193. */
  43194. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43195. /**
  43196. * Checks if a session would be supported for the creation options specified
  43197. * @param sessionMode session mode to check if supported eg. immersive-vr
  43198. * @returns A Promise that resolves to true if supported and false if not
  43199. */
  43200. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43201. /**
  43202. * Resets the reference space to the one started the session
  43203. */
  43204. resetReferenceSpace(): void;
  43205. /**
  43206. * Starts rendering to the xr layer
  43207. */
  43208. runXRRenderLoop(): void;
  43209. /**
  43210. * Sets the reference space on the xr session
  43211. * @param referenceSpaceType space to set
  43212. * @returns a promise that will resolve once the reference space has been set
  43213. */
  43214. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43215. /**
  43216. * Updates the render state of the session
  43217. * @param state state to set
  43218. * @returns a promise that resolves once the render state has been updated
  43219. */
  43220. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43221. /**
  43222. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43223. * @param sessionMode defines the session to test
  43224. * @returns a promise with boolean as final value
  43225. */
  43226. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43227. private _createRenderTargetTexture;
  43228. }
  43229. }
  43230. declare module BABYLON {
  43231. /**
  43232. * WebXR Camera which holds the views for the xrSession
  43233. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43234. */
  43235. export class WebXRCamera extends FreeCamera {
  43236. private _xrSessionManager;
  43237. private _firstFrame;
  43238. private _referenceQuaternion;
  43239. private _referencedPosition;
  43240. private _xrInvPositionCache;
  43241. private _xrInvQuaternionCache;
  43242. /**
  43243. * Should position compensation execute on first frame.
  43244. * This is used when copying the position from a native (non XR) camera
  43245. */
  43246. compensateOnFirstFrame: boolean;
  43247. /**
  43248. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43249. * @param name the name of the camera
  43250. * @param scene the scene to add the camera to
  43251. * @param _xrSessionManager a constructed xr session manager
  43252. */
  43253. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43254. /**
  43255. * Return the user's height, unrelated to the current ground.
  43256. * This will be the y position of this camera, when ground level is 0.
  43257. */
  43258. get realWorldHeight(): number;
  43259. /** @hidden */
  43260. _updateForDualEyeDebugging(): void;
  43261. /**
  43262. * Sets this camera's transformation based on a non-vr camera
  43263. * @param otherCamera the non-vr camera to copy the transformation from
  43264. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43265. */
  43266. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43267. /**
  43268. * Gets the current instance class name ("WebXRCamera").
  43269. * @returns the class name
  43270. */
  43271. getClassName(): string;
  43272. private _updateFromXRSession;
  43273. private _updateNumberOfRigCameras;
  43274. private _updateReferenceSpace;
  43275. private _updateReferenceSpaceOffset;
  43276. }
  43277. }
  43278. declare module BABYLON {
  43279. /**
  43280. * Defining the interface required for a (webxr) feature
  43281. */
  43282. export interface IWebXRFeature extends IDisposable {
  43283. /**
  43284. * Is this feature attached
  43285. */
  43286. attached: boolean;
  43287. /**
  43288. * Should auto-attach be disabled?
  43289. */
  43290. disableAutoAttach: boolean;
  43291. /**
  43292. * Attach the feature to the session
  43293. * Will usually be called by the features manager
  43294. *
  43295. * @param force should attachment be forced (even when already attached)
  43296. * @returns true if successful.
  43297. */
  43298. attach(force?: boolean): boolean;
  43299. /**
  43300. * Detach the feature from the session
  43301. * Will usually be called by the features manager
  43302. *
  43303. * @returns true if successful.
  43304. */
  43305. detach(): boolean;
  43306. }
  43307. /**
  43308. * A list of the currently available features without referencing them
  43309. */
  43310. export class WebXRFeatureName {
  43311. /**
  43312. * The name of the anchor system feature
  43313. */
  43314. static ANCHOR_SYSTEM: string;
  43315. /**
  43316. * The name of the background remover feature
  43317. */
  43318. static BACKGROUND_REMOVER: string;
  43319. /**
  43320. * The name of the hit test feature
  43321. */
  43322. static HIT_TEST: string;
  43323. /**
  43324. * physics impostors for xr controllers feature
  43325. */
  43326. static PHYSICS_CONTROLLERS: string;
  43327. /**
  43328. * The name of the plane detection feature
  43329. */
  43330. static PLANE_DETECTION: string;
  43331. /**
  43332. * The name of the pointer selection feature
  43333. */
  43334. static POINTER_SELECTION: string;
  43335. /**
  43336. * The name of the teleportation feature
  43337. */
  43338. static TELEPORTATION: string;
  43339. }
  43340. /**
  43341. * Defining the constructor of a feature. Used to register the modules.
  43342. */
  43343. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43344. /**
  43345. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43346. * It is mainly used in AR sessions.
  43347. *
  43348. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43349. */
  43350. export class WebXRFeaturesManager implements IDisposable {
  43351. private _xrSessionManager;
  43352. private static readonly _AvailableFeatures;
  43353. private _features;
  43354. /**
  43355. * constructs a new features manages.
  43356. *
  43357. * @param _xrSessionManager an instance of WebXRSessionManager
  43358. */
  43359. constructor(_xrSessionManager: WebXRSessionManager);
  43360. /**
  43361. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43362. * Mainly used internally.
  43363. *
  43364. * @param featureName the name of the feature to register
  43365. * @param constructorFunction the function used to construct the module
  43366. * @param version the (babylon) version of the module
  43367. * @param stable is that a stable version of this module
  43368. */
  43369. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43370. /**
  43371. * Returns a constructor of a specific feature.
  43372. *
  43373. * @param featureName the name of the feature to construct
  43374. * @param version the version of the feature to load
  43375. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43376. * @param options optional options provided to the module.
  43377. * @returns a function that, when called, will return a new instance of this feature
  43378. */
  43379. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43380. /**
  43381. * Can be used to return the list of features currently registered
  43382. *
  43383. * @returns an Array of available features
  43384. */
  43385. static GetAvailableFeatures(): string[];
  43386. /**
  43387. * Gets the versions available for a specific feature
  43388. * @param featureName the name of the feature
  43389. * @returns an array with the available versions
  43390. */
  43391. static GetAvailableVersions(featureName: string): string[];
  43392. /**
  43393. * Return the latest unstable version of this feature
  43394. * @param featureName the name of the feature to search
  43395. * @returns the version number. if not found will return -1
  43396. */
  43397. static GetLatestVersionOfFeature(featureName: string): number;
  43398. /**
  43399. * Return the latest stable version of this feature
  43400. * @param featureName the name of the feature to search
  43401. * @returns the version number. if not found will return -1
  43402. */
  43403. static GetStableVersionOfFeature(featureName: string): number;
  43404. /**
  43405. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43406. * Can be used during a session to start a feature
  43407. * @param featureName the name of feature to attach
  43408. */
  43409. attachFeature(featureName: string): void;
  43410. /**
  43411. * Can be used inside a session or when the session ends to detach a specific feature
  43412. * @param featureName the name of the feature to detach
  43413. */
  43414. detachFeature(featureName: string): void;
  43415. /**
  43416. * Used to disable an already-enabled feature
  43417. * The feature will be disposed and will be recreated once enabled.
  43418. * @param featureName the feature to disable
  43419. * @returns true if disable was successful
  43420. */
  43421. disableFeature(featureName: string | {
  43422. Name: string;
  43423. }): boolean;
  43424. /**
  43425. * dispose this features manager
  43426. */
  43427. dispose(): void;
  43428. /**
  43429. * 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.
  43430. * 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.
  43431. *
  43432. * @param featureName the name of the feature to load or the class of the feature
  43433. * @param version optional version to load. if not provided the latest version will be enabled
  43434. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43435. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43436. * @returns a new constructed feature or throws an error if feature not found.
  43437. */
  43438. enableFeature(featureName: string | {
  43439. Name: string;
  43440. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43441. /**
  43442. * get the implementation of an enabled feature.
  43443. * @param featureName the name of the feature to load
  43444. * @returns the feature class, if found
  43445. */
  43446. getEnabledFeature(featureName: string): IWebXRFeature;
  43447. /**
  43448. * Get the list of enabled features
  43449. * @returns an array of enabled features
  43450. */
  43451. getEnabledFeatures(): string[];
  43452. }
  43453. }
  43454. declare module BABYLON {
  43455. /**
  43456. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43457. * @see https://doc.babylonjs.com/how_to/webxr
  43458. */
  43459. export class WebXRExperienceHelper implements IDisposable {
  43460. private scene;
  43461. private _nonVRCamera;
  43462. private _originalSceneAutoClear;
  43463. private _supported;
  43464. /**
  43465. * Camera used to render xr content
  43466. */
  43467. camera: WebXRCamera;
  43468. /** A features manager for this xr session */
  43469. featuresManager: WebXRFeaturesManager;
  43470. /**
  43471. * Observers registered here will be triggered after the camera's initial transformation is set
  43472. * This can be used to set a different ground level or an extra rotation.
  43473. *
  43474. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43475. * to the position set after this observable is done executing.
  43476. */
  43477. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43478. /**
  43479. * Fires when the state of the experience helper has changed
  43480. */
  43481. onStateChangedObservable: Observable<WebXRState>;
  43482. /** Session manager used to keep track of xr session */
  43483. sessionManager: WebXRSessionManager;
  43484. /**
  43485. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43486. */
  43487. state: WebXRState;
  43488. /**
  43489. * Creates a WebXRExperienceHelper
  43490. * @param scene The scene the helper should be created in
  43491. */
  43492. private constructor();
  43493. /**
  43494. * Creates the experience helper
  43495. * @param scene the scene to attach the experience helper to
  43496. * @returns a promise for the experience helper
  43497. */
  43498. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43499. /**
  43500. * Disposes of the experience helper
  43501. */
  43502. dispose(): void;
  43503. /**
  43504. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43505. * @param sessionMode options for the XR session
  43506. * @param referenceSpaceType frame of reference of the XR session
  43507. * @param renderTarget the output canvas that will be used to enter XR mode
  43508. * @returns promise that resolves after xr mode has entered
  43509. */
  43510. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43511. /**
  43512. * Exits XR mode and returns the scene to its original state
  43513. * @returns promise that resolves after xr mode has exited
  43514. */
  43515. exitXRAsync(): Promise<void>;
  43516. private _nonXRToXRCamera;
  43517. private _setState;
  43518. }
  43519. }
  43520. declare module BABYLON {
  43521. /**
  43522. * X-Y values for axes in WebXR
  43523. */
  43524. export interface IWebXRMotionControllerAxesValue {
  43525. /**
  43526. * The value of the x axis
  43527. */
  43528. x: number;
  43529. /**
  43530. * The value of the y-axis
  43531. */
  43532. y: number;
  43533. }
  43534. /**
  43535. * changed / previous values for the values of this component
  43536. */
  43537. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43538. /**
  43539. * current (this frame) value
  43540. */
  43541. current: T;
  43542. /**
  43543. * previous (last change) value
  43544. */
  43545. previous: T;
  43546. }
  43547. /**
  43548. * Represents changes in the component between current frame and last values recorded
  43549. */
  43550. export interface IWebXRMotionControllerComponentChanges {
  43551. /**
  43552. * will be populated with previous and current values if axes changed
  43553. */
  43554. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43555. /**
  43556. * will be populated with previous and current values if pressed changed
  43557. */
  43558. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43559. /**
  43560. * will be populated with previous and current values if touched changed
  43561. */
  43562. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43563. /**
  43564. * will be populated with previous and current values if value changed
  43565. */
  43566. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43567. }
  43568. /**
  43569. * This class represents a single component (for example button or thumbstick) of a motion controller
  43570. */
  43571. export class WebXRControllerComponent implements IDisposable {
  43572. /**
  43573. * the id of this component
  43574. */
  43575. id: string;
  43576. /**
  43577. * the type of the component
  43578. */
  43579. type: MotionControllerComponentType;
  43580. private _buttonIndex;
  43581. private _axesIndices;
  43582. private _axes;
  43583. private _changes;
  43584. private _currentValue;
  43585. private _hasChanges;
  43586. private _pressed;
  43587. private _touched;
  43588. /**
  43589. * button component type
  43590. */
  43591. static BUTTON_TYPE: MotionControllerComponentType;
  43592. /**
  43593. * squeeze component type
  43594. */
  43595. static SQUEEZE_TYPE: MotionControllerComponentType;
  43596. /**
  43597. * Thumbstick component type
  43598. */
  43599. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43600. /**
  43601. * Touchpad component type
  43602. */
  43603. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43604. /**
  43605. * trigger component type
  43606. */
  43607. static TRIGGER_TYPE: MotionControllerComponentType;
  43608. /**
  43609. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43610. * the axes data changes
  43611. */
  43612. onAxisValueChangedObservable: Observable<{
  43613. x: number;
  43614. y: number;
  43615. }>;
  43616. /**
  43617. * Observers registered here will be triggered when the state of a button changes
  43618. * State change is either pressed / touched / value
  43619. */
  43620. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43621. /**
  43622. * Creates a new component for a motion controller.
  43623. * It is created by the motion controller itself
  43624. *
  43625. * @param id the id of this component
  43626. * @param type the type of the component
  43627. * @param _buttonIndex index in the buttons array of the gamepad
  43628. * @param _axesIndices indices of the values in the axes array of the gamepad
  43629. */
  43630. constructor(
  43631. /**
  43632. * the id of this component
  43633. */
  43634. id: string,
  43635. /**
  43636. * the type of the component
  43637. */
  43638. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43639. /**
  43640. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43641. */
  43642. get axes(): IWebXRMotionControllerAxesValue;
  43643. /**
  43644. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43645. */
  43646. get changes(): IWebXRMotionControllerComponentChanges;
  43647. /**
  43648. * Return whether or not the component changed the last frame
  43649. */
  43650. get hasChanges(): boolean;
  43651. /**
  43652. * is the button currently pressed
  43653. */
  43654. get pressed(): boolean;
  43655. /**
  43656. * is the button currently touched
  43657. */
  43658. get touched(): boolean;
  43659. /**
  43660. * Get the current value of this component
  43661. */
  43662. get value(): number;
  43663. /**
  43664. * Dispose this component
  43665. */
  43666. dispose(): void;
  43667. /**
  43668. * Are there axes correlating to this component
  43669. * @return true is axes data is available
  43670. */
  43671. isAxes(): boolean;
  43672. /**
  43673. * Is this component a button (hence - pressable)
  43674. * @returns true if can be pressed
  43675. */
  43676. isButton(): boolean;
  43677. /**
  43678. * update this component using the gamepad object it is in. Called on every frame
  43679. * @param nativeController the native gamepad controller object
  43680. */
  43681. update(nativeController: IMinimalMotionControllerObject): void;
  43682. }
  43683. }
  43684. declare module BABYLON {
  43685. /**
  43686. * Class used to represent data loading progression
  43687. */
  43688. export class SceneLoaderProgressEvent {
  43689. /** defines if data length to load can be evaluated */
  43690. readonly lengthComputable: boolean;
  43691. /** defines the loaded data length */
  43692. readonly loaded: number;
  43693. /** defines the data length to load */
  43694. readonly total: number;
  43695. /**
  43696. * Create a new progress event
  43697. * @param lengthComputable defines if data length to load can be evaluated
  43698. * @param loaded defines the loaded data length
  43699. * @param total defines the data length to load
  43700. */
  43701. constructor(
  43702. /** defines if data length to load can be evaluated */
  43703. lengthComputable: boolean,
  43704. /** defines the loaded data length */
  43705. loaded: number,
  43706. /** defines the data length to load */
  43707. total: number);
  43708. /**
  43709. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43710. * @param event defines the source event
  43711. * @returns a new SceneLoaderProgressEvent
  43712. */
  43713. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43714. }
  43715. /**
  43716. * Interface used by SceneLoader plugins to define supported file extensions
  43717. */
  43718. export interface ISceneLoaderPluginExtensions {
  43719. /**
  43720. * Defines the list of supported extensions
  43721. */
  43722. [extension: string]: {
  43723. isBinary: boolean;
  43724. };
  43725. }
  43726. /**
  43727. * Interface used by SceneLoader plugin factory
  43728. */
  43729. export interface ISceneLoaderPluginFactory {
  43730. /**
  43731. * Defines the name of the factory
  43732. */
  43733. name: string;
  43734. /**
  43735. * Function called to create a new plugin
  43736. * @return the new plugin
  43737. */
  43738. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43739. /**
  43740. * The callback that returns true if the data can be directly loaded.
  43741. * @param data string containing the file data
  43742. * @returns if the data can be loaded directly
  43743. */
  43744. canDirectLoad?(data: string): boolean;
  43745. }
  43746. /**
  43747. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43748. */
  43749. export interface ISceneLoaderPluginBase {
  43750. /**
  43751. * The friendly name of this plugin.
  43752. */
  43753. name: string;
  43754. /**
  43755. * The file extensions supported by this plugin.
  43756. */
  43757. extensions: string | ISceneLoaderPluginExtensions;
  43758. /**
  43759. * The callback called when loading from a url.
  43760. * @param scene scene loading this url
  43761. * @param url url to load
  43762. * @param onSuccess callback called when the file successfully loads
  43763. * @param onProgress callback called while file is loading (if the server supports this mode)
  43764. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43765. * @param onError callback called when the file fails to load
  43766. * @returns a file request object
  43767. */
  43768. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43769. /**
  43770. * The callback called when loading from a file object.
  43771. * @param scene scene loading this file
  43772. * @param file defines the file to load
  43773. * @param onSuccess defines the callback to call when data is loaded
  43774. * @param onProgress defines the callback to call during loading process
  43775. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43776. * @param onError defines the callback to call when an error occurs
  43777. * @returns a file request object
  43778. */
  43779. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43780. /**
  43781. * The callback that returns true if the data can be directly loaded.
  43782. * @param data string containing the file data
  43783. * @returns if the data can be loaded directly
  43784. */
  43785. canDirectLoad?(data: string): boolean;
  43786. /**
  43787. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43788. * @param scene scene loading this data
  43789. * @param data string containing the data
  43790. * @returns data to pass to the plugin
  43791. */
  43792. directLoad?(scene: Scene, data: string): any;
  43793. /**
  43794. * The callback that allows custom handling of the root url based on the response url.
  43795. * @param rootUrl the original root url
  43796. * @param responseURL the response url if available
  43797. * @returns the new root url
  43798. */
  43799. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43800. }
  43801. /**
  43802. * Interface used to define a SceneLoader plugin
  43803. */
  43804. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43805. /**
  43806. * Import meshes into a scene.
  43807. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43808. * @param scene The scene to import into
  43809. * @param data The data to import
  43810. * @param rootUrl The root url for scene and resources
  43811. * @param meshes The meshes array to import into
  43812. * @param particleSystems The particle systems array to import into
  43813. * @param skeletons The skeletons array to import into
  43814. * @param onError The callback when import fails
  43815. * @returns True if successful or false otherwise
  43816. */
  43817. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43818. /**
  43819. * Load into a scene.
  43820. * @param scene The scene to load into
  43821. * @param data The data to import
  43822. * @param rootUrl The root url for scene and resources
  43823. * @param onError The callback when import fails
  43824. * @returns True if successful or false otherwise
  43825. */
  43826. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43827. /**
  43828. * Load into an asset container.
  43829. * @param scene The scene to load into
  43830. * @param data The data to import
  43831. * @param rootUrl The root url for scene and resources
  43832. * @param onError The callback when import fails
  43833. * @returns The loaded asset container
  43834. */
  43835. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43836. }
  43837. /**
  43838. * Interface used to define an async SceneLoader plugin
  43839. */
  43840. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43841. /**
  43842. * Import meshes into a scene.
  43843. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43844. * @param scene The scene to import into
  43845. * @param data The data to import
  43846. * @param rootUrl The root url for scene and resources
  43847. * @param onProgress The callback when the load progresses
  43848. * @param fileName Defines the name of the file to load
  43849. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43850. */
  43851. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43852. meshes: AbstractMesh[];
  43853. particleSystems: IParticleSystem[];
  43854. skeletons: Skeleton[];
  43855. animationGroups: AnimationGroup[];
  43856. }>;
  43857. /**
  43858. * Load into a scene.
  43859. * @param scene The scene to load into
  43860. * @param data The data to import
  43861. * @param rootUrl The root url for scene and resources
  43862. * @param onProgress The callback when the load progresses
  43863. * @param fileName Defines the name of the file to load
  43864. * @returns Nothing
  43865. */
  43866. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43867. /**
  43868. * Load into an asset container.
  43869. * @param scene The scene to load into
  43870. * @param data The data to import
  43871. * @param rootUrl The root url for scene and resources
  43872. * @param onProgress The callback when the load progresses
  43873. * @param fileName Defines the name of the file to load
  43874. * @returns The loaded asset container
  43875. */
  43876. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43877. }
  43878. /**
  43879. * Mode that determines how to handle old animation groups before loading new ones.
  43880. */
  43881. export enum SceneLoaderAnimationGroupLoadingMode {
  43882. /**
  43883. * Reset all old animations to initial state then dispose them.
  43884. */
  43885. Clean = 0,
  43886. /**
  43887. * Stop all old animations.
  43888. */
  43889. Stop = 1,
  43890. /**
  43891. * Restart old animations from first frame.
  43892. */
  43893. Sync = 2,
  43894. /**
  43895. * Old animations remains untouched.
  43896. */
  43897. NoSync = 3
  43898. }
  43899. /**
  43900. * Class used to load scene from various file formats using registered plugins
  43901. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43902. */
  43903. export class SceneLoader {
  43904. /**
  43905. * No logging while loading
  43906. */
  43907. static readonly NO_LOGGING: number;
  43908. /**
  43909. * Minimal logging while loading
  43910. */
  43911. static readonly MINIMAL_LOGGING: number;
  43912. /**
  43913. * Summary logging while loading
  43914. */
  43915. static readonly SUMMARY_LOGGING: number;
  43916. /**
  43917. * Detailled logging while loading
  43918. */
  43919. static readonly DETAILED_LOGGING: number;
  43920. /**
  43921. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43922. */
  43923. static get ForceFullSceneLoadingForIncremental(): boolean;
  43924. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43925. /**
  43926. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43927. */
  43928. static get ShowLoadingScreen(): boolean;
  43929. static set ShowLoadingScreen(value: boolean);
  43930. /**
  43931. * Defines the current logging level (while loading the scene)
  43932. * @ignorenaming
  43933. */
  43934. static get loggingLevel(): number;
  43935. static set loggingLevel(value: number);
  43936. /**
  43937. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43938. */
  43939. static get CleanBoneMatrixWeights(): boolean;
  43940. static set CleanBoneMatrixWeights(value: boolean);
  43941. /**
  43942. * Event raised when a plugin is used to load a scene
  43943. */
  43944. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43945. private static _registeredPlugins;
  43946. private static _getDefaultPlugin;
  43947. private static _getPluginForExtension;
  43948. private static _getPluginForDirectLoad;
  43949. private static _getPluginForFilename;
  43950. private static _getDirectLoad;
  43951. private static _loadData;
  43952. private static _getFileInfo;
  43953. /**
  43954. * Gets a plugin that can load the given extension
  43955. * @param extension defines the extension to load
  43956. * @returns a plugin or null if none works
  43957. */
  43958. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43959. /**
  43960. * Gets a boolean indicating that the given extension can be loaded
  43961. * @param extension defines the extension to load
  43962. * @returns true if the extension is supported
  43963. */
  43964. static IsPluginForExtensionAvailable(extension: string): boolean;
  43965. /**
  43966. * Adds a new plugin to the list of registered plugins
  43967. * @param plugin defines the plugin to add
  43968. */
  43969. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43970. /**
  43971. * Import meshes into a scene
  43972. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43973. * @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)
  43974. * @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)
  43975. * @param scene the instance of BABYLON.Scene to append to
  43976. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43977. * @param onProgress a callback with a progress event for each file being loaded
  43978. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43979. * @param pluginExtension the extension used to determine the plugin
  43980. * @returns The loaded plugin
  43981. */
  43982. 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>;
  43983. /**
  43984. * Import meshes into a scene
  43985. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43986. * @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)
  43987. * @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)
  43988. * @param scene the instance of BABYLON.Scene to append to
  43989. * @param onProgress a callback with a progress event for each file being loaded
  43990. * @param pluginExtension the extension used to determine the plugin
  43991. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43992. */
  43993. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43994. meshes: AbstractMesh[];
  43995. particleSystems: IParticleSystem[];
  43996. skeletons: Skeleton[];
  43997. animationGroups: AnimationGroup[];
  43998. }>;
  43999. /**
  44000. * Load a scene
  44001. * @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)
  44002. * @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)
  44003. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44004. * @param onSuccess a callback with the scene when import succeeds
  44005. * @param onProgress a callback with a progress event for each file being loaded
  44006. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44007. * @param pluginExtension the extension used to determine the plugin
  44008. * @returns The loaded plugin
  44009. */
  44010. 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>;
  44011. /**
  44012. * Load a scene
  44013. * @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)
  44014. * @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)
  44015. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44016. * @param onProgress a callback with a progress event for each file being loaded
  44017. * @param pluginExtension the extension used to determine the plugin
  44018. * @returns The loaded scene
  44019. */
  44020. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44021. /**
  44022. * Append a scene
  44023. * @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)
  44024. * @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)
  44025. * @param scene is the instance of BABYLON.Scene to append to
  44026. * @param onSuccess a callback with the scene when import succeeds
  44027. * @param onProgress a callback with a progress event for each file being loaded
  44028. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44029. * @param pluginExtension the extension used to determine the plugin
  44030. * @returns The loaded plugin
  44031. */
  44032. 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>;
  44033. /**
  44034. * Append a scene
  44035. * @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)
  44036. * @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)
  44037. * @param scene is the instance of BABYLON.Scene to append to
  44038. * @param onProgress a callback with a progress event for each file being loaded
  44039. * @param pluginExtension the extension used to determine the plugin
  44040. * @returns The given scene
  44041. */
  44042. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44043. /**
  44044. * Load a scene into an asset container
  44045. * @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)
  44046. * @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)
  44047. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44048. * @param onSuccess a callback with the scene when import succeeds
  44049. * @param onProgress a callback with a progress event for each file being loaded
  44050. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44051. * @param pluginExtension the extension used to determine the plugin
  44052. * @returns The loaded plugin
  44053. */
  44054. 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>;
  44055. /**
  44056. * Load a scene into an asset container
  44057. * @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)
  44058. * @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)
  44059. * @param scene is the instance of Scene to append to
  44060. * @param onProgress a callback with a progress event for each file being loaded
  44061. * @param pluginExtension the extension used to determine the plugin
  44062. * @returns The loaded asset container
  44063. */
  44064. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44065. /**
  44066. * Import animations from a file into a scene
  44067. * @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)
  44068. * @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)
  44069. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44070. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44071. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44072. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44073. * @param onSuccess a callback with the scene when import succeeds
  44074. * @param onProgress a callback with a progress event for each file being loaded
  44075. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44076. */
  44077. 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;
  44078. /**
  44079. * Import animations from a file into a scene
  44080. * @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)
  44081. * @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)
  44082. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44083. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44084. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44085. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44086. * @param onSuccess a callback with the scene when import succeeds
  44087. * @param onProgress a callback with a progress event for each file being loaded
  44088. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44089. * @returns the updated scene with imported animations
  44090. */
  44091. 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>;
  44092. }
  44093. }
  44094. declare module BABYLON {
  44095. /**
  44096. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44097. */
  44098. export type MotionControllerHandness = "none" | "left" | "right";
  44099. /**
  44100. * The type of components available in motion controllers.
  44101. * This is not the name of the component.
  44102. */
  44103. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44104. /**
  44105. * The state of a controller component
  44106. */
  44107. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44108. /**
  44109. * The schema of motion controller layout.
  44110. * No object will be initialized using this interface
  44111. * This is used just to define the profile.
  44112. */
  44113. export interface IMotionControllerLayout {
  44114. /**
  44115. * Path to load the assets. Usually relative to the base path
  44116. */
  44117. assetPath: string;
  44118. /**
  44119. * Available components (unsorted)
  44120. */
  44121. components: {
  44122. /**
  44123. * A map of component Ids
  44124. */
  44125. [componentId: string]: {
  44126. /**
  44127. * The type of input the component outputs
  44128. */
  44129. type: MotionControllerComponentType;
  44130. /**
  44131. * The indices of this component in the gamepad object
  44132. */
  44133. gamepadIndices: {
  44134. /**
  44135. * Index of button
  44136. */
  44137. button?: number;
  44138. /**
  44139. * If available, index of x-axis
  44140. */
  44141. xAxis?: number;
  44142. /**
  44143. * If available, index of y-axis
  44144. */
  44145. yAxis?: number;
  44146. };
  44147. /**
  44148. * The mesh's root node name
  44149. */
  44150. rootNodeName: string;
  44151. /**
  44152. * Animation definitions for this model
  44153. */
  44154. visualResponses: {
  44155. [stateKey: string]: {
  44156. /**
  44157. * What property will be animated
  44158. */
  44159. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44160. /**
  44161. * What states influence this visual response
  44162. */
  44163. states: MotionControllerComponentStateType[];
  44164. /**
  44165. * Type of animation - movement or visibility
  44166. */
  44167. valueNodeProperty: "transform" | "visibility";
  44168. /**
  44169. * Base node name to move. Its position will be calculated according to the min and max nodes
  44170. */
  44171. valueNodeName?: string;
  44172. /**
  44173. * Minimum movement node
  44174. */
  44175. minNodeName?: string;
  44176. /**
  44177. * Max movement node
  44178. */
  44179. maxNodeName?: string;
  44180. };
  44181. };
  44182. /**
  44183. * If touch enabled, what is the name of node to display user feedback
  44184. */
  44185. touchPointNodeName?: string;
  44186. };
  44187. };
  44188. /**
  44189. * Is it xr standard mapping or not
  44190. */
  44191. gamepadMapping: "" | "xr-standard";
  44192. /**
  44193. * Base root node of this entire model
  44194. */
  44195. rootNodeName: string;
  44196. /**
  44197. * Defines the main button component id
  44198. */
  44199. selectComponentId: string;
  44200. }
  44201. /**
  44202. * A definition for the layout map in the input profile
  44203. */
  44204. export interface IMotionControllerLayoutMap {
  44205. /**
  44206. * Layouts with handness type as a key
  44207. */
  44208. [handness: string]: IMotionControllerLayout;
  44209. }
  44210. /**
  44211. * The XR Input profile schema
  44212. * Profiles can be found here:
  44213. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44214. */
  44215. export interface IMotionControllerProfile {
  44216. /**
  44217. * fallback profiles for this profileId
  44218. */
  44219. fallbackProfileIds: string[];
  44220. /**
  44221. * The layout map, with handness as key
  44222. */
  44223. layouts: IMotionControllerLayoutMap;
  44224. /**
  44225. * The id of this profile
  44226. * correlates to the profile(s) in the xrInput.profiles array
  44227. */
  44228. profileId: string;
  44229. }
  44230. /**
  44231. * A helper-interface for the 3 meshes needed for controller button animation
  44232. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44233. */
  44234. export interface IMotionControllerButtonMeshMap {
  44235. /**
  44236. * the mesh that defines the pressed value mesh position.
  44237. * This is used to find the max-position of this button
  44238. */
  44239. pressedMesh: AbstractMesh;
  44240. /**
  44241. * the mesh that defines the unpressed value mesh position.
  44242. * This is used to find the min (or initial) position of this button
  44243. */
  44244. unpressedMesh: AbstractMesh;
  44245. /**
  44246. * The mesh that will be changed when value changes
  44247. */
  44248. valueMesh: AbstractMesh;
  44249. }
  44250. /**
  44251. * A helper-interface for the 3 meshes needed for controller axis animation.
  44252. * This will be expanded when touchpad animations are fully supported
  44253. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44254. */
  44255. export interface IMotionControllerMeshMap {
  44256. /**
  44257. * the mesh that defines the maximum value mesh position.
  44258. */
  44259. maxMesh?: AbstractMesh;
  44260. /**
  44261. * the mesh that defines the minimum value mesh position.
  44262. */
  44263. minMesh?: AbstractMesh;
  44264. /**
  44265. * The mesh that will be changed when axis value changes
  44266. */
  44267. valueMesh: AbstractMesh;
  44268. }
  44269. /**
  44270. * The elements needed for change-detection of the gamepad objects in motion controllers
  44271. */
  44272. export interface IMinimalMotionControllerObject {
  44273. /**
  44274. * Available axes of this controller
  44275. */
  44276. axes: number[];
  44277. /**
  44278. * An array of available buttons
  44279. */
  44280. buttons: Array<{
  44281. /**
  44282. * Value of the button/trigger
  44283. */
  44284. value: number;
  44285. /**
  44286. * If the button/trigger is currently touched
  44287. */
  44288. touched: boolean;
  44289. /**
  44290. * If the button/trigger is currently pressed
  44291. */
  44292. pressed: boolean;
  44293. }>;
  44294. }
  44295. /**
  44296. * An Abstract Motion controller
  44297. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44298. * Each component has an observable to check for changes in value and state
  44299. */
  44300. export abstract class WebXRAbstractMotionController implements IDisposable {
  44301. protected scene: Scene;
  44302. protected layout: IMotionControllerLayout;
  44303. /**
  44304. * The gamepad object correlating to this controller
  44305. */
  44306. gamepadObject: IMinimalMotionControllerObject;
  44307. /**
  44308. * handness (left/right/none) of this controller
  44309. */
  44310. handness: MotionControllerHandness;
  44311. private _initComponent;
  44312. private _modelReady;
  44313. /**
  44314. * A map of components (WebXRControllerComponent) in this motion controller
  44315. * Components have a ComponentType and can also have both button and axis definitions
  44316. */
  44317. readonly components: {
  44318. [id: string]: WebXRControllerComponent;
  44319. };
  44320. /**
  44321. * Disable the model's animation. Can be set at any time.
  44322. */
  44323. disableAnimation: boolean;
  44324. /**
  44325. * Observers registered here will be triggered when the model of this controller is done loading
  44326. */
  44327. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44328. /**
  44329. * The profile id of this motion controller
  44330. */
  44331. abstract profileId: string;
  44332. /**
  44333. * The root mesh of the model. It is null if the model was not yet initialized
  44334. */
  44335. rootMesh: Nullable<AbstractMesh>;
  44336. /**
  44337. * constructs a new abstract motion controller
  44338. * @param scene the scene to which the model of the controller will be added
  44339. * @param layout The profile layout to load
  44340. * @param gamepadObject The gamepad object correlating to this controller
  44341. * @param handness handness (left/right/none) of this controller
  44342. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44343. */
  44344. constructor(scene: Scene, layout: IMotionControllerLayout,
  44345. /**
  44346. * The gamepad object correlating to this controller
  44347. */
  44348. gamepadObject: IMinimalMotionControllerObject,
  44349. /**
  44350. * handness (left/right/none) of this controller
  44351. */
  44352. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44353. /**
  44354. * Dispose this controller, the model mesh and all its components
  44355. */
  44356. dispose(): void;
  44357. /**
  44358. * Returns all components of specific type
  44359. * @param type the type to search for
  44360. * @return an array of components with this type
  44361. */
  44362. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44363. /**
  44364. * get a component based an its component id as defined in layout.components
  44365. * @param id the id of the component
  44366. * @returns the component correlates to the id or undefined if not found
  44367. */
  44368. getComponent(id: string): WebXRControllerComponent;
  44369. /**
  44370. * Get the list of components available in this motion controller
  44371. * @returns an array of strings correlating to available components
  44372. */
  44373. getComponentIds(): string[];
  44374. /**
  44375. * Get the first component of specific type
  44376. * @param type type of component to find
  44377. * @return a controller component or null if not found
  44378. */
  44379. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44380. /**
  44381. * Get the main (Select) component of this controller as defined in the layout
  44382. * @returns the main component of this controller
  44383. */
  44384. getMainComponent(): WebXRControllerComponent;
  44385. /**
  44386. * Loads the model correlating to this controller
  44387. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44388. * @returns A promise fulfilled with the result of the model loading
  44389. */
  44390. loadModel(): Promise<boolean>;
  44391. /**
  44392. * Update this model using the current XRFrame
  44393. * @param xrFrame the current xr frame to use and update the model
  44394. */
  44395. updateFromXRFrame(xrFrame: XRFrame): void;
  44396. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44397. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44398. /**
  44399. * Moves the axis on the controller mesh based on its current state
  44400. * @param axis the index of the axis
  44401. * @param axisValue the value of the axis which determines the meshes new position
  44402. * @hidden
  44403. */
  44404. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44405. /**
  44406. * Update the model itself with the current frame data
  44407. * @param xrFrame the frame to use for updating the model mesh
  44408. */
  44409. protected updateModel(xrFrame: XRFrame): void;
  44410. /**
  44411. * Get the filename and path for this controller's model
  44412. * @returns a map of filename and path
  44413. */
  44414. protected abstract _getFilenameAndPath(): {
  44415. filename: string;
  44416. path: string;
  44417. };
  44418. /**
  44419. * This function is called before the mesh is loaded. It checks for loading constraints.
  44420. * For example, this function can check if the GLB loader is available
  44421. * If this function returns false, the generic controller will be loaded instead
  44422. * @returns Is the client ready to load the mesh
  44423. */
  44424. protected abstract _getModelLoadingConstraints(): boolean;
  44425. /**
  44426. * This function will be called after the model was successfully loaded and can be used
  44427. * for mesh transformations before it is available for the user
  44428. * @param meshes the loaded meshes
  44429. */
  44430. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44431. /**
  44432. * Set the root mesh for this controller. Important for the WebXR controller class
  44433. * @param meshes the loaded meshes
  44434. */
  44435. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44436. /**
  44437. * A function executed each frame that updates the mesh (if needed)
  44438. * @param xrFrame the current xrFrame
  44439. */
  44440. protected abstract _updateModel(xrFrame: XRFrame): void;
  44441. private _getGenericFilenameAndPath;
  44442. private _getGenericParentMesh;
  44443. }
  44444. }
  44445. declare module BABYLON {
  44446. /**
  44447. * A generic trigger-only motion controller for WebXR
  44448. */
  44449. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44450. /**
  44451. * Static version of the profile id of this controller
  44452. */
  44453. static ProfileId: string;
  44454. profileId: string;
  44455. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44456. protected _getFilenameAndPath(): {
  44457. filename: string;
  44458. path: string;
  44459. };
  44460. protected _getModelLoadingConstraints(): boolean;
  44461. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44462. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44463. protected _updateModel(): void;
  44464. }
  44465. }
  44466. declare module BABYLON {
  44467. /**
  44468. * Class containing static functions to help procedurally build meshes
  44469. */
  44470. export class SphereBuilder {
  44471. /**
  44472. * Creates a sphere mesh
  44473. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44474. * * 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`)
  44475. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44476. * * 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
  44477. * * 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)
  44478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44479. * * 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
  44480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44481. * @param name defines the name of the mesh
  44482. * @param options defines the options used to create the mesh
  44483. * @param scene defines the hosting scene
  44484. * @returns the sphere mesh
  44485. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44486. */
  44487. static CreateSphere(name: string, options: {
  44488. segments?: number;
  44489. diameter?: number;
  44490. diameterX?: number;
  44491. diameterY?: number;
  44492. diameterZ?: number;
  44493. arc?: number;
  44494. slice?: number;
  44495. sideOrientation?: number;
  44496. frontUVs?: Vector4;
  44497. backUVs?: Vector4;
  44498. updatable?: boolean;
  44499. }, scene?: Nullable<Scene>): Mesh;
  44500. }
  44501. }
  44502. declare module BABYLON {
  44503. /**
  44504. * A profiled motion controller has its profile loaded from an online repository.
  44505. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44506. */
  44507. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44508. private _repositoryUrl;
  44509. private _buttonMeshMapping;
  44510. private _touchDots;
  44511. /**
  44512. * The profile ID of this controller. Will be populated when the controller initializes.
  44513. */
  44514. profileId: string;
  44515. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44516. dispose(): void;
  44517. protected _getFilenameAndPath(): {
  44518. filename: string;
  44519. path: string;
  44520. };
  44521. protected _getModelLoadingConstraints(): boolean;
  44522. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44523. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44524. protected _updateModel(_xrFrame: XRFrame): void;
  44525. }
  44526. }
  44527. declare module BABYLON {
  44528. /**
  44529. * A construction function type to create a new controller based on an xrInput object
  44530. */
  44531. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44532. /**
  44533. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44534. *
  44535. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44536. * it should be replaced with auto-loaded controllers.
  44537. *
  44538. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44539. */
  44540. export class WebXRMotionControllerManager {
  44541. private static _AvailableControllers;
  44542. private static _Fallbacks;
  44543. private static _ProfileLoadingPromises;
  44544. private static _ProfilesList;
  44545. /**
  44546. * The base URL of the online controller repository. Can be changed at any time.
  44547. */
  44548. static BaseRepositoryUrl: string;
  44549. /**
  44550. * Which repository gets priority - local or online
  44551. */
  44552. static PrioritizeOnlineRepository: boolean;
  44553. /**
  44554. * Use the online repository, or use only locally-defined controllers
  44555. */
  44556. static UseOnlineRepository: boolean;
  44557. /**
  44558. * Clear the cache used for profile loading and reload when requested again
  44559. */
  44560. static ClearProfilesCache(): void;
  44561. /**
  44562. * Register the default fallbacks.
  44563. * This function is called automatically when this file is imported.
  44564. */
  44565. static DefaultFallbacks(): void;
  44566. /**
  44567. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44568. * @param profileId the profile to which a fallback needs to be found
  44569. * @return an array with corresponding fallback profiles
  44570. */
  44571. static FindFallbackWithProfileId(profileId: string): string[];
  44572. /**
  44573. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44574. * The order of search:
  44575. *
  44576. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44577. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44578. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44579. * 4) return the generic trigger controller if none were found
  44580. *
  44581. * @param xrInput the xrInput to which a new controller is initialized
  44582. * @param scene the scene to which the model will be added
  44583. * @param forceProfile force a certain profile for this controller
  44584. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44585. */
  44586. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44587. /**
  44588. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44589. *
  44590. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44591. *
  44592. * @param type the profile type to register
  44593. * @param constructFunction the function to be called when loading this profile
  44594. */
  44595. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44596. /**
  44597. * Register a fallback to a specific profile.
  44598. * @param profileId the profileId that will receive the fallbacks
  44599. * @param fallbacks A list of fallback profiles
  44600. */
  44601. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44602. /**
  44603. * Will update the list of profiles available in the repository
  44604. * @return a promise that resolves to a map of profiles available online
  44605. */
  44606. static UpdateProfilesList(): Promise<{
  44607. [profile: string]: string;
  44608. }>;
  44609. private static _LoadProfileFromRepository;
  44610. private static _LoadProfilesFromAvailableControllers;
  44611. }
  44612. }
  44613. declare module BABYLON {
  44614. /**
  44615. * Configuration options for the WebXR controller creation
  44616. */
  44617. export interface IWebXRControllerOptions {
  44618. /**
  44619. * Should the controller mesh be animated when a user interacts with it
  44620. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44621. */
  44622. disableMotionControllerAnimation?: boolean;
  44623. /**
  44624. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44625. */
  44626. doNotLoadControllerMesh?: boolean;
  44627. /**
  44628. * Force a specific controller type for this controller.
  44629. * This can be used when creating your own profile or when testing different controllers
  44630. */
  44631. forceControllerProfile?: string;
  44632. }
  44633. /**
  44634. * Represents an XR controller
  44635. */
  44636. export class WebXRInputSource {
  44637. private _scene;
  44638. /** The underlying input source for the controller */
  44639. inputSource: XRInputSource;
  44640. private _options;
  44641. private _tmpQuaternion;
  44642. private _tmpVector;
  44643. private _uniqueId;
  44644. /**
  44645. * 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
  44646. */
  44647. grip?: AbstractMesh;
  44648. /**
  44649. * If available, this is the gamepad object related to this controller.
  44650. * Using this object it is possible to get click events and trackpad changes of the
  44651. * webxr controller that is currently being used.
  44652. */
  44653. motionController?: WebXRAbstractMotionController;
  44654. /**
  44655. * Event that fires when the controller is removed/disposed.
  44656. * The object provided as event data is this controller, after associated assets were disposed.
  44657. * uniqueId is still available.
  44658. */
  44659. onDisposeObservable: Observable<WebXRInputSource>;
  44660. /**
  44661. * Will be triggered when the mesh associated with the motion controller is done loading.
  44662. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44663. * A shortened version of controller -> motion controller -> on mesh loaded.
  44664. */
  44665. onMeshLoadedObservable: Observable<AbstractMesh>;
  44666. /**
  44667. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44668. */
  44669. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44670. /**
  44671. * Pointer which can be used to select objects or attach a visible laser to
  44672. */
  44673. pointer: AbstractMesh;
  44674. /**
  44675. * Creates the controller
  44676. * @see https://doc.babylonjs.com/how_to/webxr
  44677. * @param _scene the scene which the controller should be associated to
  44678. * @param inputSource the underlying input source for the controller
  44679. * @param _options options for this controller creation
  44680. */
  44681. constructor(_scene: Scene,
  44682. /** The underlying input source for the controller */
  44683. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44684. /**
  44685. * Get this controllers unique id
  44686. */
  44687. get uniqueId(): string;
  44688. /**
  44689. * Disposes of the object
  44690. */
  44691. dispose(): void;
  44692. /**
  44693. * Gets a world space ray coming from the pointer or grip
  44694. * @param result the resulting ray
  44695. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44696. */
  44697. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44698. /**
  44699. * Updates the controller pose based on the given XRFrame
  44700. * @param xrFrame xr frame to update the pose with
  44701. * @param referenceSpace reference space to use
  44702. */
  44703. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44704. }
  44705. }
  44706. declare module BABYLON {
  44707. /**
  44708. * The schema for initialization options of the XR Input class
  44709. */
  44710. export interface IWebXRInputOptions {
  44711. /**
  44712. * If set to true no model will be automatically loaded
  44713. */
  44714. doNotLoadControllerMeshes?: boolean;
  44715. /**
  44716. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44717. * If not found, the xr input profile data will be used.
  44718. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44719. */
  44720. forceInputProfile?: string;
  44721. /**
  44722. * Do not send a request to the controller repository to load the profile.
  44723. *
  44724. * Instead, use the controllers available in babylon itself.
  44725. */
  44726. disableOnlineControllerRepository?: boolean;
  44727. /**
  44728. * A custom URL for the controllers repository
  44729. */
  44730. customControllersRepositoryURL?: string;
  44731. /**
  44732. * Should the controller model's components not move according to the user input
  44733. */
  44734. disableControllerAnimation?: boolean;
  44735. }
  44736. /**
  44737. * XR input used to track XR inputs such as controllers/rays
  44738. */
  44739. export class WebXRInput implements IDisposable {
  44740. /**
  44741. * the xr session manager for this session
  44742. */
  44743. xrSessionManager: WebXRSessionManager;
  44744. /**
  44745. * the WebXR camera for this session. Mainly used for teleportation
  44746. */
  44747. xrCamera: WebXRCamera;
  44748. private readonly options;
  44749. /**
  44750. * XR controllers being tracked
  44751. */
  44752. controllers: Array<WebXRInputSource>;
  44753. private _frameObserver;
  44754. private _sessionEndedObserver;
  44755. private _sessionInitObserver;
  44756. /**
  44757. * Event when a controller has been connected/added
  44758. */
  44759. onControllerAddedObservable: Observable<WebXRInputSource>;
  44760. /**
  44761. * Event when a controller has been removed/disconnected
  44762. */
  44763. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44764. /**
  44765. * Initializes the WebXRInput
  44766. * @param xrSessionManager the xr session manager for this session
  44767. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44768. * @param options = initialization options for this xr input
  44769. */
  44770. constructor(
  44771. /**
  44772. * the xr session manager for this session
  44773. */
  44774. xrSessionManager: WebXRSessionManager,
  44775. /**
  44776. * the WebXR camera for this session. Mainly used for teleportation
  44777. */
  44778. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44779. private _onInputSourcesChange;
  44780. private _addAndRemoveControllers;
  44781. /**
  44782. * Disposes of the object
  44783. */
  44784. dispose(): void;
  44785. }
  44786. }
  44787. declare module BABYLON {
  44788. /**
  44789. * This is the base class for all WebXR features.
  44790. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44791. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44792. */
  44793. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44794. protected _xrSessionManager: WebXRSessionManager;
  44795. private _attached;
  44796. private _removeOnDetach;
  44797. /**
  44798. * Should auto-attach be disabled?
  44799. */
  44800. disableAutoAttach: boolean;
  44801. /**
  44802. * Construct a new (abstract) WebXR feature
  44803. * @param _xrSessionManager the xr session manager for this feature
  44804. */
  44805. constructor(_xrSessionManager: WebXRSessionManager);
  44806. /**
  44807. * Is this feature attached
  44808. */
  44809. get attached(): boolean;
  44810. /**
  44811. * attach this feature
  44812. *
  44813. * @param force should attachment be forced (even when already attached)
  44814. * @returns true if successful, false is failed or already attached
  44815. */
  44816. attach(force?: boolean): boolean;
  44817. /**
  44818. * detach this feature.
  44819. *
  44820. * @returns true if successful, false if failed or already detached
  44821. */
  44822. detach(): boolean;
  44823. /**
  44824. * Dispose this feature and all of the resources attached
  44825. */
  44826. dispose(): void;
  44827. /**
  44828. * This is used to register callbacks that will automatically be removed when detach is called.
  44829. * @param observable the observable to which the observer will be attached
  44830. * @param callback the callback to register
  44831. */
  44832. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44833. /**
  44834. * Code in this function will be executed on each xrFrame received from the browser.
  44835. * This function will not execute after the feature is detached.
  44836. * @param _xrFrame the current frame
  44837. */
  44838. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44839. }
  44840. }
  44841. declare module BABYLON {
  44842. /**
  44843. * Renders a layer on top of an existing scene
  44844. */
  44845. export class UtilityLayerRenderer implements IDisposable {
  44846. /** the original scene that will be rendered on top of */
  44847. originalScene: Scene;
  44848. private _pointerCaptures;
  44849. private _lastPointerEvents;
  44850. private static _DefaultUtilityLayer;
  44851. private static _DefaultKeepDepthUtilityLayer;
  44852. private _sharedGizmoLight;
  44853. private _renderCamera;
  44854. /**
  44855. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44856. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44857. * @returns the camera that is used when rendering the utility layer
  44858. */
  44859. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44860. /**
  44861. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44862. * @param cam the camera that should be used when rendering the utility layer
  44863. */
  44864. setRenderCamera(cam: Nullable<Camera>): void;
  44865. /**
  44866. * @hidden
  44867. * Light which used by gizmos to get light shading
  44868. */
  44869. _getSharedGizmoLight(): HemisphericLight;
  44870. /**
  44871. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44872. */
  44873. pickUtilitySceneFirst: boolean;
  44874. /**
  44875. * 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)
  44876. */
  44877. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44878. /**
  44879. * 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)
  44880. */
  44881. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44882. /**
  44883. * The scene that is rendered on top of the original scene
  44884. */
  44885. utilityLayerScene: Scene;
  44886. /**
  44887. * If the utility layer should automatically be rendered on top of existing scene
  44888. */
  44889. shouldRender: boolean;
  44890. /**
  44891. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44892. */
  44893. onlyCheckPointerDownEvents: boolean;
  44894. /**
  44895. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44896. */
  44897. processAllEvents: boolean;
  44898. /**
  44899. * Observable raised when the pointer move from the utility layer scene to the main scene
  44900. */
  44901. onPointerOutObservable: Observable<number>;
  44902. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44903. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44904. private _afterRenderObserver;
  44905. private _sceneDisposeObserver;
  44906. private _originalPointerObserver;
  44907. /**
  44908. * Instantiates a UtilityLayerRenderer
  44909. * @param originalScene the original scene that will be rendered on top of
  44910. * @param handleEvents boolean indicating if the utility layer should handle events
  44911. */
  44912. constructor(
  44913. /** the original scene that will be rendered on top of */
  44914. originalScene: Scene, handleEvents?: boolean);
  44915. private _notifyObservers;
  44916. /**
  44917. * Renders the utility layers scene on top of the original scene
  44918. */
  44919. render(): void;
  44920. /**
  44921. * Disposes of the renderer
  44922. */
  44923. dispose(): void;
  44924. private _updateCamera;
  44925. }
  44926. }
  44927. declare module BABYLON {
  44928. /**
  44929. * Options interface for the pointer selection module
  44930. */
  44931. export interface IWebXRControllerPointerSelectionOptions {
  44932. /**
  44933. * if provided, this scene will be used to render meshes.
  44934. */
  44935. customUtilityLayerScene?: Scene;
  44936. /**
  44937. * 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)
  44938. * If not disabled, the last picked point will be used to execute a pointer up event
  44939. * If disabled, pointer up event will be triggered right after the pointer down event.
  44940. * Used in screen and gaze target ray mode only
  44941. */
  44942. disablePointerUpOnTouchOut: boolean;
  44943. /**
  44944. * For gaze mode (time to select instead of press)
  44945. */
  44946. forceGazeMode: boolean;
  44947. /**
  44948. * 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
  44949. * to start a new countdown to the pointer down event.
  44950. * Defaults to 1.
  44951. */
  44952. gazeModePointerMovedFactor?: number;
  44953. /**
  44954. * Different button type to use instead of the main component
  44955. */
  44956. overrideButtonId?: string;
  44957. /**
  44958. * use this rendering group id for the meshes (optional)
  44959. */
  44960. renderingGroupId?: number;
  44961. /**
  44962. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44963. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44964. * 3000 means 3 seconds between pointing at something and selecting it
  44965. */
  44966. timeToSelect?: number;
  44967. /**
  44968. * Should meshes created here be added to a utility layer or the main scene
  44969. */
  44970. useUtilityLayer?: boolean;
  44971. /**
  44972. * the xr input to use with this pointer selection
  44973. */
  44974. xrInput: WebXRInput;
  44975. }
  44976. /**
  44977. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44978. */
  44979. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44980. private readonly _options;
  44981. private static _idCounter;
  44982. private _attachController;
  44983. private _controllers;
  44984. private _scene;
  44985. private _tmpVectorForPickCompare;
  44986. /**
  44987. * The module's name
  44988. */
  44989. static readonly Name: string;
  44990. /**
  44991. * The (Babylon) version of this module.
  44992. * This is an integer representing the implementation version.
  44993. * This number does not correspond to the WebXR specs version
  44994. */
  44995. static readonly Version: number;
  44996. /**
  44997. * Disable lighting on the laser pointer (so it will always be visible)
  44998. */
  44999. disablePointerLighting: boolean;
  45000. /**
  45001. * Disable lighting on the selection mesh (so it will always be visible)
  45002. */
  45003. disableSelectionMeshLighting: boolean;
  45004. /**
  45005. * Should the laser pointer be displayed
  45006. */
  45007. displayLaserPointer: boolean;
  45008. /**
  45009. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45010. */
  45011. displaySelectionMesh: boolean;
  45012. /**
  45013. * This color will be set to the laser pointer when selection is triggered
  45014. */
  45015. laserPointerPickedColor: Color3;
  45016. /**
  45017. * Default color of the laser pointer
  45018. */
  45019. lasterPointerDefaultColor: Color3;
  45020. /**
  45021. * default color of the selection ring
  45022. */
  45023. selectionMeshDefaultColor: Color3;
  45024. /**
  45025. * This color will be applied to the selection ring when selection is triggered
  45026. */
  45027. selectionMeshPickedColor: Color3;
  45028. /**
  45029. * Optional filter to be used for ray selection. This predicate shares behavior with
  45030. * scene.pointerMovePredicate which takes priority if it is also assigned.
  45031. */
  45032. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45033. /**
  45034. * constructs a new background remover module
  45035. * @param _xrSessionManager the session manager for this module
  45036. * @param _options read-only options to be used in this module
  45037. */
  45038. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45039. /**
  45040. * attach this feature
  45041. * Will usually be called by the features manager
  45042. *
  45043. * @returns true if successful.
  45044. */
  45045. attach(): boolean;
  45046. /**
  45047. * detach this feature.
  45048. * Will usually be called by the features manager
  45049. *
  45050. * @returns true if successful.
  45051. */
  45052. detach(): boolean;
  45053. /**
  45054. * Will get the mesh under a specific pointer.
  45055. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  45056. * @param controllerId the controllerId to check
  45057. * @returns The mesh under pointer or null if no mesh is under the pointer
  45058. */
  45059. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  45060. /**
  45061. * Get the xr controller that correlates to the pointer id in the pointer event
  45062. *
  45063. * @param id the pointer id to search for
  45064. * @returns the controller that correlates to this id or null if not found
  45065. */
  45066. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  45067. protected _onXRFrame(_xrFrame: XRFrame): void;
  45068. private _attachGazeMode;
  45069. private _attachScreenRayMode;
  45070. private _attachTrackedPointerRayMode;
  45071. private _convertNormalToDirectionOfRay;
  45072. private _detachController;
  45073. private _generateNewMeshPair;
  45074. private _pickingMoved;
  45075. private _updatePointerDistance;
  45076. }
  45077. }
  45078. declare module BABYLON {
  45079. /**
  45080. * Button which can be used to enter a different mode of XR
  45081. */
  45082. export class WebXREnterExitUIButton {
  45083. /** button element */
  45084. element: HTMLElement;
  45085. /** XR initialization options for the button */
  45086. sessionMode: XRSessionMode;
  45087. /** Reference space type */
  45088. referenceSpaceType: XRReferenceSpaceType;
  45089. /**
  45090. * Creates a WebXREnterExitUIButton
  45091. * @param element button element
  45092. * @param sessionMode XR initialization session mode
  45093. * @param referenceSpaceType the type of reference space to be used
  45094. */
  45095. constructor(
  45096. /** button element */
  45097. element: HTMLElement,
  45098. /** XR initialization options for the button */
  45099. sessionMode: XRSessionMode,
  45100. /** Reference space type */
  45101. referenceSpaceType: XRReferenceSpaceType);
  45102. /**
  45103. * Extendable function which can be used to update the button's visuals when the state changes
  45104. * @param activeButton the current active button in the UI
  45105. */
  45106. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45107. }
  45108. /**
  45109. * Options to create the webXR UI
  45110. */
  45111. export class WebXREnterExitUIOptions {
  45112. /**
  45113. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45114. */
  45115. customButtons?: Array<WebXREnterExitUIButton>;
  45116. /**
  45117. * A reference space type to use when creating the default button.
  45118. * Default is local-floor
  45119. */
  45120. referenceSpaceType?: XRReferenceSpaceType;
  45121. /**
  45122. * Context to enter xr with
  45123. */
  45124. renderTarget?: Nullable<WebXRRenderTarget>;
  45125. /**
  45126. * A session mode to use when creating the default button.
  45127. * Default is immersive-vr
  45128. */
  45129. sessionMode?: XRSessionMode;
  45130. }
  45131. /**
  45132. * UI to allow the user to enter/exit XR mode
  45133. */
  45134. export class WebXREnterExitUI implements IDisposable {
  45135. private scene;
  45136. /** version of the options passed to this UI */
  45137. options: WebXREnterExitUIOptions;
  45138. private _activeButton;
  45139. private _buttons;
  45140. private _overlay;
  45141. /**
  45142. * Fired every time the active button is changed.
  45143. *
  45144. * When xr is entered via a button that launches xr that button will be the callback parameter
  45145. *
  45146. * When exiting xr the callback parameter will be null)
  45147. */
  45148. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45149. /**
  45150. *
  45151. * @param scene babylon scene object to use
  45152. * @param options (read-only) version of the options passed to this UI
  45153. */
  45154. private constructor();
  45155. /**
  45156. * Creates UI to allow the user to enter/exit XR mode
  45157. * @param scene the scene to add the ui to
  45158. * @param helper the xr experience helper to enter/exit xr with
  45159. * @param options options to configure the UI
  45160. * @returns the created ui
  45161. */
  45162. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45163. /**
  45164. * Disposes of the XR UI component
  45165. */
  45166. dispose(): void;
  45167. private _updateButtons;
  45168. }
  45169. }
  45170. declare module BABYLON {
  45171. /**
  45172. * Class containing static functions to help procedurally build meshes
  45173. */
  45174. export class LinesBuilder {
  45175. /**
  45176. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45177. * * 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
  45178. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45179. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45180. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45181. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45182. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45183. * * 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
  45184. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45186. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45187. * @param name defines the name of the new line system
  45188. * @param options defines the options used to create the line system
  45189. * @param scene defines the hosting scene
  45190. * @returns a new line system mesh
  45191. */
  45192. static CreateLineSystem(name: string, options: {
  45193. lines: Vector3[][];
  45194. updatable?: boolean;
  45195. instance?: Nullable<LinesMesh>;
  45196. colors?: Nullable<Color4[][]>;
  45197. useVertexAlpha?: boolean;
  45198. }, scene: Nullable<Scene>): LinesMesh;
  45199. /**
  45200. * Creates a line mesh
  45201. * 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
  45202. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45203. * * The parameter `points` is an array successive Vector3
  45204. * * 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
  45205. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45206. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45207. * * When updating an instance, remember that only point positions can change, not the number of points
  45208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45209. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45210. * @param name defines the name of the new line system
  45211. * @param options defines the options used to create the line system
  45212. * @param scene defines the hosting scene
  45213. * @returns a new line mesh
  45214. */
  45215. static CreateLines(name: string, options: {
  45216. points: Vector3[];
  45217. updatable?: boolean;
  45218. instance?: Nullable<LinesMesh>;
  45219. colors?: Color4[];
  45220. useVertexAlpha?: boolean;
  45221. }, scene?: Nullable<Scene>): LinesMesh;
  45222. /**
  45223. * Creates a dashed line mesh
  45224. * * 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
  45225. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45226. * * The parameter `points` is an array successive Vector3
  45227. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45228. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45229. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45230. * * 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
  45231. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45232. * * When updating an instance, remember that only point positions can change, not the number of points
  45233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45234. * @param name defines the name of the mesh
  45235. * @param options defines the options used to create the mesh
  45236. * @param scene defines the hosting scene
  45237. * @returns the dashed line mesh
  45238. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45239. */
  45240. static CreateDashedLines(name: string, options: {
  45241. points: Vector3[];
  45242. dashSize?: number;
  45243. gapSize?: number;
  45244. dashNb?: number;
  45245. updatable?: boolean;
  45246. instance?: LinesMesh;
  45247. useVertexAlpha?: boolean;
  45248. }, scene?: Nullable<Scene>): LinesMesh;
  45249. }
  45250. }
  45251. declare module BABYLON {
  45252. /**
  45253. * The options container for the teleportation module
  45254. */
  45255. export interface IWebXRTeleportationOptions {
  45256. /**
  45257. * if provided, this scene will be used to render meshes.
  45258. */
  45259. customUtilityLayerScene?: Scene;
  45260. /**
  45261. * Values to configure the default target mesh
  45262. */
  45263. defaultTargetMeshOptions?: {
  45264. /**
  45265. * Fill color of the teleportation area
  45266. */
  45267. teleportationFillColor?: string;
  45268. /**
  45269. * Border color for the teleportation area
  45270. */
  45271. teleportationBorderColor?: string;
  45272. /**
  45273. * Disable the mesh's animation sequence
  45274. */
  45275. disableAnimation?: boolean;
  45276. /**
  45277. * Disable lighting on the material or the ring and arrow
  45278. */
  45279. disableLighting?: boolean;
  45280. /**
  45281. * Override the default material of the torus and arrow
  45282. */
  45283. torusArrowMaterial?: Material;
  45284. };
  45285. /**
  45286. * A list of meshes to use as floor meshes.
  45287. * Meshes can be added and removed after initializing the feature using the
  45288. * addFloorMesh and removeFloorMesh functions
  45289. * If empty, rotation will still work
  45290. */
  45291. floorMeshes?: AbstractMesh[];
  45292. /**
  45293. * use this rendering group id for the meshes (optional)
  45294. */
  45295. renderingGroupId?: number;
  45296. /**
  45297. * Should teleportation move only to snap points
  45298. */
  45299. snapPointsOnly?: boolean;
  45300. /**
  45301. * An array of points to which the teleportation will snap to.
  45302. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45303. */
  45304. snapPositions?: Vector3[];
  45305. /**
  45306. * How close should the teleportation ray be in order to snap to position.
  45307. * Default to 0.8 units (meters)
  45308. */
  45309. snapToPositionRadius?: number;
  45310. /**
  45311. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45312. * If you want to support rotation, make sure your mesh has a direction indicator.
  45313. *
  45314. * When left untouched, the default mesh will be initialized.
  45315. */
  45316. teleportationTargetMesh?: AbstractMesh;
  45317. /**
  45318. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45319. */
  45320. timeToTeleport?: number;
  45321. /**
  45322. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45323. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45324. */
  45325. useMainComponentOnly?: boolean;
  45326. /**
  45327. * Should meshes created here be added to a utility layer or the main scene
  45328. */
  45329. useUtilityLayer?: boolean;
  45330. /**
  45331. * Babylon XR Input class for controller
  45332. */
  45333. xrInput: WebXRInput;
  45334. }
  45335. /**
  45336. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45337. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45338. * the input of the attached controllers.
  45339. */
  45340. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45341. private _options;
  45342. private _controllers;
  45343. private _currentTeleportationControllerId;
  45344. private _floorMeshes;
  45345. private _quadraticBezierCurve;
  45346. private _selectionFeature;
  45347. private _snapToPositions;
  45348. private _snappedToPoint;
  45349. private _teleportationRingMaterial?;
  45350. private _tmpRay;
  45351. private _tmpVector;
  45352. /**
  45353. * The module's name
  45354. */
  45355. static readonly Name: string;
  45356. /**
  45357. * The (Babylon) version of this module.
  45358. * This is an integer representing the implementation version.
  45359. * This number does not correspond to the webxr specs version
  45360. */
  45361. static readonly Version: number;
  45362. /**
  45363. * Is movement backwards enabled
  45364. */
  45365. backwardsMovementEnabled: boolean;
  45366. /**
  45367. * Distance to travel when moving backwards
  45368. */
  45369. backwardsTeleportationDistance: number;
  45370. /**
  45371. * The distance from the user to the inspection point in the direction of the controller
  45372. * A higher number will allow the user to move further
  45373. * defaults to 5 (meters, in xr units)
  45374. */
  45375. parabolicCheckRadius: number;
  45376. /**
  45377. * Should the module support parabolic ray on top of direct ray
  45378. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45379. * Very helpful when moving between floors / different heights
  45380. */
  45381. parabolicRayEnabled: boolean;
  45382. /**
  45383. * How much rotation should be applied when rotating right and left
  45384. */
  45385. rotationAngle: number;
  45386. /**
  45387. * Is rotation enabled when moving forward?
  45388. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45389. */
  45390. rotationEnabled: boolean;
  45391. /**
  45392. * constructs a new anchor system
  45393. * @param _xrSessionManager an instance of WebXRSessionManager
  45394. * @param _options configuration object for this feature
  45395. */
  45396. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45397. /**
  45398. * Get the snapPointsOnly flag
  45399. */
  45400. get snapPointsOnly(): boolean;
  45401. /**
  45402. * Sets the snapPointsOnly flag
  45403. * @param snapToPoints should teleportation be exclusively to snap points
  45404. */
  45405. set snapPointsOnly(snapToPoints: boolean);
  45406. /**
  45407. * Add a new mesh to the floor meshes array
  45408. * @param mesh the mesh to use as floor mesh
  45409. */
  45410. addFloorMesh(mesh: AbstractMesh): void;
  45411. /**
  45412. * Add a new snap-to point to fix teleportation to this position
  45413. * @param newSnapPoint The new Snap-To point
  45414. */
  45415. addSnapPoint(newSnapPoint: Vector3): void;
  45416. attach(): boolean;
  45417. detach(): boolean;
  45418. dispose(): void;
  45419. /**
  45420. * Remove a mesh from the floor meshes array
  45421. * @param mesh the mesh to remove
  45422. */
  45423. removeFloorMesh(mesh: AbstractMesh): void;
  45424. /**
  45425. * Remove a mesh from the floor meshes array using its name
  45426. * @param name the mesh name to remove
  45427. */
  45428. removeFloorMeshByName(name: string): void;
  45429. /**
  45430. * 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
  45431. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45432. * @returns was the point found and removed or not
  45433. */
  45434. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45435. /**
  45436. * This function sets a selection feature that will be disabled when
  45437. * the forward ray is shown and will be reattached when hidden.
  45438. * This is used to remove the selection rays when moving.
  45439. * @param selectionFeature the feature to disable when forward movement is enabled
  45440. */
  45441. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45442. protected _onXRFrame(_xrFrame: XRFrame): void;
  45443. private _attachController;
  45444. private _createDefaultTargetMesh;
  45445. private _detachController;
  45446. private _findClosestSnapPointWithRadius;
  45447. private _setTargetMeshPosition;
  45448. private _setTargetMeshVisibility;
  45449. private _showParabolicPath;
  45450. private _teleportForward;
  45451. }
  45452. }
  45453. declare module BABYLON {
  45454. /**
  45455. * Options for the default xr helper
  45456. */
  45457. export class WebXRDefaultExperienceOptions {
  45458. /**
  45459. * Enable or disable default UI to enter XR
  45460. */
  45461. disableDefaultUI?: boolean;
  45462. /**
  45463. * Should teleportation not initialize. defaults to false.
  45464. */
  45465. disableTeleportation?: boolean;
  45466. /**
  45467. * Floor meshes that will be used for teleport
  45468. */
  45469. floorMeshes?: Array<AbstractMesh>;
  45470. /**
  45471. * If set to true, the first frame will not be used to reset position
  45472. * The first frame is mainly used when copying transformation from the old camera
  45473. * Mainly used in AR
  45474. */
  45475. ignoreNativeCameraTransformation?: boolean;
  45476. /**
  45477. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45478. */
  45479. inputOptions?: IWebXRInputOptions;
  45480. /**
  45481. * optional configuration for the output canvas
  45482. */
  45483. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45484. /**
  45485. * optional UI options. This can be used among other to change session mode and reference space type
  45486. */
  45487. uiOptions?: WebXREnterExitUIOptions;
  45488. /**
  45489. * When loading teleportation and pointer select, use stable versions instead of latest.
  45490. */
  45491. useStablePlugins?: boolean;
  45492. }
  45493. /**
  45494. * Default experience which provides a similar setup to the previous webVRExperience
  45495. */
  45496. export class WebXRDefaultExperience {
  45497. /**
  45498. * Base experience
  45499. */
  45500. baseExperience: WebXRExperienceHelper;
  45501. /**
  45502. * Enables ui for entering/exiting xr
  45503. */
  45504. enterExitUI: WebXREnterExitUI;
  45505. /**
  45506. * Input experience extension
  45507. */
  45508. input: WebXRInput;
  45509. /**
  45510. * Enables laser pointer and selection
  45511. */
  45512. pointerSelection: WebXRControllerPointerSelection;
  45513. /**
  45514. * Default target xr should render to
  45515. */
  45516. renderTarget: WebXRRenderTarget;
  45517. /**
  45518. * Enables teleportation
  45519. */
  45520. teleportation: WebXRMotionControllerTeleportation;
  45521. private constructor();
  45522. /**
  45523. * Creates the default xr experience
  45524. * @param scene scene
  45525. * @param options options for basic configuration
  45526. * @returns resulting WebXRDefaultExperience
  45527. */
  45528. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45529. /**
  45530. * DIsposes of the experience helper
  45531. */
  45532. dispose(): void;
  45533. }
  45534. }
  45535. declare module BABYLON {
  45536. /**
  45537. * Options to modify the vr teleportation behavior.
  45538. */
  45539. export interface VRTeleportationOptions {
  45540. /**
  45541. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45542. */
  45543. floorMeshName?: string;
  45544. /**
  45545. * A list of meshes to be used as the teleportation floor. (default: empty)
  45546. */
  45547. floorMeshes?: Mesh[];
  45548. /**
  45549. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45550. */
  45551. teleportationMode?: number;
  45552. /**
  45553. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45554. */
  45555. teleportationTime?: number;
  45556. /**
  45557. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45558. */
  45559. teleportationSpeed?: number;
  45560. /**
  45561. * The easing function used in the animation or null for Linear. (default CircleEase)
  45562. */
  45563. easingFunction?: EasingFunction;
  45564. }
  45565. /**
  45566. * Options to modify the vr experience helper's behavior.
  45567. */
  45568. export interface VRExperienceHelperOptions extends WebVROptions {
  45569. /**
  45570. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45571. */
  45572. createDeviceOrientationCamera?: boolean;
  45573. /**
  45574. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45575. */
  45576. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45577. /**
  45578. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45579. */
  45580. laserToggle?: boolean;
  45581. /**
  45582. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45583. */
  45584. floorMeshes?: Mesh[];
  45585. /**
  45586. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45587. */
  45588. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45589. /**
  45590. * Defines if WebXR should be used instead of WebVR (if available)
  45591. */
  45592. useXR?: boolean;
  45593. }
  45594. /**
  45595. * Event containing information after VR has been entered
  45596. */
  45597. export class OnAfterEnteringVRObservableEvent {
  45598. /**
  45599. * If entering vr was successful
  45600. */
  45601. success: boolean;
  45602. }
  45603. /**
  45604. * Helps to quickly add VR support to an existing scene.
  45605. * See http://doc.babylonjs.com/how_to/webvr_helper
  45606. */
  45607. export class VRExperienceHelper {
  45608. /** Options to modify the vr experience helper's behavior. */
  45609. webVROptions: VRExperienceHelperOptions;
  45610. private _scene;
  45611. private _position;
  45612. private _btnVR;
  45613. private _btnVRDisplayed;
  45614. private _webVRsupported;
  45615. private _webVRready;
  45616. private _webVRrequesting;
  45617. private _webVRpresenting;
  45618. private _hasEnteredVR;
  45619. private _fullscreenVRpresenting;
  45620. private _inputElement;
  45621. private _webVRCamera;
  45622. private _vrDeviceOrientationCamera;
  45623. private _deviceOrientationCamera;
  45624. private _existingCamera;
  45625. private _onKeyDown;
  45626. private _onVrDisplayPresentChange;
  45627. private _onVRDisplayChanged;
  45628. private _onVRRequestPresentStart;
  45629. private _onVRRequestPresentComplete;
  45630. /**
  45631. * 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)
  45632. */
  45633. enableGazeEvenWhenNoPointerLock: boolean;
  45634. /**
  45635. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45636. */
  45637. exitVROnDoubleTap: boolean;
  45638. /**
  45639. * Observable raised right before entering VR.
  45640. */
  45641. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45642. /**
  45643. * Observable raised when entering VR has completed.
  45644. */
  45645. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45646. /**
  45647. * Observable raised when exiting VR.
  45648. */
  45649. onExitingVRObservable: Observable<VRExperienceHelper>;
  45650. /**
  45651. * Observable raised when controller mesh is loaded.
  45652. */
  45653. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45654. /** Return this.onEnteringVRObservable
  45655. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45656. */
  45657. get onEnteringVR(): Observable<VRExperienceHelper>;
  45658. /** Return this.onExitingVRObservable
  45659. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45660. */
  45661. get onExitingVR(): Observable<VRExperienceHelper>;
  45662. /** Return this.onControllerMeshLoadedObservable
  45663. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45664. */
  45665. get onControllerMeshLoaded(): Observable<WebVRController>;
  45666. private _rayLength;
  45667. private _useCustomVRButton;
  45668. private _teleportationRequested;
  45669. private _teleportActive;
  45670. private _floorMeshName;
  45671. private _floorMeshesCollection;
  45672. private _teleportationMode;
  45673. private _teleportationTime;
  45674. private _teleportationSpeed;
  45675. private _teleportationEasing;
  45676. private _rotationAllowed;
  45677. private _teleportBackwardsVector;
  45678. private _teleportationTarget;
  45679. private _isDefaultTeleportationTarget;
  45680. private _postProcessMove;
  45681. private _teleportationFillColor;
  45682. private _teleportationBorderColor;
  45683. private _rotationAngle;
  45684. private _haloCenter;
  45685. private _cameraGazer;
  45686. private _padSensibilityUp;
  45687. private _padSensibilityDown;
  45688. private _leftController;
  45689. private _rightController;
  45690. private _gazeColor;
  45691. private _laserColor;
  45692. private _pickedLaserColor;
  45693. private _pickedGazeColor;
  45694. /**
  45695. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45696. */
  45697. onNewMeshSelected: Observable<AbstractMesh>;
  45698. /**
  45699. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45700. * This observable will provide the mesh and the controller used to select the mesh
  45701. */
  45702. onMeshSelectedWithController: Observable<{
  45703. mesh: AbstractMesh;
  45704. controller: WebVRController;
  45705. }>;
  45706. /**
  45707. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45708. */
  45709. onNewMeshPicked: Observable<PickingInfo>;
  45710. private _circleEase;
  45711. /**
  45712. * Observable raised before camera teleportation
  45713. */
  45714. onBeforeCameraTeleport: Observable<Vector3>;
  45715. /**
  45716. * Observable raised after camera teleportation
  45717. */
  45718. onAfterCameraTeleport: Observable<Vector3>;
  45719. /**
  45720. * Observable raised when current selected mesh gets unselected
  45721. */
  45722. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45723. private _raySelectionPredicate;
  45724. /**
  45725. * To be optionaly changed by user to define custom ray selection
  45726. */
  45727. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45728. /**
  45729. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45730. */
  45731. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45732. /**
  45733. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45734. */
  45735. teleportationEnabled: boolean;
  45736. private _defaultHeight;
  45737. private _teleportationInitialized;
  45738. private _interactionsEnabled;
  45739. private _interactionsRequested;
  45740. private _displayGaze;
  45741. private _displayLaserPointer;
  45742. /**
  45743. * The mesh used to display where the user is going to teleport.
  45744. */
  45745. get teleportationTarget(): Mesh;
  45746. /**
  45747. * Sets the mesh to be used to display where the user is going to teleport.
  45748. */
  45749. set teleportationTarget(value: Mesh);
  45750. /**
  45751. * 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
  45752. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45753. * See http://doc.babylonjs.com/resources/baking_transformations
  45754. */
  45755. get gazeTrackerMesh(): Mesh;
  45756. set gazeTrackerMesh(value: Mesh);
  45757. /**
  45758. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45759. */
  45760. updateGazeTrackerScale: boolean;
  45761. /**
  45762. * If the gaze trackers color should be updated when selecting meshes
  45763. */
  45764. updateGazeTrackerColor: boolean;
  45765. /**
  45766. * If the controller laser color should be updated when selecting meshes
  45767. */
  45768. updateControllerLaserColor: boolean;
  45769. /**
  45770. * The gaze tracking mesh corresponding to the left controller
  45771. */
  45772. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45773. /**
  45774. * The gaze tracking mesh corresponding to the right controller
  45775. */
  45776. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45777. /**
  45778. * If the ray of the gaze should be displayed.
  45779. */
  45780. get displayGaze(): boolean;
  45781. /**
  45782. * Sets if the ray of the gaze should be displayed.
  45783. */
  45784. set displayGaze(value: boolean);
  45785. /**
  45786. * If the ray of the LaserPointer should be displayed.
  45787. */
  45788. get displayLaserPointer(): boolean;
  45789. /**
  45790. * Sets if the ray of the LaserPointer should be displayed.
  45791. */
  45792. set displayLaserPointer(value: boolean);
  45793. /**
  45794. * The deviceOrientationCamera used as the camera when not in VR.
  45795. */
  45796. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45797. /**
  45798. * Based on the current WebVR support, returns the current VR camera used.
  45799. */
  45800. get currentVRCamera(): Nullable<Camera>;
  45801. /**
  45802. * The webVRCamera which is used when in VR.
  45803. */
  45804. get webVRCamera(): WebVRFreeCamera;
  45805. /**
  45806. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45807. */
  45808. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45809. /**
  45810. * The html button that is used to trigger entering into VR.
  45811. */
  45812. get vrButton(): Nullable<HTMLButtonElement>;
  45813. private get _teleportationRequestInitiated();
  45814. /**
  45815. * Defines whether or not Pointer lock should be requested when switching to
  45816. * full screen.
  45817. */
  45818. requestPointerLockOnFullScreen: boolean;
  45819. /**
  45820. * If asking to force XR, this will be populated with the default xr experience
  45821. */
  45822. xr: WebXRDefaultExperience;
  45823. /**
  45824. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45825. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45826. */
  45827. xrTestDone: boolean;
  45828. /**
  45829. * Instantiates a VRExperienceHelper.
  45830. * Helps to quickly add VR support to an existing scene.
  45831. * @param scene The scene the VRExperienceHelper belongs to.
  45832. * @param webVROptions Options to modify the vr experience helper's behavior.
  45833. */
  45834. constructor(scene: Scene,
  45835. /** Options to modify the vr experience helper's behavior. */
  45836. webVROptions?: VRExperienceHelperOptions);
  45837. private completeVRInit;
  45838. private _onDefaultMeshLoaded;
  45839. private _onResize;
  45840. private _onFullscreenChange;
  45841. /**
  45842. * Gets a value indicating if we are currently in VR mode.
  45843. */
  45844. get isInVRMode(): boolean;
  45845. private onVrDisplayPresentChange;
  45846. private onVRDisplayChanged;
  45847. private moveButtonToBottomRight;
  45848. private displayVRButton;
  45849. private updateButtonVisibility;
  45850. private _cachedAngularSensibility;
  45851. /**
  45852. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45853. * Otherwise, will use the fullscreen API.
  45854. */
  45855. enterVR(): void;
  45856. /**
  45857. * Attempt to exit VR, or fullscreen.
  45858. */
  45859. exitVR(): void;
  45860. /**
  45861. * The position of the vr experience helper.
  45862. */
  45863. get position(): Vector3;
  45864. /**
  45865. * Sets the position of the vr experience helper.
  45866. */
  45867. set position(value: Vector3);
  45868. /**
  45869. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45870. */
  45871. enableInteractions(): void;
  45872. private get _noControllerIsActive();
  45873. private beforeRender;
  45874. private _isTeleportationFloor;
  45875. /**
  45876. * Adds a floor mesh to be used for teleportation.
  45877. * @param floorMesh the mesh to be used for teleportation.
  45878. */
  45879. addFloorMesh(floorMesh: Mesh): void;
  45880. /**
  45881. * Removes a floor mesh from being used for teleportation.
  45882. * @param floorMesh the mesh to be removed.
  45883. */
  45884. removeFloorMesh(floorMesh: Mesh): void;
  45885. /**
  45886. * Enables interactions and teleportation using the VR controllers and gaze.
  45887. * @param vrTeleportationOptions options to modify teleportation behavior.
  45888. */
  45889. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45890. private _onNewGamepadConnected;
  45891. private _tryEnableInteractionOnController;
  45892. private _onNewGamepadDisconnected;
  45893. private _enableInteractionOnController;
  45894. private _checkTeleportWithRay;
  45895. private _checkRotate;
  45896. private _checkTeleportBackwards;
  45897. private _enableTeleportationOnController;
  45898. private _createTeleportationCircles;
  45899. private _displayTeleportationTarget;
  45900. private _hideTeleportationTarget;
  45901. private _rotateCamera;
  45902. private _moveTeleportationSelectorTo;
  45903. private _workingVector;
  45904. private _workingQuaternion;
  45905. private _workingMatrix;
  45906. /**
  45907. * Time Constant Teleportation Mode
  45908. */
  45909. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45910. /**
  45911. * Speed Constant Teleportation Mode
  45912. */
  45913. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45914. /**
  45915. * Teleports the users feet to the desired location
  45916. * @param location The location where the user's feet should be placed
  45917. */
  45918. teleportCamera(location: Vector3): void;
  45919. private _convertNormalToDirectionOfRay;
  45920. private _castRayAndSelectObject;
  45921. private _notifySelectedMeshUnselected;
  45922. /**
  45923. * Permanently set new colors for the laser pointer
  45924. * @param color the new laser color
  45925. * @param pickedColor the new laser color when picked mesh detected
  45926. */
  45927. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45928. /**
  45929. * Set lighting enabled / disabled on the laser pointer of both controllers
  45930. * @param enabled should the lighting be enabled on the laser pointer
  45931. */
  45932. setLaserLightingState(enabled?: boolean): void;
  45933. /**
  45934. * Permanently set new colors for the gaze pointer
  45935. * @param color the new gaze color
  45936. * @param pickedColor the new gaze color when picked mesh detected
  45937. */
  45938. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45939. /**
  45940. * Sets the color of the laser ray from the vr controllers.
  45941. * @param color new color for the ray.
  45942. */
  45943. changeLaserColor(color: Color3): void;
  45944. /**
  45945. * Sets the color of the ray from the vr headsets gaze.
  45946. * @param color new color for the ray.
  45947. */
  45948. changeGazeColor(color: Color3): void;
  45949. /**
  45950. * Exits VR and disposes of the vr experience helper
  45951. */
  45952. dispose(): void;
  45953. /**
  45954. * Gets the name of the VRExperienceHelper class
  45955. * @returns "VRExperienceHelper"
  45956. */
  45957. getClassName(): string;
  45958. }
  45959. }
  45960. declare module BABYLON {
  45961. /**
  45962. * Contains an array of blocks representing the octree
  45963. */
  45964. export interface IOctreeContainer<T> {
  45965. /**
  45966. * Blocks within the octree
  45967. */
  45968. blocks: Array<OctreeBlock<T>>;
  45969. }
  45970. /**
  45971. * Class used to store a cell in an octree
  45972. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45973. */
  45974. export class OctreeBlock<T> {
  45975. /**
  45976. * Gets the content of the current block
  45977. */
  45978. entries: T[];
  45979. /**
  45980. * Gets the list of block children
  45981. */
  45982. blocks: Array<OctreeBlock<T>>;
  45983. private _depth;
  45984. private _maxDepth;
  45985. private _capacity;
  45986. private _minPoint;
  45987. private _maxPoint;
  45988. private _boundingVectors;
  45989. private _creationFunc;
  45990. /**
  45991. * Creates a new block
  45992. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45993. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45994. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45995. * @param depth defines the current depth of this block in the octree
  45996. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45997. * @param creationFunc defines a callback to call when an element is added to the block
  45998. */
  45999. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46000. /**
  46001. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46002. */
  46003. get capacity(): number;
  46004. /**
  46005. * Gets the minimum vector (in world space) of the block's bounding box
  46006. */
  46007. get minPoint(): Vector3;
  46008. /**
  46009. * Gets the maximum vector (in world space) of the block's bounding box
  46010. */
  46011. get maxPoint(): Vector3;
  46012. /**
  46013. * Add a new element to this block
  46014. * @param entry defines the element to add
  46015. */
  46016. addEntry(entry: T): void;
  46017. /**
  46018. * Remove an element from this block
  46019. * @param entry defines the element to remove
  46020. */
  46021. removeEntry(entry: T): void;
  46022. /**
  46023. * Add an array of elements to this block
  46024. * @param entries defines the array of elements to add
  46025. */
  46026. addEntries(entries: T[]): void;
  46027. /**
  46028. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46029. * @param frustumPlanes defines the frustum planes to test
  46030. * @param selection defines the array to store current content if selection is positive
  46031. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46032. */
  46033. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46034. /**
  46035. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46036. * @param sphereCenter defines the bounding sphere center
  46037. * @param sphereRadius defines the bounding sphere radius
  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. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46042. /**
  46043. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46044. * @param ray defines the ray to test with
  46045. * @param selection defines the array to store current content if selection is positive
  46046. */
  46047. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46048. /**
  46049. * Subdivide the content into child blocks (this block will then be empty)
  46050. */
  46051. createInnerBlocks(): void;
  46052. /**
  46053. * @hidden
  46054. */
  46055. 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;
  46056. }
  46057. }
  46058. declare module BABYLON {
  46059. /**
  46060. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46061. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46062. */
  46063. export class Octree<T> {
  46064. /** 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.) */
  46065. maxDepth: number;
  46066. /**
  46067. * Blocks within the octree containing objects
  46068. */
  46069. blocks: Array<OctreeBlock<T>>;
  46070. /**
  46071. * Content stored in the octree
  46072. */
  46073. dynamicContent: T[];
  46074. private _maxBlockCapacity;
  46075. private _selectionContent;
  46076. private _creationFunc;
  46077. /**
  46078. * Creates a octree
  46079. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46080. * @param creationFunc function to be used to instatiate the octree
  46081. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46082. * @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.)
  46083. */
  46084. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46085. /** 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.) */
  46086. maxDepth?: number);
  46087. /**
  46088. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46089. * @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);
  46090. * @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);
  46091. * @param entries meshes to be added to the octree blocks
  46092. */
  46093. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46094. /**
  46095. * Adds a mesh to the octree
  46096. * @param entry Mesh to add to the octree
  46097. */
  46098. addMesh(entry: T): void;
  46099. /**
  46100. * Remove an element from the octree
  46101. * @param entry defines the element to remove
  46102. */
  46103. removeMesh(entry: T): void;
  46104. /**
  46105. * Selects an array of meshes within the frustum
  46106. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46107. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46108. * @returns array of meshes within the frustum
  46109. */
  46110. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46111. /**
  46112. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46113. * @param sphereCenter defines the bounding sphere center
  46114. * @param sphereRadius defines the bounding sphere radius
  46115. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46116. * @returns an array of objects that intersect the sphere
  46117. */
  46118. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46119. /**
  46120. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46121. * @param ray defines the ray to test with
  46122. * @returns array of intersected objects
  46123. */
  46124. intersectsRay(ray: Ray): SmartArray<T>;
  46125. /**
  46126. * Adds a mesh into the octree block if it intersects the block
  46127. */
  46128. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46129. /**
  46130. * Adds a submesh into the octree block if it intersects the block
  46131. */
  46132. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46133. }
  46134. }
  46135. declare module BABYLON {
  46136. interface Scene {
  46137. /**
  46138. * @hidden
  46139. * Backing Filed
  46140. */
  46141. _selectionOctree: Octree<AbstractMesh>;
  46142. /**
  46143. * Gets the octree used to boost mesh selection (picking)
  46144. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46145. */
  46146. selectionOctree: Octree<AbstractMesh>;
  46147. /**
  46148. * Creates or updates the octree used to boost selection (picking)
  46149. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46150. * @param maxCapacity defines the maximum capacity per leaf
  46151. * @param maxDepth defines the maximum depth of the octree
  46152. * @returns an octree of AbstractMesh
  46153. */
  46154. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46155. }
  46156. interface AbstractMesh {
  46157. /**
  46158. * @hidden
  46159. * Backing Field
  46160. */
  46161. _submeshesOctree: Octree<SubMesh>;
  46162. /**
  46163. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46164. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46165. * @param maxCapacity defines the maximum size of each block (64 by default)
  46166. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46167. * @returns the new octree
  46168. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46169. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46170. */
  46171. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46172. }
  46173. /**
  46174. * Defines the octree scene component responsible to manage any octrees
  46175. * in a given scene.
  46176. */
  46177. export class OctreeSceneComponent {
  46178. /**
  46179. * The component name help to identify the component in the list of scene components.
  46180. */
  46181. readonly name: string;
  46182. /**
  46183. * The scene the component belongs to.
  46184. */
  46185. scene: Scene;
  46186. /**
  46187. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46188. */
  46189. readonly checksIsEnabled: boolean;
  46190. /**
  46191. * Creates a new instance of the component for the given scene
  46192. * @param scene Defines the scene to register the component in
  46193. */
  46194. constructor(scene: Scene);
  46195. /**
  46196. * Registers the component in a given scene
  46197. */
  46198. register(): void;
  46199. /**
  46200. * Return the list of active meshes
  46201. * @returns the list of active meshes
  46202. */
  46203. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46204. /**
  46205. * Return the list of active sub meshes
  46206. * @param mesh The mesh to get the candidates sub meshes from
  46207. * @returns the list of active sub meshes
  46208. */
  46209. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46210. private _tempRay;
  46211. /**
  46212. * Return the list of sub meshes intersecting with a given local ray
  46213. * @param mesh defines the mesh to find the submesh for
  46214. * @param localRay defines the ray in local space
  46215. * @returns the list of intersecting sub meshes
  46216. */
  46217. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46218. /**
  46219. * Return the list of sub meshes colliding with a collider
  46220. * @param mesh defines the mesh to find the submesh for
  46221. * @param collider defines the collider to evaluate the collision against
  46222. * @returns the list of colliding sub meshes
  46223. */
  46224. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46225. /**
  46226. * Rebuilds the elements related to this component in case of
  46227. * context lost for instance.
  46228. */
  46229. rebuild(): void;
  46230. /**
  46231. * Disposes the component and the associated ressources.
  46232. */
  46233. dispose(): void;
  46234. }
  46235. }
  46236. declare module BABYLON {
  46237. /**
  46238. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46239. */
  46240. export class Gizmo implements IDisposable {
  46241. /** The utility layer the gizmo will be added to */
  46242. gizmoLayer: UtilityLayerRenderer;
  46243. /**
  46244. * The root mesh of the gizmo
  46245. */
  46246. _rootMesh: Mesh;
  46247. private _attachedMesh;
  46248. /**
  46249. * Ratio for the scale of the gizmo (Default: 1)
  46250. */
  46251. scaleRatio: number;
  46252. /**
  46253. * If a custom mesh has been set (Default: false)
  46254. */
  46255. protected _customMeshSet: boolean;
  46256. /**
  46257. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46258. * * When set, interactions will be enabled
  46259. */
  46260. get attachedMesh(): Nullable<AbstractMesh>;
  46261. set attachedMesh(value: Nullable<AbstractMesh>);
  46262. /**
  46263. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46264. * @param mesh The mesh to replace the default mesh of the gizmo
  46265. */
  46266. setCustomMesh(mesh: Mesh): void;
  46267. /**
  46268. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46269. */
  46270. updateGizmoRotationToMatchAttachedMesh: boolean;
  46271. /**
  46272. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46273. */
  46274. updateGizmoPositionToMatchAttachedMesh: boolean;
  46275. /**
  46276. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46277. */
  46278. updateScale: boolean;
  46279. protected _interactionsEnabled: boolean;
  46280. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46281. private _beforeRenderObserver;
  46282. private _tempVector;
  46283. /**
  46284. * Creates a gizmo
  46285. * @param gizmoLayer The utility layer the gizmo will be added to
  46286. */
  46287. constructor(
  46288. /** The utility layer the gizmo will be added to */
  46289. gizmoLayer?: UtilityLayerRenderer);
  46290. /**
  46291. * Updates the gizmo to match the attached mesh's position/rotation
  46292. */
  46293. protected _update(): void;
  46294. /**
  46295. * Disposes of the gizmo
  46296. */
  46297. dispose(): void;
  46298. }
  46299. }
  46300. declare module BABYLON {
  46301. /**
  46302. * Single plane drag gizmo
  46303. */
  46304. export class PlaneDragGizmo extends Gizmo {
  46305. /**
  46306. * Drag behavior responsible for the gizmos dragging interactions
  46307. */
  46308. dragBehavior: PointerDragBehavior;
  46309. private _pointerObserver;
  46310. /**
  46311. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46312. */
  46313. snapDistance: number;
  46314. /**
  46315. * Event that fires each time the gizmo snaps to a new location.
  46316. * * snapDistance is the the change in distance
  46317. */
  46318. onSnapObservable: Observable<{
  46319. snapDistance: number;
  46320. }>;
  46321. private _plane;
  46322. private _coloredMaterial;
  46323. private _hoverMaterial;
  46324. private _isEnabled;
  46325. private _parent;
  46326. /** @hidden */
  46327. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46328. /** @hidden */
  46329. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46330. /**
  46331. * Creates a PlaneDragGizmo
  46332. * @param gizmoLayer The utility layer the gizmo will be added to
  46333. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46334. * @param color The color of the gizmo
  46335. */
  46336. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46337. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46338. /**
  46339. * If the gizmo is enabled
  46340. */
  46341. set isEnabled(value: boolean);
  46342. get isEnabled(): boolean;
  46343. /**
  46344. * Disposes of the gizmo
  46345. */
  46346. dispose(): void;
  46347. }
  46348. }
  46349. declare module BABYLON {
  46350. /**
  46351. * Gizmo that enables dragging a mesh along 3 axis
  46352. */
  46353. export class PositionGizmo extends Gizmo {
  46354. /**
  46355. * Internal gizmo used for interactions on the x axis
  46356. */
  46357. xGizmo: AxisDragGizmo;
  46358. /**
  46359. * Internal gizmo used for interactions on the y axis
  46360. */
  46361. yGizmo: AxisDragGizmo;
  46362. /**
  46363. * Internal gizmo used for interactions on the z axis
  46364. */
  46365. zGizmo: AxisDragGizmo;
  46366. /**
  46367. * Internal gizmo used for interactions on the yz plane
  46368. */
  46369. xPlaneGizmo: PlaneDragGizmo;
  46370. /**
  46371. * Internal gizmo used for interactions on the xz plane
  46372. */
  46373. yPlaneGizmo: PlaneDragGizmo;
  46374. /**
  46375. * Internal gizmo used for interactions on the xy plane
  46376. */
  46377. zPlaneGizmo: PlaneDragGizmo;
  46378. /**
  46379. * private variables
  46380. */
  46381. private _meshAttached;
  46382. private _updateGizmoRotationToMatchAttachedMesh;
  46383. private _snapDistance;
  46384. private _scaleRatio;
  46385. /** Fires an event when any of it's sub gizmos are dragged */
  46386. onDragStartObservable: Observable<unknown>;
  46387. /** Fires an event when any of it's sub gizmos are released from dragging */
  46388. onDragEndObservable: Observable<unknown>;
  46389. /**
  46390. * If set to true, planar drag is enabled
  46391. */
  46392. private _planarGizmoEnabled;
  46393. get attachedMesh(): Nullable<AbstractMesh>;
  46394. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46395. /**
  46396. * Creates a PositionGizmo
  46397. * @param gizmoLayer The utility layer the gizmo will be added to
  46398. */
  46399. constructor(gizmoLayer?: UtilityLayerRenderer);
  46400. /**
  46401. * If the planar drag gizmo is enabled
  46402. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46403. */
  46404. set planarGizmoEnabled(value: boolean);
  46405. get planarGizmoEnabled(): boolean;
  46406. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46407. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46408. /**
  46409. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46410. */
  46411. set snapDistance(value: number);
  46412. get snapDistance(): number;
  46413. /**
  46414. * Ratio for the scale of the gizmo (Default: 1)
  46415. */
  46416. set scaleRatio(value: number);
  46417. get scaleRatio(): number;
  46418. /**
  46419. * Disposes of the gizmo
  46420. */
  46421. dispose(): void;
  46422. /**
  46423. * CustomMeshes are not supported by this gizmo
  46424. * @param mesh The mesh to replace the default mesh of the gizmo
  46425. */
  46426. setCustomMesh(mesh: Mesh): void;
  46427. }
  46428. }
  46429. declare module BABYLON {
  46430. /**
  46431. * Single axis drag gizmo
  46432. */
  46433. export class AxisDragGizmo extends Gizmo {
  46434. /**
  46435. * Drag behavior responsible for the gizmos dragging interactions
  46436. */
  46437. dragBehavior: PointerDragBehavior;
  46438. private _pointerObserver;
  46439. /**
  46440. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46441. */
  46442. snapDistance: number;
  46443. /**
  46444. * Event that fires each time the gizmo snaps to a new location.
  46445. * * snapDistance is the the change in distance
  46446. */
  46447. onSnapObservable: Observable<{
  46448. snapDistance: number;
  46449. }>;
  46450. private _isEnabled;
  46451. private _parent;
  46452. private _arrow;
  46453. private _coloredMaterial;
  46454. private _hoverMaterial;
  46455. /** @hidden */
  46456. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46457. /** @hidden */
  46458. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46459. /**
  46460. * Creates an AxisDragGizmo
  46461. * @param gizmoLayer The utility layer the gizmo will be added to
  46462. * @param dragAxis The axis which the gizmo will be able to drag on
  46463. * @param color The color of the gizmo
  46464. */
  46465. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46466. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46467. /**
  46468. * If the gizmo is enabled
  46469. */
  46470. set isEnabled(value: boolean);
  46471. get isEnabled(): boolean;
  46472. /**
  46473. * Disposes of the gizmo
  46474. */
  46475. dispose(): void;
  46476. }
  46477. }
  46478. declare module BABYLON.Debug {
  46479. /**
  46480. * The Axes viewer will show 3 axes in a specific point in space
  46481. */
  46482. export class AxesViewer {
  46483. private _xAxis;
  46484. private _yAxis;
  46485. private _zAxis;
  46486. private _scaleLinesFactor;
  46487. private _instanced;
  46488. /**
  46489. * Gets the hosting scene
  46490. */
  46491. scene: Scene;
  46492. /**
  46493. * Gets or sets a number used to scale line length
  46494. */
  46495. scaleLines: number;
  46496. /** Gets the node hierarchy used to render x-axis */
  46497. get xAxis(): TransformNode;
  46498. /** Gets the node hierarchy used to render y-axis */
  46499. get yAxis(): TransformNode;
  46500. /** Gets the node hierarchy used to render z-axis */
  46501. get zAxis(): TransformNode;
  46502. /**
  46503. * Creates a new AxesViewer
  46504. * @param scene defines the hosting scene
  46505. * @param scaleLines defines a number used to scale line length (1 by default)
  46506. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46507. * @param xAxis defines the node hierarchy used to render the x-axis
  46508. * @param yAxis defines the node hierarchy used to render the y-axis
  46509. * @param zAxis defines the node hierarchy used to render the z-axis
  46510. */
  46511. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46512. /**
  46513. * Force the viewer to update
  46514. * @param position defines the position of the viewer
  46515. * @param xaxis defines the x axis of the viewer
  46516. * @param yaxis defines the y axis of the viewer
  46517. * @param zaxis defines the z axis of the viewer
  46518. */
  46519. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46520. /**
  46521. * Creates an instance of this axes viewer.
  46522. * @returns a new axes viewer with instanced meshes
  46523. */
  46524. createInstance(): AxesViewer;
  46525. /** Releases resources */
  46526. dispose(): void;
  46527. private static _SetRenderingGroupId;
  46528. }
  46529. }
  46530. declare module BABYLON.Debug {
  46531. /**
  46532. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46533. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46534. */
  46535. export class BoneAxesViewer extends AxesViewer {
  46536. /**
  46537. * Gets or sets the target mesh where to display the axes viewer
  46538. */
  46539. mesh: Nullable<Mesh>;
  46540. /**
  46541. * Gets or sets the target bone where to display the axes viewer
  46542. */
  46543. bone: Nullable<Bone>;
  46544. /** Gets current position */
  46545. pos: Vector3;
  46546. /** Gets direction of X axis */
  46547. xaxis: Vector3;
  46548. /** Gets direction of Y axis */
  46549. yaxis: Vector3;
  46550. /** Gets direction of Z axis */
  46551. zaxis: Vector3;
  46552. /**
  46553. * Creates a new BoneAxesViewer
  46554. * @param scene defines the hosting scene
  46555. * @param bone defines the target bone
  46556. * @param mesh defines the target mesh
  46557. * @param scaleLines defines a scaling factor for line length (1 by default)
  46558. */
  46559. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46560. /**
  46561. * Force the viewer to update
  46562. */
  46563. update(): void;
  46564. /** Releases resources */
  46565. dispose(): void;
  46566. }
  46567. }
  46568. declare module BABYLON {
  46569. /**
  46570. * Interface used to define scene explorer extensibility option
  46571. */
  46572. export interface IExplorerExtensibilityOption {
  46573. /**
  46574. * Define the option label
  46575. */
  46576. label: string;
  46577. /**
  46578. * Defines the action to execute on click
  46579. */
  46580. action: (entity: any) => void;
  46581. }
  46582. /**
  46583. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46584. */
  46585. export interface IExplorerExtensibilityGroup {
  46586. /**
  46587. * Defines a predicate to test if a given type mut be extended
  46588. */
  46589. predicate: (entity: any) => boolean;
  46590. /**
  46591. * Gets the list of options added to a type
  46592. */
  46593. entries: IExplorerExtensibilityOption[];
  46594. }
  46595. /**
  46596. * Interface used to define the options to use to create the Inspector
  46597. */
  46598. export interface IInspectorOptions {
  46599. /**
  46600. * Display in overlay mode (default: false)
  46601. */
  46602. overlay?: boolean;
  46603. /**
  46604. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46605. */
  46606. globalRoot?: HTMLElement;
  46607. /**
  46608. * Display the Scene explorer
  46609. */
  46610. showExplorer?: boolean;
  46611. /**
  46612. * Display the property inspector
  46613. */
  46614. showInspector?: boolean;
  46615. /**
  46616. * Display in embed mode (both panes on the right)
  46617. */
  46618. embedMode?: boolean;
  46619. /**
  46620. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46621. */
  46622. handleResize?: boolean;
  46623. /**
  46624. * Allow the panes to popup (default: true)
  46625. */
  46626. enablePopup?: boolean;
  46627. /**
  46628. * Allow the panes to be closed by users (default: true)
  46629. */
  46630. enableClose?: boolean;
  46631. /**
  46632. * Optional list of extensibility entries
  46633. */
  46634. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46635. /**
  46636. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46637. */
  46638. inspectorURL?: string;
  46639. /**
  46640. * Optional initial tab (default to DebugLayerTab.Properties)
  46641. */
  46642. initialTab?: DebugLayerTab;
  46643. }
  46644. interface Scene {
  46645. /**
  46646. * @hidden
  46647. * Backing field
  46648. */
  46649. _debugLayer: DebugLayer;
  46650. /**
  46651. * Gets the debug layer (aka Inspector) associated with the scene
  46652. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46653. */
  46654. debugLayer: DebugLayer;
  46655. }
  46656. /**
  46657. * Enum of inspector action tab
  46658. */
  46659. export enum DebugLayerTab {
  46660. /**
  46661. * Properties tag (default)
  46662. */
  46663. Properties = 0,
  46664. /**
  46665. * Debug tab
  46666. */
  46667. Debug = 1,
  46668. /**
  46669. * Statistics tab
  46670. */
  46671. Statistics = 2,
  46672. /**
  46673. * Tools tab
  46674. */
  46675. Tools = 3,
  46676. /**
  46677. * Settings tab
  46678. */
  46679. Settings = 4
  46680. }
  46681. /**
  46682. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46683. * what is happening in your scene
  46684. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46685. */
  46686. export class DebugLayer {
  46687. /**
  46688. * Define the url to get the inspector script from.
  46689. * By default it uses the babylonjs CDN.
  46690. * @ignoreNaming
  46691. */
  46692. static InspectorURL: string;
  46693. private _scene;
  46694. private BJSINSPECTOR;
  46695. private _onPropertyChangedObservable?;
  46696. /**
  46697. * Observable triggered when a property is changed through the inspector.
  46698. */
  46699. get onPropertyChangedObservable(): any;
  46700. /**
  46701. * Instantiates a new debug layer.
  46702. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46703. * what is happening in your scene
  46704. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46705. * @param scene Defines the scene to inspect
  46706. */
  46707. constructor(scene: Scene);
  46708. /** Creates the inspector window. */
  46709. private _createInspector;
  46710. /**
  46711. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46712. * @param entity defines the entity to select
  46713. * @param lineContainerTitle defines the specific block to highlight
  46714. */
  46715. select(entity: any, lineContainerTitle?: string): void;
  46716. /** Get the inspector from bundle or global */
  46717. private _getGlobalInspector;
  46718. /**
  46719. * Get if the inspector is visible or not.
  46720. * @returns true if visible otherwise, false
  46721. */
  46722. isVisible(): boolean;
  46723. /**
  46724. * Hide the inspector and close its window.
  46725. */
  46726. hide(): void;
  46727. /**
  46728. * Launch the debugLayer.
  46729. * @param config Define the configuration of the inspector
  46730. * @return a promise fulfilled when the debug layer is visible
  46731. */
  46732. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46733. }
  46734. }
  46735. declare module BABYLON {
  46736. /**
  46737. * Class containing static functions to help procedurally build meshes
  46738. */
  46739. export class BoxBuilder {
  46740. /**
  46741. * Creates a box mesh
  46742. * * The parameter `size` sets the size (float) of each box side (default 1)
  46743. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46744. * * 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)
  46745. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46747. * * 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
  46748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46749. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46750. * @param name defines the name of the mesh
  46751. * @param options defines the options used to create the mesh
  46752. * @param scene defines the hosting scene
  46753. * @returns the box mesh
  46754. */
  46755. static CreateBox(name: string, options: {
  46756. size?: number;
  46757. width?: number;
  46758. height?: number;
  46759. depth?: number;
  46760. faceUV?: Vector4[];
  46761. faceColors?: Color4[];
  46762. sideOrientation?: number;
  46763. frontUVs?: Vector4;
  46764. backUVs?: Vector4;
  46765. wrap?: boolean;
  46766. topBaseAt?: number;
  46767. bottomBaseAt?: number;
  46768. updatable?: boolean;
  46769. }, scene?: Nullable<Scene>): Mesh;
  46770. }
  46771. }
  46772. declare module BABYLON.Debug {
  46773. /**
  46774. * Used to show the physics impostor around the specific mesh
  46775. */
  46776. export class PhysicsViewer {
  46777. /** @hidden */
  46778. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46779. /** @hidden */
  46780. protected _meshes: Array<Nullable<AbstractMesh>>;
  46781. /** @hidden */
  46782. protected _scene: Nullable<Scene>;
  46783. /** @hidden */
  46784. protected _numMeshes: number;
  46785. /** @hidden */
  46786. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46787. private _renderFunction;
  46788. private _utilityLayer;
  46789. private _debugBoxMesh;
  46790. private _debugSphereMesh;
  46791. private _debugCylinderMesh;
  46792. private _debugMaterial;
  46793. private _debugMeshMeshes;
  46794. /**
  46795. * Creates a new PhysicsViewer
  46796. * @param scene defines the hosting scene
  46797. */
  46798. constructor(scene: Scene);
  46799. /** @hidden */
  46800. protected _updateDebugMeshes(): void;
  46801. /**
  46802. * Renders a specified physic impostor
  46803. * @param impostor defines the impostor to render
  46804. * @param targetMesh defines the mesh represented by the impostor
  46805. * @returns the new debug mesh used to render the impostor
  46806. */
  46807. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46808. /**
  46809. * Hides a specified physic impostor
  46810. * @param impostor defines the impostor to hide
  46811. */
  46812. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46813. private _getDebugMaterial;
  46814. private _getDebugBoxMesh;
  46815. private _getDebugSphereMesh;
  46816. private _getDebugCylinderMesh;
  46817. private _getDebugMeshMesh;
  46818. private _getDebugMesh;
  46819. /** Releases all resources */
  46820. dispose(): void;
  46821. }
  46822. }
  46823. declare module BABYLON {
  46824. /**
  46825. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46826. * in order to better appreciate the issue one might have.
  46827. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46828. */
  46829. export class RayHelper {
  46830. /**
  46831. * Defines the ray we are currently tryin to visualize.
  46832. */
  46833. ray: Nullable<Ray>;
  46834. private _renderPoints;
  46835. private _renderLine;
  46836. private _renderFunction;
  46837. private _scene;
  46838. private _updateToMeshFunction;
  46839. private _attachedToMesh;
  46840. private _meshSpaceDirection;
  46841. private _meshSpaceOrigin;
  46842. /**
  46843. * Helper function to create a colored helper in a scene in one line.
  46844. * @param ray Defines the ray we are currently tryin to visualize
  46845. * @param scene Defines the scene the ray is used in
  46846. * @param color Defines the color we want to see the ray in
  46847. * @returns The newly created ray helper.
  46848. */
  46849. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46850. /**
  46851. * Instantiate a new ray helper.
  46852. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46853. * in order to better appreciate the issue one might have.
  46854. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46855. * @param ray Defines the ray we are currently tryin to visualize
  46856. */
  46857. constructor(ray: Ray);
  46858. /**
  46859. * Shows the ray we are willing to debug.
  46860. * @param scene Defines the scene the ray needs to be rendered in
  46861. * @param color Defines the color the ray needs to be rendered in
  46862. */
  46863. show(scene: Scene, color?: Color3): void;
  46864. /**
  46865. * Hides the ray we are debugging.
  46866. */
  46867. hide(): void;
  46868. private _render;
  46869. /**
  46870. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46871. * @param mesh Defines the mesh we want the helper attached to
  46872. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46873. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46874. * @param length Defines the length of the ray
  46875. */
  46876. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46877. /**
  46878. * Detach the ray helper from the mesh it has previously been attached to.
  46879. */
  46880. detachFromMesh(): void;
  46881. private _updateToMesh;
  46882. /**
  46883. * Dispose the helper and release its associated resources.
  46884. */
  46885. dispose(): void;
  46886. }
  46887. }
  46888. declare module BABYLON.Debug {
  46889. /**
  46890. * Class used to render a debug view of a given skeleton
  46891. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46892. */
  46893. export class SkeletonViewer {
  46894. /** defines the skeleton to render */
  46895. skeleton: Skeleton;
  46896. /** defines the mesh attached to the skeleton */
  46897. mesh: AbstractMesh;
  46898. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46899. autoUpdateBonesMatrices: boolean;
  46900. /** defines the rendering group id to use with the viewer */
  46901. renderingGroupId: number;
  46902. /** Gets or sets the color used to render the skeleton */
  46903. color: Color3;
  46904. private _scene;
  46905. private _debugLines;
  46906. private _debugMesh;
  46907. private _isEnabled;
  46908. private _renderFunction;
  46909. private _utilityLayer;
  46910. /**
  46911. * Returns the mesh used to render the bones
  46912. */
  46913. get debugMesh(): Nullable<LinesMesh>;
  46914. /**
  46915. * Creates a new SkeletonViewer
  46916. * @param skeleton defines the skeleton to render
  46917. * @param mesh defines the mesh attached to the skeleton
  46918. * @param scene defines the hosting scene
  46919. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46920. * @param renderingGroupId defines the rendering group id to use with the viewer
  46921. */
  46922. constructor(
  46923. /** defines the skeleton to render */
  46924. skeleton: Skeleton,
  46925. /** defines the mesh attached to the skeleton */
  46926. mesh: AbstractMesh, scene: Scene,
  46927. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46928. autoUpdateBonesMatrices?: boolean,
  46929. /** defines the rendering group id to use with the viewer */
  46930. renderingGroupId?: number);
  46931. /** Gets or sets a boolean indicating if the viewer is enabled */
  46932. set isEnabled(value: boolean);
  46933. get isEnabled(): boolean;
  46934. private _getBonePosition;
  46935. private _getLinesForBonesWithLength;
  46936. private _getLinesForBonesNoLength;
  46937. /** Update the viewer to sync with current skeleton state */
  46938. update(): void;
  46939. /** Release associated resources */
  46940. dispose(): void;
  46941. }
  46942. }
  46943. declare module BABYLON {
  46944. /**
  46945. * This class will take all inputs from Keyboard, Pointer, and
  46946. * any Gamepads and provide a polling system that all devices
  46947. * will use. This class assumes that there will only be one
  46948. * pointer device and one keyboard.
  46949. */
  46950. export class DeviceInputSystem implements IDisposable {
  46951. /** POINTER_DEVICE */
  46952. static readonly POINTER_DEVICE: string;
  46953. /** KEYBOARD_DEVICE */
  46954. static readonly KEYBOARD_DEVICE: string;
  46955. /**
  46956. * Observable to be triggered when a device is connected
  46957. */
  46958. onDeviceConnectedObservable: Observable<string>;
  46959. /**
  46960. * Observable to be triggered when a device is disconnected
  46961. */
  46962. onDeviceDisconnectedObservable: Observable<string>;
  46963. private _inputs;
  46964. private _gamepads;
  46965. private _keyboardActive;
  46966. private _pointerActive;
  46967. private _elementToAttachTo;
  46968. private _keyboardDownEvent;
  46969. private _keyboardUpEvent;
  46970. private _pointerMoveEvent;
  46971. private _pointerDownEvent;
  46972. private _pointerUpEvent;
  46973. private _gamepadConnectedEvent;
  46974. private _gamepadDisconnectedEvent;
  46975. private static _MAX_KEYCODES;
  46976. private static _MAX_POINTER_INPUTS;
  46977. /**
  46978. * Default Constructor
  46979. * @param engine - engine to pull input element from
  46980. */
  46981. constructor(engine: Engine);
  46982. /**
  46983. * Checks for current device input value, given an id and input index
  46984. * @param deviceName Id of connected device
  46985. * @param inputIndex Index of device input
  46986. * @returns Current value of input
  46987. */
  46988. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  46989. /**
  46990. * Dispose of all the eventlisteners and clears the observables
  46991. */
  46992. dispose(): void;
  46993. /**
  46994. * Add device and inputs to device map
  46995. * @param deviceName Assigned name of device (may be SN)
  46996. * @param numberOfInputs Number of input entries to create for given device
  46997. */
  46998. private _registerDevice;
  46999. /**
  47000. * Given a specific device name, remove that device from the device map
  47001. * @param deviceName Name of device to be removed
  47002. */
  47003. private _unregisterDevice;
  47004. /**
  47005. * Handle all actions that come from keyboard interaction
  47006. */
  47007. private _handleKeyActions;
  47008. /**
  47009. * Handle all actions that come from pointer interaction
  47010. */
  47011. private _handlePointerActions;
  47012. /**
  47013. * Handle all actions that come from gamepad interaction
  47014. */
  47015. private _handleGamepadActions;
  47016. /**
  47017. * Update all non-event based devices with each frame
  47018. */
  47019. private _updateDevice;
  47020. }
  47021. }
  47022. declare module BABYLON {
  47023. /**
  47024. * Options to create the null engine
  47025. */
  47026. export class NullEngineOptions {
  47027. /**
  47028. * Render width (Default: 512)
  47029. */
  47030. renderWidth: number;
  47031. /**
  47032. * Render height (Default: 256)
  47033. */
  47034. renderHeight: number;
  47035. /**
  47036. * Texture size (Default: 512)
  47037. */
  47038. textureSize: number;
  47039. /**
  47040. * If delta time between frames should be constant
  47041. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47042. */
  47043. deterministicLockstep: boolean;
  47044. /**
  47045. * Maximum about of steps between frames (Default: 4)
  47046. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47047. */
  47048. lockstepMaxSteps: number;
  47049. }
  47050. /**
  47051. * The null engine class provides support for headless version of babylon.js.
  47052. * This can be used in server side scenario or for testing purposes
  47053. */
  47054. export class NullEngine extends Engine {
  47055. private _options;
  47056. /**
  47057. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47058. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47059. * @returns true if engine is in deterministic lock step mode
  47060. */
  47061. isDeterministicLockStep(): boolean;
  47062. /**
  47063. * Gets the max steps when engine is running in deterministic lock step
  47064. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47065. * @returns the max steps
  47066. */
  47067. getLockstepMaxSteps(): number;
  47068. /**
  47069. * Gets the current hardware scaling level.
  47070. * By default the hardware scaling level is computed from the window device ratio.
  47071. * 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.
  47072. * @returns a number indicating the current hardware scaling level
  47073. */
  47074. getHardwareScalingLevel(): number;
  47075. constructor(options?: NullEngineOptions);
  47076. /**
  47077. * Creates a vertex buffer
  47078. * @param vertices the data for the vertex buffer
  47079. * @returns the new WebGL static buffer
  47080. */
  47081. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47082. /**
  47083. * Creates a new index buffer
  47084. * @param indices defines the content of the index buffer
  47085. * @param updatable defines if the index buffer must be updatable
  47086. * @returns a new webGL buffer
  47087. */
  47088. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47089. /**
  47090. * Clear the current render buffer or the current render target (if any is set up)
  47091. * @param color defines the color to use
  47092. * @param backBuffer defines if the back buffer must be cleared
  47093. * @param depth defines if the depth buffer must be cleared
  47094. * @param stencil defines if the stencil buffer must be cleared
  47095. */
  47096. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47097. /**
  47098. * Gets the current render width
  47099. * @param useScreen defines if screen size must be used (or the current render target if any)
  47100. * @returns a number defining the current render width
  47101. */
  47102. getRenderWidth(useScreen?: boolean): number;
  47103. /**
  47104. * Gets the current render height
  47105. * @param useScreen defines if screen size must be used (or the current render target if any)
  47106. * @returns a number defining the current render height
  47107. */
  47108. getRenderHeight(useScreen?: boolean): number;
  47109. /**
  47110. * Set the WebGL's viewport
  47111. * @param viewport defines the viewport element to be used
  47112. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47113. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47114. */
  47115. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47116. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47117. /**
  47118. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47119. * @param pipelineContext defines the pipeline context to use
  47120. * @param uniformsNames defines the list of uniform names
  47121. * @returns an array of webGL uniform locations
  47122. */
  47123. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47124. /**
  47125. * Gets the lsit of active attributes for a given webGL program
  47126. * @param pipelineContext defines the pipeline context to use
  47127. * @param attributesNames defines the list of attribute names to get
  47128. * @returns an array of indices indicating the offset of each attribute
  47129. */
  47130. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47131. /**
  47132. * Binds an effect to the webGL context
  47133. * @param effect defines the effect to bind
  47134. */
  47135. bindSamplers(effect: Effect): void;
  47136. /**
  47137. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47138. * @param effect defines the effect to activate
  47139. */
  47140. enableEffect(effect: Effect): void;
  47141. /**
  47142. * Set various states to the webGL context
  47143. * @param culling defines backface culling state
  47144. * @param zOffset defines the value to apply to zOffset (0 by default)
  47145. * @param force defines if states must be applied even if cache is up to date
  47146. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47147. */
  47148. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47149. /**
  47150. * Set the value of an uniform to an array of int32
  47151. * @param uniform defines the webGL uniform location where to store the value
  47152. * @param array defines the array of int32 to store
  47153. */
  47154. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47155. /**
  47156. * Set the value of an uniform to an array of int32 (stored as vec2)
  47157. * @param uniform defines the webGL uniform location where to store the value
  47158. * @param array defines the array of int32 to store
  47159. */
  47160. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47161. /**
  47162. * Set the value of an uniform to an array of int32 (stored as vec3)
  47163. * @param uniform defines the webGL uniform location where to store the value
  47164. * @param array defines the array of int32 to store
  47165. */
  47166. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47167. /**
  47168. * Set the value of an uniform to an array of int32 (stored as vec4)
  47169. * @param uniform defines the webGL uniform location where to store the value
  47170. * @param array defines the array of int32 to store
  47171. */
  47172. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47173. /**
  47174. * Set the value of an uniform to an array of float32
  47175. * @param uniform defines the webGL uniform location where to store the value
  47176. * @param array defines the array of float32 to store
  47177. */
  47178. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47179. /**
  47180. * Set the value of an uniform to an array of float32 (stored as vec2)
  47181. * @param uniform defines the webGL uniform location where to store the value
  47182. * @param array defines the array of float32 to store
  47183. */
  47184. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47185. /**
  47186. * Set the value of an uniform to an array of float32 (stored as vec3)
  47187. * @param uniform defines the webGL uniform location where to store the value
  47188. * @param array defines the array of float32 to store
  47189. */
  47190. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47191. /**
  47192. * Set the value of an uniform to an array of float32 (stored as vec4)
  47193. * @param uniform defines the webGL uniform location where to store the value
  47194. * @param array defines the array of float32 to store
  47195. */
  47196. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47197. /**
  47198. * Set the value of an uniform to an array of number
  47199. * @param uniform defines the webGL uniform location where to store the value
  47200. * @param array defines the array of number to store
  47201. */
  47202. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47203. /**
  47204. * Set the value of an uniform to an array of number (stored as vec2)
  47205. * @param uniform defines the webGL uniform location where to store the value
  47206. * @param array defines the array of number to store
  47207. */
  47208. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47209. /**
  47210. * Set the value of an uniform to an array of number (stored as vec3)
  47211. * @param uniform defines the webGL uniform location where to store the value
  47212. * @param array defines the array of number to store
  47213. */
  47214. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47215. /**
  47216. * Set the value of an uniform to an array of number (stored as vec4)
  47217. * @param uniform defines the webGL uniform location where to store the value
  47218. * @param array defines the array of number to store
  47219. */
  47220. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47221. /**
  47222. * Set the value of an uniform to an array of float32 (stored as matrices)
  47223. * @param uniform defines the webGL uniform location where to store the value
  47224. * @param matrices defines the array of float32 to store
  47225. */
  47226. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47227. /**
  47228. * Set the value of an uniform to a matrix (3x3)
  47229. * @param uniform defines the webGL uniform location where to store the value
  47230. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47231. */
  47232. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47233. /**
  47234. * Set the value of an uniform to a matrix (2x2)
  47235. * @param uniform defines the webGL uniform location where to store the value
  47236. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47237. */
  47238. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47239. /**
  47240. * Set the value of an uniform to a number (float)
  47241. * @param uniform defines the webGL uniform location where to store the value
  47242. * @param value defines the float number to store
  47243. */
  47244. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47245. /**
  47246. * Set the value of an uniform to a vec2
  47247. * @param uniform defines the webGL uniform location where to store the value
  47248. * @param x defines the 1st component of the value
  47249. * @param y defines the 2nd component of the value
  47250. */
  47251. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47252. /**
  47253. * Set the value of an uniform to a vec3
  47254. * @param uniform defines the webGL uniform location where to store the value
  47255. * @param x defines the 1st component of the value
  47256. * @param y defines the 2nd component of the value
  47257. * @param z defines the 3rd component of the value
  47258. */
  47259. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47260. /**
  47261. * Set the value of an uniform to a boolean
  47262. * @param uniform defines the webGL uniform location where to store the value
  47263. * @param bool defines the boolean to store
  47264. */
  47265. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47266. /**
  47267. * Set the value of an uniform to a vec4
  47268. * @param uniform defines the webGL uniform location where to store the value
  47269. * @param x defines the 1st component of the value
  47270. * @param y defines the 2nd component of the value
  47271. * @param z defines the 3rd component of the value
  47272. * @param w defines the 4th component of the value
  47273. */
  47274. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47275. /**
  47276. * Sets the current alpha mode
  47277. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47278. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47279. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47280. */
  47281. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47282. /**
  47283. * Bind webGl buffers directly to the webGL context
  47284. * @param vertexBuffers defines the vertex buffer to bind
  47285. * @param indexBuffer defines the index buffer to bind
  47286. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47287. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47288. * @param effect defines the effect associated with the vertex buffer
  47289. */
  47290. bindBuffers(vertexBuffers: {
  47291. [key: string]: VertexBuffer;
  47292. }, indexBuffer: DataBuffer, effect: Effect): void;
  47293. /**
  47294. * Force the entire cache to be cleared
  47295. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47296. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47297. */
  47298. wipeCaches(bruteForce?: boolean): void;
  47299. /**
  47300. * Send a draw order
  47301. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47302. * @param indexStart defines the starting index
  47303. * @param indexCount defines the number of index to draw
  47304. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47305. */
  47306. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47307. /**
  47308. * Draw a list of indexed primitives
  47309. * @param fillMode defines the primitive to use
  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. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47315. /**
  47316. * Draw a list of unindexed primitives
  47317. * @param fillMode defines the primitive to use
  47318. * @param verticesStart defines the index of first vertex to draw
  47319. * @param verticesCount defines the count of vertices to draw
  47320. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47321. */
  47322. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47323. /** @hidden */
  47324. _createTexture(): WebGLTexture;
  47325. /** @hidden */
  47326. _releaseTexture(texture: InternalTexture): void;
  47327. /**
  47328. * Usually called from Texture.ts.
  47329. * Passed information to create a WebGLTexture
  47330. * @param urlArg defines a value which contains one of the following:
  47331. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47332. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47333. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47334. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47335. * @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)
  47336. * @param scene needed for loading to the correct scene
  47337. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47338. * @param onLoad optional callback to be called upon successful completion
  47339. * @param onError optional callback to be called upon failure
  47340. * @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
  47341. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47342. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47343. * @param forcedExtension defines the extension to use to pick the right loader
  47344. * @param mimeType defines an optional mime type
  47345. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47346. */
  47347. 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;
  47348. /**
  47349. * Creates a new render target texture
  47350. * @param size defines the size of the texture
  47351. * @param options defines the options used to create the texture
  47352. * @returns a new render target texture stored in an InternalTexture
  47353. */
  47354. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47355. /**
  47356. * Update the sampling mode of a given texture
  47357. * @param samplingMode defines the required sampling mode
  47358. * @param texture defines the texture to update
  47359. */
  47360. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47361. /**
  47362. * Binds the frame buffer to the specified texture.
  47363. * @param texture The texture to render to or null for the default canvas
  47364. * @param faceIndex The face of the texture to render to in case of cube texture
  47365. * @param requiredWidth The width of the target to render to
  47366. * @param requiredHeight The height of the target to render to
  47367. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47368. * @param lodLevel defines le lod level to bind to the frame buffer
  47369. */
  47370. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47371. /**
  47372. * Unbind the current render target texture from the webGL context
  47373. * @param texture defines the render target texture to unbind
  47374. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47375. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47376. */
  47377. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47378. /**
  47379. * Creates a dynamic vertex buffer
  47380. * @param vertices the data for the dynamic vertex buffer
  47381. * @returns the new WebGL dynamic buffer
  47382. */
  47383. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47384. /**
  47385. * Update the content of a dynamic texture
  47386. * @param texture defines the texture to update
  47387. * @param canvas defines the canvas containing the source
  47388. * @param invertY defines if data must be stored with Y axis inverted
  47389. * @param premulAlpha defines if alpha is stored as premultiplied
  47390. * @param format defines the format of the data
  47391. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47392. */
  47393. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47394. /**
  47395. * Gets a boolean indicating if all created effects are ready
  47396. * @returns true if all effects are ready
  47397. */
  47398. areAllEffectsReady(): boolean;
  47399. /**
  47400. * @hidden
  47401. * Get the current error code of the webGL context
  47402. * @returns the error code
  47403. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47404. */
  47405. getError(): number;
  47406. /** @hidden */
  47407. _getUnpackAlignement(): number;
  47408. /** @hidden */
  47409. _unpackFlipY(value: boolean): void;
  47410. /**
  47411. * Update a dynamic index buffer
  47412. * @param indexBuffer defines the target index buffer
  47413. * @param indices defines the data to update
  47414. * @param offset defines the offset in the target index buffer where update should start
  47415. */
  47416. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47417. /**
  47418. * Updates a dynamic vertex buffer.
  47419. * @param vertexBuffer the vertex buffer to update
  47420. * @param vertices the data used to update the vertex buffer
  47421. * @param byteOffset the byte offset of the data (optional)
  47422. * @param byteLength the byte length of the data (optional)
  47423. */
  47424. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47425. /** @hidden */
  47426. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47427. /** @hidden */
  47428. _bindTexture(channel: number, texture: InternalTexture): void;
  47429. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47430. /**
  47431. * 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
  47432. */
  47433. releaseEffects(): void;
  47434. displayLoadingUI(): void;
  47435. hideLoadingUI(): void;
  47436. /** @hidden */
  47437. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47438. /** @hidden */
  47439. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47440. /** @hidden */
  47441. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47442. /** @hidden */
  47443. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47444. }
  47445. }
  47446. declare module BABYLON {
  47447. /**
  47448. * @hidden
  47449. **/
  47450. export class _TimeToken {
  47451. _startTimeQuery: Nullable<WebGLQuery>;
  47452. _endTimeQuery: Nullable<WebGLQuery>;
  47453. _timeElapsedQuery: Nullable<WebGLQuery>;
  47454. _timeElapsedQueryEnded: boolean;
  47455. }
  47456. }
  47457. declare module BABYLON {
  47458. /** @hidden */
  47459. export class _OcclusionDataStorage {
  47460. /** @hidden */
  47461. occlusionInternalRetryCounter: number;
  47462. /** @hidden */
  47463. isOcclusionQueryInProgress: boolean;
  47464. /** @hidden */
  47465. isOccluded: boolean;
  47466. /** @hidden */
  47467. occlusionRetryCount: number;
  47468. /** @hidden */
  47469. occlusionType: number;
  47470. /** @hidden */
  47471. occlusionQueryAlgorithmType: number;
  47472. }
  47473. interface Engine {
  47474. /**
  47475. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47476. * @return the new query
  47477. */
  47478. createQuery(): WebGLQuery;
  47479. /**
  47480. * Delete and release a webGL query
  47481. * @param query defines the query to delete
  47482. * @return the current engine
  47483. */
  47484. deleteQuery(query: WebGLQuery): Engine;
  47485. /**
  47486. * Check if a given query has resolved and got its value
  47487. * @param query defines the query to check
  47488. * @returns true if the query got its value
  47489. */
  47490. isQueryResultAvailable(query: WebGLQuery): boolean;
  47491. /**
  47492. * Gets the value of a given query
  47493. * @param query defines the query to check
  47494. * @returns the value of the query
  47495. */
  47496. getQueryResult(query: WebGLQuery): number;
  47497. /**
  47498. * Initiates an occlusion query
  47499. * @param algorithmType defines the algorithm to use
  47500. * @param query defines the query to use
  47501. * @returns the current engine
  47502. * @see http://doc.babylonjs.com/features/occlusionquery
  47503. */
  47504. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47505. /**
  47506. * Ends an occlusion query
  47507. * @see http://doc.babylonjs.com/features/occlusionquery
  47508. * @param algorithmType defines the algorithm to use
  47509. * @returns the current engine
  47510. */
  47511. endOcclusionQuery(algorithmType: number): Engine;
  47512. /**
  47513. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47514. * Please note that only one query can be issued at a time
  47515. * @returns a time token used to track the time span
  47516. */
  47517. startTimeQuery(): Nullable<_TimeToken>;
  47518. /**
  47519. * Ends a time query
  47520. * @param token defines the token used to measure the time span
  47521. * @returns the time spent (in ns)
  47522. */
  47523. endTimeQuery(token: _TimeToken): int;
  47524. /** @hidden */
  47525. _currentNonTimestampToken: Nullable<_TimeToken>;
  47526. /** @hidden */
  47527. _createTimeQuery(): WebGLQuery;
  47528. /** @hidden */
  47529. _deleteTimeQuery(query: WebGLQuery): void;
  47530. /** @hidden */
  47531. _getGlAlgorithmType(algorithmType: number): number;
  47532. /** @hidden */
  47533. _getTimeQueryResult(query: WebGLQuery): any;
  47534. /** @hidden */
  47535. _getTimeQueryAvailability(query: WebGLQuery): any;
  47536. }
  47537. interface AbstractMesh {
  47538. /**
  47539. * Backing filed
  47540. * @hidden
  47541. */
  47542. __occlusionDataStorage: _OcclusionDataStorage;
  47543. /**
  47544. * Access property
  47545. * @hidden
  47546. */
  47547. _occlusionDataStorage: _OcclusionDataStorage;
  47548. /**
  47549. * 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.
  47550. * The default value is -1 which means don't break the query and wait till the result
  47551. * @see http://doc.babylonjs.com/features/occlusionquery
  47552. */
  47553. occlusionRetryCount: number;
  47554. /**
  47555. * 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:
  47556. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47557. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47558. * * 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.
  47559. * @see http://doc.babylonjs.com/features/occlusionquery
  47560. */
  47561. occlusionType: number;
  47562. /**
  47563. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47564. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47565. * * 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.
  47566. * @see http://doc.babylonjs.com/features/occlusionquery
  47567. */
  47568. occlusionQueryAlgorithmType: number;
  47569. /**
  47570. * 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
  47571. * @see http://doc.babylonjs.com/features/occlusionquery
  47572. */
  47573. isOccluded: boolean;
  47574. /**
  47575. * Flag to check the progress status of the query
  47576. * @see http://doc.babylonjs.com/features/occlusionquery
  47577. */
  47578. isOcclusionQueryInProgress: boolean;
  47579. }
  47580. }
  47581. declare module BABYLON {
  47582. /** @hidden */
  47583. export var _forceTransformFeedbackToBundle: boolean;
  47584. interface Engine {
  47585. /**
  47586. * Creates a webGL transform feedback object
  47587. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47588. * @returns the webGL transform feedback object
  47589. */
  47590. createTransformFeedback(): WebGLTransformFeedback;
  47591. /**
  47592. * Delete a webGL transform feedback object
  47593. * @param value defines the webGL transform feedback object to delete
  47594. */
  47595. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47596. /**
  47597. * Bind a webGL transform feedback object to the webgl context
  47598. * @param value defines the webGL transform feedback object to bind
  47599. */
  47600. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47601. /**
  47602. * Begins a transform feedback operation
  47603. * @param usePoints defines if points or triangles must be used
  47604. */
  47605. beginTransformFeedback(usePoints: boolean): void;
  47606. /**
  47607. * Ends a transform feedback operation
  47608. */
  47609. endTransformFeedback(): void;
  47610. /**
  47611. * Specify the varyings to use with transform feedback
  47612. * @param program defines the associated webGL program
  47613. * @param value defines the list of strings representing the varying names
  47614. */
  47615. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47616. /**
  47617. * Bind a webGL buffer for a transform feedback operation
  47618. * @param value defines the webGL buffer to bind
  47619. */
  47620. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47621. }
  47622. }
  47623. declare module BABYLON {
  47624. /**
  47625. * Creation options of the multi render target texture.
  47626. */
  47627. export interface IMultiRenderTargetOptions {
  47628. /**
  47629. * Define if the texture needs to create mip maps after render.
  47630. */
  47631. generateMipMaps?: boolean;
  47632. /**
  47633. * Define the types of all the draw buffers we want to create
  47634. */
  47635. types?: number[];
  47636. /**
  47637. * Define the sampling modes of all the draw buffers we want to create
  47638. */
  47639. samplingModes?: number[];
  47640. /**
  47641. * Define if a depth buffer is required
  47642. */
  47643. generateDepthBuffer?: boolean;
  47644. /**
  47645. * Define if a stencil buffer is required
  47646. */
  47647. generateStencilBuffer?: boolean;
  47648. /**
  47649. * Define if a depth texture is required instead of a depth buffer
  47650. */
  47651. generateDepthTexture?: boolean;
  47652. /**
  47653. * Define the number of desired draw buffers
  47654. */
  47655. textureCount?: number;
  47656. /**
  47657. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47658. */
  47659. doNotChangeAspectRatio?: boolean;
  47660. /**
  47661. * Define the default type of the buffers we are creating
  47662. */
  47663. defaultType?: number;
  47664. }
  47665. /**
  47666. * A multi render target, like a render target provides the ability to render to a texture.
  47667. * Unlike the render target, it can render to several draw buffers in one draw.
  47668. * This is specially interesting in deferred rendering or for any effects requiring more than
  47669. * just one color from a single pass.
  47670. */
  47671. export class MultiRenderTarget extends RenderTargetTexture {
  47672. private _internalTextures;
  47673. private _textures;
  47674. private _multiRenderTargetOptions;
  47675. /**
  47676. * Get if draw buffers are currently supported by the used hardware and browser.
  47677. */
  47678. get isSupported(): boolean;
  47679. /**
  47680. * Get the list of textures generated by the multi render target.
  47681. */
  47682. get textures(): Texture[];
  47683. /**
  47684. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47685. */
  47686. get depthTexture(): Texture;
  47687. /**
  47688. * Set the wrapping mode on U of all the textures we are rendering to.
  47689. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47690. */
  47691. set wrapU(wrap: number);
  47692. /**
  47693. * Set the wrapping mode on V of all the textures we are rendering to.
  47694. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47695. */
  47696. set wrapV(wrap: number);
  47697. /**
  47698. * Instantiate a new multi render target texture.
  47699. * A multi render target, like a render target provides the ability to render to a texture.
  47700. * Unlike the render target, it can render to several draw buffers in one draw.
  47701. * This is specially interesting in deferred rendering or for any effects requiring more than
  47702. * just one color from a single pass.
  47703. * @param name Define the name of the texture
  47704. * @param size Define the size of the buffers to render to
  47705. * @param count Define the number of target we are rendering into
  47706. * @param scene Define the scene the texture belongs to
  47707. * @param options Define the options used to create the multi render target
  47708. */
  47709. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47710. /** @hidden */
  47711. _rebuild(): void;
  47712. private _createInternalTextures;
  47713. private _createTextures;
  47714. /**
  47715. * Define the number of samples used if MSAA is enabled.
  47716. */
  47717. get samples(): number;
  47718. set samples(value: number);
  47719. /**
  47720. * Resize all the textures in the multi render target.
  47721. * Be carrefull as it will recreate all the data in the new texture.
  47722. * @param size Define the new size
  47723. */
  47724. resize(size: any): void;
  47725. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47726. /**
  47727. * Dispose the render targets and their associated resources
  47728. */
  47729. dispose(): void;
  47730. /**
  47731. * Release all the underlying texture used as draw buffers.
  47732. */
  47733. releaseInternalTextures(): void;
  47734. }
  47735. }
  47736. declare module BABYLON {
  47737. interface ThinEngine {
  47738. /**
  47739. * Unbind a list of render target textures from the webGL context
  47740. * This is used only when drawBuffer extension or webGL2 are active
  47741. * @param textures defines the render target textures to unbind
  47742. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47743. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47744. */
  47745. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47746. /**
  47747. * Create a multi render target texture
  47748. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47749. * @param size defines the size of the texture
  47750. * @param options defines the creation options
  47751. * @returns the cube texture as an InternalTexture
  47752. */
  47753. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47754. /**
  47755. * Update the sample count for a given multiple render target texture
  47756. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47757. * @param textures defines the textures to update
  47758. * @param samples defines the sample count to set
  47759. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47760. */
  47761. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47762. }
  47763. }
  47764. declare module BABYLON {
  47765. /**
  47766. * Class used to define an additional view for the engine
  47767. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47768. */
  47769. export class EngineView {
  47770. /** Defines the canvas where to render the view */
  47771. target: HTMLCanvasElement;
  47772. /** Defines an optional camera used to render the view (will use active camera else) */
  47773. camera?: Camera;
  47774. }
  47775. interface Engine {
  47776. /**
  47777. * Gets or sets the HTML element to use for attaching events
  47778. */
  47779. inputElement: Nullable<HTMLElement>;
  47780. /**
  47781. * Gets the current engine view
  47782. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47783. */
  47784. activeView: Nullable<EngineView>;
  47785. /** Gets or sets the list of views */
  47786. views: EngineView[];
  47787. /**
  47788. * Register a new child canvas
  47789. * @param canvas defines the canvas to register
  47790. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47791. * @returns the associated view
  47792. */
  47793. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47794. /**
  47795. * Remove a registered child canvas
  47796. * @param canvas defines the canvas to remove
  47797. * @returns the current engine
  47798. */
  47799. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47800. }
  47801. }
  47802. declare module BABYLON {
  47803. interface Engine {
  47804. /** @hidden */
  47805. _excludedCompressedTextures: string[];
  47806. /** @hidden */
  47807. _textureFormatInUse: string;
  47808. /**
  47809. * Gets the list of texture formats supported
  47810. */
  47811. readonly texturesSupported: Array<string>;
  47812. /**
  47813. * Gets the texture format in use
  47814. */
  47815. readonly textureFormatInUse: Nullable<string>;
  47816. /**
  47817. * Set the compressed texture extensions or file names to skip.
  47818. *
  47819. * @param skippedFiles defines the list of those texture files you want to skip
  47820. * Example: [".dds", ".env", "myfile.png"]
  47821. */
  47822. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47823. /**
  47824. * Set the compressed texture format to use, based on the formats you have, and the formats
  47825. * supported by the hardware / browser.
  47826. *
  47827. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47828. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47829. * to API arguments needed to compressed textures. This puts the burden on the container
  47830. * generator to house the arcane code for determining these for current & future formats.
  47831. *
  47832. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47833. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47834. *
  47835. * Note: The result of this call is not taken into account when a texture is base64.
  47836. *
  47837. * @param formatsAvailable defines the list of those format families you have created
  47838. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47839. *
  47840. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47841. * @returns The extension selected.
  47842. */
  47843. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47844. }
  47845. }
  47846. declare module BABYLON {
  47847. /**
  47848. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47849. */
  47850. export interface CubeMapInfo {
  47851. /**
  47852. * The pixel array for the front face.
  47853. * This is stored in format, left to right, up to down format.
  47854. */
  47855. front: Nullable<ArrayBufferView>;
  47856. /**
  47857. * The pixel array for the back face.
  47858. * This is stored in format, left to right, up to down format.
  47859. */
  47860. back: Nullable<ArrayBufferView>;
  47861. /**
  47862. * The pixel array for the left face.
  47863. * This is stored in format, left to right, up to down format.
  47864. */
  47865. left: Nullable<ArrayBufferView>;
  47866. /**
  47867. * The pixel array for the right face.
  47868. * This is stored in format, left to right, up to down format.
  47869. */
  47870. right: Nullable<ArrayBufferView>;
  47871. /**
  47872. * The pixel array for the up face.
  47873. * This is stored in format, left to right, up to down format.
  47874. */
  47875. up: Nullable<ArrayBufferView>;
  47876. /**
  47877. * The pixel array for the down face.
  47878. * This is stored in format, left to right, up to down format.
  47879. */
  47880. down: Nullable<ArrayBufferView>;
  47881. /**
  47882. * The size of the cubemap stored.
  47883. *
  47884. * Each faces will be size * size pixels.
  47885. */
  47886. size: number;
  47887. /**
  47888. * The format of the texture.
  47889. *
  47890. * RGBA, RGB.
  47891. */
  47892. format: number;
  47893. /**
  47894. * The type of the texture data.
  47895. *
  47896. * UNSIGNED_INT, FLOAT.
  47897. */
  47898. type: number;
  47899. /**
  47900. * Specifies whether the texture is in gamma space.
  47901. */
  47902. gammaSpace: boolean;
  47903. }
  47904. /**
  47905. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47906. */
  47907. export class PanoramaToCubeMapTools {
  47908. private static FACE_FRONT;
  47909. private static FACE_BACK;
  47910. private static FACE_RIGHT;
  47911. private static FACE_LEFT;
  47912. private static FACE_DOWN;
  47913. private static FACE_UP;
  47914. /**
  47915. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47916. *
  47917. * @param float32Array The source data.
  47918. * @param inputWidth The width of the input panorama.
  47919. * @param inputHeight The height of the input panorama.
  47920. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47921. * @return The cubemap data
  47922. */
  47923. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47924. private static CreateCubemapTexture;
  47925. private static CalcProjectionSpherical;
  47926. }
  47927. }
  47928. declare module BABYLON {
  47929. /**
  47930. * Helper class dealing with the extraction of spherical polynomial dataArray
  47931. * from a cube map.
  47932. */
  47933. export class CubeMapToSphericalPolynomialTools {
  47934. private static FileFaces;
  47935. /**
  47936. * Converts a texture to the according Spherical Polynomial data.
  47937. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47938. *
  47939. * @param texture The texture to extract the information from.
  47940. * @return The Spherical Polynomial data.
  47941. */
  47942. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47943. /**
  47944. * Converts a cubemap 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 cubeInfo The Cube map to extract the information from.
  47948. * @return The Spherical Polynomial data.
  47949. */
  47950. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47951. }
  47952. }
  47953. declare module BABYLON {
  47954. interface BaseTexture {
  47955. /**
  47956. * Get the polynomial representation of the texture data.
  47957. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47958. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47959. */
  47960. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47961. }
  47962. }
  47963. declare module BABYLON {
  47964. /** @hidden */
  47965. export var rgbdEncodePixelShader: {
  47966. name: string;
  47967. shader: string;
  47968. };
  47969. }
  47970. declare module BABYLON {
  47971. /** @hidden */
  47972. export var rgbdDecodePixelShader: {
  47973. name: string;
  47974. shader: string;
  47975. };
  47976. }
  47977. declare module BABYLON {
  47978. /**
  47979. * Raw texture data and descriptor sufficient for WebGL texture upload
  47980. */
  47981. export interface EnvironmentTextureInfo {
  47982. /**
  47983. * Version of the environment map
  47984. */
  47985. version: number;
  47986. /**
  47987. * Width of image
  47988. */
  47989. width: number;
  47990. /**
  47991. * Irradiance information stored in the file.
  47992. */
  47993. irradiance: any;
  47994. /**
  47995. * Specular information stored in the file.
  47996. */
  47997. specular: any;
  47998. }
  47999. /**
  48000. * Defines One Image in the file. It requires only the position in the file
  48001. * as well as the length.
  48002. */
  48003. interface BufferImageData {
  48004. /**
  48005. * Length of the image data.
  48006. */
  48007. length: number;
  48008. /**
  48009. * Position of the data from the null terminator delimiting the end of the JSON.
  48010. */
  48011. position: number;
  48012. }
  48013. /**
  48014. * Defines the specular data enclosed in the file.
  48015. * This corresponds to the version 1 of the data.
  48016. */
  48017. export interface EnvironmentTextureSpecularInfoV1 {
  48018. /**
  48019. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48020. */
  48021. specularDataPosition?: number;
  48022. /**
  48023. * This contains all the images data needed to reconstruct the cubemap.
  48024. */
  48025. mipmaps: Array<BufferImageData>;
  48026. /**
  48027. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48028. */
  48029. lodGenerationScale: number;
  48030. }
  48031. /**
  48032. * Sets of helpers addressing the serialization and deserialization of environment texture
  48033. * stored in a BabylonJS env file.
  48034. * Those files are usually stored as .env files.
  48035. */
  48036. export class EnvironmentTextureTools {
  48037. /**
  48038. * Magic number identifying the env file.
  48039. */
  48040. private static _MagicBytes;
  48041. /**
  48042. * Gets the environment info from an env file.
  48043. * @param data The array buffer containing the .env bytes.
  48044. * @returns the environment file info (the json header) if successfully parsed.
  48045. */
  48046. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  48047. /**
  48048. * Creates an environment texture from a loaded cube texture.
  48049. * @param texture defines the cube texture to convert in env file
  48050. * @return a promise containing the environment data if succesfull.
  48051. */
  48052. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48053. /**
  48054. * Creates a JSON representation of the spherical data.
  48055. * @param texture defines the texture containing the polynomials
  48056. * @return the JSON representation of the spherical info
  48057. */
  48058. private static _CreateEnvTextureIrradiance;
  48059. /**
  48060. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48061. * @param data the image data
  48062. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48063. * @return the views described by info providing access to the underlying buffer
  48064. */
  48065. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48066. /**
  48067. * Uploads the texture info contained in the env file to the GPU.
  48068. * @param texture defines the internal texture to upload to
  48069. * @param data defines the data to load
  48070. * @param info defines the texture info retrieved through the GetEnvInfo method
  48071. * @returns a promise
  48072. */
  48073. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  48074. private static _OnImageReadyAsync;
  48075. /**
  48076. * Uploads the levels of image data to the GPU.
  48077. * @param texture defines the internal texture to upload to
  48078. * @param imageData defines the array buffer views of image data [mipmap][face]
  48079. * @returns a promise
  48080. */
  48081. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48082. /**
  48083. * Uploads spherical polynomials information to the texture.
  48084. * @param texture defines the texture we are trying to upload the information to
  48085. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48086. */
  48087. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48088. /** @hidden */
  48089. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48090. }
  48091. }
  48092. declare module BABYLON {
  48093. /**
  48094. * Contains position and normal vectors for a vertex
  48095. */
  48096. export class PositionNormalVertex {
  48097. /** the position of the vertex (defaut: 0,0,0) */
  48098. position: Vector3;
  48099. /** the normal of the vertex (defaut: 0,1,0) */
  48100. normal: Vector3;
  48101. /**
  48102. * Creates a PositionNormalVertex
  48103. * @param position the position of the vertex (defaut: 0,0,0)
  48104. * @param normal the normal of the vertex (defaut: 0,1,0)
  48105. */
  48106. constructor(
  48107. /** the position of the vertex (defaut: 0,0,0) */
  48108. position?: Vector3,
  48109. /** the normal of the vertex (defaut: 0,1,0) */
  48110. normal?: Vector3);
  48111. /**
  48112. * Clones the PositionNormalVertex
  48113. * @returns the cloned PositionNormalVertex
  48114. */
  48115. clone(): PositionNormalVertex;
  48116. }
  48117. /**
  48118. * Contains position, normal and uv vectors for a vertex
  48119. */
  48120. export class PositionNormalTextureVertex {
  48121. /** the position of the vertex (defaut: 0,0,0) */
  48122. position: Vector3;
  48123. /** the normal of the vertex (defaut: 0,1,0) */
  48124. normal: Vector3;
  48125. /** the uv of the vertex (default: 0,0) */
  48126. uv: Vector2;
  48127. /**
  48128. * Creates a PositionNormalTextureVertex
  48129. * @param position the position of the vertex (defaut: 0,0,0)
  48130. * @param normal the normal of the vertex (defaut: 0,1,0)
  48131. * @param uv the uv of the vertex (default: 0,0)
  48132. */
  48133. constructor(
  48134. /** the position of the vertex (defaut: 0,0,0) */
  48135. position?: Vector3,
  48136. /** the normal of the vertex (defaut: 0,1,0) */
  48137. normal?: Vector3,
  48138. /** the uv of the vertex (default: 0,0) */
  48139. uv?: Vector2);
  48140. /**
  48141. * Clones the PositionNormalTextureVertex
  48142. * @returns the cloned PositionNormalTextureVertex
  48143. */
  48144. clone(): PositionNormalTextureVertex;
  48145. }
  48146. }
  48147. declare module BABYLON {
  48148. /** @hidden */
  48149. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48150. private _genericAttributeLocation;
  48151. private _varyingLocationCount;
  48152. private _varyingLocationMap;
  48153. private _replacements;
  48154. private _textureCount;
  48155. private _uniforms;
  48156. lineProcessor(line: string): string;
  48157. attributeProcessor(attribute: string): string;
  48158. varyingProcessor(varying: string, isFragment: boolean): string;
  48159. uniformProcessor(uniform: string): string;
  48160. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48161. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48162. }
  48163. }
  48164. declare module BABYLON {
  48165. /**
  48166. * Container for accessors for natively-stored mesh data buffers.
  48167. */
  48168. class NativeDataBuffer extends DataBuffer {
  48169. /**
  48170. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48171. */
  48172. nativeIndexBuffer?: any;
  48173. /**
  48174. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48175. */
  48176. nativeVertexBuffer?: any;
  48177. }
  48178. /** @hidden */
  48179. class NativeTexture extends InternalTexture {
  48180. getInternalTexture(): InternalTexture;
  48181. getViewCount(): number;
  48182. }
  48183. /** @hidden */
  48184. export class NativeEngine extends Engine {
  48185. private readonly _native;
  48186. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48187. private readonly INVALID_HANDLE;
  48188. getHardwareScalingLevel(): number;
  48189. constructor();
  48190. dispose(): void;
  48191. /**
  48192. * Can be used to override the current requestAnimationFrame requester.
  48193. * @hidden
  48194. */
  48195. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48196. /**
  48197. * Override default engine behavior.
  48198. * @param color
  48199. * @param backBuffer
  48200. * @param depth
  48201. * @param stencil
  48202. */
  48203. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48204. /**
  48205. * Gets host document
  48206. * @returns the host document object
  48207. */
  48208. getHostDocument(): Nullable<Document>;
  48209. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48210. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48211. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48212. recordVertexArrayObject(vertexBuffers: {
  48213. [key: string]: VertexBuffer;
  48214. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48215. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48216. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48217. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48218. /**
  48219. * Draw a list of indexed primitives
  48220. * @param fillMode defines the primitive to use
  48221. * @param indexStart defines the starting index
  48222. * @param indexCount defines the number of index to draw
  48223. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48224. */
  48225. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48226. /**
  48227. * Draw a list of unindexed primitives
  48228. * @param fillMode defines the primitive to use
  48229. * @param verticesStart defines the index of first vertex to draw
  48230. * @param verticesCount defines the count of vertices to draw
  48231. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48232. */
  48233. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48234. createPipelineContext(): IPipelineContext;
  48235. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48236. /** @hidden */
  48237. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48238. /** @hidden */
  48239. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48240. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48241. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48242. protected _setProgram(program: WebGLProgram): void;
  48243. _releaseEffect(effect: Effect): void;
  48244. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48245. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48246. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48247. bindSamplers(effect: Effect): void;
  48248. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48249. getRenderWidth(useScreen?: boolean): number;
  48250. getRenderHeight(useScreen?: boolean): number;
  48251. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48252. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48253. /**
  48254. * Set the z offset to apply to current rendering
  48255. * @param value defines the offset to apply
  48256. */
  48257. setZOffset(value: number): void;
  48258. /**
  48259. * Gets the current value of the zOffset
  48260. * @returns the current zOffset state
  48261. */
  48262. getZOffset(): number;
  48263. /**
  48264. * Enable or disable depth buffering
  48265. * @param enable defines the state to set
  48266. */
  48267. setDepthBuffer(enable: boolean): void;
  48268. /**
  48269. * Gets a boolean indicating if depth writing is enabled
  48270. * @returns the current depth writing state
  48271. */
  48272. getDepthWrite(): boolean;
  48273. /**
  48274. * Enable or disable depth writing
  48275. * @param enable defines the state to set
  48276. */
  48277. setDepthWrite(enable: boolean): void;
  48278. /**
  48279. * Enable or disable color writing
  48280. * @param enable defines the state to set
  48281. */
  48282. setColorWrite(enable: boolean): void;
  48283. /**
  48284. * Gets a boolean indicating if color writing is enabled
  48285. * @returns the current color writing state
  48286. */
  48287. getColorWrite(): boolean;
  48288. /**
  48289. * Sets alpha constants used by some alpha blending modes
  48290. * @param r defines the red component
  48291. * @param g defines the green component
  48292. * @param b defines the blue component
  48293. * @param a defines the alpha component
  48294. */
  48295. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48296. /**
  48297. * Sets the current alpha mode
  48298. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48299. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48300. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48301. */
  48302. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48303. /**
  48304. * Gets the current alpha mode
  48305. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48306. * @returns the current alpha mode
  48307. */
  48308. getAlphaMode(): number;
  48309. setInt(uniform: WebGLUniformLocation, int: number): void;
  48310. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48311. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48312. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48313. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48314. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48315. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48316. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48317. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48318. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48319. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48320. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48321. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48322. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48323. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48324. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48325. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48326. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48327. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48328. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48329. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48330. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48331. wipeCaches(bruteForce?: boolean): void;
  48332. _createTexture(): WebGLTexture;
  48333. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48334. /**
  48335. * Usually called from Texture.ts.
  48336. * Passed information to create a WebGLTexture
  48337. * @param url defines a value which contains one of the following:
  48338. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48339. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48340. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48341. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48342. * @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)
  48343. * @param scene needed for loading to the correct scene
  48344. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48345. * @param onLoad optional callback to be called upon successful completion
  48346. * @param onError optional callback to be called upon failure
  48347. * @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
  48348. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48349. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48350. * @param forcedExtension defines the extension to use to pick the right loader
  48351. * @param mimeType defines an optional mime type
  48352. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48353. */
  48354. 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;
  48355. /**
  48356. * Creates a cube texture
  48357. * @param rootUrl defines the url where the files to load is located
  48358. * @param scene defines the current scene
  48359. * @param files defines the list of files to load (1 per face)
  48360. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48361. * @param onLoad defines an optional callback raised when the texture is loaded
  48362. * @param onError defines an optional callback raised if there is an issue to load the texture
  48363. * @param format defines the format of the data
  48364. * @param forcedExtension defines the extension to use to pick the right loader
  48365. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48366. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48367. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48368. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48369. * @returns the cube texture as an InternalTexture
  48370. */
  48371. 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;
  48372. private _getSamplingFilter;
  48373. private static _GetNativeTextureFormat;
  48374. createRenderTargetTexture(size: number | {
  48375. width: number;
  48376. height: number;
  48377. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48378. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48379. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48380. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48381. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48382. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48383. /**
  48384. * Updates a dynamic vertex buffer.
  48385. * @param vertexBuffer the vertex buffer to update
  48386. * @param data the data used to update the vertex buffer
  48387. * @param byteOffset the byte offset of the data (optional)
  48388. * @param byteLength the byte length of the data (optional)
  48389. */
  48390. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48391. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48392. private _updateAnisotropicLevel;
  48393. private _getAddressMode;
  48394. /** @hidden */
  48395. _bindTexture(channel: number, texture: InternalTexture): void;
  48396. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48397. releaseEffects(): void;
  48398. /** @hidden */
  48399. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48400. /** @hidden */
  48401. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48402. /** @hidden */
  48403. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48404. /** @hidden */
  48405. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48406. }
  48407. }
  48408. declare module BABYLON {
  48409. /**
  48410. * Gather the list of clipboard event types as constants.
  48411. */
  48412. export class ClipboardEventTypes {
  48413. /**
  48414. * The clipboard event is fired when a copy command is active (pressed).
  48415. */
  48416. static readonly COPY: number;
  48417. /**
  48418. * The clipboard event is fired when a cut command is active (pressed).
  48419. */
  48420. static readonly CUT: number;
  48421. /**
  48422. * The clipboard event is fired when a paste command is active (pressed).
  48423. */
  48424. static readonly PASTE: number;
  48425. }
  48426. /**
  48427. * This class is used to store clipboard related info for the onClipboardObservable event.
  48428. */
  48429. export class ClipboardInfo {
  48430. /**
  48431. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48432. */
  48433. type: number;
  48434. /**
  48435. * Defines the related dom event
  48436. */
  48437. event: ClipboardEvent;
  48438. /**
  48439. *Creates an instance of ClipboardInfo.
  48440. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48441. * @param event Defines the related dom event
  48442. */
  48443. constructor(
  48444. /**
  48445. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48446. */
  48447. type: number,
  48448. /**
  48449. * Defines the related dom event
  48450. */
  48451. event: ClipboardEvent);
  48452. /**
  48453. * Get the clipboard event's type from the keycode.
  48454. * @param keyCode Defines the keyCode for the current keyboard event.
  48455. * @return {number}
  48456. */
  48457. static GetTypeFromCharacter(keyCode: number): number;
  48458. }
  48459. }
  48460. declare module BABYLON {
  48461. /**
  48462. * Google Daydream controller
  48463. */
  48464. export class DaydreamController extends WebVRController {
  48465. /**
  48466. * Base Url for the controller model.
  48467. */
  48468. static MODEL_BASE_URL: string;
  48469. /**
  48470. * File name for the controller model.
  48471. */
  48472. static MODEL_FILENAME: string;
  48473. /**
  48474. * Gamepad Id prefix used to identify Daydream Controller.
  48475. */
  48476. static readonly GAMEPAD_ID_PREFIX: string;
  48477. /**
  48478. * Creates a new DaydreamController from a gamepad
  48479. * @param vrGamepad the gamepad that the controller should be created from
  48480. */
  48481. constructor(vrGamepad: any);
  48482. /**
  48483. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48484. * @param scene scene in which to add meshes
  48485. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48486. */
  48487. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48488. /**
  48489. * Called once for each button that changed state since the last frame
  48490. * @param buttonIdx Which button index changed
  48491. * @param state New state of the button
  48492. * @param changes Which properties on the state changed since last frame
  48493. */
  48494. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48495. }
  48496. }
  48497. declare module BABYLON {
  48498. /**
  48499. * Gear VR Controller
  48500. */
  48501. export class GearVRController extends WebVRController {
  48502. /**
  48503. * Base Url for the controller model.
  48504. */
  48505. static MODEL_BASE_URL: string;
  48506. /**
  48507. * File name for the controller model.
  48508. */
  48509. static MODEL_FILENAME: string;
  48510. /**
  48511. * Gamepad Id prefix used to identify this controller.
  48512. */
  48513. static readonly GAMEPAD_ID_PREFIX: string;
  48514. private readonly _buttonIndexToObservableNameMap;
  48515. /**
  48516. * Creates a new GearVRController from a gamepad
  48517. * @param vrGamepad the gamepad that the controller should be created from
  48518. */
  48519. constructor(vrGamepad: any);
  48520. /**
  48521. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48522. * @param scene scene in which to add meshes
  48523. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48524. */
  48525. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48526. /**
  48527. * Called once for each button that changed state since the last frame
  48528. * @param buttonIdx Which button index changed
  48529. * @param state New state of the button
  48530. * @param changes Which properties on the state changed since last frame
  48531. */
  48532. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48533. }
  48534. }
  48535. declare module BABYLON {
  48536. /**
  48537. * Generic Controller
  48538. */
  48539. export class GenericController extends WebVRController {
  48540. /**
  48541. * Base Url for the controller model.
  48542. */
  48543. static readonly MODEL_BASE_URL: string;
  48544. /**
  48545. * File name for the controller model.
  48546. */
  48547. static readonly MODEL_FILENAME: string;
  48548. /**
  48549. * Creates a new GenericController from a gamepad
  48550. * @param vrGamepad the gamepad that the controller should be created from
  48551. */
  48552. constructor(vrGamepad: any);
  48553. /**
  48554. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48555. * @param scene scene in which to add meshes
  48556. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48557. */
  48558. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48559. /**
  48560. * Called once for each button that changed state since the last frame
  48561. * @param buttonIdx Which button index changed
  48562. * @param state New state of the button
  48563. * @param changes Which properties on the state changed since last frame
  48564. */
  48565. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48566. }
  48567. }
  48568. declare module BABYLON {
  48569. /**
  48570. * Oculus Touch Controller
  48571. */
  48572. export class OculusTouchController extends WebVRController {
  48573. /**
  48574. * Base Url for the controller model.
  48575. */
  48576. static MODEL_BASE_URL: string;
  48577. /**
  48578. * File name for the left controller model.
  48579. */
  48580. static MODEL_LEFT_FILENAME: string;
  48581. /**
  48582. * File name for the right controller model.
  48583. */
  48584. static MODEL_RIGHT_FILENAME: string;
  48585. /**
  48586. * Base Url for the Quest controller model.
  48587. */
  48588. static QUEST_MODEL_BASE_URL: string;
  48589. /**
  48590. * @hidden
  48591. * If the controllers are running on a device that needs the updated Quest controller models
  48592. */
  48593. static _IsQuest: boolean;
  48594. /**
  48595. * Fired when the secondary trigger on this controller is modified
  48596. */
  48597. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48598. /**
  48599. * Fired when the thumb rest on this controller is modified
  48600. */
  48601. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48602. /**
  48603. * Creates a new OculusTouchController from a gamepad
  48604. * @param vrGamepad the gamepad that the controller should be created from
  48605. */
  48606. constructor(vrGamepad: any);
  48607. /**
  48608. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48609. * @param scene scene in which to add meshes
  48610. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48611. */
  48612. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48613. /**
  48614. * Fired when the A button on this controller is modified
  48615. */
  48616. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48617. /**
  48618. * Fired when the B button on this controller is modified
  48619. */
  48620. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48621. /**
  48622. * Fired when the X button on this controller is modified
  48623. */
  48624. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48625. /**
  48626. * Fired when the Y button on this controller is modified
  48627. */
  48628. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48629. /**
  48630. * Called once for each button that changed state since the last frame
  48631. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48632. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48633. * 2) secondary trigger (same)
  48634. * 3) A (right) X (left), touch, pressed = value
  48635. * 4) B / Y
  48636. * 5) thumb rest
  48637. * @param buttonIdx Which button index changed
  48638. * @param state New state of the button
  48639. * @param changes Which properties on the state changed since last frame
  48640. */
  48641. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48642. }
  48643. }
  48644. declare module BABYLON {
  48645. /**
  48646. * Vive Controller
  48647. */
  48648. export class ViveController extends WebVRController {
  48649. /**
  48650. * Base Url for the controller model.
  48651. */
  48652. static MODEL_BASE_URL: string;
  48653. /**
  48654. * File name for the controller model.
  48655. */
  48656. static MODEL_FILENAME: string;
  48657. /**
  48658. * Creates a new ViveController from a gamepad
  48659. * @param vrGamepad the gamepad that the controller should be created from
  48660. */
  48661. constructor(vrGamepad: any);
  48662. /**
  48663. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48664. * @param scene scene in which to add meshes
  48665. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48666. */
  48667. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48668. /**
  48669. * Fired when the left button on this controller is modified
  48670. */
  48671. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48672. /**
  48673. * Fired when the right button on this controller is modified
  48674. */
  48675. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48676. /**
  48677. * Fired when the menu button on this controller is modified
  48678. */
  48679. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48680. /**
  48681. * Called once for each button that changed state since the last frame
  48682. * Vive mapping:
  48683. * 0: touchpad
  48684. * 1: trigger
  48685. * 2: left AND right buttons
  48686. * 3: menu button
  48687. * @param buttonIdx Which button index changed
  48688. * @param state New state of the button
  48689. * @param changes Which properties on the state changed since last frame
  48690. */
  48691. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48692. }
  48693. }
  48694. declare module BABYLON {
  48695. /**
  48696. * Defines the WindowsMotionController object that the state of the windows motion controller
  48697. */
  48698. export class WindowsMotionController extends WebVRController {
  48699. /**
  48700. * The base url used to load the left and right controller models
  48701. */
  48702. static MODEL_BASE_URL: string;
  48703. /**
  48704. * The name of the left controller model file
  48705. */
  48706. static MODEL_LEFT_FILENAME: string;
  48707. /**
  48708. * The name of the right controller model file
  48709. */
  48710. static MODEL_RIGHT_FILENAME: string;
  48711. /**
  48712. * The controller name prefix for this controller type
  48713. */
  48714. static readonly GAMEPAD_ID_PREFIX: string;
  48715. /**
  48716. * The controller id pattern for this controller type
  48717. */
  48718. private static readonly GAMEPAD_ID_PATTERN;
  48719. private _loadedMeshInfo;
  48720. protected readonly _mapping: {
  48721. buttons: string[];
  48722. buttonMeshNames: {
  48723. trigger: string;
  48724. menu: string;
  48725. grip: string;
  48726. thumbstick: string;
  48727. trackpad: string;
  48728. };
  48729. buttonObservableNames: {
  48730. trigger: string;
  48731. menu: string;
  48732. grip: string;
  48733. thumbstick: string;
  48734. trackpad: string;
  48735. };
  48736. axisMeshNames: string[];
  48737. pointingPoseMeshName: string;
  48738. };
  48739. /**
  48740. * Fired when the trackpad on this controller is clicked
  48741. */
  48742. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48743. /**
  48744. * Fired when the trackpad on this controller is modified
  48745. */
  48746. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48747. /**
  48748. * The current x and y values of this controller's trackpad
  48749. */
  48750. trackpad: StickValues;
  48751. /**
  48752. * Creates a new WindowsMotionController from a gamepad
  48753. * @param vrGamepad the gamepad that the controller should be created from
  48754. */
  48755. constructor(vrGamepad: any);
  48756. /**
  48757. * Fired when the trigger on this controller is modified
  48758. */
  48759. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48760. /**
  48761. * Fired when the menu button on this controller is modified
  48762. */
  48763. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48764. /**
  48765. * Fired when the grip button on this controller is modified
  48766. */
  48767. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48768. /**
  48769. * Fired when the thumbstick button on this controller is modified
  48770. */
  48771. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48772. /**
  48773. * Fired when the touchpad button on this controller is modified
  48774. */
  48775. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48776. /**
  48777. * Fired when the touchpad values on this controller are modified
  48778. */
  48779. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48780. protected _updateTrackpad(): void;
  48781. /**
  48782. * Called once per frame by the engine.
  48783. */
  48784. update(): void;
  48785. /**
  48786. * Called once for each button that changed state since the last frame
  48787. * @param buttonIdx Which button index changed
  48788. * @param state New state of the button
  48789. * @param changes Which properties on the state changed since last frame
  48790. */
  48791. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48792. /**
  48793. * Moves the buttons on the controller mesh based on their current state
  48794. * @param buttonName the name of the button to move
  48795. * @param buttonValue the value of the button which determines the buttons new position
  48796. */
  48797. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48798. /**
  48799. * Moves the axis on the controller mesh based on its current state
  48800. * @param axis the index of the axis
  48801. * @param axisValue the value of the axis which determines the meshes new position
  48802. * @hidden
  48803. */
  48804. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48805. /**
  48806. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48807. * @param scene scene in which to add meshes
  48808. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48809. */
  48810. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48811. /**
  48812. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48813. * can be transformed by button presses and axes values, based on this._mapping.
  48814. *
  48815. * @param scene scene in which the meshes exist
  48816. * @param meshes list of meshes that make up the controller model to process
  48817. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48818. */
  48819. private processModel;
  48820. private createMeshInfo;
  48821. /**
  48822. * Gets the ray of the controller in the direction the controller is pointing
  48823. * @param length the length the resulting ray should be
  48824. * @returns a ray in the direction the controller is pointing
  48825. */
  48826. getForwardRay(length?: number): Ray;
  48827. /**
  48828. * Disposes of the controller
  48829. */
  48830. dispose(): void;
  48831. }
  48832. /**
  48833. * This class represents a new windows motion controller in XR.
  48834. */
  48835. export class XRWindowsMotionController extends WindowsMotionController {
  48836. /**
  48837. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48838. */
  48839. protected readonly _mapping: {
  48840. buttons: string[];
  48841. buttonMeshNames: {
  48842. trigger: string;
  48843. menu: string;
  48844. grip: string;
  48845. thumbstick: string;
  48846. trackpad: string;
  48847. };
  48848. buttonObservableNames: {
  48849. trigger: string;
  48850. menu: string;
  48851. grip: string;
  48852. thumbstick: string;
  48853. trackpad: string;
  48854. };
  48855. axisMeshNames: string[];
  48856. pointingPoseMeshName: string;
  48857. };
  48858. /**
  48859. * Construct a new XR-Based windows motion controller
  48860. *
  48861. * @param gamepadInfo the gamepad object from the browser
  48862. */
  48863. constructor(gamepadInfo: any);
  48864. /**
  48865. * holds the thumbstick values (X,Y)
  48866. */
  48867. thumbstickValues: StickValues;
  48868. /**
  48869. * Fired when the thumbstick on this controller is clicked
  48870. */
  48871. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48872. /**
  48873. * Fired when the thumbstick on this controller is modified
  48874. */
  48875. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48876. /**
  48877. * Fired when the touchpad button on this controller is modified
  48878. */
  48879. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48880. /**
  48881. * Fired when the touchpad values on this controller are modified
  48882. */
  48883. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48884. /**
  48885. * Fired when the thumbstick button on this controller is modified
  48886. * here to prevent breaking changes
  48887. */
  48888. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48889. /**
  48890. * updating the thumbstick(!) and not the trackpad.
  48891. * This is named this way due to the difference between WebVR and XR and to avoid
  48892. * changing the parent class.
  48893. */
  48894. protected _updateTrackpad(): void;
  48895. /**
  48896. * Disposes the class with joy
  48897. */
  48898. dispose(): void;
  48899. }
  48900. }
  48901. declare module BABYLON {
  48902. /**
  48903. * Class containing static functions to help procedurally build meshes
  48904. */
  48905. export class PolyhedronBuilder {
  48906. /**
  48907. * Creates a polyhedron mesh
  48908. * * 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
  48909. * * The parameter `size` (positive float, default 1) sets the polygon size
  48910. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48911. * * 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`
  48912. * * 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
  48913. * * 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)`)
  48914. * * 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
  48915. * * 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
  48916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48917. * * 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
  48918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48919. * @param name defines the name of the mesh
  48920. * @param options defines the options used to create the mesh
  48921. * @param scene defines the hosting scene
  48922. * @returns the polyhedron mesh
  48923. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48924. */
  48925. static CreatePolyhedron(name: string, options: {
  48926. type?: number;
  48927. size?: number;
  48928. sizeX?: number;
  48929. sizeY?: number;
  48930. sizeZ?: number;
  48931. custom?: any;
  48932. faceUV?: Vector4[];
  48933. faceColors?: Color4[];
  48934. flat?: boolean;
  48935. updatable?: boolean;
  48936. sideOrientation?: number;
  48937. frontUVs?: Vector4;
  48938. backUVs?: Vector4;
  48939. }, scene?: Nullable<Scene>): Mesh;
  48940. }
  48941. }
  48942. declare module BABYLON {
  48943. /**
  48944. * Gizmo that enables scaling a mesh along 3 axis
  48945. */
  48946. export class ScaleGizmo extends Gizmo {
  48947. /**
  48948. * Internal gizmo used for interactions on the x axis
  48949. */
  48950. xGizmo: AxisScaleGizmo;
  48951. /**
  48952. * Internal gizmo used for interactions on the y axis
  48953. */
  48954. yGizmo: AxisScaleGizmo;
  48955. /**
  48956. * Internal gizmo used for interactions on the z axis
  48957. */
  48958. zGizmo: AxisScaleGizmo;
  48959. /**
  48960. * Internal gizmo used to scale all axis equally
  48961. */
  48962. uniformScaleGizmo: AxisScaleGizmo;
  48963. private _meshAttached;
  48964. private _updateGizmoRotationToMatchAttachedMesh;
  48965. private _snapDistance;
  48966. private _scaleRatio;
  48967. private _uniformScalingMesh;
  48968. private _octahedron;
  48969. private _sensitivity;
  48970. /** Fires an event when any of it's sub gizmos are dragged */
  48971. onDragStartObservable: Observable<unknown>;
  48972. /** Fires an event when any of it's sub gizmos are released from dragging */
  48973. onDragEndObservable: Observable<unknown>;
  48974. get attachedMesh(): Nullable<AbstractMesh>;
  48975. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48976. /**
  48977. * Creates a ScaleGizmo
  48978. * @param gizmoLayer The utility layer the gizmo will be added to
  48979. */
  48980. constructor(gizmoLayer?: UtilityLayerRenderer);
  48981. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48982. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48983. /**
  48984. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48985. */
  48986. set snapDistance(value: number);
  48987. get snapDistance(): number;
  48988. /**
  48989. * Ratio for the scale of the gizmo (Default: 1)
  48990. */
  48991. set scaleRatio(value: number);
  48992. get scaleRatio(): number;
  48993. /**
  48994. * Sensitivity factor for dragging (Default: 1)
  48995. */
  48996. set sensitivity(value: number);
  48997. get sensitivity(): number;
  48998. /**
  48999. * Disposes of the gizmo
  49000. */
  49001. dispose(): void;
  49002. }
  49003. }
  49004. declare module BABYLON {
  49005. /**
  49006. * Single axis scale gizmo
  49007. */
  49008. export class AxisScaleGizmo extends Gizmo {
  49009. /**
  49010. * Drag behavior responsible for the gizmos dragging interactions
  49011. */
  49012. dragBehavior: PointerDragBehavior;
  49013. private _pointerObserver;
  49014. /**
  49015. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49016. */
  49017. snapDistance: number;
  49018. /**
  49019. * Event that fires each time the gizmo snaps to a new location.
  49020. * * snapDistance is the the change in distance
  49021. */
  49022. onSnapObservable: Observable<{
  49023. snapDistance: number;
  49024. }>;
  49025. /**
  49026. * If the scaling operation should be done on all axis (default: false)
  49027. */
  49028. uniformScaling: boolean;
  49029. /**
  49030. * Custom sensitivity value for the drag strength
  49031. */
  49032. sensitivity: number;
  49033. private _isEnabled;
  49034. private _parent;
  49035. private _arrow;
  49036. private _coloredMaterial;
  49037. private _hoverMaterial;
  49038. /**
  49039. * Creates an AxisScaleGizmo
  49040. * @param gizmoLayer The utility layer the gizmo will be added to
  49041. * @param dragAxis The axis which the gizmo will be able to scale on
  49042. * @param color The color of the gizmo
  49043. */
  49044. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49045. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49046. /**
  49047. * If the gizmo is enabled
  49048. */
  49049. set isEnabled(value: boolean);
  49050. get isEnabled(): boolean;
  49051. /**
  49052. * Disposes of the gizmo
  49053. */
  49054. dispose(): void;
  49055. /**
  49056. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49057. * @param mesh The mesh to replace the default mesh of the gizmo
  49058. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49059. */
  49060. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49061. }
  49062. }
  49063. declare module BABYLON {
  49064. /**
  49065. * Bounding box gizmo
  49066. */
  49067. export class BoundingBoxGizmo extends Gizmo {
  49068. private _lineBoundingBox;
  49069. private _rotateSpheresParent;
  49070. private _scaleBoxesParent;
  49071. private _boundingDimensions;
  49072. private _renderObserver;
  49073. private _pointerObserver;
  49074. private _scaleDragSpeed;
  49075. private _tmpQuaternion;
  49076. private _tmpVector;
  49077. private _tmpRotationMatrix;
  49078. /**
  49079. * 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)
  49080. */
  49081. ignoreChildren: boolean;
  49082. /**
  49083. * 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)
  49084. */
  49085. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49086. /**
  49087. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49088. */
  49089. rotationSphereSize: number;
  49090. /**
  49091. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49092. */
  49093. scaleBoxSize: number;
  49094. /**
  49095. * 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)
  49096. */
  49097. fixedDragMeshScreenSize: boolean;
  49098. /**
  49099. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49100. */
  49101. fixedDragMeshScreenSizeDistanceFactor: number;
  49102. /**
  49103. * Fired when a rotation sphere or scale box is dragged
  49104. */
  49105. onDragStartObservable: Observable<{}>;
  49106. /**
  49107. * Fired when a scale box is dragged
  49108. */
  49109. onScaleBoxDragObservable: Observable<{}>;
  49110. /**
  49111. * Fired when a scale box drag is ended
  49112. */
  49113. onScaleBoxDragEndObservable: Observable<{}>;
  49114. /**
  49115. * Fired when a rotation sphere is dragged
  49116. */
  49117. onRotationSphereDragObservable: Observable<{}>;
  49118. /**
  49119. * Fired when a rotation sphere drag is ended
  49120. */
  49121. onRotationSphereDragEndObservable: Observable<{}>;
  49122. /**
  49123. * 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)
  49124. */
  49125. scalePivot: Nullable<Vector3>;
  49126. /**
  49127. * Mesh used as a pivot to rotate the attached mesh
  49128. */
  49129. private _anchorMesh;
  49130. private _existingMeshScale;
  49131. private _dragMesh;
  49132. private pointerDragBehavior;
  49133. private coloredMaterial;
  49134. private hoverColoredMaterial;
  49135. /**
  49136. * Sets the color of the bounding box gizmo
  49137. * @param color the color to set
  49138. */
  49139. setColor(color: Color3): void;
  49140. /**
  49141. * Creates an BoundingBoxGizmo
  49142. * @param gizmoLayer The utility layer the gizmo will be added to
  49143. * @param color The color of the gizmo
  49144. */
  49145. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49146. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49147. private _selectNode;
  49148. /**
  49149. * Updates the bounding box information for the Gizmo
  49150. */
  49151. updateBoundingBox(): void;
  49152. private _updateRotationSpheres;
  49153. private _updateScaleBoxes;
  49154. /**
  49155. * Enables rotation on the specified axis and disables rotation on the others
  49156. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49157. */
  49158. setEnabledRotationAxis(axis: string): void;
  49159. /**
  49160. * Enables/disables scaling
  49161. * @param enable if scaling should be enabled
  49162. * @param homogeneousScaling defines if scaling should only be homogeneous
  49163. */
  49164. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49165. private _updateDummy;
  49166. /**
  49167. * Enables a pointer drag behavior on the bounding box of the gizmo
  49168. */
  49169. enableDragBehavior(): void;
  49170. /**
  49171. * Disposes of the gizmo
  49172. */
  49173. dispose(): void;
  49174. /**
  49175. * 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)
  49176. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49177. * @returns the bounding box mesh with the passed in mesh as a child
  49178. */
  49179. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49180. /**
  49181. * CustomMeshes are not supported by this gizmo
  49182. * @param mesh The mesh to replace the default mesh of the gizmo
  49183. */
  49184. setCustomMesh(mesh: Mesh): void;
  49185. }
  49186. }
  49187. declare module BABYLON {
  49188. /**
  49189. * Single plane rotation gizmo
  49190. */
  49191. export class PlaneRotationGizmo extends Gizmo {
  49192. /**
  49193. * Drag behavior responsible for the gizmos dragging interactions
  49194. */
  49195. dragBehavior: PointerDragBehavior;
  49196. private _pointerObserver;
  49197. /**
  49198. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49199. */
  49200. snapDistance: number;
  49201. /**
  49202. * Event that fires each time the gizmo snaps to a new location.
  49203. * * snapDistance is the the change in distance
  49204. */
  49205. onSnapObservable: Observable<{
  49206. snapDistance: number;
  49207. }>;
  49208. private _isEnabled;
  49209. private _parent;
  49210. /**
  49211. * Creates a PlaneRotationGizmo
  49212. * @param gizmoLayer The utility layer the gizmo will be added to
  49213. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49214. * @param color The color of the gizmo
  49215. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49216. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49217. */
  49218. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49219. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49220. /**
  49221. * If the gizmo is enabled
  49222. */
  49223. set isEnabled(value: boolean);
  49224. get isEnabled(): boolean;
  49225. /**
  49226. * Disposes of the gizmo
  49227. */
  49228. dispose(): void;
  49229. }
  49230. }
  49231. declare module BABYLON {
  49232. /**
  49233. * Gizmo that enables rotating a mesh along 3 axis
  49234. */
  49235. export class RotationGizmo extends Gizmo {
  49236. /**
  49237. * Internal gizmo used for interactions on the x axis
  49238. */
  49239. xGizmo: PlaneRotationGizmo;
  49240. /**
  49241. * Internal gizmo used for interactions on the y axis
  49242. */
  49243. yGizmo: PlaneRotationGizmo;
  49244. /**
  49245. * Internal gizmo used for interactions on the z axis
  49246. */
  49247. zGizmo: PlaneRotationGizmo;
  49248. /** Fires an event when any of it's sub gizmos are dragged */
  49249. onDragStartObservable: Observable<unknown>;
  49250. /** Fires an event when any of it's sub gizmos are released from dragging */
  49251. onDragEndObservable: Observable<unknown>;
  49252. private _meshAttached;
  49253. get attachedMesh(): Nullable<AbstractMesh>;
  49254. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49255. /**
  49256. * Creates a RotationGizmo
  49257. * @param gizmoLayer The utility layer the gizmo will be added to
  49258. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49259. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49260. */
  49261. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49262. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49263. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49264. /**
  49265. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49266. */
  49267. set snapDistance(value: number);
  49268. get snapDistance(): number;
  49269. /**
  49270. * Ratio for the scale of the gizmo (Default: 1)
  49271. */
  49272. set scaleRatio(value: number);
  49273. get scaleRatio(): number;
  49274. /**
  49275. * Disposes of the gizmo
  49276. */
  49277. dispose(): void;
  49278. /**
  49279. * CustomMeshes are not supported by this gizmo
  49280. * @param mesh The mesh to replace the default mesh of the gizmo
  49281. */
  49282. setCustomMesh(mesh: Mesh): void;
  49283. }
  49284. }
  49285. declare module BABYLON {
  49286. /**
  49287. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49288. */
  49289. export class GizmoManager implements IDisposable {
  49290. private scene;
  49291. /**
  49292. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49293. */
  49294. gizmos: {
  49295. positionGizmo: Nullable<PositionGizmo>;
  49296. rotationGizmo: Nullable<RotationGizmo>;
  49297. scaleGizmo: Nullable<ScaleGizmo>;
  49298. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49299. };
  49300. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49301. clearGizmoOnEmptyPointerEvent: boolean;
  49302. /** Fires an event when the manager is attached to a mesh */
  49303. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49304. private _gizmosEnabled;
  49305. private _pointerObserver;
  49306. private _attachedMesh;
  49307. private _boundingBoxColor;
  49308. private _defaultUtilityLayer;
  49309. private _defaultKeepDepthUtilityLayer;
  49310. /**
  49311. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49312. */
  49313. boundingBoxDragBehavior: SixDofDragBehavior;
  49314. /**
  49315. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49316. */
  49317. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49318. /**
  49319. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49320. */
  49321. usePointerToAttachGizmos: boolean;
  49322. /**
  49323. * Utility layer that the bounding box gizmo belongs to
  49324. */
  49325. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49326. /**
  49327. * Utility layer that all gizmos besides bounding box belong to
  49328. */
  49329. get utilityLayer(): UtilityLayerRenderer;
  49330. /**
  49331. * Instatiates a gizmo manager
  49332. * @param scene the scene to overlay the gizmos on top of
  49333. */
  49334. constructor(scene: Scene);
  49335. /**
  49336. * Attaches a set of gizmos to the specified mesh
  49337. * @param mesh The mesh the gizmo's should be attached to
  49338. */
  49339. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49340. /**
  49341. * If the position gizmo is enabled
  49342. */
  49343. set positionGizmoEnabled(value: boolean);
  49344. get positionGizmoEnabled(): boolean;
  49345. /**
  49346. * If the rotation gizmo is enabled
  49347. */
  49348. set rotationGizmoEnabled(value: boolean);
  49349. get rotationGizmoEnabled(): boolean;
  49350. /**
  49351. * If the scale gizmo is enabled
  49352. */
  49353. set scaleGizmoEnabled(value: boolean);
  49354. get scaleGizmoEnabled(): boolean;
  49355. /**
  49356. * If the boundingBox gizmo is enabled
  49357. */
  49358. set boundingBoxGizmoEnabled(value: boolean);
  49359. get boundingBoxGizmoEnabled(): boolean;
  49360. /**
  49361. * Disposes of the gizmo manager
  49362. */
  49363. dispose(): void;
  49364. }
  49365. }
  49366. declare module BABYLON {
  49367. /**
  49368. * A directional light is defined by a direction (what a surprise!).
  49369. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49370. * 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.
  49371. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49372. */
  49373. export class DirectionalLight extends ShadowLight {
  49374. private _shadowFrustumSize;
  49375. /**
  49376. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49377. */
  49378. get shadowFrustumSize(): number;
  49379. /**
  49380. * Specifies a fix frustum size for the shadow generation.
  49381. */
  49382. set shadowFrustumSize(value: number);
  49383. private _shadowOrthoScale;
  49384. /**
  49385. * Gets the shadow projection scale against the optimal computed one.
  49386. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49387. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49388. */
  49389. get shadowOrthoScale(): number;
  49390. /**
  49391. * Sets the shadow projection scale against the optimal computed one.
  49392. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49393. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49394. */
  49395. set shadowOrthoScale(value: number);
  49396. /**
  49397. * Automatically compute the projection matrix to best fit (including all the casters)
  49398. * on each frame.
  49399. */
  49400. autoUpdateExtends: boolean;
  49401. /**
  49402. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49403. * on each frame. autoUpdateExtends must be set to true for this to work
  49404. */
  49405. autoCalcShadowZBounds: boolean;
  49406. private _orthoLeft;
  49407. private _orthoRight;
  49408. private _orthoTop;
  49409. private _orthoBottom;
  49410. /**
  49411. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49412. * The directional light is emitted from everywhere in the given direction.
  49413. * It can cast shadows.
  49414. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49415. * @param name The friendly name of the light
  49416. * @param direction The direction of the light
  49417. * @param scene The scene the light belongs to
  49418. */
  49419. constructor(name: string, direction: Vector3, scene: Scene);
  49420. /**
  49421. * Returns the string "DirectionalLight".
  49422. * @return The class name
  49423. */
  49424. getClassName(): string;
  49425. /**
  49426. * Returns the integer 1.
  49427. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49428. */
  49429. getTypeID(): number;
  49430. /**
  49431. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49432. * Returns the DirectionalLight Shadow projection matrix.
  49433. */
  49434. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49435. /**
  49436. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49437. * Returns the DirectionalLight Shadow projection matrix.
  49438. */
  49439. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49440. /**
  49441. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49442. * Returns the DirectionalLight Shadow projection matrix.
  49443. */
  49444. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49445. protected _buildUniformLayout(): void;
  49446. /**
  49447. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49448. * @param effect The effect to update
  49449. * @param lightIndex The index of the light in the effect to update
  49450. * @returns The directional light
  49451. */
  49452. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49453. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49454. /**
  49455. * Gets the minZ used for shadow according to both the scene and the light.
  49456. *
  49457. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49458. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49459. * @param activeCamera The camera we are returning the min for
  49460. * @returns the depth min z
  49461. */
  49462. getDepthMinZ(activeCamera: Camera): number;
  49463. /**
  49464. * Gets the maxZ used for shadow according to both the scene and the light.
  49465. *
  49466. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49467. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49468. * @param activeCamera The camera we are returning the max for
  49469. * @returns the depth max z
  49470. */
  49471. getDepthMaxZ(activeCamera: Camera): number;
  49472. /**
  49473. * Prepares the list of defines specific to the light type.
  49474. * @param defines the list of defines
  49475. * @param lightIndex defines the index of the light for the effect
  49476. */
  49477. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49478. }
  49479. }
  49480. declare module BABYLON {
  49481. /**
  49482. * Class containing static functions to help procedurally build meshes
  49483. */
  49484. export class HemisphereBuilder {
  49485. /**
  49486. * Creates a hemisphere mesh
  49487. * @param name defines the name of the mesh
  49488. * @param options defines the options used to create the mesh
  49489. * @param scene defines the hosting scene
  49490. * @returns the hemisphere mesh
  49491. */
  49492. static CreateHemisphere(name: string, options: {
  49493. segments?: number;
  49494. diameter?: number;
  49495. sideOrientation?: number;
  49496. }, scene: any): Mesh;
  49497. }
  49498. }
  49499. declare module BABYLON {
  49500. /**
  49501. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49502. * These values define a cone of light starting from the position, emitting toward the direction.
  49503. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49504. * and the exponent defines the speed of the decay of the light with distance (reach).
  49505. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49506. */
  49507. export class SpotLight extends ShadowLight {
  49508. private _angle;
  49509. private _innerAngle;
  49510. private _cosHalfAngle;
  49511. private _lightAngleScale;
  49512. private _lightAngleOffset;
  49513. /**
  49514. * Gets the cone angle of the spot light in Radians.
  49515. */
  49516. get angle(): number;
  49517. /**
  49518. * Sets the cone angle of the spot light in Radians.
  49519. */
  49520. set angle(value: number);
  49521. /**
  49522. * Only used in gltf falloff mode, this defines the angle where
  49523. * the directional falloff will start before cutting at angle which could be seen
  49524. * as outer angle.
  49525. */
  49526. get innerAngle(): number;
  49527. /**
  49528. * Only used in gltf falloff mode, this defines the angle where
  49529. * the directional falloff will start before cutting at angle which could be seen
  49530. * as outer angle.
  49531. */
  49532. set innerAngle(value: number);
  49533. private _shadowAngleScale;
  49534. /**
  49535. * Allows scaling the angle of the light for shadow generation only.
  49536. */
  49537. get shadowAngleScale(): number;
  49538. /**
  49539. * Allows scaling the angle of the light for shadow generation only.
  49540. */
  49541. set shadowAngleScale(value: number);
  49542. /**
  49543. * The light decay speed with the distance from the emission spot.
  49544. */
  49545. exponent: number;
  49546. private _projectionTextureMatrix;
  49547. /**
  49548. * Allows reading the projecton texture
  49549. */
  49550. get projectionTextureMatrix(): Matrix;
  49551. protected _projectionTextureLightNear: number;
  49552. /**
  49553. * Gets the near clip of the Spotlight for texture projection.
  49554. */
  49555. get projectionTextureLightNear(): number;
  49556. /**
  49557. * Sets the near clip of the Spotlight for texture projection.
  49558. */
  49559. set projectionTextureLightNear(value: number);
  49560. protected _projectionTextureLightFar: number;
  49561. /**
  49562. * Gets the far clip of the Spotlight for texture projection.
  49563. */
  49564. get projectionTextureLightFar(): number;
  49565. /**
  49566. * Sets the far clip of the Spotlight for texture projection.
  49567. */
  49568. set projectionTextureLightFar(value: number);
  49569. protected _projectionTextureUpDirection: Vector3;
  49570. /**
  49571. * Gets the Up vector of the Spotlight for texture projection.
  49572. */
  49573. get projectionTextureUpDirection(): Vector3;
  49574. /**
  49575. * Sets the Up vector of the Spotlight for texture projection.
  49576. */
  49577. set projectionTextureUpDirection(value: Vector3);
  49578. private _projectionTexture;
  49579. /**
  49580. * Gets the projection texture of the light.
  49581. */
  49582. get projectionTexture(): Nullable<BaseTexture>;
  49583. /**
  49584. * Sets the projection texture of the light.
  49585. */
  49586. set projectionTexture(value: Nullable<BaseTexture>);
  49587. private _projectionTextureViewLightDirty;
  49588. private _projectionTextureProjectionLightDirty;
  49589. private _projectionTextureDirty;
  49590. private _projectionTextureViewTargetVector;
  49591. private _projectionTextureViewLightMatrix;
  49592. private _projectionTextureProjectionLightMatrix;
  49593. private _projectionTextureScalingMatrix;
  49594. /**
  49595. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49596. * It can cast shadows.
  49597. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49598. * @param name The light friendly name
  49599. * @param position The position of the spot light in the scene
  49600. * @param direction The direction of the light in the scene
  49601. * @param angle The cone angle of the light in Radians
  49602. * @param exponent The light decay speed with the distance from the emission spot
  49603. * @param scene The scene the lights belongs to
  49604. */
  49605. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49606. /**
  49607. * Returns the string "SpotLight".
  49608. * @returns the class name
  49609. */
  49610. getClassName(): string;
  49611. /**
  49612. * Returns the integer 2.
  49613. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49614. */
  49615. getTypeID(): number;
  49616. /**
  49617. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49618. */
  49619. protected _setDirection(value: Vector3): void;
  49620. /**
  49621. * Overrides the position setter to recompute the projection texture view light Matrix.
  49622. */
  49623. protected _setPosition(value: Vector3): void;
  49624. /**
  49625. * 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.
  49626. * Returns the SpotLight.
  49627. */
  49628. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49629. protected _computeProjectionTextureViewLightMatrix(): void;
  49630. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49631. /**
  49632. * Main function for light texture projection matrix computing.
  49633. */
  49634. protected _computeProjectionTextureMatrix(): void;
  49635. protected _buildUniformLayout(): void;
  49636. private _computeAngleValues;
  49637. /**
  49638. * Sets the passed Effect "effect" with the Light textures.
  49639. * @param effect The effect to update
  49640. * @param lightIndex The index of the light in the effect to update
  49641. * @returns The light
  49642. */
  49643. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49644. /**
  49645. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49646. * @param effect The effect to update
  49647. * @param lightIndex The index of the light in the effect to update
  49648. * @returns The spot light
  49649. */
  49650. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49651. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49652. /**
  49653. * Disposes the light and the associated resources.
  49654. */
  49655. dispose(): void;
  49656. /**
  49657. * Prepares the list of defines specific to the light type.
  49658. * @param defines the list of defines
  49659. * @param lightIndex defines the index of the light for the effect
  49660. */
  49661. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49662. }
  49663. }
  49664. declare module BABYLON {
  49665. /**
  49666. * Gizmo that enables viewing a light
  49667. */
  49668. export class LightGizmo extends Gizmo {
  49669. private _lightMesh;
  49670. private _material;
  49671. private _cachedPosition;
  49672. private _cachedForward;
  49673. private _attachedMeshParent;
  49674. /**
  49675. * Creates a LightGizmo
  49676. * @param gizmoLayer The utility layer the gizmo will be added to
  49677. */
  49678. constructor(gizmoLayer?: UtilityLayerRenderer);
  49679. private _light;
  49680. /**
  49681. * The light that the gizmo is attached to
  49682. */
  49683. set light(light: Nullable<Light>);
  49684. get light(): Nullable<Light>;
  49685. /**
  49686. * Gets the material used to render the light gizmo
  49687. */
  49688. get material(): StandardMaterial;
  49689. /**
  49690. * @hidden
  49691. * Updates the gizmo to match the attached mesh's position/rotation
  49692. */
  49693. protected _update(): void;
  49694. private static _Scale;
  49695. /**
  49696. * Creates the lines for a light mesh
  49697. */
  49698. private static _CreateLightLines;
  49699. /**
  49700. * Disposes of the light gizmo
  49701. */
  49702. dispose(): void;
  49703. private static _CreateHemisphericLightMesh;
  49704. private static _CreatePointLightMesh;
  49705. private static _CreateSpotLightMesh;
  49706. private static _CreateDirectionalLightMesh;
  49707. }
  49708. }
  49709. declare module BABYLON {
  49710. /** @hidden */
  49711. export var backgroundFragmentDeclaration: {
  49712. name: string;
  49713. shader: string;
  49714. };
  49715. }
  49716. declare module BABYLON {
  49717. /** @hidden */
  49718. export var backgroundUboDeclaration: {
  49719. name: string;
  49720. shader: string;
  49721. };
  49722. }
  49723. declare module BABYLON {
  49724. /** @hidden */
  49725. export var backgroundPixelShader: {
  49726. name: string;
  49727. shader: string;
  49728. };
  49729. }
  49730. declare module BABYLON {
  49731. /** @hidden */
  49732. export var backgroundVertexDeclaration: {
  49733. name: string;
  49734. shader: string;
  49735. };
  49736. }
  49737. declare module BABYLON {
  49738. /** @hidden */
  49739. export var backgroundVertexShader: {
  49740. name: string;
  49741. shader: string;
  49742. };
  49743. }
  49744. declare module BABYLON {
  49745. /**
  49746. * Background material used to create an efficient environement around your scene.
  49747. */
  49748. export class BackgroundMaterial extends PushMaterial {
  49749. /**
  49750. * Standard reflectance value at parallel view angle.
  49751. */
  49752. static StandardReflectance0: number;
  49753. /**
  49754. * Standard reflectance value at grazing angle.
  49755. */
  49756. static StandardReflectance90: number;
  49757. protected _primaryColor: Color3;
  49758. /**
  49759. * Key light Color (multiply against the environement texture)
  49760. */
  49761. primaryColor: Color3;
  49762. protected __perceptualColor: Nullable<Color3>;
  49763. /**
  49764. * Experimental Internal Use Only.
  49765. *
  49766. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49767. * This acts as a helper to set the primary color to a more "human friendly" value.
  49768. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49769. * output color as close as possible from the chosen value.
  49770. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49771. * part of lighting setup.)
  49772. */
  49773. get _perceptualColor(): Nullable<Color3>;
  49774. set _perceptualColor(value: Nullable<Color3>);
  49775. protected _primaryColorShadowLevel: float;
  49776. /**
  49777. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49778. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49779. */
  49780. get primaryColorShadowLevel(): float;
  49781. set primaryColorShadowLevel(value: float);
  49782. protected _primaryColorHighlightLevel: float;
  49783. /**
  49784. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49785. * The primary color is used at the level chosen to define what the white area would look.
  49786. */
  49787. get primaryColorHighlightLevel(): float;
  49788. set primaryColorHighlightLevel(value: float);
  49789. protected _reflectionTexture: Nullable<BaseTexture>;
  49790. /**
  49791. * Reflection Texture used in the material.
  49792. * Should be author in a specific way for the best result (refer to the documentation).
  49793. */
  49794. reflectionTexture: Nullable<BaseTexture>;
  49795. protected _reflectionBlur: float;
  49796. /**
  49797. * Reflection Texture level of blur.
  49798. *
  49799. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49800. * texture twice.
  49801. */
  49802. reflectionBlur: float;
  49803. protected _diffuseTexture: Nullable<BaseTexture>;
  49804. /**
  49805. * Diffuse Texture used in the material.
  49806. * Should be author in a specific way for the best result (refer to the documentation).
  49807. */
  49808. diffuseTexture: Nullable<BaseTexture>;
  49809. protected _shadowLights: Nullable<IShadowLight[]>;
  49810. /**
  49811. * Specify the list of lights casting shadow on the material.
  49812. * All scene shadow lights will be included if null.
  49813. */
  49814. shadowLights: Nullable<IShadowLight[]>;
  49815. protected _shadowLevel: float;
  49816. /**
  49817. * Helps adjusting the shadow to a softer level if required.
  49818. * 0 means black shadows and 1 means no shadows.
  49819. */
  49820. shadowLevel: float;
  49821. protected _sceneCenter: Vector3;
  49822. /**
  49823. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49824. * It is usually zero but might be interesting to modify according to your setup.
  49825. */
  49826. sceneCenter: Vector3;
  49827. protected _opacityFresnel: boolean;
  49828. /**
  49829. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49830. * This helps ensuring a nice transition when the camera goes under the ground.
  49831. */
  49832. opacityFresnel: boolean;
  49833. protected _reflectionFresnel: boolean;
  49834. /**
  49835. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49836. * This helps adding a mirror texture on the ground.
  49837. */
  49838. reflectionFresnel: boolean;
  49839. protected _reflectionFalloffDistance: number;
  49840. /**
  49841. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49842. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49843. */
  49844. reflectionFalloffDistance: number;
  49845. protected _reflectionAmount: number;
  49846. /**
  49847. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49848. */
  49849. reflectionAmount: number;
  49850. protected _reflectionReflectance0: number;
  49851. /**
  49852. * This specifies the weight of the reflection at grazing angle.
  49853. */
  49854. reflectionReflectance0: number;
  49855. protected _reflectionReflectance90: number;
  49856. /**
  49857. * This specifies the weight of the reflection at a perpendicular point of view.
  49858. */
  49859. reflectionReflectance90: number;
  49860. /**
  49861. * Sets the reflection reflectance fresnel values according to the default standard
  49862. * empirically know to work well :-)
  49863. */
  49864. set reflectionStandardFresnelWeight(value: number);
  49865. protected _useRGBColor: boolean;
  49866. /**
  49867. * Helps to directly use the maps channels instead of their level.
  49868. */
  49869. useRGBColor: boolean;
  49870. protected _enableNoise: boolean;
  49871. /**
  49872. * This helps reducing the banding effect that could occur on the background.
  49873. */
  49874. enableNoise: boolean;
  49875. /**
  49876. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49877. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49878. * Recommended to be keep at 1.0 except for special cases.
  49879. */
  49880. get fovMultiplier(): number;
  49881. set fovMultiplier(value: number);
  49882. private _fovMultiplier;
  49883. /**
  49884. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49885. */
  49886. useEquirectangularFOV: boolean;
  49887. private _maxSimultaneousLights;
  49888. /**
  49889. * Number of Simultaneous lights allowed on the material.
  49890. */
  49891. maxSimultaneousLights: int;
  49892. /**
  49893. * Default configuration related to image processing available in the Background Material.
  49894. */
  49895. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49896. /**
  49897. * Keep track of the image processing observer to allow dispose and replace.
  49898. */
  49899. private _imageProcessingObserver;
  49900. /**
  49901. * Attaches a new image processing configuration to the PBR Material.
  49902. * @param configuration (if null the scene configuration will be use)
  49903. */
  49904. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49905. /**
  49906. * Gets the image processing configuration used either in this material.
  49907. */
  49908. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49909. /**
  49910. * Sets the Default image processing configuration used either in the this material.
  49911. *
  49912. * If sets to null, the scene one is in use.
  49913. */
  49914. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49915. /**
  49916. * Gets wether the color curves effect is enabled.
  49917. */
  49918. get cameraColorCurvesEnabled(): boolean;
  49919. /**
  49920. * Sets wether the color curves effect is enabled.
  49921. */
  49922. set cameraColorCurvesEnabled(value: boolean);
  49923. /**
  49924. * Gets wether the color grading effect is enabled.
  49925. */
  49926. get cameraColorGradingEnabled(): boolean;
  49927. /**
  49928. * Gets wether the color grading effect is enabled.
  49929. */
  49930. set cameraColorGradingEnabled(value: boolean);
  49931. /**
  49932. * Gets wether tonemapping is enabled or not.
  49933. */
  49934. get cameraToneMappingEnabled(): boolean;
  49935. /**
  49936. * Sets wether tonemapping is enabled or not
  49937. */
  49938. set cameraToneMappingEnabled(value: boolean);
  49939. /**
  49940. * The camera exposure used on this material.
  49941. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49942. * This corresponds to a photographic exposure.
  49943. */
  49944. get cameraExposure(): float;
  49945. /**
  49946. * The camera exposure used on this material.
  49947. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49948. * This corresponds to a photographic exposure.
  49949. */
  49950. set cameraExposure(value: float);
  49951. /**
  49952. * Gets The camera contrast used on this material.
  49953. */
  49954. get cameraContrast(): float;
  49955. /**
  49956. * Sets The camera contrast used on this material.
  49957. */
  49958. set cameraContrast(value: float);
  49959. /**
  49960. * Gets the Color Grading 2D Lookup Texture.
  49961. */
  49962. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49963. /**
  49964. * Sets the Color Grading 2D Lookup Texture.
  49965. */
  49966. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49967. /**
  49968. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49969. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49970. * 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;
  49971. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49972. */
  49973. get cameraColorCurves(): Nullable<ColorCurves>;
  49974. /**
  49975. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49976. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49977. * 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;
  49978. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49979. */
  49980. set cameraColorCurves(value: Nullable<ColorCurves>);
  49981. /**
  49982. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49983. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49984. */
  49985. switchToBGR: boolean;
  49986. private _renderTargets;
  49987. private _reflectionControls;
  49988. private _white;
  49989. private _primaryShadowColor;
  49990. private _primaryHighlightColor;
  49991. /**
  49992. * Instantiates a Background Material in the given scene
  49993. * @param name The friendly name of the material
  49994. * @param scene The scene to add the material to
  49995. */
  49996. constructor(name: string, scene: Scene);
  49997. /**
  49998. * Gets a boolean indicating that current material needs to register RTT
  49999. */
  50000. get hasRenderTargetTextures(): boolean;
  50001. /**
  50002. * The entire material has been created in order to prevent overdraw.
  50003. * @returns false
  50004. */
  50005. needAlphaTesting(): boolean;
  50006. /**
  50007. * The entire material has been created in order to prevent overdraw.
  50008. * @returns true if blending is enable
  50009. */
  50010. needAlphaBlending(): boolean;
  50011. /**
  50012. * Checks wether the material is ready to be rendered for a given mesh.
  50013. * @param mesh The mesh to render
  50014. * @param subMesh The submesh to check against
  50015. * @param useInstances Specify wether or not the material is used with instances
  50016. * @returns true if all the dependencies are ready (Textures, Effects...)
  50017. */
  50018. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50019. /**
  50020. * Compute the primary color according to the chosen perceptual color.
  50021. */
  50022. private _computePrimaryColorFromPerceptualColor;
  50023. /**
  50024. * Compute the highlights and shadow colors according to their chosen levels.
  50025. */
  50026. private _computePrimaryColors;
  50027. /**
  50028. * Build the uniform buffer used in the material.
  50029. */
  50030. buildUniformLayout(): void;
  50031. /**
  50032. * Unbind the material.
  50033. */
  50034. unbind(): void;
  50035. /**
  50036. * Bind only the world matrix to the material.
  50037. * @param world The world matrix to bind.
  50038. */
  50039. bindOnlyWorldMatrix(world: Matrix): void;
  50040. /**
  50041. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50042. * @param world The world matrix to bind.
  50043. * @param subMesh The submesh to bind for.
  50044. */
  50045. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50046. /**
  50047. * Checks to see if a texture is used in the material.
  50048. * @param texture - Base texture to use.
  50049. * @returns - Boolean specifying if a texture is used in the material.
  50050. */
  50051. hasTexture(texture: BaseTexture): boolean;
  50052. /**
  50053. * Dispose the material.
  50054. * @param forceDisposeEffect Force disposal of the associated effect.
  50055. * @param forceDisposeTextures Force disposal of the associated textures.
  50056. */
  50057. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50058. /**
  50059. * Clones the material.
  50060. * @param name The cloned name.
  50061. * @returns The cloned material.
  50062. */
  50063. clone(name: string): BackgroundMaterial;
  50064. /**
  50065. * Serializes the current material to its JSON representation.
  50066. * @returns The JSON representation.
  50067. */
  50068. serialize(): any;
  50069. /**
  50070. * Gets the class name of the material
  50071. * @returns "BackgroundMaterial"
  50072. */
  50073. getClassName(): string;
  50074. /**
  50075. * Parse a JSON input to create back a background material.
  50076. * @param source The JSON data to parse
  50077. * @param scene The scene to create the parsed material in
  50078. * @param rootUrl The root url of the assets the material depends upon
  50079. * @returns the instantiated BackgroundMaterial.
  50080. */
  50081. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50082. }
  50083. }
  50084. declare module BABYLON {
  50085. /**
  50086. * Represents the different options available during the creation of
  50087. * a Environment helper.
  50088. *
  50089. * This can control the default ground, skybox and image processing setup of your scene.
  50090. */
  50091. export interface IEnvironmentHelperOptions {
  50092. /**
  50093. * Specifies whether or not to create a ground.
  50094. * True by default.
  50095. */
  50096. createGround: boolean;
  50097. /**
  50098. * Specifies the ground size.
  50099. * 15 by default.
  50100. */
  50101. groundSize: number;
  50102. /**
  50103. * The texture used on the ground for the main color.
  50104. * Comes from the BabylonJS CDN by default.
  50105. *
  50106. * Remarks: Can be either a texture or a url.
  50107. */
  50108. groundTexture: string | BaseTexture;
  50109. /**
  50110. * The color mixed in the ground texture by default.
  50111. * BabylonJS clearColor by default.
  50112. */
  50113. groundColor: Color3;
  50114. /**
  50115. * Specifies the ground opacity.
  50116. * 1 by default.
  50117. */
  50118. groundOpacity: number;
  50119. /**
  50120. * Enables the ground to receive shadows.
  50121. * True by default.
  50122. */
  50123. enableGroundShadow: boolean;
  50124. /**
  50125. * Helps preventing the shadow to be fully black on the ground.
  50126. * 0.5 by default.
  50127. */
  50128. groundShadowLevel: number;
  50129. /**
  50130. * Creates a mirror texture attach to the ground.
  50131. * false by default.
  50132. */
  50133. enableGroundMirror: boolean;
  50134. /**
  50135. * Specifies the ground mirror size ratio.
  50136. * 0.3 by default as the default kernel is 64.
  50137. */
  50138. groundMirrorSizeRatio: number;
  50139. /**
  50140. * Specifies the ground mirror blur kernel size.
  50141. * 64 by default.
  50142. */
  50143. groundMirrorBlurKernel: number;
  50144. /**
  50145. * Specifies the ground mirror visibility amount.
  50146. * 1 by default
  50147. */
  50148. groundMirrorAmount: number;
  50149. /**
  50150. * Specifies the ground mirror reflectance weight.
  50151. * This uses the standard weight of the background material to setup the fresnel effect
  50152. * of the mirror.
  50153. * 1 by default.
  50154. */
  50155. groundMirrorFresnelWeight: number;
  50156. /**
  50157. * Specifies the ground mirror Falloff distance.
  50158. * This can helps reducing the size of the reflection.
  50159. * 0 by Default.
  50160. */
  50161. groundMirrorFallOffDistance: number;
  50162. /**
  50163. * Specifies the ground mirror texture type.
  50164. * Unsigned Int by Default.
  50165. */
  50166. groundMirrorTextureType: number;
  50167. /**
  50168. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50169. * the shown objects.
  50170. */
  50171. groundYBias: number;
  50172. /**
  50173. * Specifies whether or not to create a skybox.
  50174. * True by default.
  50175. */
  50176. createSkybox: boolean;
  50177. /**
  50178. * Specifies the skybox size.
  50179. * 20 by default.
  50180. */
  50181. skyboxSize: number;
  50182. /**
  50183. * The texture used on the skybox for the main color.
  50184. * Comes from the BabylonJS CDN by default.
  50185. *
  50186. * Remarks: Can be either a texture or a url.
  50187. */
  50188. skyboxTexture: string | BaseTexture;
  50189. /**
  50190. * The color mixed in the skybox texture by default.
  50191. * BabylonJS clearColor by default.
  50192. */
  50193. skyboxColor: Color3;
  50194. /**
  50195. * The background rotation around the Y axis of the scene.
  50196. * This helps aligning the key lights of your scene with the background.
  50197. * 0 by default.
  50198. */
  50199. backgroundYRotation: number;
  50200. /**
  50201. * Compute automatically the size of the elements to best fit with the scene.
  50202. */
  50203. sizeAuto: boolean;
  50204. /**
  50205. * Default position of the rootMesh if autoSize is not true.
  50206. */
  50207. rootPosition: Vector3;
  50208. /**
  50209. * Sets up the image processing in the scene.
  50210. * true by default.
  50211. */
  50212. setupImageProcessing: boolean;
  50213. /**
  50214. * The texture used as your environment texture in the scene.
  50215. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50216. *
  50217. * Remarks: Can be either a texture or a url.
  50218. */
  50219. environmentTexture: string | BaseTexture;
  50220. /**
  50221. * The value of the exposure to apply to the scene.
  50222. * 0.6 by default if setupImageProcessing is true.
  50223. */
  50224. cameraExposure: number;
  50225. /**
  50226. * The value of the contrast to apply to the scene.
  50227. * 1.6 by default if setupImageProcessing is true.
  50228. */
  50229. cameraContrast: number;
  50230. /**
  50231. * Specifies whether or not tonemapping should be enabled in the scene.
  50232. * true by default if setupImageProcessing is true.
  50233. */
  50234. toneMappingEnabled: boolean;
  50235. }
  50236. /**
  50237. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50238. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50239. * It also helps with the default setup of your imageProcessing configuration.
  50240. */
  50241. export class EnvironmentHelper {
  50242. /**
  50243. * Default ground texture URL.
  50244. */
  50245. private static _groundTextureCDNUrl;
  50246. /**
  50247. * Default skybox texture URL.
  50248. */
  50249. private static _skyboxTextureCDNUrl;
  50250. /**
  50251. * Default environment texture URL.
  50252. */
  50253. private static _environmentTextureCDNUrl;
  50254. /**
  50255. * Creates the default options for the helper.
  50256. */
  50257. private static _getDefaultOptions;
  50258. private _rootMesh;
  50259. /**
  50260. * Gets the root mesh created by the helper.
  50261. */
  50262. get rootMesh(): Mesh;
  50263. private _skybox;
  50264. /**
  50265. * Gets the skybox created by the helper.
  50266. */
  50267. get skybox(): Nullable<Mesh>;
  50268. private _skyboxTexture;
  50269. /**
  50270. * Gets the skybox texture created by the helper.
  50271. */
  50272. get skyboxTexture(): Nullable<BaseTexture>;
  50273. private _skyboxMaterial;
  50274. /**
  50275. * Gets the skybox material created by the helper.
  50276. */
  50277. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50278. private _ground;
  50279. /**
  50280. * Gets the ground mesh created by the helper.
  50281. */
  50282. get ground(): Nullable<Mesh>;
  50283. private _groundTexture;
  50284. /**
  50285. * Gets the ground texture created by the helper.
  50286. */
  50287. get groundTexture(): Nullable<BaseTexture>;
  50288. private _groundMirror;
  50289. /**
  50290. * Gets the ground mirror created by the helper.
  50291. */
  50292. get groundMirror(): Nullable<MirrorTexture>;
  50293. /**
  50294. * Gets the ground mirror render list to helps pushing the meshes
  50295. * you wish in the ground reflection.
  50296. */
  50297. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50298. private _groundMaterial;
  50299. /**
  50300. * Gets the ground material created by the helper.
  50301. */
  50302. get groundMaterial(): Nullable<BackgroundMaterial>;
  50303. /**
  50304. * Stores the creation options.
  50305. */
  50306. private readonly _scene;
  50307. private _options;
  50308. /**
  50309. * This observable will be notified with any error during the creation of the environment,
  50310. * mainly texture creation errors.
  50311. */
  50312. onErrorObservable: Observable<{
  50313. message?: string;
  50314. exception?: any;
  50315. }>;
  50316. /**
  50317. * constructor
  50318. * @param options Defines the options we want to customize the helper
  50319. * @param scene The scene to add the material to
  50320. */
  50321. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50322. /**
  50323. * Updates the background according to the new options
  50324. * @param options
  50325. */
  50326. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50327. /**
  50328. * Sets the primary color of all the available elements.
  50329. * @param color the main color to affect to the ground and the background
  50330. */
  50331. setMainColor(color: Color3): void;
  50332. /**
  50333. * Setup the image processing according to the specified options.
  50334. */
  50335. private _setupImageProcessing;
  50336. /**
  50337. * Setup the environment texture according to the specified options.
  50338. */
  50339. private _setupEnvironmentTexture;
  50340. /**
  50341. * Setup the background according to the specified options.
  50342. */
  50343. private _setupBackground;
  50344. /**
  50345. * Get the scene sizes according to the setup.
  50346. */
  50347. private _getSceneSize;
  50348. /**
  50349. * Setup the ground according to the specified options.
  50350. */
  50351. private _setupGround;
  50352. /**
  50353. * Setup the ground material according to the specified options.
  50354. */
  50355. private _setupGroundMaterial;
  50356. /**
  50357. * Setup the ground diffuse texture according to the specified options.
  50358. */
  50359. private _setupGroundDiffuseTexture;
  50360. /**
  50361. * Setup the ground mirror texture according to the specified options.
  50362. */
  50363. private _setupGroundMirrorTexture;
  50364. /**
  50365. * Setup the ground to receive the mirror texture.
  50366. */
  50367. private _setupMirrorInGroundMaterial;
  50368. /**
  50369. * Setup the skybox according to the specified options.
  50370. */
  50371. private _setupSkybox;
  50372. /**
  50373. * Setup the skybox material according to the specified options.
  50374. */
  50375. private _setupSkyboxMaterial;
  50376. /**
  50377. * Setup the skybox reflection texture according to the specified options.
  50378. */
  50379. private _setupSkyboxReflectionTexture;
  50380. private _errorHandler;
  50381. /**
  50382. * Dispose all the elements created by the Helper.
  50383. */
  50384. dispose(): void;
  50385. }
  50386. }
  50387. declare module BABYLON {
  50388. /**
  50389. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50390. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50391. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50392. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50393. */
  50394. export class PhotoDome extends TransformNode {
  50395. /**
  50396. * Define the image as a Monoscopic panoramic 360 image.
  50397. */
  50398. static readonly MODE_MONOSCOPIC: number;
  50399. /**
  50400. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50401. */
  50402. static readonly MODE_TOPBOTTOM: number;
  50403. /**
  50404. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50405. */
  50406. static readonly MODE_SIDEBYSIDE: number;
  50407. private _useDirectMapping;
  50408. /**
  50409. * The texture being displayed on the sphere
  50410. */
  50411. protected _photoTexture: Texture;
  50412. /**
  50413. * Gets or sets the texture being displayed on the sphere
  50414. */
  50415. get photoTexture(): Texture;
  50416. set photoTexture(value: Texture);
  50417. /**
  50418. * Observable raised when an error occured while loading the 360 image
  50419. */
  50420. onLoadErrorObservable: Observable<string>;
  50421. /**
  50422. * The skybox material
  50423. */
  50424. protected _material: BackgroundMaterial;
  50425. /**
  50426. * The surface used for the skybox
  50427. */
  50428. protected _mesh: Mesh;
  50429. /**
  50430. * Gets the mesh used for the skybox.
  50431. */
  50432. get mesh(): Mesh;
  50433. /**
  50434. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50435. * Also see the options.resolution property.
  50436. */
  50437. get fovMultiplier(): number;
  50438. set fovMultiplier(value: number);
  50439. private _imageMode;
  50440. /**
  50441. * Gets or set the current video mode for the video. It can be:
  50442. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50443. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50444. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50445. */
  50446. get imageMode(): number;
  50447. set imageMode(value: number);
  50448. /**
  50449. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50450. * @param name Element's name, child elements will append suffixes for their own names.
  50451. * @param urlsOfPhoto defines the url of the photo to display
  50452. * @param options defines an object containing optional or exposed sub element properties
  50453. * @param onError defines a callback called when an error occured while loading the texture
  50454. */
  50455. constructor(name: string, urlOfPhoto: string, options: {
  50456. resolution?: number;
  50457. size?: number;
  50458. useDirectMapping?: boolean;
  50459. faceForward?: boolean;
  50460. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50461. private _onBeforeCameraRenderObserver;
  50462. private _changeImageMode;
  50463. /**
  50464. * Releases resources associated with this node.
  50465. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50466. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50467. */
  50468. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50469. }
  50470. }
  50471. declare module BABYLON {
  50472. /**
  50473. * Class used to host RGBD texture specific utilities
  50474. */
  50475. export class RGBDTextureTools {
  50476. /**
  50477. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50478. * @param texture the texture to expand.
  50479. */
  50480. static ExpandRGBDTexture(texture: Texture): void;
  50481. }
  50482. }
  50483. declare module BABYLON {
  50484. /**
  50485. * Class used to host texture specific utilities
  50486. */
  50487. export class BRDFTextureTools {
  50488. /**
  50489. * Prevents texture cache collision
  50490. */
  50491. private static _instanceNumber;
  50492. /**
  50493. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50494. * @param scene defines the hosting scene
  50495. * @returns the environment BRDF texture
  50496. */
  50497. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50498. private static _environmentBRDFBase64Texture;
  50499. }
  50500. }
  50501. declare module BABYLON {
  50502. /**
  50503. * @hidden
  50504. */
  50505. export interface IMaterialClearCoatDefines {
  50506. CLEARCOAT: boolean;
  50507. CLEARCOAT_DEFAULTIOR: boolean;
  50508. CLEARCOAT_TEXTURE: boolean;
  50509. CLEARCOAT_TEXTUREDIRECTUV: number;
  50510. CLEARCOAT_BUMP: boolean;
  50511. CLEARCOAT_BUMPDIRECTUV: number;
  50512. CLEARCOAT_TINT: boolean;
  50513. CLEARCOAT_TINT_TEXTURE: boolean;
  50514. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50515. /** @hidden */
  50516. _areTexturesDirty: boolean;
  50517. }
  50518. /**
  50519. * Define the code related to the clear coat parameters of the pbr material.
  50520. */
  50521. export class PBRClearCoatConfiguration {
  50522. /**
  50523. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50524. * The default fits with a polyurethane material.
  50525. */
  50526. private static readonly _DefaultIndexOfRefraction;
  50527. private _isEnabled;
  50528. /**
  50529. * Defines if the clear coat is enabled in the material.
  50530. */
  50531. isEnabled: boolean;
  50532. /**
  50533. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50534. */
  50535. intensity: number;
  50536. /**
  50537. * Defines the clear coat layer roughness.
  50538. */
  50539. roughness: number;
  50540. private _indexOfRefraction;
  50541. /**
  50542. * Defines the index of refraction of the clear coat.
  50543. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50544. * The default fits with a polyurethane material.
  50545. * Changing the default value is more performance intensive.
  50546. */
  50547. indexOfRefraction: number;
  50548. private _texture;
  50549. /**
  50550. * Stores the clear coat values in a texture.
  50551. */
  50552. texture: Nullable<BaseTexture>;
  50553. private _bumpTexture;
  50554. /**
  50555. * Define the clear coat specific bump texture.
  50556. */
  50557. bumpTexture: Nullable<BaseTexture>;
  50558. private _isTintEnabled;
  50559. /**
  50560. * Defines if the clear coat tint is enabled in the material.
  50561. */
  50562. isTintEnabled: boolean;
  50563. /**
  50564. * Defines the clear coat tint of the material.
  50565. * This is only use if tint is enabled
  50566. */
  50567. tintColor: Color3;
  50568. /**
  50569. * Defines the distance at which the tint color should be found in the
  50570. * clear coat media.
  50571. * This is only use if tint is enabled
  50572. */
  50573. tintColorAtDistance: number;
  50574. /**
  50575. * Defines the clear coat layer thickness.
  50576. * This is only use if tint is enabled
  50577. */
  50578. tintThickness: number;
  50579. private _tintTexture;
  50580. /**
  50581. * Stores the clear tint values in a texture.
  50582. * rgb is tint
  50583. * a is a thickness factor
  50584. */
  50585. tintTexture: Nullable<BaseTexture>;
  50586. /** @hidden */
  50587. private _internalMarkAllSubMeshesAsTexturesDirty;
  50588. /** @hidden */
  50589. _markAllSubMeshesAsTexturesDirty(): void;
  50590. /**
  50591. * Instantiate a new istance of clear coat configuration.
  50592. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50593. */
  50594. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50595. /**
  50596. * Gets wehter the submesh is ready to be used or not.
  50597. * @param defines the list of "defines" to update.
  50598. * @param scene defines the scene the material belongs to.
  50599. * @param engine defines the engine the material belongs to.
  50600. * @param disableBumpMap defines wether the material disables bump or not.
  50601. * @returns - boolean indicating that the submesh is ready or not.
  50602. */
  50603. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50604. /**
  50605. * Checks to see if a texture is used in the material.
  50606. * @param defines the list of "defines" to update.
  50607. * @param scene defines the scene to the material belongs to.
  50608. */
  50609. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50610. /**
  50611. * Binds the material data.
  50612. * @param uniformBuffer defines the Uniform buffer to fill in.
  50613. * @param scene defines the scene the material belongs to.
  50614. * @param engine defines the engine the material belongs to.
  50615. * @param disableBumpMap defines wether the material disables bump or not.
  50616. * @param isFrozen defines wether the material is frozen or not.
  50617. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50618. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50619. */
  50620. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50621. /**
  50622. * Checks to see if a texture is used in the material.
  50623. * @param texture - Base texture to use.
  50624. * @returns - Boolean specifying if a texture is used in the material.
  50625. */
  50626. hasTexture(texture: BaseTexture): boolean;
  50627. /**
  50628. * Returns an array of the actively used textures.
  50629. * @param activeTextures Array of BaseTextures
  50630. */
  50631. getActiveTextures(activeTextures: BaseTexture[]): void;
  50632. /**
  50633. * Returns the animatable textures.
  50634. * @param animatables Array of animatable textures.
  50635. */
  50636. getAnimatables(animatables: IAnimatable[]): void;
  50637. /**
  50638. * Disposes the resources of the material.
  50639. * @param forceDisposeTextures - Forces the disposal of all textures.
  50640. */
  50641. dispose(forceDisposeTextures?: boolean): void;
  50642. /**
  50643. * Get the current class name of the texture useful for serialization or dynamic coding.
  50644. * @returns "PBRClearCoatConfiguration"
  50645. */
  50646. getClassName(): string;
  50647. /**
  50648. * Add fallbacks to the effect fallbacks list.
  50649. * @param defines defines the Base texture to use.
  50650. * @param fallbacks defines the current fallback list.
  50651. * @param currentRank defines the current fallback rank.
  50652. * @returns the new fallback rank.
  50653. */
  50654. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50655. /**
  50656. * Add the required uniforms to the current list.
  50657. * @param uniforms defines the current uniform list.
  50658. */
  50659. static AddUniforms(uniforms: string[]): void;
  50660. /**
  50661. * Add the required samplers to the current list.
  50662. * @param samplers defines the current sampler list.
  50663. */
  50664. static AddSamplers(samplers: string[]): void;
  50665. /**
  50666. * Add the required uniforms to the current buffer.
  50667. * @param uniformBuffer defines the current uniform buffer.
  50668. */
  50669. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50670. /**
  50671. * Makes a duplicate of the current configuration into another one.
  50672. * @param clearCoatConfiguration define the config where to copy the info
  50673. */
  50674. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50675. /**
  50676. * Serializes this clear coat configuration.
  50677. * @returns - An object with the serialized config.
  50678. */
  50679. serialize(): any;
  50680. /**
  50681. * Parses a anisotropy Configuration from a serialized object.
  50682. * @param source - Serialized object.
  50683. * @param scene Defines the scene we are parsing for
  50684. * @param rootUrl Defines the rootUrl to load from
  50685. */
  50686. parse(source: any, scene: Scene, rootUrl: string): void;
  50687. }
  50688. }
  50689. declare module BABYLON {
  50690. /**
  50691. * @hidden
  50692. */
  50693. export interface IMaterialAnisotropicDefines {
  50694. ANISOTROPIC: boolean;
  50695. ANISOTROPIC_TEXTURE: boolean;
  50696. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50697. MAINUV1: boolean;
  50698. _areTexturesDirty: boolean;
  50699. _needUVs: boolean;
  50700. }
  50701. /**
  50702. * Define the code related to the anisotropic parameters of the pbr material.
  50703. */
  50704. export class PBRAnisotropicConfiguration {
  50705. private _isEnabled;
  50706. /**
  50707. * Defines if the anisotropy is enabled in the material.
  50708. */
  50709. isEnabled: boolean;
  50710. /**
  50711. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50712. */
  50713. intensity: number;
  50714. /**
  50715. * Defines if the effect is along the tangents, bitangents or in between.
  50716. * By default, the effect is "strectching" the highlights along the tangents.
  50717. */
  50718. direction: Vector2;
  50719. private _texture;
  50720. /**
  50721. * Stores the anisotropy values in a texture.
  50722. * rg is direction (like normal from -1 to 1)
  50723. * b is a intensity
  50724. */
  50725. texture: Nullable<BaseTexture>;
  50726. /** @hidden */
  50727. private _internalMarkAllSubMeshesAsTexturesDirty;
  50728. /** @hidden */
  50729. _markAllSubMeshesAsTexturesDirty(): void;
  50730. /**
  50731. * Instantiate a new istance of anisotropy configuration.
  50732. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50733. */
  50734. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50735. /**
  50736. * Specifies that the submesh is ready to be used.
  50737. * @param defines the list of "defines" to update.
  50738. * @param scene defines the scene the material belongs to.
  50739. * @returns - boolean indicating that the submesh is ready or not.
  50740. */
  50741. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50742. /**
  50743. * Checks to see if a texture is used in the material.
  50744. * @param defines the list of "defines" to update.
  50745. * @param mesh the mesh we are preparing the defines for.
  50746. * @param scene defines the scene the material belongs to.
  50747. */
  50748. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50749. /**
  50750. * Binds the material data.
  50751. * @param uniformBuffer defines the Uniform buffer to fill in.
  50752. * @param scene defines the scene the material belongs to.
  50753. * @param isFrozen defines wether the material is frozen or not.
  50754. */
  50755. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50756. /**
  50757. * Checks to see if a texture is used in the material.
  50758. * @param texture - Base texture to use.
  50759. * @returns - Boolean specifying if a texture is used in the material.
  50760. */
  50761. hasTexture(texture: BaseTexture): boolean;
  50762. /**
  50763. * Returns an array of the actively used textures.
  50764. * @param activeTextures Array of BaseTextures
  50765. */
  50766. getActiveTextures(activeTextures: BaseTexture[]): void;
  50767. /**
  50768. * Returns the animatable textures.
  50769. * @param animatables Array of animatable textures.
  50770. */
  50771. getAnimatables(animatables: IAnimatable[]): void;
  50772. /**
  50773. * Disposes the resources of the material.
  50774. * @param forceDisposeTextures - Forces the disposal of all textures.
  50775. */
  50776. dispose(forceDisposeTextures?: boolean): void;
  50777. /**
  50778. * Get the current class name of the texture useful for serialization or dynamic coding.
  50779. * @returns "PBRAnisotropicConfiguration"
  50780. */
  50781. getClassName(): string;
  50782. /**
  50783. * Add fallbacks to the effect fallbacks list.
  50784. * @param defines defines the Base texture to use.
  50785. * @param fallbacks defines the current fallback list.
  50786. * @param currentRank defines the current fallback rank.
  50787. * @returns the new fallback rank.
  50788. */
  50789. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50790. /**
  50791. * Add the required uniforms to the current list.
  50792. * @param uniforms defines the current uniform list.
  50793. */
  50794. static AddUniforms(uniforms: string[]): void;
  50795. /**
  50796. * Add the required uniforms to the current buffer.
  50797. * @param uniformBuffer defines the current uniform buffer.
  50798. */
  50799. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50800. /**
  50801. * Add the required samplers to the current list.
  50802. * @param samplers defines the current sampler list.
  50803. */
  50804. static AddSamplers(samplers: string[]): void;
  50805. /**
  50806. * Makes a duplicate of the current configuration into another one.
  50807. * @param anisotropicConfiguration define the config where to copy the info
  50808. */
  50809. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50810. /**
  50811. * Serializes this anisotropy configuration.
  50812. * @returns - An object with the serialized config.
  50813. */
  50814. serialize(): any;
  50815. /**
  50816. * Parses a anisotropy Configuration from a serialized object.
  50817. * @param source - Serialized object.
  50818. * @param scene Defines the scene we are parsing for
  50819. * @param rootUrl Defines the rootUrl to load from
  50820. */
  50821. parse(source: any, scene: Scene, rootUrl: string): void;
  50822. }
  50823. }
  50824. declare module BABYLON {
  50825. /**
  50826. * @hidden
  50827. */
  50828. export interface IMaterialBRDFDefines {
  50829. BRDF_V_HEIGHT_CORRELATED: boolean;
  50830. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50831. SPHERICAL_HARMONICS: boolean;
  50832. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50833. /** @hidden */
  50834. _areMiscDirty: boolean;
  50835. }
  50836. /**
  50837. * Define the code related to the BRDF parameters of the pbr material.
  50838. */
  50839. export class PBRBRDFConfiguration {
  50840. /**
  50841. * Default value used for the energy conservation.
  50842. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50843. */
  50844. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50845. /**
  50846. * Default value used for the Smith Visibility Height Correlated mode.
  50847. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50848. */
  50849. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50850. /**
  50851. * Default value used for the IBL diffuse part.
  50852. * This can help switching back to the polynomials mode globally which is a tiny bit
  50853. * less GPU intensive at the drawback of a lower quality.
  50854. */
  50855. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50856. /**
  50857. * Default value used for activating energy conservation for the specular workflow.
  50858. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50859. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50860. */
  50861. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50862. private _useEnergyConservation;
  50863. /**
  50864. * Defines if the material uses energy conservation.
  50865. */
  50866. useEnergyConservation: boolean;
  50867. private _useSmithVisibilityHeightCorrelated;
  50868. /**
  50869. * LEGACY Mode set to false
  50870. * Defines if the material uses height smith correlated visibility term.
  50871. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50872. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50873. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50874. * Not relying on height correlated will also disable energy conservation.
  50875. */
  50876. useSmithVisibilityHeightCorrelated: boolean;
  50877. private _useSphericalHarmonics;
  50878. /**
  50879. * LEGACY Mode set to false
  50880. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50881. * diffuse part of the IBL.
  50882. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50883. * to the ground truth.
  50884. */
  50885. useSphericalHarmonics: boolean;
  50886. private _useSpecularGlossinessInputEnergyConservation;
  50887. /**
  50888. * Defines if the material uses energy conservation, when the specular workflow is active.
  50889. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50890. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50891. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50892. */
  50893. useSpecularGlossinessInputEnergyConservation: boolean;
  50894. /** @hidden */
  50895. private _internalMarkAllSubMeshesAsMiscDirty;
  50896. /** @hidden */
  50897. _markAllSubMeshesAsMiscDirty(): void;
  50898. /**
  50899. * Instantiate a new istance of clear coat configuration.
  50900. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50901. */
  50902. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50903. /**
  50904. * Checks to see if a texture is used in the material.
  50905. * @param defines the list of "defines" to update.
  50906. */
  50907. prepareDefines(defines: IMaterialBRDFDefines): void;
  50908. /**
  50909. * Get the current class name of the texture useful for serialization or dynamic coding.
  50910. * @returns "PBRClearCoatConfiguration"
  50911. */
  50912. getClassName(): string;
  50913. /**
  50914. * Makes a duplicate of the current configuration into another one.
  50915. * @param brdfConfiguration define the config where to copy the info
  50916. */
  50917. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50918. /**
  50919. * Serializes this BRDF configuration.
  50920. * @returns - An object with the serialized config.
  50921. */
  50922. serialize(): any;
  50923. /**
  50924. * Parses a anisotropy Configuration from a serialized object.
  50925. * @param source - Serialized object.
  50926. * @param scene Defines the scene we are parsing for
  50927. * @param rootUrl Defines the rootUrl to load from
  50928. */
  50929. parse(source: any, scene: Scene, rootUrl: string): void;
  50930. }
  50931. }
  50932. declare module BABYLON {
  50933. /**
  50934. * @hidden
  50935. */
  50936. export interface IMaterialSheenDefines {
  50937. SHEEN: boolean;
  50938. SHEEN_TEXTURE: boolean;
  50939. SHEEN_TEXTUREDIRECTUV: number;
  50940. SHEEN_LINKWITHALBEDO: boolean;
  50941. SHEEN_ROUGHNESS: boolean;
  50942. SHEEN_ALBEDOSCALING: boolean;
  50943. /** @hidden */
  50944. _areTexturesDirty: boolean;
  50945. }
  50946. /**
  50947. * Define the code related to the Sheen parameters of the pbr material.
  50948. */
  50949. export class PBRSheenConfiguration {
  50950. private _isEnabled;
  50951. /**
  50952. * Defines if the material uses sheen.
  50953. */
  50954. isEnabled: boolean;
  50955. private _linkSheenWithAlbedo;
  50956. /**
  50957. * Defines if the sheen is linked to the sheen color.
  50958. */
  50959. linkSheenWithAlbedo: boolean;
  50960. /**
  50961. * Defines the sheen intensity.
  50962. */
  50963. intensity: number;
  50964. /**
  50965. * Defines the sheen color.
  50966. */
  50967. color: Color3;
  50968. private _texture;
  50969. /**
  50970. * Stores the sheen tint values in a texture.
  50971. * rgb is tint
  50972. * a is a intensity
  50973. */
  50974. texture: Nullable<BaseTexture>;
  50975. private _roughness;
  50976. /**
  50977. * Defines the sheen roughness.
  50978. * It is not taken into account if linkSheenWithAlbedo is true.
  50979. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50980. */
  50981. roughness: Nullable<number>;
  50982. private _albedoScaling;
  50983. /**
  50984. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50985. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50986. * making it easier to setup and tweak the effect
  50987. */
  50988. albedoScaling: boolean;
  50989. /** @hidden */
  50990. private _internalMarkAllSubMeshesAsTexturesDirty;
  50991. /** @hidden */
  50992. _markAllSubMeshesAsTexturesDirty(): void;
  50993. /**
  50994. * Instantiate a new istance of clear coat configuration.
  50995. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50996. */
  50997. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50998. /**
  50999. * Specifies that the submesh is ready to be used.
  51000. * @param defines the list of "defines" to update.
  51001. * @param scene defines the scene the material belongs to.
  51002. * @returns - boolean indicating that the submesh is ready or not.
  51003. */
  51004. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51005. /**
  51006. * Checks to see if a texture is used in the material.
  51007. * @param defines the list of "defines" to update.
  51008. * @param scene defines the scene the material belongs to.
  51009. */
  51010. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51011. /**
  51012. * Binds the material data.
  51013. * @param uniformBuffer defines the Uniform buffer to fill in.
  51014. * @param scene defines the scene the material belongs to.
  51015. * @param isFrozen defines wether the material is frozen or not.
  51016. */
  51017. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51018. /**
  51019. * Checks to see if a texture is used in the material.
  51020. * @param texture - Base texture to use.
  51021. * @returns - Boolean specifying if a texture is used in the material.
  51022. */
  51023. hasTexture(texture: BaseTexture): boolean;
  51024. /**
  51025. * Returns an array of the actively used textures.
  51026. * @param activeTextures Array of BaseTextures
  51027. */
  51028. getActiveTextures(activeTextures: BaseTexture[]): void;
  51029. /**
  51030. * Returns the animatable textures.
  51031. * @param animatables Array of animatable textures.
  51032. */
  51033. getAnimatables(animatables: IAnimatable[]): void;
  51034. /**
  51035. * Disposes the resources of the material.
  51036. * @param forceDisposeTextures - Forces the disposal of all textures.
  51037. */
  51038. dispose(forceDisposeTextures?: boolean): void;
  51039. /**
  51040. * Get the current class name of the texture useful for serialization or dynamic coding.
  51041. * @returns "PBRSheenConfiguration"
  51042. */
  51043. getClassName(): string;
  51044. /**
  51045. * Add fallbacks to the effect fallbacks list.
  51046. * @param defines defines the Base texture to use.
  51047. * @param fallbacks defines the current fallback list.
  51048. * @param currentRank defines the current fallback rank.
  51049. * @returns the new fallback rank.
  51050. */
  51051. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51052. /**
  51053. * Add the required uniforms to the current list.
  51054. * @param uniforms defines the current uniform list.
  51055. */
  51056. static AddUniforms(uniforms: string[]): void;
  51057. /**
  51058. * Add the required uniforms to the current buffer.
  51059. * @param uniformBuffer defines the current uniform buffer.
  51060. */
  51061. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51062. /**
  51063. * Add the required samplers to the current list.
  51064. * @param samplers defines the current sampler list.
  51065. */
  51066. static AddSamplers(samplers: string[]): void;
  51067. /**
  51068. * Makes a duplicate of the current configuration into another one.
  51069. * @param sheenConfiguration define the config where to copy the info
  51070. */
  51071. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51072. /**
  51073. * Serializes this BRDF configuration.
  51074. * @returns - An object with the serialized config.
  51075. */
  51076. serialize(): any;
  51077. /**
  51078. * Parses a anisotropy Configuration from a serialized object.
  51079. * @param source - Serialized object.
  51080. * @param scene Defines the scene we are parsing for
  51081. * @param rootUrl Defines the rootUrl to load from
  51082. */
  51083. parse(source: any, scene: Scene, rootUrl: string): void;
  51084. }
  51085. }
  51086. declare module BABYLON {
  51087. /**
  51088. * @hidden
  51089. */
  51090. export interface IMaterialSubSurfaceDefines {
  51091. SUBSURFACE: boolean;
  51092. SS_REFRACTION: boolean;
  51093. SS_TRANSLUCENCY: boolean;
  51094. SS_SCATERRING: boolean;
  51095. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51096. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51097. SS_REFRACTIONMAP_3D: boolean;
  51098. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51099. SS_LODINREFRACTIONALPHA: boolean;
  51100. SS_GAMMAREFRACTION: boolean;
  51101. SS_RGBDREFRACTION: boolean;
  51102. SS_LINEARSPECULARREFRACTION: boolean;
  51103. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51104. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51105. /** @hidden */
  51106. _areTexturesDirty: boolean;
  51107. }
  51108. /**
  51109. * Define the code related to the sub surface parameters of the pbr material.
  51110. */
  51111. export class PBRSubSurfaceConfiguration {
  51112. private _isRefractionEnabled;
  51113. /**
  51114. * Defines if the refraction is enabled in the material.
  51115. */
  51116. isRefractionEnabled: boolean;
  51117. private _isTranslucencyEnabled;
  51118. /**
  51119. * Defines if the translucency is enabled in the material.
  51120. */
  51121. isTranslucencyEnabled: boolean;
  51122. private _isScatteringEnabled;
  51123. /**
  51124. * Defines the refraction intensity of the material.
  51125. * The refraction when enabled replaces the Diffuse part of the material.
  51126. * The intensity helps transitionning between diffuse and refraction.
  51127. */
  51128. refractionIntensity: number;
  51129. /**
  51130. * Defines the translucency intensity of the material.
  51131. * When translucency has been enabled, this defines how much of the "translucency"
  51132. * is addded to the diffuse part of the material.
  51133. */
  51134. translucencyIntensity: number;
  51135. /**
  51136. * Defines the scattering intensity of the material.
  51137. * When scattering has been enabled, this defines how much of the "scattered light"
  51138. * is addded to the diffuse part of the material.
  51139. */
  51140. scatteringIntensity: number;
  51141. private _thicknessTexture;
  51142. /**
  51143. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51144. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51145. * 0 would mean minimumThickness
  51146. * 1 would mean maximumThickness
  51147. * The other channels might be use as a mask to vary the different effects intensity.
  51148. */
  51149. thicknessTexture: Nullable<BaseTexture>;
  51150. private _refractionTexture;
  51151. /**
  51152. * Defines the texture to use for refraction.
  51153. */
  51154. refractionTexture: Nullable<BaseTexture>;
  51155. private _indexOfRefraction;
  51156. /**
  51157. * Defines the index of refraction used in the material.
  51158. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51159. */
  51160. indexOfRefraction: number;
  51161. private _invertRefractionY;
  51162. /**
  51163. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51164. */
  51165. invertRefractionY: boolean;
  51166. private _linkRefractionWithTransparency;
  51167. /**
  51168. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51169. * Materials half opaque for instance using refraction could benefit from this control.
  51170. */
  51171. linkRefractionWithTransparency: boolean;
  51172. /**
  51173. * Defines the minimum thickness stored in the thickness map.
  51174. * If no thickness map is defined, this value will be used to simulate thickness.
  51175. */
  51176. minimumThickness: number;
  51177. /**
  51178. * Defines the maximum thickness stored in the thickness map.
  51179. */
  51180. maximumThickness: number;
  51181. /**
  51182. * Defines the volume tint of the material.
  51183. * This is used for both translucency and scattering.
  51184. */
  51185. tintColor: Color3;
  51186. /**
  51187. * Defines the distance at which the tint color should be found in the media.
  51188. * This is used for refraction only.
  51189. */
  51190. tintColorAtDistance: number;
  51191. /**
  51192. * Defines how far each channel transmit through the media.
  51193. * It is defined as a color to simplify it selection.
  51194. */
  51195. diffusionDistance: Color3;
  51196. private _useMaskFromThicknessTexture;
  51197. /**
  51198. * Stores the intensity of the different subsurface effects in the thickness texture.
  51199. * * the green channel is the translucency intensity.
  51200. * * the blue channel is the scattering intensity.
  51201. * * the alpha channel is the refraction intensity.
  51202. */
  51203. useMaskFromThicknessTexture: boolean;
  51204. /** @hidden */
  51205. private _internalMarkAllSubMeshesAsTexturesDirty;
  51206. /** @hidden */
  51207. _markAllSubMeshesAsTexturesDirty(): void;
  51208. /**
  51209. * Instantiate a new istance of sub surface configuration.
  51210. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51211. */
  51212. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51213. /**
  51214. * Gets wehter the submesh is ready to be used or not.
  51215. * @param defines the list of "defines" to update.
  51216. * @param scene defines the scene the material belongs to.
  51217. * @returns - boolean indicating that the submesh is ready or not.
  51218. */
  51219. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51220. /**
  51221. * Checks to see if a texture is used in the material.
  51222. * @param defines the list of "defines" to update.
  51223. * @param scene defines the scene to the material belongs to.
  51224. */
  51225. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51226. /**
  51227. * Binds the material data.
  51228. * @param uniformBuffer defines the Uniform buffer to fill in.
  51229. * @param scene defines the scene the material belongs to.
  51230. * @param engine defines the engine the material belongs to.
  51231. * @param isFrozen defines wether the material is frozen or not.
  51232. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51233. */
  51234. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51235. /**
  51236. * Unbinds the material from the mesh.
  51237. * @param activeEffect defines the effect that should be unbound from.
  51238. * @returns true if unbound, otherwise false
  51239. */
  51240. unbind(activeEffect: Effect): boolean;
  51241. /**
  51242. * Returns the texture used for refraction or null if none is used.
  51243. * @param scene defines the scene the material belongs to.
  51244. * @returns - Refraction texture if present. If no refraction texture and refraction
  51245. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51246. */
  51247. private _getRefractionTexture;
  51248. /**
  51249. * Returns true if alpha blending should be disabled.
  51250. */
  51251. get disableAlphaBlending(): boolean;
  51252. /**
  51253. * Fills the list of render target textures.
  51254. * @param renderTargets the list of render targets to update
  51255. */
  51256. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51257. /**
  51258. * Checks to see if a texture is used in the material.
  51259. * @param texture - Base texture to use.
  51260. * @returns - Boolean specifying if a texture is used in the material.
  51261. */
  51262. hasTexture(texture: BaseTexture): boolean;
  51263. /**
  51264. * Gets a boolean indicating that current material needs to register RTT
  51265. * @returns true if this uses a render target otherwise false.
  51266. */
  51267. hasRenderTargetTextures(): boolean;
  51268. /**
  51269. * Returns an array of the actively used textures.
  51270. * @param activeTextures Array of BaseTextures
  51271. */
  51272. getActiveTextures(activeTextures: BaseTexture[]): void;
  51273. /**
  51274. * Returns the animatable textures.
  51275. * @param animatables Array of animatable textures.
  51276. */
  51277. getAnimatables(animatables: IAnimatable[]): void;
  51278. /**
  51279. * Disposes the resources of the material.
  51280. * @param forceDisposeTextures - Forces the disposal of all textures.
  51281. */
  51282. dispose(forceDisposeTextures?: boolean): void;
  51283. /**
  51284. * Get the current class name of the texture useful for serialization or dynamic coding.
  51285. * @returns "PBRSubSurfaceConfiguration"
  51286. */
  51287. getClassName(): string;
  51288. /**
  51289. * Add fallbacks to the effect fallbacks list.
  51290. * @param defines defines the Base texture to use.
  51291. * @param fallbacks defines the current fallback list.
  51292. * @param currentRank defines the current fallback rank.
  51293. * @returns the new fallback rank.
  51294. */
  51295. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51296. /**
  51297. * Add the required uniforms to the current list.
  51298. * @param uniforms defines the current uniform list.
  51299. */
  51300. static AddUniforms(uniforms: string[]): void;
  51301. /**
  51302. * Add the required samplers to the current list.
  51303. * @param samplers defines the current sampler list.
  51304. */
  51305. static AddSamplers(samplers: string[]): void;
  51306. /**
  51307. * Add the required uniforms to the current buffer.
  51308. * @param uniformBuffer defines the current uniform buffer.
  51309. */
  51310. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51311. /**
  51312. * Makes a duplicate of the current configuration into another one.
  51313. * @param configuration define the config where to copy the info
  51314. */
  51315. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51316. /**
  51317. * Serializes this Sub Surface configuration.
  51318. * @returns - An object with the serialized config.
  51319. */
  51320. serialize(): any;
  51321. /**
  51322. * Parses a anisotropy Configuration from a serialized object.
  51323. * @param source - Serialized object.
  51324. * @param scene Defines the scene we are parsing for
  51325. * @param rootUrl Defines the rootUrl to load from
  51326. */
  51327. parse(source: any, scene: Scene, rootUrl: string): void;
  51328. }
  51329. }
  51330. declare module BABYLON {
  51331. /** @hidden */
  51332. export var pbrFragmentDeclaration: {
  51333. name: string;
  51334. shader: string;
  51335. };
  51336. }
  51337. declare module BABYLON {
  51338. /** @hidden */
  51339. export var pbrUboDeclaration: {
  51340. name: string;
  51341. shader: string;
  51342. };
  51343. }
  51344. declare module BABYLON {
  51345. /** @hidden */
  51346. export var pbrFragmentExtraDeclaration: {
  51347. name: string;
  51348. shader: string;
  51349. };
  51350. }
  51351. declare module BABYLON {
  51352. /** @hidden */
  51353. export var pbrFragmentSamplersDeclaration: {
  51354. name: string;
  51355. shader: string;
  51356. };
  51357. }
  51358. declare module BABYLON {
  51359. /** @hidden */
  51360. export var pbrHelperFunctions: {
  51361. name: string;
  51362. shader: string;
  51363. };
  51364. }
  51365. declare module BABYLON {
  51366. /** @hidden */
  51367. export var harmonicsFunctions: {
  51368. name: string;
  51369. shader: string;
  51370. };
  51371. }
  51372. declare module BABYLON {
  51373. /** @hidden */
  51374. export var pbrDirectLightingSetupFunctions: {
  51375. name: string;
  51376. shader: string;
  51377. };
  51378. }
  51379. declare module BABYLON {
  51380. /** @hidden */
  51381. export var pbrDirectLightingFalloffFunctions: {
  51382. name: string;
  51383. shader: string;
  51384. };
  51385. }
  51386. declare module BABYLON {
  51387. /** @hidden */
  51388. export var pbrBRDFFunctions: {
  51389. name: string;
  51390. shader: string;
  51391. };
  51392. }
  51393. declare module BABYLON {
  51394. /** @hidden */
  51395. export var pbrDirectLightingFunctions: {
  51396. name: string;
  51397. shader: string;
  51398. };
  51399. }
  51400. declare module BABYLON {
  51401. /** @hidden */
  51402. export var pbrIBLFunctions: {
  51403. name: string;
  51404. shader: string;
  51405. };
  51406. }
  51407. declare module BABYLON {
  51408. /** @hidden */
  51409. export var pbrBlockAlbedoOpacity: {
  51410. name: string;
  51411. shader: string;
  51412. };
  51413. }
  51414. declare module BABYLON {
  51415. /** @hidden */
  51416. export var pbrBlockReflectivity: {
  51417. name: string;
  51418. shader: string;
  51419. };
  51420. }
  51421. declare module BABYLON {
  51422. /** @hidden */
  51423. export var pbrBlockAmbientOcclusion: {
  51424. name: string;
  51425. shader: string;
  51426. };
  51427. }
  51428. declare module BABYLON {
  51429. /** @hidden */
  51430. export var pbrBlockAlphaFresnel: {
  51431. name: string;
  51432. shader: string;
  51433. };
  51434. }
  51435. declare module BABYLON {
  51436. /** @hidden */
  51437. export var pbrBlockAnisotropic: {
  51438. name: string;
  51439. shader: string;
  51440. };
  51441. }
  51442. declare module BABYLON {
  51443. /** @hidden */
  51444. export var pbrBlockReflection: {
  51445. name: string;
  51446. shader: string;
  51447. };
  51448. }
  51449. declare module BABYLON {
  51450. /** @hidden */
  51451. export var pbrBlockSheen: {
  51452. name: string;
  51453. shader: string;
  51454. };
  51455. }
  51456. declare module BABYLON {
  51457. /** @hidden */
  51458. export var pbrBlockClearcoat: {
  51459. name: string;
  51460. shader: string;
  51461. };
  51462. }
  51463. declare module BABYLON {
  51464. /** @hidden */
  51465. export var pbrBlockSubSurface: {
  51466. name: string;
  51467. shader: string;
  51468. };
  51469. }
  51470. declare module BABYLON {
  51471. /** @hidden */
  51472. export var pbrBlockNormalGeometric: {
  51473. name: string;
  51474. shader: string;
  51475. };
  51476. }
  51477. declare module BABYLON {
  51478. /** @hidden */
  51479. export var pbrBlockNormalFinal: {
  51480. name: string;
  51481. shader: string;
  51482. };
  51483. }
  51484. declare module BABYLON {
  51485. /** @hidden */
  51486. export var pbrBlockGeometryInfo: {
  51487. name: string;
  51488. shader: string;
  51489. };
  51490. }
  51491. declare module BABYLON {
  51492. /** @hidden */
  51493. export var pbrBlockReflectance0: {
  51494. name: string;
  51495. shader: string;
  51496. };
  51497. }
  51498. declare module BABYLON {
  51499. /** @hidden */
  51500. export var pbrBlockReflectance: {
  51501. name: string;
  51502. shader: string;
  51503. };
  51504. }
  51505. declare module BABYLON {
  51506. /** @hidden */
  51507. export var pbrBlockDirectLighting: {
  51508. name: string;
  51509. shader: string;
  51510. };
  51511. }
  51512. declare module BABYLON {
  51513. /** @hidden */
  51514. export var pbrBlockFinalLitComponents: {
  51515. name: string;
  51516. shader: string;
  51517. };
  51518. }
  51519. declare module BABYLON {
  51520. /** @hidden */
  51521. export var pbrBlockFinalUnlitComponents: {
  51522. name: string;
  51523. shader: string;
  51524. };
  51525. }
  51526. declare module BABYLON {
  51527. /** @hidden */
  51528. export var pbrBlockFinalColorComposition: {
  51529. name: string;
  51530. shader: string;
  51531. };
  51532. }
  51533. declare module BABYLON {
  51534. /** @hidden */
  51535. export var pbrBlockImageProcessing: {
  51536. name: string;
  51537. shader: string;
  51538. };
  51539. }
  51540. declare module BABYLON {
  51541. /** @hidden */
  51542. export var pbrDebug: {
  51543. name: string;
  51544. shader: string;
  51545. };
  51546. }
  51547. declare module BABYLON {
  51548. /** @hidden */
  51549. export var pbrPixelShader: {
  51550. name: string;
  51551. shader: string;
  51552. };
  51553. }
  51554. declare module BABYLON {
  51555. /** @hidden */
  51556. export var pbrVertexDeclaration: {
  51557. name: string;
  51558. shader: string;
  51559. };
  51560. }
  51561. declare module BABYLON {
  51562. /** @hidden */
  51563. export var pbrVertexShader: {
  51564. name: string;
  51565. shader: string;
  51566. };
  51567. }
  51568. declare module BABYLON {
  51569. /**
  51570. * Manages the defines for the PBR Material.
  51571. * @hidden
  51572. */
  51573. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51574. PBR: boolean;
  51575. MAINUV1: boolean;
  51576. MAINUV2: boolean;
  51577. UV1: boolean;
  51578. UV2: boolean;
  51579. ALBEDO: boolean;
  51580. GAMMAALBEDO: boolean;
  51581. ALBEDODIRECTUV: number;
  51582. VERTEXCOLOR: boolean;
  51583. AMBIENT: boolean;
  51584. AMBIENTDIRECTUV: number;
  51585. AMBIENTINGRAYSCALE: boolean;
  51586. OPACITY: boolean;
  51587. VERTEXALPHA: boolean;
  51588. OPACITYDIRECTUV: number;
  51589. OPACITYRGB: boolean;
  51590. ALPHATEST: boolean;
  51591. DEPTHPREPASS: boolean;
  51592. ALPHABLEND: boolean;
  51593. ALPHAFROMALBEDO: boolean;
  51594. ALPHATESTVALUE: string;
  51595. SPECULAROVERALPHA: boolean;
  51596. RADIANCEOVERALPHA: boolean;
  51597. ALPHAFRESNEL: boolean;
  51598. LINEARALPHAFRESNEL: boolean;
  51599. PREMULTIPLYALPHA: boolean;
  51600. EMISSIVE: boolean;
  51601. EMISSIVEDIRECTUV: number;
  51602. REFLECTIVITY: boolean;
  51603. REFLECTIVITYDIRECTUV: number;
  51604. SPECULARTERM: boolean;
  51605. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51606. MICROSURFACEAUTOMATIC: boolean;
  51607. LODBASEDMICROSFURACE: boolean;
  51608. MICROSURFACEMAP: boolean;
  51609. MICROSURFACEMAPDIRECTUV: number;
  51610. METALLICWORKFLOW: boolean;
  51611. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51612. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51613. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51614. AOSTOREINMETALMAPRED: boolean;
  51615. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51616. ENVIRONMENTBRDF: boolean;
  51617. ENVIRONMENTBRDF_RGBD: boolean;
  51618. NORMAL: boolean;
  51619. TANGENT: boolean;
  51620. BUMP: boolean;
  51621. BUMPDIRECTUV: number;
  51622. OBJECTSPACE_NORMALMAP: boolean;
  51623. PARALLAX: boolean;
  51624. PARALLAXOCCLUSION: boolean;
  51625. NORMALXYSCALE: boolean;
  51626. LIGHTMAP: boolean;
  51627. LIGHTMAPDIRECTUV: number;
  51628. USELIGHTMAPASSHADOWMAP: boolean;
  51629. GAMMALIGHTMAP: boolean;
  51630. RGBDLIGHTMAP: boolean;
  51631. REFLECTION: boolean;
  51632. REFLECTIONMAP_3D: boolean;
  51633. REFLECTIONMAP_SPHERICAL: boolean;
  51634. REFLECTIONMAP_PLANAR: boolean;
  51635. REFLECTIONMAP_CUBIC: boolean;
  51636. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51637. REFLECTIONMAP_PROJECTION: boolean;
  51638. REFLECTIONMAP_SKYBOX: boolean;
  51639. REFLECTIONMAP_EXPLICIT: boolean;
  51640. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51641. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51642. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51643. INVERTCUBICMAP: boolean;
  51644. USESPHERICALFROMREFLECTIONMAP: boolean;
  51645. USEIRRADIANCEMAP: boolean;
  51646. SPHERICAL_HARMONICS: boolean;
  51647. USESPHERICALINVERTEX: boolean;
  51648. REFLECTIONMAP_OPPOSITEZ: boolean;
  51649. LODINREFLECTIONALPHA: boolean;
  51650. GAMMAREFLECTION: boolean;
  51651. RGBDREFLECTION: boolean;
  51652. LINEARSPECULARREFLECTION: boolean;
  51653. RADIANCEOCCLUSION: boolean;
  51654. HORIZONOCCLUSION: boolean;
  51655. INSTANCES: boolean;
  51656. NUM_BONE_INFLUENCERS: number;
  51657. BonesPerMesh: number;
  51658. BONETEXTURE: boolean;
  51659. NONUNIFORMSCALING: boolean;
  51660. MORPHTARGETS: boolean;
  51661. MORPHTARGETS_NORMAL: boolean;
  51662. MORPHTARGETS_TANGENT: boolean;
  51663. MORPHTARGETS_UV: boolean;
  51664. NUM_MORPH_INFLUENCERS: number;
  51665. IMAGEPROCESSING: boolean;
  51666. VIGNETTE: boolean;
  51667. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51668. VIGNETTEBLENDMODEOPAQUE: boolean;
  51669. TONEMAPPING: boolean;
  51670. TONEMAPPING_ACES: boolean;
  51671. CONTRAST: boolean;
  51672. COLORCURVES: boolean;
  51673. COLORGRADING: boolean;
  51674. COLORGRADING3D: boolean;
  51675. SAMPLER3DGREENDEPTH: boolean;
  51676. SAMPLER3DBGRMAP: boolean;
  51677. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51678. EXPOSURE: boolean;
  51679. MULTIVIEW: boolean;
  51680. USEPHYSICALLIGHTFALLOFF: boolean;
  51681. USEGLTFLIGHTFALLOFF: boolean;
  51682. TWOSIDEDLIGHTING: boolean;
  51683. SHADOWFLOAT: boolean;
  51684. CLIPPLANE: boolean;
  51685. CLIPPLANE2: boolean;
  51686. CLIPPLANE3: boolean;
  51687. CLIPPLANE4: boolean;
  51688. CLIPPLANE5: boolean;
  51689. CLIPPLANE6: boolean;
  51690. POINTSIZE: boolean;
  51691. FOG: boolean;
  51692. LOGARITHMICDEPTH: boolean;
  51693. FORCENORMALFORWARD: boolean;
  51694. SPECULARAA: boolean;
  51695. CLEARCOAT: boolean;
  51696. CLEARCOAT_DEFAULTIOR: boolean;
  51697. CLEARCOAT_TEXTURE: boolean;
  51698. CLEARCOAT_TEXTUREDIRECTUV: number;
  51699. CLEARCOAT_BUMP: boolean;
  51700. CLEARCOAT_BUMPDIRECTUV: number;
  51701. CLEARCOAT_TINT: boolean;
  51702. CLEARCOAT_TINT_TEXTURE: boolean;
  51703. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51704. ANISOTROPIC: boolean;
  51705. ANISOTROPIC_TEXTURE: boolean;
  51706. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51707. BRDF_V_HEIGHT_CORRELATED: boolean;
  51708. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51709. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51710. SHEEN: boolean;
  51711. SHEEN_TEXTURE: boolean;
  51712. SHEEN_TEXTUREDIRECTUV: number;
  51713. SHEEN_LINKWITHALBEDO: boolean;
  51714. SHEEN_ROUGHNESS: boolean;
  51715. SHEEN_ALBEDOSCALING: boolean;
  51716. SUBSURFACE: boolean;
  51717. SS_REFRACTION: boolean;
  51718. SS_TRANSLUCENCY: boolean;
  51719. SS_SCATERRING: boolean;
  51720. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51721. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51722. SS_REFRACTIONMAP_3D: boolean;
  51723. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51724. SS_LODINREFRACTIONALPHA: boolean;
  51725. SS_GAMMAREFRACTION: boolean;
  51726. SS_RGBDREFRACTION: boolean;
  51727. SS_LINEARSPECULARREFRACTION: boolean;
  51728. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51729. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51730. UNLIT: boolean;
  51731. DEBUGMODE: number;
  51732. /**
  51733. * Initializes the PBR Material defines.
  51734. */
  51735. constructor();
  51736. /**
  51737. * Resets the PBR Material defines.
  51738. */
  51739. reset(): void;
  51740. }
  51741. /**
  51742. * The Physically based material base class of BJS.
  51743. *
  51744. * This offers the main features of a standard PBR material.
  51745. * For more information, please refer to the documentation :
  51746. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51747. */
  51748. export abstract class PBRBaseMaterial extends PushMaterial {
  51749. /**
  51750. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51751. */
  51752. static readonly PBRMATERIAL_OPAQUE: number;
  51753. /**
  51754. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51755. */
  51756. static readonly PBRMATERIAL_ALPHATEST: number;
  51757. /**
  51758. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51759. */
  51760. static readonly PBRMATERIAL_ALPHABLEND: number;
  51761. /**
  51762. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51763. * They are also discarded below the alpha cutoff threshold to improve performances.
  51764. */
  51765. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51766. /**
  51767. * Defines the default value of how much AO map is occluding the analytical lights
  51768. * (point spot...).
  51769. */
  51770. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51771. /**
  51772. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51773. */
  51774. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51775. /**
  51776. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51777. * to enhance interoperability with other engines.
  51778. */
  51779. static readonly LIGHTFALLOFF_GLTF: number;
  51780. /**
  51781. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51782. * to enhance interoperability with other materials.
  51783. */
  51784. static readonly LIGHTFALLOFF_STANDARD: number;
  51785. /**
  51786. * Intensity of the direct lights e.g. the four lights available in your scene.
  51787. * This impacts both the direct diffuse and specular highlights.
  51788. */
  51789. protected _directIntensity: number;
  51790. /**
  51791. * Intensity of the emissive part of the material.
  51792. * This helps controlling the emissive effect without modifying the emissive color.
  51793. */
  51794. protected _emissiveIntensity: number;
  51795. /**
  51796. * Intensity of the environment e.g. how much the environment will light the object
  51797. * either through harmonics for rough material or through the refelction for shiny ones.
  51798. */
  51799. protected _environmentIntensity: number;
  51800. /**
  51801. * This is a special control allowing the reduction of the specular highlights coming from the
  51802. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51803. */
  51804. protected _specularIntensity: number;
  51805. /**
  51806. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51807. */
  51808. private _lightingInfos;
  51809. /**
  51810. * Debug Control allowing disabling the bump map on this material.
  51811. */
  51812. protected _disableBumpMap: boolean;
  51813. /**
  51814. * AKA Diffuse Texture in standard nomenclature.
  51815. */
  51816. protected _albedoTexture: Nullable<BaseTexture>;
  51817. /**
  51818. * AKA Occlusion Texture in other nomenclature.
  51819. */
  51820. protected _ambientTexture: Nullable<BaseTexture>;
  51821. /**
  51822. * AKA Occlusion Texture Intensity in other nomenclature.
  51823. */
  51824. protected _ambientTextureStrength: number;
  51825. /**
  51826. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51827. * 1 means it completely occludes it
  51828. * 0 mean it has no impact
  51829. */
  51830. protected _ambientTextureImpactOnAnalyticalLights: number;
  51831. /**
  51832. * Stores the alpha values in a texture.
  51833. */
  51834. protected _opacityTexture: Nullable<BaseTexture>;
  51835. /**
  51836. * Stores the reflection values in a texture.
  51837. */
  51838. protected _reflectionTexture: Nullable<BaseTexture>;
  51839. /**
  51840. * Stores the emissive values in a texture.
  51841. */
  51842. protected _emissiveTexture: Nullable<BaseTexture>;
  51843. /**
  51844. * AKA Specular texture in other nomenclature.
  51845. */
  51846. protected _reflectivityTexture: Nullable<BaseTexture>;
  51847. /**
  51848. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51849. */
  51850. protected _metallicTexture: Nullable<BaseTexture>;
  51851. /**
  51852. * Specifies the metallic scalar of the metallic/roughness workflow.
  51853. * Can also be used to scale the metalness values of the metallic texture.
  51854. */
  51855. protected _metallic: Nullable<number>;
  51856. /**
  51857. * Specifies the roughness scalar of the metallic/roughness workflow.
  51858. * Can also be used to scale the roughness values of the metallic texture.
  51859. */
  51860. protected _roughness: Nullable<number>;
  51861. /**
  51862. * Specifies the an F0 factor to help configuring the material F0.
  51863. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51864. * to 0.5 the previously hard coded value stays the same.
  51865. * Can also be used to scale the F0 values of the metallic texture.
  51866. */
  51867. protected _metallicF0Factor: number;
  51868. /**
  51869. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51870. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51871. * your expectation as it multiplies with the texture data.
  51872. */
  51873. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51874. /**
  51875. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51876. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51877. */
  51878. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51879. /**
  51880. * Stores surface normal data used to displace a mesh in a texture.
  51881. */
  51882. protected _bumpTexture: Nullable<BaseTexture>;
  51883. /**
  51884. * Stores the pre-calculated light information of a mesh in a texture.
  51885. */
  51886. protected _lightmapTexture: Nullable<BaseTexture>;
  51887. /**
  51888. * The color of a material in ambient lighting.
  51889. */
  51890. protected _ambientColor: Color3;
  51891. /**
  51892. * AKA Diffuse Color in other nomenclature.
  51893. */
  51894. protected _albedoColor: Color3;
  51895. /**
  51896. * AKA Specular Color in other nomenclature.
  51897. */
  51898. protected _reflectivityColor: Color3;
  51899. /**
  51900. * The color applied when light is reflected from a material.
  51901. */
  51902. protected _reflectionColor: Color3;
  51903. /**
  51904. * The color applied when light is emitted from a material.
  51905. */
  51906. protected _emissiveColor: Color3;
  51907. /**
  51908. * AKA Glossiness in other nomenclature.
  51909. */
  51910. protected _microSurface: number;
  51911. /**
  51912. * Specifies that the material will use the light map as a show map.
  51913. */
  51914. protected _useLightmapAsShadowmap: boolean;
  51915. /**
  51916. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51917. * makes the reflect vector face the model (under horizon).
  51918. */
  51919. protected _useHorizonOcclusion: boolean;
  51920. /**
  51921. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51922. * too much the area relying on ambient texture to define their ambient occlusion.
  51923. */
  51924. protected _useRadianceOcclusion: boolean;
  51925. /**
  51926. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51927. */
  51928. protected _useAlphaFromAlbedoTexture: boolean;
  51929. /**
  51930. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51931. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51932. */
  51933. protected _useSpecularOverAlpha: boolean;
  51934. /**
  51935. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51936. */
  51937. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51938. /**
  51939. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51940. */
  51941. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51942. /**
  51943. * Specifies if the metallic texture contains the roughness information in its green channel.
  51944. */
  51945. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51946. /**
  51947. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51948. */
  51949. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51950. /**
  51951. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51952. */
  51953. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51954. /**
  51955. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51956. */
  51957. protected _useAmbientInGrayScale: boolean;
  51958. /**
  51959. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51960. * The material will try to infer what glossiness each pixel should be.
  51961. */
  51962. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51963. /**
  51964. * Defines the falloff type used in this material.
  51965. * It by default is Physical.
  51966. */
  51967. protected _lightFalloff: number;
  51968. /**
  51969. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51970. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51971. */
  51972. protected _useRadianceOverAlpha: boolean;
  51973. /**
  51974. * Allows using an object space normal map (instead of tangent space).
  51975. */
  51976. protected _useObjectSpaceNormalMap: boolean;
  51977. /**
  51978. * Allows using the bump map in parallax mode.
  51979. */
  51980. protected _useParallax: boolean;
  51981. /**
  51982. * Allows using the bump map in parallax occlusion mode.
  51983. */
  51984. protected _useParallaxOcclusion: boolean;
  51985. /**
  51986. * Controls the scale bias of the parallax mode.
  51987. */
  51988. protected _parallaxScaleBias: number;
  51989. /**
  51990. * If sets to true, disables all the lights affecting the material.
  51991. */
  51992. protected _disableLighting: boolean;
  51993. /**
  51994. * Number of Simultaneous lights allowed on the material.
  51995. */
  51996. protected _maxSimultaneousLights: number;
  51997. /**
  51998. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51999. */
  52000. protected _invertNormalMapX: boolean;
  52001. /**
  52002. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52003. */
  52004. protected _invertNormalMapY: boolean;
  52005. /**
  52006. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52007. */
  52008. protected _twoSidedLighting: boolean;
  52009. /**
  52010. * Defines the alpha limits in alpha test mode.
  52011. */
  52012. protected _alphaCutOff: number;
  52013. /**
  52014. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52015. */
  52016. protected _forceAlphaTest: boolean;
  52017. /**
  52018. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52019. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52020. */
  52021. protected _useAlphaFresnel: boolean;
  52022. /**
  52023. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52024. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52025. */
  52026. protected _useLinearAlphaFresnel: boolean;
  52027. /**
  52028. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52029. * from cos thetav and roughness:
  52030. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52031. */
  52032. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52033. /**
  52034. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52035. */
  52036. protected _forceIrradianceInFragment: boolean;
  52037. /**
  52038. * Force normal to face away from face.
  52039. */
  52040. protected _forceNormalForward: boolean;
  52041. /**
  52042. * Enables specular anti aliasing in the PBR shader.
  52043. * It will both interacts on the Geometry for analytical and IBL lighting.
  52044. * It also prefilter the roughness map based on the bump values.
  52045. */
  52046. protected _enableSpecularAntiAliasing: boolean;
  52047. /**
  52048. * Default configuration related to image processing available in the PBR Material.
  52049. */
  52050. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52051. /**
  52052. * Keep track of the image processing observer to allow dispose and replace.
  52053. */
  52054. private _imageProcessingObserver;
  52055. /**
  52056. * Attaches a new image processing configuration to the PBR Material.
  52057. * @param configuration
  52058. */
  52059. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52060. /**
  52061. * Stores the available render targets.
  52062. */
  52063. private _renderTargets;
  52064. /**
  52065. * Sets the global ambient color for the material used in lighting calculations.
  52066. */
  52067. private _globalAmbientColor;
  52068. /**
  52069. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52070. */
  52071. private _useLogarithmicDepth;
  52072. /**
  52073. * If set to true, no lighting calculations will be applied.
  52074. */
  52075. private _unlit;
  52076. private _debugMode;
  52077. /**
  52078. * @hidden
  52079. * This is reserved for the inspector.
  52080. * Defines the material debug mode.
  52081. * It helps seeing only some components of the material while troubleshooting.
  52082. */
  52083. debugMode: number;
  52084. /**
  52085. * @hidden
  52086. * This is reserved for the inspector.
  52087. * Specify from where on screen the debug mode should start.
  52088. * The value goes from -1 (full screen) to 1 (not visible)
  52089. * It helps with side by side comparison against the final render
  52090. * This defaults to -1
  52091. */
  52092. private debugLimit;
  52093. /**
  52094. * @hidden
  52095. * This is reserved for the inspector.
  52096. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52097. * You can use the factor to better multiply the final value.
  52098. */
  52099. private debugFactor;
  52100. /**
  52101. * Defines the clear coat layer parameters for the material.
  52102. */
  52103. readonly clearCoat: PBRClearCoatConfiguration;
  52104. /**
  52105. * Defines the anisotropic parameters for the material.
  52106. */
  52107. readonly anisotropy: PBRAnisotropicConfiguration;
  52108. /**
  52109. * Defines the BRDF parameters for the material.
  52110. */
  52111. readonly brdf: PBRBRDFConfiguration;
  52112. /**
  52113. * Defines the Sheen parameters for the material.
  52114. */
  52115. readonly sheen: PBRSheenConfiguration;
  52116. /**
  52117. * Defines the SubSurface parameters for the material.
  52118. */
  52119. readonly subSurface: PBRSubSurfaceConfiguration;
  52120. protected _rebuildInParallel: boolean;
  52121. /**
  52122. * Instantiates a new PBRMaterial instance.
  52123. *
  52124. * @param name The material name
  52125. * @param scene The scene the material will be use in.
  52126. */
  52127. constructor(name: string, scene: Scene);
  52128. /**
  52129. * Gets a boolean indicating that current material needs to register RTT
  52130. */
  52131. get hasRenderTargetTextures(): boolean;
  52132. /**
  52133. * Gets the name of the material class.
  52134. */
  52135. getClassName(): string;
  52136. /**
  52137. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52138. */
  52139. get useLogarithmicDepth(): boolean;
  52140. /**
  52141. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52142. */
  52143. set useLogarithmicDepth(value: boolean);
  52144. /**
  52145. * Returns true if alpha blending should be disabled.
  52146. */
  52147. protected get _disableAlphaBlending(): boolean;
  52148. /**
  52149. * Specifies whether or not this material should be rendered in alpha blend mode.
  52150. */
  52151. needAlphaBlending(): boolean;
  52152. /**
  52153. * Specifies whether or not this material should be rendered in alpha test mode.
  52154. */
  52155. needAlphaTesting(): boolean;
  52156. /**
  52157. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52158. */
  52159. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52160. /**
  52161. * Gets the texture used for the alpha test.
  52162. */
  52163. getAlphaTestTexture(): Nullable<BaseTexture>;
  52164. /**
  52165. * Specifies that the submesh is ready to be used.
  52166. * @param mesh - BJS mesh.
  52167. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52168. * @param useInstances - Specifies that instances should be used.
  52169. * @returns - boolean indicating that the submesh is ready or not.
  52170. */
  52171. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52172. /**
  52173. * Specifies if the material uses metallic roughness workflow.
  52174. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52175. */
  52176. isMetallicWorkflow(): boolean;
  52177. private _prepareEffect;
  52178. private _prepareDefines;
  52179. /**
  52180. * Force shader compilation
  52181. */
  52182. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52183. /**
  52184. * Initializes the uniform buffer layout for the shader.
  52185. */
  52186. buildUniformLayout(): void;
  52187. /**
  52188. * Unbinds the material from the mesh
  52189. */
  52190. unbind(): void;
  52191. /**
  52192. * Binds the submesh data.
  52193. * @param world - The world matrix.
  52194. * @param mesh - The BJS mesh.
  52195. * @param subMesh - A submesh of the BJS mesh.
  52196. */
  52197. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52198. /**
  52199. * Returns the animatable textures.
  52200. * @returns - Array of animatable textures.
  52201. */
  52202. getAnimatables(): IAnimatable[];
  52203. /**
  52204. * Returns the texture used for reflections.
  52205. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52206. */
  52207. private _getReflectionTexture;
  52208. /**
  52209. * Returns an array of the actively used textures.
  52210. * @returns - Array of BaseTextures
  52211. */
  52212. getActiveTextures(): BaseTexture[];
  52213. /**
  52214. * Checks to see if a texture is used in the material.
  52215. * @param texture - Base texture to use.
  52216. * @returns - Boolean specifying if a texture is used in the material.
  52217. */
  52218. hasTexture(texture: BaseTexture): boolean;
  52219. /**
  52220. * Disposes the resources of the material.
  52221. * @param forceDisposeEffect - Forces the disposal of effects.
  52222. * @param forceDisposeTextures - Forces the disposal of all textures.
  52223. */
  52224. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52225. }
  52226. }
  52227. declare module BABYLON {
  52228. /**
  52229. * The Physically based material of BJS.
  52230. *
  52231. * This offers the main features of a standard PBR material.
  52232. * For more information, please refer to the documentation :
  52233. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52234. */
  52235. export class PBRMaterial extends PBRBaseMaterial {
  52236. /**
  52237. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52238. */
  52239. static readonly PBRMATERIAL_OPAQUE: number;
  52240. /**
  52241. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52242. */
  52243. static readonly PBRMATERIAL_ALPHATEST: number;
  52244. /**
  52245. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52246. */
  52247. static readonly PBRMATERIAL_ALPHABLEND: number;
  52248. /**
  52249. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52250. * They are also discarded below the alpha cutoff threshold to improve performances.
  52251. */
  52252. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52253. /**
  52254. * Defines the default value of how much AO map is occluding the analytical lights
  52255. * (point spot...).
  52256. */
  52257. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52258. /**
  52259. * Intensity of the direct lights e.g. the four lights available in your scene.
  52260. * This impacts both the direct diffuse and specular highlights.
  52261. */
  52262. directIntensity: number;
  52263. /**
  52264. * Intensity of the emissive part of the material.
  52265. * This helps controlling the emissive effect without modifying the emissive color.
  52266. */
  52267. emissiveIntensity: number;
  52268. /**
  52269. * Intensity of the environment e.g. how much the environment will light the object
  52270. * either through harmonics for rough material or through the refelction for shiny ones.
  52271. */
  52272. environmentIntensity: number;
  52273. /**
  52274. * This is a special control allowing the reduction of the specular highlights coming from the
  52275. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52276. */
  52277. specularIntensity: number;
  52278. /**
  52279. * Debug Control allowing disabling the bump map on this material.
  52280. */
  52281. disableBumpMap: boolean;
  52282. /**
  52283. * AKA Diffuse Texture in standard nomenclature.
  52284. */
  52285. albedoTexture: BaseTexture;
  52286. /**
  52287. * AKA Occlusion Texture in other nomenclature.
  52288. */
  52289. ambientTexture: BaseTexture;
  52290. /**
  52291. * AKA Occlusion Texture Intensity in other nomenclature.
  52292. */
  52293. ambientTextureStrength: number;
  52294. /**
  52295. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52296. * 1 means it completely occludes it
  52297. * 0 mean it has no impact
  52298. */
  52299. ambientTextureImpactOnAnalyticalLights: number;
  52300. /**
  52301. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52302. */
  52303. opacityTexture: BaseTexture;
  52304. /**
  52305. * Stores the reflection values in a texture.
  52306. */
  52307. reflectionTexture: Nullable<BaseTexture>;
  52308. /**
  52309. * Stores the emissive values in a texture.
  52310. */
  52311. emissiveTexture: BaseTexture;
  52312. /**
  52313. * AKA Specular texture in other nomenclature.
  52314. */
  52315. reflectivityTexture: BaseTexture;
  52316. /**
  52317. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52318. */
  52319. metallicTexture: BaseTexture;
  52320. /**
  52321. * Specifies the metallic scalar of the metallic/roughness workflow.
  52322. * Can also be used to scale the metalness values of the metallic texture.
  52323. */
  52324. metallic: Nullable<number>;
  52325. /**
  52326. * Specifies the roughness scalar of the metallic/roughness workflow.
  52327. * Can also be used to scale the roughness values of the metallic texture.
  52328. */
  52329. roughness: Nullable<number>;
  52330. /**
  52331. * Specifies the an F0 factor to help configuring the material F0.
  52332. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52333. * to 0.5 the previously hard coded value stays the same.
  52334. * Can also be used to scale the F0 values of the metallic texture.
  52335. */
  52336. metallicF0Factor: number;
  52337. /**
  52338. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52339. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52340. * your expectation as it multiplies with the texture data.
  52341. */
  52342. useMetallicF0FactorFromMetallicTexture: boolean;
  52343. /**
  52344. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52345. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52346. */
  52347. microSurfaceTexture: BaseTexture;
  52348. /**
  52349. * Stores surface normal data used to displace a mesh in a texture.
  52350. */
  52351. bumpTexture: BaseTexture;
  52352. /**
  52353. * Stores the pre-calculated light information of a mesh in a texture.
  52354. */
  52355. lightmapTexture: BaseTexture;
  52356. /**
  52357. * Stores the refracted light information in a texture.
  52358. */
  52359. get refractionTexture(): Nullable<BaseTexture>;
  52360. set refractionTexture(value: Nullable<BaseTexture>);
  52361. /**
  52362. * The color of a material in ambient lighting.
  52363. */
  52364. ambientColor: Color3;
  52365. /**
  52366. * AKA Diffuse Color in other nomenclature.
  52367. */
  52368. albedoColor: Color3;
  52369. /**
  52370. * AKA Specular Color in other nomenclature.
  52371. */
  52372. reflectivityColor: Color3;
  52373. /**
  52374. * The color reflected from the material.
  52375. */
  52376. reflectionColor: Color3;
  52377. /**
  52378. * The color emitted from the material.
  52379. */
  52380. emissiveColor: Color3;
  52381. /**
  52382. * AKA Glossiness in other nomenclature.
  52383. */
  52384. microSurface: number;
  52385. /**
  52386. * source material index of refraction (IOR)' / 'destination material IOR.
  52387. */
  52388. get indexOfRefraction(): number;
  52389. set indexOfRefraction(value: number);
  52390. /**
  52391. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52392. */
  52393. get invertRefractionY(): boolean;
  52394. set invertRefractionY(value: boolean);
  52395. /**
  52396. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52397. * Materials half opaque for instance using refraction could benefit from this control.
  52398. */
  52399. get linkRefractionWithTransparency(): boolean;
  52400. set linkRefractionWithTransparency(value: boolean);
  52401. /**
  52402. * If true, the light map contains occlusion information instead of lighting info.
  52403. */
  52404. useLightmapAsShadowmap: boolean;
  52405. /**
  52406. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52407. */
  52408. useAlphaFromAlbedoTexture: boolean;
  52409. /**
  52410. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52411. */
  52412. forceAlphaTest: boolean;
  52413. /**
  52414. * Defines the alpha limits in alpha test mode.
  52415. */
  52416. alphaCutOff: number;
  52417. /**
  52418. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52419. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52420. */
  52421. useSpecularOverAlpha: boolean;
  52422. /**
  52423. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52424. */
  52425. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52426. /**
  52427. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52428. */
  52429. useRoughnessFromMetallicTextureAlpha: boolean;
  52430. /**
  52431. * Specifies if the metallic texture contains the roughness information in its green channel.
  52432. */
  52433. useRoughnessFromMetallicTextureGreen: boolean;
  52434. /**
  52435. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52436. */
  52437. useMetallnessFromMetallicTextureBlue: boolean;
  52438. /**
  52439. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52440. */
  52441. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52442. /**
  52443. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52444. */
  52445. useAmbientInGrayScale: boolean;
  52446. /**
  52447. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52448. * The material will try to infer what glossiness each pixel should be.
  52449. */
  52450. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52451. /**
  52452. * BJS is using an harcoded light falloff based on a manually sets up range.
  52453. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52454. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52455. */
  52456. get usePhysicalLightFalloff(): boolean;
  52457. /**
  52458. * BJS is using an harcoded light falloff based on a manually sets up range.
  52459. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52460. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52461. */
  52462. set usePhysicalLightFalloff(value: boolean);
  52463. /**
  52464. * In order to support the falloff compatibility with gltf, a special mode has been added
  52465. * to reproduce the gltf light falloff.
  52466. */
  52467. get useGLTFLightFalloff(): boolean;
  52468. /**
  52469. * In order to support the falloff compatibility with gltf, a special mode has been added
  52470. * to reproduce the gltf light falloff.
  52471. */
  52472. set useGLTFLightFalloff(value: boolean);
  52473. /**
  52474. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52475. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52476. */
  52477. useRadianceOverAlpha: boolean;
  52478. /**
  52479. * Allows using an object space normal map (instead of tangent space).
  52480. */
  52481. useObjectSpaceNormalMap: boolean;
  52482. /**
  52483. * Allows using the bump map in parallax mode.
  52484. */
  52485. useParallax: boolean;
  52486. /**
  52487. * Allows using the bump map in parallax occlusion mode.
  52488. */
  52489. useParallaxOcclusion: boolean;
  52490. /**
  52491. * Controls the scale bias of the parallax mode.
  52492. */
  52493. parallaxScaleBias: number;
  52494. /**
  52495. * If sets to true, disables all the lights affecting the material.
  52496. */
  52497. disableLighting: boolean;
  52498. /**
  52499. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52500. */
  52501. forceIrradianceInFragment: boolean;
  52502. /**
  52503. * Number of Simultaneous lights allowed on the material.
  52504. */
  52505. maxSimultaneousLights: number;
  52506. /**
  52507. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52508. */
  52509. invertNormalMapX: boolean;
  52510. /**
  52511. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52512. */
  52513. invertNormalMapY: boolean;
  52514. /**
  52515. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52516. */
  52517. twoSidedLighting: boolean;
  52518. /**
  52519. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52520. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52521. */
  52522. useAlphaFresnel: boolean;
  52523. /**
  52524. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52525. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52526. */
  52527. useLinearAlphaFresnel: boolean;
  52528. /**
  52529. * Let user defines the brdf lookup texture used for IBL.
  52530. * A default 8bit version is embedded but you could point at :
  52531. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52532. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52533. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52534. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52535. */
  52536. environmentBRDFTexture: Nullable<BaseTexture>;
  52537. /**
  52538. * Force normal to face away from face.
  52539. */
  52540. forceNormalForward: boolean;
  52541. /**
  52542. * Enables specular anti aliasing in the PBR shader.
  52543. * It will both interacts on the Geometry for analytical and IBL lighting.
  52544. * It also prefilter the roughness map based on the bump values.
  52545. */
  52546. enableSpecularAntiAliasing: boolean;
  52547. /**
  52548. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52549. * makes the reflect vector face the model (under horizon).
  52550. */
  52551. useHorizonOcclusion: boolean;
  52552. /**
  52553. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52554. * too much the area relying on ambient texture to define their ambient occlusion.
  52555. */
  52556. useRadianceOcclusion: boolean;
  52557. /**
  52558. * If set to true, no lighting calculations will be applied.
  52559. */
  52560. unlit: boolean;
  52561. /**
  52562. * Gets the image processing configuration used either in this material.
  52563. */
  52564. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52565. /**
  52566. * Sets the Default image processing configuration used either in the this material.
  52567. *
  52568. * If sets to null, the scene one is in use.
  52569. */
  52570. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52571. /**
  52572. * Gets wether the color curves effect is enabled.
  52573. */
  52574. get cameraColorCurvesEnabled(): boolean;
  52575. /**
  52576. * Sets wether the color curves effect is enabled.
  52577. */
  52578. set cameraColorCurvesEnabled(value: boolean);
  52579. /**
  52580. * Gets wether the color grading effect is enabled.
  52581. */
  52582. get cameraColorGradingEnabled(): boolean;
  52583. /**
  52584. * Gets wether the color grading effect is enabled.
  52585. */
  52586. set cameraColorGradingEnabled(value: boolean);
  52587. /**
  52588. * Gets wether tonemapping is enabled or not.
  52589. */
  52590. get cameraToneMappingEnabled(): boolean;
  52591. /**
  52592. * Sets wether tonemapping is enabled or not
  52593. */
  52594. set cameraToneMappingEnabled(value: boolean);
  52595. /**
  52596. * The camera exposure used on this material.
  52597. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52598. * This corresponds to a photographic exposure.
  52599. */
  52600. get cameraExposure(): number;
  52601. /**
  52602. * The camera exposure used on this material.
  52603. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52604. * This corresponds to a photographic exposure.
  52605. */
  52606. set cameraExposure(value: number);
  52607. /**
  52608. * Gets The camera contrast used on this material.
  52609. */
  52610. get cameraContrast(): number;
  52611. /**
  52612. * Sets The camera contrast used on this material.
  52613. */
  52614. set cameraContrast(value: number);
  52615. /**
  52616. * Gets the Color Grading 2D Lookup Texture.
  52617. */
  52618. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52619. /**
  52620. * Sets the Color Grading 2D Lookup Texture.
  52621. */
  52622. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52623. /**
  52624. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52625. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52626. * 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;
  52627. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52628. */
  52629. get cameraColorCurves(): Nullable<ColorCurves>;
  52630. /**
  52631. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52632. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52633. * 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;
  52634. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52635. */
  52636. set cameraColorCurves(value: Nullable<ColorCurves>);
  52637. /**
  52638. * Instantiates a new PBRMaterial instance.
  52639. *
  52640. * @param name The material name
  52641. * @param scene The scene the material will be use in.
  52642. */
  52643. constructor(name: string, scene: Scene);
  52644. /**
  52645. * Returns the name of this material class.
  52646. */
  52647. getClassName(): string;
  52648. /**
  52649. * Makes a duplicate of the current material.
  52650. * @param name - name to use for the new material.
  52651. */
  52652. clone(name: string): PBRMaterial;
  52653. /**
  52654. * Serializes this PBR Material.
  52655. * @returns - An object with the serialized material.
  52656. */
  52657. serialize(): any;
  52658. /**
  52659. * Parses a PBR Material from a serialized object.
  52660. * @param source - Serialized object.
  52661. * @param scene - BJS scene instance.
  52662. * @param rootUrl - url for the scene object
  52663. * @returns - PBRMaterial
  52664. */
  52665. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52666. }
  52667. }
  52668. declare module BABYLON {
  52669. /**
  52670. * Direct draw surface info
  52671. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52672. */
  52673. export interface DDSInfo {
  52674. /**
  52675. * Width of the texture
  52676. */
  52677. width: number;
  52678. /**
  52679. * Width of the texture
  52680. */
  52681. height: number;
  52682. /**
  52683. * Number of Mipmaps for the texture
  52684. * @see https://en.wikipedia.org/wiki/Mipmap
  52685. */
  52686. mipmapCount: number;
  52687. /**
  52688. * If the textures format is a known fourCC format
  52689. * @see https://www.fourcc.org/
  52690. */
  52691. isFourCC: boolean;
  52692. /**
  52693. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52694. */
  52695. isRGB: boolean;
  52696. /**
  52697. * If the texture is a lumincance format
  52698. */
  52699. isLuminance: boolean;
  52700. /**
  52701. * If this is a cube texture
  52702. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52703. */
  52704. isCube: boolean;
  52705. /**
  52706. * If the texture is a compressed format eg. FOURCC_DXT1
  52707. */
  52708. isCompressed: boolean;
  52709. /**
  52710. * The dxgiFormat of the texture
  52711. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52712. */
  52713. dxgiFormat: number;
  52714. /**
  52715. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52716. */
  52717. textureType: number;
  52718. /**
  52719. * Sphericle polynomial created for the dds texture
  52720. */
  52721. sphericalPolynomial?: SphericalPolynomial;
  52722. }
  52723. /**
  52724. * Class used to provide DDS decompression tools
  52725. */
  52726. export class DDSTools {
  52727. /**
  52728. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52729. */
  52730. static StoreLODInAlphaChannel: boolean;
  52731. /**
  52732. * Gets DDS information from an array buffer
  52733. * @param data defines the array buffer view to read data from
  52734. * @returns the DDS information
  52735. */
  52736. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52737. private static _FloatView;
  52738. private static _Int32View;
  52739. private static _ToHalfFloat;
  52740. private static _FromHalfFloat;
  52741. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52742. private static _GetHalfFloatRGBAArrayBuffer;
  52743. private static _GetFloatRGBAArrayBuffer;
  52744. private static _GetFloatAsUIntRGBAArrayBuffer;
  52745. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52746. private static _GetRGBAArrayBuffer;
  52747. private static _ExtractLongWordOrder;
  52748. private static _GetRGBArrayBuffer;
  52749. private static _GetLuminanceArrayBuffer;
  52750. /**
  52751. * Uploads DDS Levels to a Babylon Texture
  52752. * @hidden
  52753. */
  52754. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52755. }
  52756. interface ThinEngine {
  52757. /**
  52758. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52759. * @param rootUrl defines the url where the file to load is located
  52760. * @param scene defines the current scene
  52761. * @param lodScale defines scale to apply to the mip map selection
  52762. * @param lodOffset defines offset to apply to the mip map selection
  52763. * @param onLoad defines an optional callback raised when the texture is loaded
  52764. * @param onError defines an optional callback raised if there is an issue to load the texture
  52765. * @param format defines the format of the data
  52766. * @param forcedExtension defines the extension to use to pick the right loader
  52767. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52768. * @returns the cube texture as an InternalTexture
  52769. */
  52770. 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;
  52771. }
  52772. }
  52773. declare module BABYLON {
  52774. /**
  52775. * Implementation of the DDS Texture Loader.
  52776. * @hidden
  52777. */
  52778. export class _DDSTextureLoader implements IInternalTextureLoader {
  52779. /**
  52780. * Defines wether the loader supports cascade loading the different faces.
  52781. */
  52782. readonly supportCascades: boolean;
  52783. /**
  52784. * This returns if the loader support the current file information.
  52785. * @param extension defines the file extension of the file being loaded
  52786. * @returns true if the loader can load the specified file
  52787. */
  52788. canLoad(extension: string): boolean;
  52789. /**
  52790. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52791. * @param data contains the texture data
  52792. * @param texture defines the BabylonJS internal texture
  52793. * @param createPolynomials will be true if polynomials have been requested
  52794. * @param onLoad defines the callback to trigger once the texture is ready
  52795. * @param onError defines the callback to trigger in case of error
  52796. */
  52797. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52798. /**
  52799. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52800. * @param data contains the texture data
  52801. * @param texture defines the BabylonJS internal texture
  52802. * @param callback defines the method to call once ready to upload
  52803. */
  52804. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52805. }
  52806. }
  52807. declare module BABYLON {
  52808. /**
  52809. * Implementation of the ENV Texture Loader.
  52810. * @hidden
  52811. */
  52812. export class _ENVTextureLoader implements IInternalTextureLoader {
  52813. /**
  52814. * Defines wether the loader supports cascade loading the different faces.
  52815. */
  52816. readonly supportCascades: boolean;
  52817. /**
  52818. * This returns if the loader support the current file information.
  52819. * @param extension defines the file extension of the file being loaded
  52820. * @returns true if the loader can load the specified file
  52821. */
  52822. canLoad(extension: string): boolean;
  52823. /**
  52824. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52825. * @param data contains the texture data
  52826. * @param texture defines the BabylonJS internal texture
  52827. * @param createPolynomials will be true if polynomials have been requested
  52828. * @param onLoad defines the callback to trigger once the texture is ready
  52829. * @param onError defines the callback to trigger in case of error
  52830. */
  52831. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52832. /**
  52833. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52834. * @param data contains the texture data
  52835. * @param texture defines the BabylonJS internal texture
  52836. * @param callback defines the method to call once ready to upload
  52837. */
  52838. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52839. }
  52840. }
  52841. declare module BABYLON {
  52842. /**
  52843. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52844. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52845. */
  52846. export class KhronosTextureContainer {
  52847. /** contents of the KTX container file */
  52848. data: ArrayBufferView;
  52849. private static HEADER_LEN;
  52850. private static COMPRESSED_2D;
  52851. private static COMPRESSED_3D;
  52852. private static TEX_2D;
  52853. private static TEX_3D;
  52854. /**
  52855. * Gets the openGL type
  52856. */
  52857. glType: number;
  52858. /**
  52859. * Gets the openGL type size
  52860. */
  52861. glTypeSize: number;
  52862. /**
  52863. * Gets the openGL format
  52864. */
  52865. glFormat: number;
  52866. /**
  52867. * Gets the openGL internal format
  52868. */
  52869. glInternalFormat: number;
  52870. /**
  52871. * Gets the base internal format
  52872. */
  52873. glBaseInternalFormat: number;
  52874. /**
  52875. * Gets image width in pixel
  52876. */
  52877. pixelWidth: number;
  52878. /**
  52879. * Gets image height in pixel
  52880. */
  52881. pixelHeight: number;
  52882. /**
  52883. * Gets image depth in pixels
  52884. */
  52885. pixelDepth: number;
  52886. /**
  52887. * Gets the number of array elements
  52888. */
  52889. numberOfArrayElements: number;
  52890. /**
  52891. * Gets the number of faces
  52892. */
  52893. numberOfFaces: number;
  52894. /**
  52895. * Gets the number of mipmap levels
  52896. */
  52897. numberOfMipmapLevels: number;
  52898. /**
  52899. * Gets the bytes of key value data
  52900. */
  52901. bytesOfKeyValueData: number;
  52902. /**
  52903. * Gets the load type
  52904. */
  52905. loadType: number;
  52906. /**
  52907. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52908. */
  52909. isInvalid: boolean;
  52910. /**
  52911. * Creates a new KhronosTextureContainer
  52912. * @param data contents of the KTX container file
  52913. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52914. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52915. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52916. */
  52917. constructor(
  52918. /** contents of the KTX container file */
  52919. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52920. /**
  52921. * Uploads KTX content to a Babylon Texture.
  52922. * It is assumed that the texture has already been created & is currently bound
  52923. * @hidden
  52924. */
  52925. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52926. private _upload2DCompressedLevels;
  52927. /**
  52928. * Checks if the given data starts with a KTX file identifier.
  52929. * @param data the data to check
  52930. * @returns true if the data is a KTX file or false otherwise
  52931. */
  52932. static IsValid(data: ArrayBufferView): boolean;
  52933. }
  52934. }
  52935. declare module BABYLON {
  52936. /**
  52937. * Class for loading KTX2 files
  52938. * !!! Experimental Extension Subject to Changes !!!
  52939. * @hidden
  52940. */
  52941. export class KhronosTextureContainer2 {
  52942. private static _ModulePromise;
  52943. private static _TranscodeFormat;
  52944. constructor(engine: ThinEngine);
  52945. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52946. private _determineTranscodeFormat;
  52947. /**
  52948. * Checks if the given data starts with a KTX2 file identifier.
  52949. * @param data the data to check
  52950. * @returns true if the data is a KTX2 file or false otherwise
  52951. */
  52952. static IsValid(data: ArrayBufferView): boolean;
  52953. }
  52954. }
  52955. declare module BABYLON {
  52956. /**
  52957. * Implementation of the KTX Texture Loader.
  52958. * @hidden
  52959. */
  52960. export class _KTXTextureLoader implements IInternalTextureLoader {
  52961. /**
  52962. * Defines wether the loader supports cascade loading the different faces.
  52963. */
  52964. readonly supportCascades: boolean;
  52965. /**
  52966. * This returns if the loader support the current file information.
  52967. * @param extension defines the file extension of the file being loaded
  52968. * @returns true if the loader can load the specified file
  52969. */
  52970. canLoad(extension: string): boolean;
  52971. /**
  52972. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52973. * @param data contains the texture data
  52974. * @param texture defines the BabylonJS internal texture
  52975. * @param createPolynomials will be true if polynomials have been requested
  52976. * @param onLoad defines the callback to trigger once the texture is ready
  52977. * @param onError defines the callback to trigger in case of error
  52978. */
  52979. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52980. /**
  52981. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52982. * @param data contains the texture data
  52983. * @param texture defines the BabylonJS internal texture
  52984. * @param callback defines the method to call once ready to upload
  52985. */
  52986. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52987. }
  52988. }
  52989. declare module BABYLON {
  52990. /** @hidden */
  52991. export var _forceSceneHelpersToBundle: boolean;
  52992. interface Scene {
  52993. /**
  52994. * Creates a default light for the scene.
  52995. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52996. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52997. */
  52998. createDefaultLight(replace?: boolean): void;
  52999. /**
  53000. * Creates a default camera for the scene.
  53001. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53002. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53003. * @param replace has default false, when true replaces the active camera in the scene
  53004. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53005. */
  53006. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53007. /**
  53008. * Creates a default camera and a default light.
  53009. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53010. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53011. * @param replace has the default false, when true replaces the active camera/light in the scene
  53012. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53013. */
  53014. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53015. /**
  53016. * Creates a new sky box
  53017. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53018. * @param environmentTexture defines the texture to use as environment texture
  53019. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53020. * @param scale defines the overall scale of the skybox
  53021. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53022. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53023. * @returns a new mesh holding the sky box
  53024. */
  53025. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53026. /**
  53027. * Creates a new environment
  53028. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53029. * @param options defines the options you can use to configure the environment
  53030. * @returns the new EnvironmentHelper
  53031. */
  53032. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53033. /**
  53034. * Creates a new VREXperienceHelper
  53035. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53036. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53037. * @returns a new VREXperienceHelper
  53038. */
  53039. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53040. /**
  53041. * Creates a new WebXRDefaultExperience
  53042. * @see http://doc.babylonjs.com/how_to/webxr
  53043. * @param options experience options
  53044. * @returns a promise for a new WebXRDefaultExperience
  53045. */
  53046. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53047. }
  53048. }
  53049. declare module BABYLON {
  53050. /**
  53051. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53052. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53053. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53054. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53055. */
  53056. export class VideoDome extends TransformNode {
  53057. /**
  53058. * Define the video source as a Monoscopic panoramic 360 video.
  53059. */
  53060. static readonly MODE_MONOSCOPIC: number;
  53061. /**
  53062. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53063. */
  53064. static readonly MODE_TOPBOTTOM: number;
  53065. /**
  53066. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53067. */
  53068. static readonly MODE_SIDEBYSIDE: number;
  53069. private _halfDome;
  53070. private _useDirectMapping;
  53071. /**
  53072. * The video texture being displayed on the sphere
  53073. */
  53074. protected _videoTexture: VideoTexture;
  53075. /**
  53076. * Gets the video texture being displayed on the sphere
  53077. */
  53078. get videoTexture(): VideoTexture;
  53079. /**
  53080. * The skybox material
  53081. */
  53082. protected _material: BackgroundMaterial;
  53083. /**
  53084. * The surface used for the skybox
  53085. */
  53086. protected _mesh: Mesh;
  53087. /**
  53088. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53089. */
  53090. private _halfDomeMask;
  53091. /**
  53092. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53093. * Also see the options.resolution property.
  53094. */
  53095. get fovMultiplier(): number;
  53096. set fovMultiplier(value: number);
  53097. private _videoMode;
  53098. /**
  53099. * Gets or set the current video mode for the video. It can be:
  53100. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53101. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53102. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53103. */
  53104. get videoMode(): number;
  53105. set videoMode(value: number);
  53106. /**
  53107. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53108. *
  53109. */
  53110. get halfDome(): boolean;
  53111. /**
  53112. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53113. */
  53114. set halfDome(enabled: boolean);
  53115. /**
  53116. * Oberserver used in Stereoscopic VR Mode.
  53117. */
  53118. private _onBeforeCameraRenderObserver;
  53119. /**
  53120. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53121. * @param name Element's name, child elements will append suffixes for their own names.
  53122. * @param urlsOrVideo defines the url(s) or the video element to use
  53123. * @param options An object containing optional or exposed sub element properties
  53124. */
  53125. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53126. resolution?: number;
  53127. clickToPlay?: boolean;
  53128. autoPlay?: boolean;
  53129. loop?: boolean;
  53130. size?: number;
  53131. poster?: string;
  53132. faceForward?: boolean;
  53133. useDirectMapping?: boolean;
  53134. halfDomeMode?: boolean;
  53135. }, scene: Scene);
  53136. private _changeVideoMode;
  53137. /**
  53138. * Releases resources associated with this node.
  53139. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53140. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53141. */
  53142. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53143. }
  53144. }
  53145. declare module BABYLON {
  53146. /**
  53147. * This class can be used to get instrumentation data from a Babylon engine
  53148. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53149. */
  53150. export class EngineInstrumentation implements IDisposable {
  53151. /**
  53152. * Define the instrumented engine.
  53153. */
  53154. engine: Engine;
  53155. private _captureGPUFrameTime;
  53156. private _gpuFrameTimeToken;
  53157. private _gpuFrameTime;
  53158. private _captureShaderCompilationTime;
  53159. private _shaderCompilationTime;
  53160. private _onBeginFrameObserver;
  53161. private _onEndFrameObserver;
  53162. private _onBeforeShaderCompilationObserver;
  53163. private _onAfterShaderCompilationObserver;
  53164. /**
  53165. * Gets the perf counter used for GPU frame time
  53166. */
  53167. get gpuFrameTimeCounter(): PerfCounter;
  53168. /**
  53169. * Gets the GPU frame time capture status
  53170. */
  53171. get captureGPUFrameTime(): boolean;
  53172. /**
  53173. * Enable or disable the GPU frame time capture
  53174. */
  53175. set captureGPUFrameTime(value: boolean);
  53176. /**
  53177. * Gets the perf counter used for shader compilation time
  53178. */
  53179. get shaderCompilationTimeCounter(): PerfCounter;
  53180. /**
  53181. * Gets the shader compilation time capture status
  53182. */
  53183. get captureShaderCompilationTime(): boolean;
  53184. /**
  53185. * Enable or disable the shader compilation time capture
  53186. */
  53187. set captureShaderCompilationTime(value: boolean);
  53188. /**
  53189. * Instantiates a new engine instrumentation.
  53190. * This class can be used to get instrumentation data from a Babylon engine
  53191. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53192. * @param engine Defines the engine to instrument
  53193. */
  53194. constructor(
  53195. /**
  53196. * Define the instrumented engine.
  53197. */
  53198. engine: Engine);
  53199. /**
  53200. * Dispose and release associated resources.
  53201. */
  53202. dispose(): void;
  53203. }
  53204. }
  53205. declare module BABYLON {
  53206. /**
  53207. * This class can be used to get instrumentation data from a Babylon engine
  53208. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53209. */
  53210. export class SceneInstrumentation implements IDisposable {
  53211. /**
  53212. * Defines the scene to instrument
  53213. */
  53214. scene: Scene;
  53215. private _captureActiveMeshesEvaluationTime;
  53216. private _activeMeshesEvaluationTime;
  53217. private _captureRenderTargetsRenderTime;
  53218. private _renderTargetsRenderTime;
  53219. private _captureFrameTime;
  53220. private _frameTime;
  53221. private _captureRenderTime;
  53222. private _renderTime;
  53223. private _captureInterFrameTime;
  53224. private _interFrameTime;
  53225. private _captureParticlesRenderTime;
  53226. private _particlesRenderTime;
  53227. private _captureSpritesRenderTime;
  53228. private _spritesRenderTime;
  53229. private _capturePhysicsTime;
  53230. private _physicsTime;
  53231. private _captureAnimationsTime;
  53232. private _animationsTime;
  53233. private _captureCameraRenderTime;
  53234. private _cameraRenderTime;
  53235. private _onBeforeActiveMeshesEvaluationObserver;
  53236. private _onAfterActiveMeshesEvaluationObserver;
  53237. private _onBeforeRenderTargetsRenderObserver;
  53238. private _onAfterRenderTargetsRenderObserver;
  53239. private _onAfterRenderObserver;
  53240. private _onBeforeDrawPhaseObserver;
  53241. private _onAfterDrawPhaseObserver;
  53242. private _onBeforeAnimationsObserver;
  53243. private _onBeforeParticlesRenderingObserver;
  53244. private _onAfterParticlesRenderingObserver;
  53245. private _onBeforeSpritesRenderingObserver;
  53246. private _onAfterSpritesRenderingObserver;
  53247. private _onBeforePhysicsObserver;
  53248. private _onAfterPhysicsObserver;
  53249. private _onAfterAnimationsObserver;
  53250. private _onBeforeCameraRenderObserver;
  53251. private _onAfterCameraRenderObserver;
  53252. /**
  53253. * Gets the perf counter used for active meshes evaluation time
  53254. */
  53255. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53256. /**
  53257. * Gets the active meshes evaluation time capture status
  53258. */
  53259. get captureActiveMeshesEvaluationTime(): boolean;
  53260. /**
  53261. * Enable or disable the active meshes evaluation time capture
  53262. */
  53263. set captureActiveMeshesEvaluationTime(value: boolean);
  53264. /**
  53265. * Gets the perf counter used for render targets render time
  53266. */
  53267. get renderTargetsRenderTimeCounter(): PerfCounter;
  53268. /**
  53269. * Gets the render targets render time capture status
  53270. */
  53271. get captureRenderTargetsRenderTime(): boolean;
  53272. /**
  53273. * Enable or disable the render targets render time capture
  53274. */
  53275. set captureRenderTargetsRenderTime(value: boolean);
  53276. /**
  53277. * Gets the perf counter used for particles render time
  53278. */
  53279. get particlesRenderTimeCounter(): PerfCounter;
  53280. /**
  53281. * Gets the particles render time capture status
  53282. */
  53283. get captureParticlesRenderTime(): boolean;
  53284. /**
  53285. * Enable or disable the particles render time capture
  53286. */
  53287. set captureParticlesRenderTime(value: boolean);
  53288. /**
  53289. * Gets the perf counter used for sprites render time
  53290. */
  53291. get spritesRenderTimeCounter(): PerfCounter;
  53292. /**
  53293. * Gets the sprites render time capture status
  53294. */
  53295. get captureSpritesRenderTime(): boolean;
  53296. /**
  53297. * Enable or disable the sprites render time capture
  53298. */
  53299. set captureSpritesRenderTime(value: boolean);
  53300. /**
  53301. * Gets the perf counter used for physics time
  53302. */
  53303. get physicsTimeCounter(): PerfCounter;
  53304. /**
  53305. * Gets the physics time capture status
  53306. */
  53307. get capturePhysicsTime(): boolean;
  53308. /**
  53309. * Enable or disable the physics time capture
  53310. */
  53311. set capturePhysicsTime(value: boolean);
  53312. /**
  53313. * Gets the perf counter used for animations time
  53314. */
  53315. get animationsTimeCounter(): PerfCounter;
  53316. /**
  53317. * Gets the animations time capture status
  53318. */
  53319. get captureAnimationsTime(): boolean;
  53320. /**
  53321. * Enable or disable the animations time capture
  53322. */
  53323. set captureAnimationsTime(value: boolean);
  53324. /**
  53325. * Gets the perf counter used for frame time capture
  53326. */
  53327. get frameTimeCounter(): PerfCounter;
  53328. /**
  53329. * Gets the frame time capture status
  53330. */
  53331. get captureFrameTime(): boolean;
  53332. /**
  53333. * Enable or disable the frame time capture
  53334. */
  53335. set captureFrameTime(value: boolean);
  53336. /**
  53337. * Gets the perf counter used for inter-frames time capture
  53338. */
  53339. get interFrameTimeCounter(): PerfCounter;
  53340. /**
  53341. * Gets the inter-frames time capture status
  53342. */
  53343. get captureInterFrameTime(): boolean;
  53344. /**
  53345. * Enable or disable the inter-frames time capture
  53346. */
  53347. set captureInterFrameTime(value: boolean);
  53348. /**
  53349. * Gets the perf counter used for render time capture
  53350. */
  53351. get renderTimeCounter(): PerfCounter;
  53352. /**
  53353. * Gets the render time capture status
  53354. */
  53355. get captureRenderTime(): boolean;
  53356. /**
  53357. * Enable or disable the render time capture
  53358. */
  53359. set captureRenderTime(value: boolean);
  53360. /**
  53361. * Gets the perf counter used for camera render time capture
  53362. */
  53363. get cameraRenderTimeCounter(): PerfCounter;
  53364. /**
  53365. * Gets the camera render time capture status
  53366. */
  53367. get captureCameraRenderTime(): boolean;
  53368. /**
  53369. * Enable or disable the camera render time capture
  53370. */
  53371. set captureCameraRenderTime(value: boolean);
  53372. /**
  53373. * Gets the perf counter used for draw calls
  53374. */
  53375. get drawCallsCounter(): PerfCounter;
  53376. /**
  53377. * Instantiates a new scene instrumentation.
  53378. * This class can be used to get instrumentation data from a Babylon engine
  53379. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53380. * @param scene Defines the scene to instrument
  53381. */
  53382. constructor(
  53383. /**
  53384. * Defines the scene to instrument
  53385. */
  53386. scene: Scene);
  53387. /**
  53388. * Dispose and release associated resources.
  53389. */
  53390. dispose(): void;
  53391. }
  53392. }
  53393. declare module BABYLON {
  53394. /** @hidden */
  53395. export var glowMapGenerationPixelShader: {
  53396. name: string;
  53397. shader: string;
  53398. };
  53399. }
  53400. declare module BABYLON {
  53401. /** @hidden */
  53402. export var glowMapGenerationVertexShader: {
  53403. name: string;
  53404. shader: string;
  53405. };
  53406. }
  53407. declare module BABYLON {
  53408. /**
  53409. * Effect layer options. This helps customizing the behaviour
  53410. * of the effect layer.
  53411. */
  53412. export interface IEffectLayerOptions {
  53413. /**
  53414. * Multiplication factor apply to the canvas size to compute the render target size
  53415. * used to generated the objects (the smaller the faster).
  53416. */
  53417. mainTextureRatio: number;
  53418. /**
  53419. * Enforces a fixed size texture to ensure effect stability across devices.
  53420. */
  53421. mainTextureFixedSize?: number;
  53422. /**
  53423. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53424. */
  53425. alphaBlendingMode: number;
  53426. /**
  53427. * The camera attached to the layer.
  53428. */
  53429. camera: Nullable<Camera>;
  53430. /**
  53431. * The rendering group to draw the layer in.
  53432. */
  53433. renderingGroupId: number;
  53434. }
  53435. /**
  53436. * The effect layer Helps adding post process effect blended with the main pass.
  53437. *
  53438. * This can be for instance use to generate glow or higlight effects on the scene.
  53439. *
  53440. * The effect layer class can not be used directly and is intented to inherited from to be
  53441. * customized per effects.
  53442. */
  53443. export abstract class EffectLayer {
  53444. private _vertexBuffers;
  53445. private _indexBuffer;
  53446. private _cachedDefines;
  53447. private _effectLayerMapGenerationEffect;
  53448. private _effectLayerOptions;
  53449. private _mergeEffect;
  53450. protected _scene: Scene;
  53451. protected _engine: Engine;
  53452. protected _maxSize: number;
  53453. protected _mainTextureDesiredSize: ISize;
  53454. protected _mainTexture: RenderTargetTexture;
  53455. protected _shouldRender: boolean;
  53456. protected _postProcesses: PostProcess[];
  53457. protected _textures: BaseTexture[];
  53458. protected _emissiveTextureAndColor: {
  53459. texture: Nullable<BaseTexture>;
  53460. color: Color4;
  53461. };
  53462. /**
  53463. * The name of the layer
  53464. */
  53465. name: string;
  53466. /**
  53467. * The clear color of the texture used to generate the glow map.
  53468. */
  53469. neutralColor: Color4;
  53470. /**
  53471. * Specifies whether the highlight layer is enabled or not.
  53472. */
  53473. isEnabled: boolean;
  53474. /**
  53475. * Gets the camera attached to the layer.
  53476. */
  53477. get camera(): Nullable<Camera>;
  53478. /**
  53479. * Gets the rendering group id the layer should render in.
  53480. */
  53481. get renderingGroupId(): number;
  53482. set renderingGroupId(renderingGroupId: number);
  53483. /**
  53484. * An event triggered when the effect layer has been disposed.
  53485. */
  53486. onDisposeObservable: Observable<EffectLayer>;
  53487. /**
  53488. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53489. */
  53490. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53491. /**
  53492. * An event triggered when the generated texture is being merged in the scene.
  53493. */
  53494. onBeforeComposeObservable: Observable<EffectLayer>;
  53495. /**
  53496. * An event triggered when the mesh is rendered into the effect render target.
  53497. */
  53498. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53499. /**
  53500. * An event triggered after the mesh has been rendered into the effect render target.
  53501. */
  53502. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53503. /**
  53504. * An event triggered when the generated texture has been merged in the scene.
  53505. */
  53506. onAfterComposeObservable: Observable<EffectLayer>;
  53507. /**
  53508. * An event triggered when the efffect layer changes its size.
  53509. */
  53510. onSizeChangedObservable: Observable<EffectLayer>;
  53511. /** @hidden */
  53512. static _SceneComponentInitialization: (scene: Scene) => void;
  53513. /**
  53514. * Instantiates a new effect Layer and references it in the scene.
  53515. * @param name The name of the layer
  53516. * @param scene The scene to use the layer in
  53517. */
  53518. constructor(
  53519. /** The Friendly of the effect in the scene */
  53520. name: string, scene: Scene);
  53521. /**
  53522. * Get the effect name of the layer.
  53523. * @return The effect name
  53524. */
  53525. abstract getEffectName(): string;
  53526. /**
  53527. * Checks for the readiness of the element composing the layer.
  53528. * @param subMesh the mesh to check for
  53529. * @param useInstances specify whether or not to use instances to render the mesh
  53530. * @return true if ready otherwise, false
  53531. */
  53532. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53533. /**
  53534. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53535. * @returns true if the effect requires stencil during the main canvas render pass.
  53536. */
  53537. abstract needStencil(): boolean;
  53538. /**
  53539. * Create the merge effect. This is the shader use to blit the information back
  53540. * to the main canvas at the end of the scene rendering.
  53541. * @returns The effect containing the shader used to merge the effect on the main canvas
  53542. */
  53543. protected abstract _createMergeEffect(): Effect;
  53544. /**
  53545. * Creates the render target textures and post processes used in the effect layer.
  53546. */
  53547. protected abstract _createTextureAndPostProcesses(): void;
  53548. /**
  53549. * Implementation specific of rendering the generating effect on the main canvas.
  53550. * @param effect The effect used to render through
  53551. */
  53552. protected abstract _internalRender(effect: Effect): void;
  53553. /**
  53554. * Sets the required values for both the emissive texture and and the main color.
  53555. */
  53556. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53557. /**
  53558. * Free any resources and references associated to a mesh.
  53559. * Internal use
  53560. * @param mesh The mesh to free.
  53561. */
  53562. abstract _disposeMesh(mesh: Mesh): void;
  53563. /**
  53564. * Serializes this layer (Glow or Highlight for example)
  53565. * @returns a serialized layer object
  53566. */
  53567. abstract serialize?(): any;
  53568. /**
  53569. * Initializes the effect layer with the required options.
  53570. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53571. */
  53572. protected _init(options: Partial<IEffectLayerOptions>): void;
  53573. /**
  53574. * Generates the index buffer of the full screen quad blending to the main canvas.
  53575. */
  53576. private _generateIndexBuffer;
  53577. /**
  53578. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53579. */
  53580. private _generateVertexBuffer;
  53581. /**
  53582. * Sets the main texture desired size which is the closest power of two
  53583. * of the engine canvas size.
  53584. */
  53585. private _setMainTextureSize;
  53586. /**
  53587. * Creates the main texture for the effect layer.
  53588. */
  53589. protected _createMainTexture(): void;
  53590. /**
  53591. * Adds specific effects defines.
  53592. * @param defines The defines to add specifics to.
  53593. */
  53594. protected _addCustomEffectDefines(defines: string[]): void;
  53595. /**
  53596. * Checks for the readiness of the element composing the layer.
  53597. * @param subMesh the mesh to check for
  53598. * @param useInstances specify whether or not to use instances to render the mesh
  53599. * @param emissiveTexture the associated emissive texture used to generate the glow
  53600. * @return true if ready otherwise, false
  53601. */
  53602. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53603. /**
  53604. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53605. */
  53606. render(): void;
  53607. /**
  53608. * Determine if a given mesh will be used in the current effect.
  53609. * @param mesh mesh to test
  53610. * @returns true if the mesh will be used
  53611. */
  53612. hasMesh(mesh: AbstractMesh): boolean;
  53613. /**
  53614. * Returns true if the layer contains information to display, otherwise false.
  53615. * @returns true if the glow layer should be rendered
  53616. */
  53617. shouldRender(): boolean;
  53618. /**
  53619. * Returns true if the mesh should render, otherwise false.
  53620. * @param mesh The mesh to render
  53621. * @returns true if it should render otherwise false
  53622. */
  53623. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53624. /**
  53625. * Returns true if the mesh can be rendered, otherwise false.
  53626. * @param mesh The mesh to render
  53627. * @param material The material used on the mesh
  53628. * @returns true if it can be rendered otherwise false
  53629. */
  53630. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53631. /**
  53632. * Returns true if the mesh should render, otherwise false.
  53633. * @param mesh The mesh to render
  53634. * @returns true if it should render otherwise false
  53635. */
  53636. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53637. /**
  53638. * Renders the submesh passed in parameter to the generation map.
  53639. */
  53640. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53641. /**
  53642. * Defines whether the current material of the mesh should be use to render the effect.
  53643. * @param mesh defines the current mesh to render
  53644. */
  53645. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53646. /**
  53647. * Rebuild the required buffers.
  53648. * @hidden Internal use only.
  53649. */
  53650. _rebuild(): void;
  53651. /**
  53652. * Dispose only the render target textures and post process.
  53653. */
  53654. private _disposeTextureAndPostProcesses;
  53655. /**
  53656. * Dispose the highlight layer and free resources.
  53657. */
  53658. dispose(): void;
  53659. /**
  53660. * Gets the class name of the effect layer
  53661. * @returns the string with the class name of the effect layer
  53662. */
  53663. getClassName(): string;
  53664. /**
  53665. * Creates an effect layer from parsed effect layer data
  53666. * @param parsedEffectLayer defines effect layer data
  53667. * @param scene defines the current scene
  53668. * @param rootUrl defines the root URL containing the effect layer information
  53669. * @returns a parsed effect Layer
  53670. */
  53671. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53672. }
  53673. }
  53674. declare module BABYLON {
  53675. interface AbstractScene {
  53676. /**
  53677. * The list of effect layers (highlights/glow) added to the scene
  53678. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53679. * @see http://doc.babylonjs.com/how_to/glow_layer
  53680. */
  53681. effectLayers: Array<EffectLayer>;
  53682. /**
  53683. * Removes the given effect layer from this scene.
  53684. * @param toRemove defines the effect layer to remove
  53685. * @returns the index of the removed effect layer
  53686. */
  53687. removeEffectLayer(toRemove: EffectLayer): number;
  53688. /**
  53689. * Adds the given effect layer to this scene
  53690. * @param newEffectLayer defines the effect layer to add
  53691. */
  53692. addEffectLayer(newEffectLayer: EffectLayer): void;
  53693. }
  53694. /**
  53695. * Defines the layer scene component responsible to manage any effect layers
  53696. * in a given scene.
  53697. */
  53698. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53699. /**
  53700. * The component name helpfull to identify the component in the list of scene components.
  53701. */
  53702. readonly name: string;
  53703. /**
  53704. * The scene the component belongs to.
  53705. */
  53706. scene: Scene;
  53707. private _engine;
  53708. private _renderEffects;
  53709. private _needStencil;
  53710. private _previousStencilState;
  53711. /**
  53712. * Creates a new instance of the component for the given scene
  53713. * @param scene Defines the scene to register the component in
  53714. */
  53715. constructor(scene: Scene);
  53716. /**
  53717. * Registers the component in a given scene
  53718. */
  53719. register(): void;
  53720. /**
  53721. * Rebuilds the elements related to this component in case of
  53722. * context lost for instance.
  53723. */
  53724. rebuild(): void;
  53725. /**
  53726. * Serializes the component data to the specified json object
  53727. * @param serializationObject The object to serialize to
  53728. */
  53729. serialize(serializationObject: any): void;
  53730. /**
  53731. * Adds all the elements from the container to the scene
  53732. * @param container the container holding the elements
  53733. */
  53734. addFromContainer(container: AbstractScene): void;
  53735. /**
  53736. * Removes all the elements in the container from the scene
  53737. * @param container contains the elements to remove
  53738. * @param dispose if the removed element should be disposed (default: false)
  53739. */
  53740. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53741. /**
  53742. * Disposes the component and the associated ressources.
  53743. */
  53744. dispose(): void;
  53745. private _isReadyForMesh;
  53746. private _renderMainTexture;
  53747. private _setStencil;
  53748. private _setStencilBack;
  53749. private _draw;
  53750. private _drawCamera;
  53751. private _drawRenderingGroup;
  53752. }
  53753. }
  53754. declare module BABYLON {
  53755. /** @hidden */
  53756. export var glowMapMergePixelShader: {
  53757. name: string;
  53758. shader: string;
  53759. };
  53760. }
  53761. declare module BABYLON {
  53762. /** @hidden */
  53763. export var glowMapMergeVertexShader: {
  53764. name: string;
  53765. shader: string;
  53766. };
  53767. }
  53768. declare module BABYLON {
  53769. interface AbstractScene {
  53770. /**
  53771. * Return a the first highlight layer of the scene with a given name.
  53772. * @param name The name of the highlight layer to look for.
  53773. * @return The highlight layer if found otherwise null.
  53774. */
  53775. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53776. }
  53777. /**
  53778. * Glow layer options. This helps customizing the behaviour
  53779. * of the glow layer.
  53780. */
  53781. export interface IGlowLayerOptions {
  53782. /**
  53783. * Multiplication factor apply to the canvas size to compute the render target size
  53784. * used to generated the glowing objects (the smaller the faster).
  53785. */
  53786. mainTextureRatio: number;
  53787. /**
  53788. * Enforces a fixed size texture to ensure resize independant blur.
  53789. */
  53790. mainTextureFixedSize?: number;
  53791. /**
  53792. * How big is the kernel of the blur texture.
  53793. */
  53794. blurKernelSize: number;
  53795. /**
  53796. * The camera attached to the layer.
  53797. */
  53798. camera: Nullable<Camera>;
  53799. /**
  53800. * Enable MSAA by chosing the number of samples.
  53801. */
  53802. mainTextureSamples?: number;
  53803. /**
  53804. * The rendering group to draw the layer in.
  53805. */
  53806. renderingGroupId: number;
  53807. }
  53808. /**
  53809. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53810. *
  53811. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53812. *
  53813. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53814. */
  53815. export class GlowLayer extends EffectLayer {
  53816. /**
  53817. * Effect Name of the layer.
  53818. */
  53819. static readonly EffectName: string;
  53820. /**
  53821. * The default blur kernel size used for the glow.
  53822. */
  53823. static DefaultBlurKernelSize: number;
  53824. /**
  53825. * The default texture size ratio used for the glow.
  53826. */
  53827. static DefaultTextureRatio: number;
  53828. /**
  53829. * Sets the kernel size of the blur.
  53830. */
  53831. set blurKernelSize(value: number);
  53832. /**
  53833. * Gets the kernel size of the blur.
  53834. */
  53835. get blurKernelSize(): number;
  53836. /**
  53837. * Sets the glow intensity.
  53838. */
  53839. set intensity(value: number);
  53840. /**
  53841. * Gets the glow intensity.
  53842. */
  53843. get intensity(): number;
  53844. private _options;
  53845. private _intensity;
  53846. private _horizontalBlurPostprocess1;
  53847. private _verticalBlurPostprocess1;
  53848. private _horizontalBlurPostprocess2;
  53849. private _verticalBlurPostprocess2;
  53850. private _blurTexture1;
  53851. private _blurTexture2;
  53852. private _postProcesses1;
  53853. private _postProcesses2;
  53854. private _includedOnlyMeshes;
  53855. private _excludedMeshes;
  53856. private _meshesUsingTheirOwnMaterials;
  53857. /**
  53858. * Callback used to let the user override the color selection on a per mesh basis
  53859. */
  53860. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53861. /**
  53862. * Callback used to let the user override the texture selection on a per mesh basis
  53863. */
  53864. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53865. /**
  53866. * Instantiates a new glow Layer and references it to the scene.
  53867. * @param name The name of the layer
  53868. * @param scene The scene to use the layer in
  53869. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53870. */
  53871. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53872. /**
  53873. * Get the effect name of the layer.
  53874. * @return The effect name
  53875. */
  53876. getEffectName(): string;
  53877. /**
  53878. * Create the merge effect. This is the shader use to blit the information back
  53879. * to the main canvas at the end of the scene rendering.
  53880. */
  53881. protected _createMergeEffect(): Effect;
  53882. /**
  53883. * Creates the render target textures and post processes used in the glow layer.
  53884. */
  53885. protected _createTextureAndPostProcesses(): void;
  53886. /**
  53887. * Checks for the readiness of the element composing the layer.
  53888. * @param subMesh the mesh to check for
  53889. * @param useInstances specify wether or not to use instances to render the mesh
  53890. * @param emissiveTexture the associated emissive texture used to generate the glow
  53891. * @return true if ready otherwise, false
  53892. */
  53893. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53894. /**
  53895. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53896. */
  53897. needStencil(): boolean;
  53898. /**
  53899. * Returns true if the mesh can be rendered, otherwise false.
  53900. * @param mesh The mesh to render
  53901. * @param material The material used on the mesh
  53902. * @returns true if it can be rendered otherwise false
  53903. */
  53904. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53905. /**
  53906. * Implementation specific of rendering the generating effect on the main canvas.
  53907. * @param effect The effect used to render through
  53908. */
  53909. protected _internalRender(effect: Effect): void;
  53910. /**
  53911. * Sets the required values for both the emissive texture and and the main color.
  53912. */
  53913. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53914. /**
  53915. * Returns true if the mesh should render, otherwise false.
  53916. * @param mesh The mesh to render
  53917. * @returns true if it should render otherwise false
  53918. */
  53919. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53920. /**
  53921. * Adds specific effects defines.
  53922. * @param defines The defines to add specifics to.
  53923. */
  53924. protected _addCustomEffectDefines(defines: string[]): void;
  53925. /**
  53926. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53927. * @param mesh The mesh to exclude from the glow layer
  53928. */
  53929. addExcludedMesh(mesh: Mesh): void;
  53930. /**
  53931. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53932. * @param mesh The mesh to remove
  53933. */
  53934. removeExcludedMesh(mesh: Mesh): void;
  53935. /**
  53936. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53937. * @param mesh The mesh to include in the glow layer
  53938. */
  53939. addIncludedOnlyMesh(mesh: Mesh): void;
  53940. /**
  53941. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53942. * @param mesh The mesh to remove
  53943. */
  53944. removeIncludedOnlyMesh(mesh: Mesh): void;
  53945. /**
  53946. * Determine if a given mesh will be used in the glow layer
  53947. * @param mesh The mesh to test
  53948. * @returns true if the mesh will be highlighted by the current glow layer
  53949. */
  53950. hasMesh(mesh: AbstractMesh): boolean;
  53951. /**
  53952. * Defines whether the current material of the mesh should be use to render the effect.
  53953. * @param mesh defines the current mesh to render
  53954. */
  53955. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53956. /**
  53957. * Add a mesh to be rendered through its own material and not with emissive only.
  53958. * @param mesh The mesh for which we need to use its material
  53959. */
  53960. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53961. /**
  53962. * Remove a mesh from being rendered through its own material and not with emissive only.
  53963. * @param mesh The mesh for which we need to not use its material
  53964. */
  53965. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53966. /**
  53967. * Free any resources and references associated to a mesh.
  53968. * Internal use
  53969. * @param mesh The mesh to free.
  53970. * @hidden
  53971. */
  53972. _disposeMesh(mesh: Mesh): void;
  53973. /**
  53974. * Gets the class name of the effect layer
  53975. * @returns the string with the class name of the effect layer
  53976. */
  53977. getClassName(): string;
  53978. /**
  53979. * Serializes this glow layer
  53980. * @returns a serialized glow layer object
  53981. */
  53982. serialize(): any;
  53983. /**
  53984. * Creates a Glow Layer from parsed glow layer data
  53985. * @param parsedGlowLayer defines glow layer data
  53986. * @param scene defines the current scene
  53987. * @param rootUrl defines the root URL containing the glow layer information
  53988. * @returns a parsed Glow Layer
  53989. */
  53990. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53991. }
  53992. }
  53993. declare module BABYLON {
  53994. /** @hidden */
  53995. export var glowBlurPostProcessPixelShader: {
  53996. name: string;
  53997. shader: string;
  53998. };
  53999. }
  54000. declare module BABYLON {
  54001. interface AbstractScene {
  54002. /**
  54003. * Return a the first highlight layer of the scene with a given name.
  54004. * @param name The name of the highlight layer to look for.
  54005. * @return The highlight layer if found otherwise null.
  54006. */
  54007. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54008. }
  54009. /**
  54010. * Highlight layer options. This helps customizing the behaviour
  54011. * of the highlight layer.
  54012. */
  54013. export interface IHighlightLayerOptions {
  54014. /**
  54015. * Multiplication factor apply to the canvas size to compute the render target size
  54016. * used to generated the glowing objects (the smaller the faster).
  54017. */
  54018. mainTextureRatio: number;
  54019. /**
  54020. * Enforces a fixed size texture to ensure resize independant blur.
  54021. */
  54022. mainTextureFixedSize?: number;
  54023. /**
  54024. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54025. * of the picture to blur (the smaller the faster).
  54026. */
  54027. blurTextureSizeRatio: number;
  54028. /**
  54029. * How big in texel of the blur texture is the vertical blur.
  54030. */
  54031. blurVerticalSize: number;
  54032. /**
  54033. * How big in texel of the blur texture is the horizontal blur.
  54034. */
  54035. blurHorizontalSize: number;
  54036. /**
  54037. * Alpha blending mode used to apply the blur. Default is combine.
  54038. */
  54039. alphaBlendingMode: number;
  54040. /**
  54041. * The camera attached to the layer.
  54042. */
  54043. camera: Nullable<Camera>;
  54044. /**
  54045. * Should we display highlight as a solid stroke?
  54046. */
  54047. isStroke?: boolean;
  54048. /**
  54049. * The rendering group to draw the layer in.
  54050. */
  54051. renderingGroupId: number;
  54052. }
  54053. /**
  54054. * The highlight layer Helps adding a glow effect around a mesh.
  54055. *
  54056. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54057. * glowy meshes to your scene.
  54058. *
  54059. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54060. */
  54061. export class HighlightLayer extends EffectLayer {
  54062. name: string;
  54063. /**
  54064. * Effect Name of the highlight layer.
  54065. */
  54066. static readonly EffectName: string;
  54067. /**
  54068. * The neutral color used during the preparation of the glow effect.
  54069. * This is black by default as the blend operation is a blend operation.
  54070. */
  54071. static NeutralColor: Color4;
  54072. /**
  54073. * Stencil value used for glowing meshes.
  54074. */
  54075. static GlowingMeshStencilReference: number;
  54076. /**
  54077. * Stencil value used for the other meshes in the scene.
  54078. */
  54079. static NormalMeshStencilReference: number;
  54080. /**
  54081. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54082. */
  54083. innerGlow: boolean;
  54084. /**
  54085. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54086. */
  54087. outerGlow: boolean;
  54088. /**
  54089. * Specifies the horizontal size of the blur.
  54090. */
  54091. set blurHorizontalSize(value: number);
  54092. /**
  54093. * Specifies the vertical size of the blur.
  54094. */
  54095. set blurVerticalSize(value: number);
  54096. /**
  54097. * Gets the horizontal size of the blur.
  54098. */
  54099. get blurHorizontalSize(): number;
  54100. /**
  54101. * Gets the vertical size of the blur.
  54102. */
  54103. get blurVerticalSize(): number;
  54104. /**
  54105. * An event triggered when the highlight layer is being blurred.
  54106. */
  54107. onBeforeBlurObservable: Observable<HighlightLayer>;
  54108. /**
  54109. * An event triggered when the highlight layer has been blurred.
  54110. */
  54111. onAfterBlurObservable: Observable<HighlightLayer>;
  54112. private _instanceGlowingMeshStencilReference;
  54113. private _options;
  54114. private _downSamplePostprocess;
  54115. private _horizontalBlurPostprocess;
  54116. private _verticalBlurPostprocess;
  54117. private _blurTexture;
  54118. private _meshes;
  54119. private _excludedMeshes;
  54120. /**
  54121. * Instantiates a new highlight Layer and references it to the scene..
  54122. * @param name The name of the layer
  54123. * @param scene The scene to use the layer in
  54124. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54125. */
  54126. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54127. /**
  54128. * Get the effect name of the layer.
  54129. * @return The effect name
  54130. */
  54131. getEffectName(): string;
  54132. /**
  54133. * Create the merge effect. This is the shader use to blit the information back
  54134. * to the main canvas at the end of the scene rendering.
  54135. */
  54136. protected _createMergeEffect(): Effect;
  54137. /**
  54138. * Creates the render target textures and post processes used in the highlight layer.
  54139. */
  54140. protected _createTextureAndPostProcesses(): void;
  54141. /**
  54142. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54143. */
  54144. needStencil(): boolean;
  54145. /**
  54146. * Checks for the readiness of the element composing the layer.
  54147. * @param subMesh the mesh to check for
  54148. * @param useInstances specify wether or not to use instances to render the mesh
  54149. * @param emissiveTexture the associated emissive texture used to generate the glow
  54150. * @return true if ready otherwise, false
  54151. */
  54152. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54153. /**
  54154. * Implementation specific of rendering the generating effect on the main canvas.
  54155. * @param effect The effect used to render through
  54156. */
  54157. protected _internalRender(effect: Effect): void;
  54158. /**
  54159. * Returns true if the layer contains information to display, otherwise false.
  54160. */
  54161. shouldRender(): boolean;
  54162. /**
  54163. * Returns true if the mesh should render, otherwise false.
  54164. * @param mesh The mesh to render
  54165. * @returns true if it should render otherwise false
  54166. */
  54167. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54168. /**
  54169. * Adds specific effects defines.
  54170. * @param defines The defines to add specifics to.
  54171. */
  54172. protected _addCustomEffectDefines(defines: string[]): void;
  54173. /**
  54174. * Sets the required values for both the emissive texture and and the main color.
  54175. */
  54176. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54177. /**
  54178. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54179. * @param mesh The mesh to exclude from the highlight layer
  54180. */
  54181. addExcludedMesh(mesh: Mesh): void;
  54182. /**
  54183. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54184. * @param mesh The mesh to highlight
  54185. */
  54186. removeExcludedMesh(mesh: Mesh): void;
  54187. /**
  54188. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54189. * @param mesh mesh to test
  54190. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54191. */
  54192. hasMesh(mesh: AbstractMesh): boolean;
  54193. /**
  54194. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54195. * @param mesh The mesh to highlight
  54196. * @param color The color of the highlight
  54197. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54198. */
  54199. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54200. /**
  54201. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54202. * @param mesh The mesh to highlight
  54203. */
  54204. removeMesh(mesh: Mesh): void;
  54205. /**
  54206. * Remove all the meshes currently referenced in the highlight layer
  54207. */
  54208. removeAllMeshes(): void;
  54209. /**
  54210. * Force the stencil to the normal expected value for none glowing parts
  54211. */
  54212. private _defaultStencilReference;
  54213. /**
  54214. * Free any resources and references associated to a mesh.
  54215. * Internal use
  54216. * @param mesh The mesh to free.
  54217. * @hidden
  54218. */
  54219. _disposeMesh(mesh: Mesh): void;
  54220. /**
  54221. * Dispose the highlight layer and free resources.
  54222. */
  54223. dispose(): void;
  54224. /**
  54225. * Gets the class name of the effect layer
  54226. * @returns the string with the class name of the effect layer
  54227. */
  54228. getClassName(): string;
  54229. /**
  54230. * Serializes this Highlight layer
  54231. * @returns a serialized Highlight layer object
  54232. */
  54233. serialize(): any;
  54234. /**
  54235. * Creates a Highlight layer from parsed Highlight layer data
  54236. * @param parsedHightlightLayer defines the Highlight layer data
  54237. * @param scene defines the current scene
  54238. * @param rootUrl defines the root URL containing the Highlight layer information
  54239. * @returns a parsed Highlight layer
  54240. */
  54241. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54242. }
  54243. }
  54244. declare module BABYLON {
  54245. interface AbstractScene {
  54246. /**
  54247. * The list of layers (background and foreground) of the scene
  54248. */
  54249. layers: Array<Layer>;
  54250. }
  54251. /**
  54252. * Defines the layer scene component responsible to manage any layers
  54253. * in a given scene.
  54254. */
  54255. export class LayerSceneComponent implements ISceneComponent {
  54256. /**
  54257. * The component name helpfull to identify the component in the list of scene components.
  54258. */
  54259. readonly name: string;
  54260. /**
  54261. * The scene the component belongs to.
  54262. */
  54263. scene: Scene;
  54264. private _engine;
  54265. /**
  54266. * Creates a new instance of the component for the given scene
  54267. * @param scene Defines the scene to register the component in
  54268. */
  54269. constructor(scene: Scene);
  54270. /**
  54271. * Registers the component in a given scene
  54272. */
  54273. register(): void;
  54274. /**
  54275. * Rebuilds the elements related to this component in case of
  54276. * context lost for instance.
  54277. */
  54278. rebuild(): void;
  54279. /**
  54280. * Disposes the component and the associated ressources.
  54281. */
  54282. dispose(): void;
  54283. private _draw;
  54284. private _drawCameraPredicate;
  54285. private _drawCameraBackground;
  54286. private _drawCameraForeground;
  54287. private _drawRenderTargetPredicate;
  54288. private _drawRenderTargetBackground;
  54289. private _drawRenderTargetForeground;
  54290. /**
  54291. * Adds all the elements from the container to the scene
  54292. * @param container the container holding the elements
  54293. */
  54294. addFromContainer(container: AbstractScene): void;
  54295. /**
  54296. * Removes all the elements in the container from the scene
  54297. * @param container contains the elements to remove
  54298. * @param dispose if the removed element should be disposed (default: false)
  54299. */
  54300. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54301. }
  54302. }
  54303. declare module BABYLON {
  54304. /** @hidden */
  54305. export var layerPixelShader: {
  54306. name: string;
  54307. shader: string;
  54308. };
  54309. }
  54310. declare module BABYLON {
  54311. /** @hidden */
  54312. export var layerVertexShader: {
  54313. name: string;
  54314. shader: string;
  54315. };
  54316. }
  54317. declare module BABYLON {
  54318. /**
  54319. * This represents a full screen 2d layer.
  54320. * This can be useful to display a picture in the background of your scene for instance.
  54321. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54322. */
  54323. export class Layer {
  54324. /**
  54325. * Define the name of the layer.
  54326. */
  54327. name: string;
  54328. /**
  54329. * Define the texture the layer should display.
  54330. */
  54331. texture: Nullable<Texture>;
  54332. /**
  54333. * Is the layer in background or foreground.
  54334. */
  54335. isBackground: boolean;
  54336. /**
  54337. * Define the color of the layer (instead of texture).
  54338. */
  54339. color: Color4;
  54340. /**
  54341. * Define the scale of the layer in order to zoom in out of the texture.
  54342. */
  54343. scale: Vector2;
  54344. /**
  54345. * Define an offset for the layer in order to shift the texture.
  54346. */
  54347. offset: Vector2;
  54348. /**
  54349. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54350. */
  54351. alphaBlendingMode: number;
  54352. /**
  54353. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54354. * Alpha test will not mix with the background color in case of transparency.
  54355. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54356. */
  54357. alphaTest: boolean;
  54358. /**
  54359. * Define a mask to restrict the layer to only some of the scene cameras.
  54360. */
  54361. layerMask: number;
  54362. /**
  54363. * Define the list of render target the layer is visible into.
  54364. */
  54365. renderTargetTextures: RenderTargetTexture[];
  54366. /**
  54367. * Define if the layer is only used in renderTarget or if it also
  54368. * renders in the main frame buffer of the canvas.
  54369. */
  54370. renderOnlyInRenderTargetTextures: boolean;
  54371. private _scene;
  54372. private _vertexBuffers;
  54373. private _indexBuffer;
  54374. private _effect;
  54375. private _previousDefines;
  54376. /**
  54377. * An event triggered when the layer is disposed.
  54378. */
  54379. onDisposeObservable: Observable<Layer>;
  54380. private _onDisposeObserver;
  54381. /**
  54382. * Back compatibility with callback before the onDisposeObservable existed.
  54383. * The set callback will be triggered when the layer has been disposed.
  54384. */
  54385. set onDispose(callback: () => void);
  54386. /**
  54387. * An event triggered before rendering the scene
  54388. */
  54389. onBeforeRenderObservable: Observable<Layer>;
  54390. private _onBeforeRenderObserver;
  54391. /**
  54392. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54393. * The set callback will be triggered just before rendering the layer.
  54394. */
  54395. set onBeforeRender(callback: () => void);
  54396. /**
  54397. * An event triggered after rendering the scene
  54398. */
  54399. onAfterRenderObservable: Observable<Layer>;
  54400. private _onAfterRenderObserver;
  54401. /**
  54402. * Back compatibility with callback before the onAfterRenderObservable existed.
  54403. * The set callback will be triggered just after rendering the layer.
  54404. */
  54405. set onAfterRender(callback: () => void);
  54406. /**
  54407. * Instantiates a new layer.
  54408. * This represents a full screen 2d layer.
  54409. * This can be useful to display a picture in the background of your scene for instance.
  54410. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54411. * @param name Define the name of the layer in the scene
  54412. * @param imgUrl Define the url of the texture to display in the layer
  54413. * @param scene Define the scene the layer belongs to
  54414. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54415. * @param color Defines a color for the layer
  54416. */
  54417. constructor(
  54418. /**
  54419. * Define the name of the layer.
  54420. */
  54421. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54422. private _createIndexBuffer;
  54423. /** @hidden */
  54424. _rebuild(): void;
  54425. /**
  54426. * Renders the layer in the scene.
  54427. */
  54428. render(): void;
  54429. /**
  54430. * Disposes and releases the associated ressources.
  54431. */
  54432. dispose(): void;
  54433. }
  54434. }
  54435. declare module BABYLON {
  54436. /** @hidden */
  54437. export var lensFlarePixelShader: {
  54438. name: string;
  54439. shader: string;
  54440. };
  54441. }
  54442. declare module BABYLON {
  54443. /** @hidden */
  54444. export var lensFlareVertexShader: {
  54445. name: string;
  54446. shader: string;
  54447. };
  54448. }
  54449. declare module BABYLON {
  54450. /**
  54451. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54452. * It is usually composed of several `lensFlare`.
  54453. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54454. */
  54455. export class LensFlareSystem {
  54456. /**
  54457. * Define the name of the lens flare system
  54458. */
  54459. name: string;
  54460. /**
  54461. * List of lens flares used in this system.
  54462. */
  54463. lensFlares: LensFlare[];
  54464. /**
  54465. * Define a limit from the border the lens flare can be visible.
  54466. */
  54467. borderLimit: number;
  54468. /**
  54469. * Define a viewport border we do not want to see the lens flare in.
  54470. */
  54471. viewportBorder: number;
  54472. /**
  54473. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54474. */
  54475. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54476. /**
  54477. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54478. */
  54479. layerMask: number;
  54480. /**
  54481. * Define the id of the lens flare system in the scene.
  54482. * (equal to name by default)
  54483. */
  54484. id: string;
  54485. private _scene;
  54486. private _emitter;
  54487. private _vertexBuffers;
  54488. private _indexBuffer;
  54489. private _effect;
  54490. private _positionX;
  54491. private _positionY;
  54492. private _isEnabled;
  54493. /** @hidden */
  54494. static _SceneComponentInitialization: (scene: Scene) => void;
  54495. /**
  54496. * Instantiates a lens flare system.
  54497. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54498. * It is usually composed of several `lensFlare`.
  54499. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54500. * @param name Define the name of the lens flare system in the scene
  54501. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54502. * @param scene Define the scene the lens flare system belongs to
  54503. */
  54504. constructor(
  54505. /**
  54506. * Define the name of the lens flare system
  54507. */
  54508. name: string, emitter: any, scene: Scene);
  54509. /**
  54510. * Define if the lens flare system is enabled.
  54511. */
  54512. get isEnabled(): boolean;
  54513. set isEnabled(value: boolean);
  54514. /**
  54515. * Get the scene the effects belongs to.
  54516. * @returns the scene holding the lens flare system
  54517. */
  54518. getScene(): Scene;
  54519. /**
  54520. * Get the emitter of the lens flare system.
  54521. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54522. * @returns the emitter of the lens flare system
  54523. */
  54524. getEmitter(): any;
  54525. /**
  54526. * Set the emitter of the lens flare system.
  54527. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54528. * @param newEmitter Define the new emitter of the system
  54529. */
  54530. setEmitter(newEmitter: any): void;
  54531. /**
  54532. * Get the lens flare system emitter position.
  54533. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54534. * @returns the position
  54535. */
  54536. getEmitterPosition(): Vector3;
  54537. /**
  54538. * @hidden
  54539. */
  54540. computeEffectivePosition(globalViewport: Viewport): boolean;
  54541. /** @hidden */
  54542. _isVisible(): boolean;
  54543. /**
  54544. * @hidden
  54545. */
  54546. render(): boolean;
  54547. /**
  54548. * Dispose and release the lens flare with its associated resources.
  54549. */
  54550. dispose(): void;
  54551. /**
  54552. * Parse a lens flare system from a JSON repressentation
  54553. * @param parsedLensFlareSystem Define the JSON to parse
  54554. * @param scene Define the scene the parsed system should be instantiated in
  54555. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54556. * @returns the parsed system
  54557. */
  54558. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54559. /**
  54560. * Serialize the current Lens Flare System into a JSON representation.
  54561. * @returns the serialized JSON
  54562. */
  54563. serialize(): any;
  54564. }
  54565. }
  54566. declare module BABYLON {
  54567. /**
  54568. * This represents one of the lens effect in a `lensFlareSystem`.
  54569. * It controls one of the indiviual texture used in the effect.
  54570. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54571. */
  54572. export class LensFlare {
  54573. /**
  54574. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54575. */
  54576. size: number;
  54577. /**
  54578. * 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.
  54579. */
  54580. position: number;
  54581. /**
  54582. * Define the lens color.
  54583. */
  54584. color: Color3;
  54585. /**
  54586. * Define the lens texture.
  54587. */
  54588. texture: Nullable<Texture>;
  54589. /**
  54590. * Define the alpha mode to render this particular lens.
  54591. */
  54592. alphaMode: number;
  54593. private _system;
  54594. /**
  54595. * Creates a new Lens Flare.
  54596. * This represents one of the lens effect in a `lensFlareSystem`.
  54597. * It controls one of the indiviual texture used in the effect.
  54598. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54599. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54600. * @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.
  54601. * @param color Define the lens color
  54602. * @param imgUrl Define the lens texture url
  54603. * @param system Define the `lensFlareSystem` this flare is part of
  54604. * @returns The newly created Lens Flare
  54605. */
  54606. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54607. /**
  54608. * Instantiates a new Lens Flare.
  54609. * This represents one of the lens effect in a `lensFlareSystem`.
  54610. * It controls one of the indiviual texture used in the effect.
  54611. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54612. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54613. * @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.
  54614. * @param color Define the lens color
  54615. * @param imgUrl Define the lens texture url
  54616. * @param system Define the `lensFlareSystem` this flare is part of
  54617. */
  54618. constructor(
  54619. /**
  54620. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54621. */
  54622. size: number,
  54623. /**
  54624. * 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.
  54625. */
  54626. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54627. /**
  54628. * Dispose and release the lens flare with its associated resources.
  54629. */
  54630. dispose(): void;
  54631. }
  54632. }
  54633. declare module BABYLON {
  54634. interface AbstractScene {
  54635. /**
  54636. * The list of lens flare system added to the scene
  54637. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54638. */
  54639. lensFlareSystems: Array<LensFlareSystem>;
  54640. /**
  54641. * Removes the given lens flare system from this scene.
  54642. * @param toRemove The lens flare system to remove
  54643. * @returns The index of the removed lens flare system
  54644. */
  54645. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54646. /**
  54647. * Adds the given lens flare system to this scene
  54648. * @param newLensFlareSystem The lens flare system to add
  54649. */
  54650. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54651. /**
  54652. * Gets a lens flare system using its name
  54653. * @param name defines the name to look for
  54654. * @returns the lens flare system or null if not found
  54655. */
  54656. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54657. /**
  54658. * Gets a lens flare system using its id
  54659. * @param id defines the id to look for
  54660. * @returns the lens flare system or null if not found
  54661. */
  54662. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54663. }
  54664. /**
  54665. * Defines the lens flare scene component responsible to manage any lens flares
  54666. * in a given scene.
  54667. */
  54668. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54669. /**
  54670. * The component name helpfull to identify the component in the list of scene components.
  54671. */
  54672. readonly name: string;
  54673. /**
  54674. * The scene the component belongs to.
  54675. */
  54676. scene: Scene;
  54677. /**
  54678. * Creates a new instance of the component for the given scene
  54679. * @param scene Defines the scene to register the component in
  54680. */
  54681. constructor(scene: Scene);
  54682. /**
  54683. * Registers the component in a given scene
  54684. */
  54685. register(): void;
  54686. /**
  54687. * Rebuilds the elements related to this component in case of
  54688. * context lost for instance.
  54689. */
  54690. rebuild(): void;
  54691. /**
  54692. * Adds all the elements from the container to the scene
  54693. * @param container the container holding the elements
  54694. */
  54695. addFromContainer(container: AbstractScene): void;
  54696. /**
  54697. * Removes all the elements in the container from the scene
  54698. * @param container contains the elements to remove
  54699. * @param dispose if the removed element should be disposed (default: false)
  54700. */
  54701. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54702. /**
  54703. * Serializes the component data to the specified json object
  54704. * @param serializationObject The object to serialize to
  54705. */
  54706. serialize(serializationObject: any): void;
  54707. /**
  54708. * Disposes the component and the associated ressources.
  54709. */
  54710. dispose(): void;
  54711. private _draw;
  54712. }
  54713. }
  54714. declare module BABYLON {
  54715. /** @hidden */
  54716. export var depthPixelShader: {
  54717. name: string;
  54718. shader: string;
  54719. };
  54720. }
  54721. declare module BABYLON {
  54722. /** @hidden */
  54723. export var depthVertexShader: {
  54724. name: string;
  54725. shader: string;
  54726. };
  54727. }
  54728. declare module BABYLON {
  54729. /**
  54730. * This represents a depth renderer in Babylon.
  54731. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54732. */
  54733. export class DepthRenderer {
  54734. private _scene;
  54735. private _depthMap;
  54736. private _effect;
  54737. private readonly _storeNonLinearDepth;
  54738. private readonly _clearColor;
  54739. /** Get if the depth renderer is using packed depth or not */
  54740. readonly isPacked: boolean;
  54741. private _cachedDefines;
  54742. private _camera;
  54743. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54744. enabled: boolean;
  54745. /**
  54746. * Specifiess that the depth renderer will only be used within
  54747. * the camera it is created for.
  54748. * This can help forcing its rendering during the camera processing.
  54749. */
  54750. useOnlyInActiveCamera: boolean;
  54751. /** @hidden */
  54752. static _SceneComponentInitialization: (scene: Scene) => void;
  54753. /**
  54754. * Instantiates a depth renderer
  54755. * @param scene The scene the renderer belongs to
  54756. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54757. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54758. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54759. */
  54760. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54761. /**
  54762. * Creates the depth rendering effect and checks if the effect is ready.
  54763. * @param subMesh The submesh to be used to render the depth map of
  54764. * @param useInstances If multiple world instances should be used
  54765. * @returns if the depth renderer is ready to render the depth map
  54766. */
  54767. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54768. /**
  54769. * Gets the texture which the depth map will be written to.
  54770. * @returns The depth map texture
  54771. */
  54772. getDepthMap(): RenderTargetTexture;
  54773. /**
  54774. * Disposes of the depth renderer.
  54775. */
  54776. dispose(): void;
  54777. }
  54778. }
  54779. declare module BABYLON {
  54780. /** @hidden */
  54781. export var minmaxReduxPixelShader: {
  54782. name: string;
  54783. shader: string;
  54784. };
  54785. }
  54786. declare module BABYLON {
  54787. /**
  54788. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54789. * and maximum values from all values of the texture.
  54790. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54791. * The source values are read from the red channel of the texture.
  54792. */
  54793. export class MinMaxReducer {
  54794. /**
  54795. * Observable triggered when the computation has been performed
  54796. */
  54797. onAfterReductionPerformed: Observable<{
  54798. min: number;
  54799. max: number;
  54800. }>;
  54801. protected _camera: Camera;
  54802. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54803. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54804. protected _postProcessManager: PostProcessManager;
  54805. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54806. protected _forceFullscreenViewport: boolean;
  54807. /**
  54808. * Creates a min/max reducer
  54809. * @param camera The camera to use for the post processes
  54810. */
  54811. constructor(camera: Camera);
  54812. /**
  54813. * Gets the texture used to read the values from.
  54814. */
  54815. get sourceTexture(): Nullable<RenderTargetTexture>;
  54816. /**
  54817. * Sets the source texture to read the values from.
  54818. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54819. * because in such textures '1' value must not be taken into account to compute the maximum
  54820. * as this value is used to clear the texture.
  54821. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54822. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54823. * @param depthRedux Indicates if the texture is a depth texture or not
  54824. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54825. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54826. */
  54827. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54828. /**
  54829. * Defines the refresh rate of the computation.
  54830. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54831. */
  54832. get refreshRate(): number;
  54833. set refreshRate(value: number);
  54834. protected _activated: boolean;
  54835. /**
  54836. * Gets the activation status of the reducer
  54837. */
  54838. get activated(): boolean;
  54839. /**
  54840. * Activates the reduction computation.
  54841. * When activated, the observers registered in onAfterReductionPerformed are
  54842. * called after the compuation is performed
  54843. */
  54844. activate(): void;
  54845. /**
  54846. * Deactivates the reduction computation.
  54847. */
  54848. deactivate(): void;
  54849. /**
  54850. * Disposes the min/max reducer
  54851. * @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.
  54852. */
  54853. dispose(disposeAll?: boolean): void;
  54854. }
  54855. }
  54856. declare module BABYLON {
  54857. /**
  54858. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54859. */
  54860. export class DepthReducer extends MinMaxReducer {
  54861. private _depthRenderer;
  54862. private _depthRendererId;
  54863. /**
  54864. * Gets the depth renderer used for the computation.
  54865. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54866. */
  54867. get depthRenderer(): Nullable<DepthRenderer>;
  54868. /**
  54869. * Creates a depth reducer
  54870. * @param camera The camera used to render the depth texture
  54871. */
  54872. constructor(camera: Camera);
  54873. /**
  54874. * Sets the depth renderer to use to generate the depth map
  54875. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54876. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54877. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54878. */
  54879. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54880. /** @hidden */
  54881. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54882. /**
  54883. * Activates the reduction computation.
  54884. * When activated, the observers registered in onAfterReductionPerformed are
  54885. * called after the compuation is performed
  54886. */
  54887. activate(): void;
  54888. /**
  54889. * Deactivates the reduction computation.
  54890. */
  54891. deactivate(): void;
  54892. /**
  54893. * Disposes the depth reducer
  54894. * @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.
  54895. */
  54896. dispose(disposeAll?: boolean): void;
  54897. }
  54898. }
  54899. declare module BABYLON {
  54900. /**
  54901. * A CSM implementation allowing casting shadows on large scenes.
  54902. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54903. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54904. */
  54905. export class CascadedShadowGenerator extends ShadowGenerator {
  54906. private static readonly frustumCornersNDCSpace;
  54907. /**
  54908. * Name of the CSM class
  54909. */
  54910. static CLASSNAME: string;
  54911. /**
  54912. * Defines the default number of cascades used by the CSM.
  54913. */
  54914. static readonly DEFAULT_CASCADES_COUNT: number;
  54915. /**
  54916. * Defines the minimum number of cascades used by the CSM.
  54917. */
  54918. static readonly MIN_CASCADES_COUNT: number;
  54919. /**
  54920. * Defines the maximum number of cascades used by the CSM.
  54921. */
  54922. static readonly MAX_CASCADES_COUNT: number;
  54923. protected _validateFilter(filter: number): number;
  54924. /**
  54925. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54926. */
  54927. penumbraDarkness: number;
  54928. private _numCascades;
  54929. /**
  54930. * Gets or set the number of cascades used by the CSM.
  54931. */
  54932. get numCascades(): number;
  54933. set numCascades(value: number);
  54934. /**
  54935. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54936. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54937. */
  54938. stabilizeCascades: boolean;
  54939. private _freezeShadowCastersBoundingInfo;
  54940. private _freezeShadowCastersBoundingInfoObservable;
  54941. /**
  54942. * Enables or disables the shadow casters bounding info computation.
  54943. * If your shadow casters don't move, you can disable this feature.
  54944. * If it is enabled, the bounding box computation is done every frame.
  54945. */
  54946. get freezeShadowCastersBoundingInfo(): boolean;
  54947. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54948. private _scbiMin;
  54949. private _scbiMax;
  54950. protected _computeShadowCastersBoundingInfo(): void;
  54951. protected _shadowCastersBoundingInfo: BoundingInfo;
  54952. /**
  54953. * Gets or sets the shadow casters bounding info.
  54954. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54955. * so that the system won't overwrite the bounds you provide
  54956. */
  54957. get shadowCastersBoundingInfo(): BoundingInfo;
  54958. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54959. protected _breaksAreDirty: boolean;
  54960. protected _minDistance: number;
  54961. protected _maxDistance: number;
  54962. /**
  54963. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54964. *
  54965. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54966. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54967. * @param min minimal distance for the breaks (default to 0.)
  54968. * @param max maximal distance for the breaks (default to 1.)
  54969. */
  54970. setMinMaxDistance(min: number, max: number): void;
  54971. /** Gets the minimal distance used in the cascade break computation */
  54972. get minDistance(): number;
  54973. /** Gets the maximal distance used in the cascade break computation */
  54974. get maxDistance(): number;
  54975. /**
  54976. * Gets the class name of that object
  54977. * @returns "CascadedShadowGenerator"
  54978. */
  54979. getClassName(): string;
  54980. private _cascadeMinExtents;
  54981. private _cascadeMaxExtents;
  54982. /**
  54983. * Gets a cascade minimum extents
  54984. * @param cascadeIndex index of the cascade
  54985. * @returns the minimum cascade extents
  54986. */
  54987. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54988. /**
  54989. * Gets a cascade maximum extents
  54990. * @param cascadeIndex index of the cascade
  54991. * @returns the maximum cascade extents
  54992. */
  54993. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54994. private _cascades;
  54995. private _currentLayer;
  54996. private _viewSpaceFrustumsZ;
  54997. private _viewMatrices;
  54998. private _projectionMatrices;
  54999. private _transformMatrices;
  55000. private _transformMatricesAsArray;
  55001. private _frustumLengths;
  55002. private _lightSizeUVCorrection;
  55003. private _depthCorrection;
  55004. private _frustumCornersWorldSpace;
  55005. private _frustumCenter;
  55006. private _shadowCameraPos;
  55007. private _shadowMaxZ;
  55008. /**
  55009. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  55010. * It defaults to camera.maxZ
  55011. */
  55012. get shadowMaxZ(): number;
  55013. /**
  55014. * Sets the shadow max z distance.
  55015. */
  55016. set shadowMaxZ(value: number);
  55017. protected _debug: boolean;
  55018. /**
  55019. * Gets or sets the debug flag.
  55020. * When enabled, the cascades are materialized by different colors on the screen.
  55021. */
  55022. get debug(): boolean;
  55023. set debug(dbg: boolean);
  55024. private _depthClamp;
  55025. /**
  55026. * Gets or sets the depth clamping value.
  55027. *
  55028. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  55029. * to account for the shadow casters far away.
  55030. *
  55031. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  55032. */
  55033. get depthClamp(): boolean;
  55034. set depthClamp(value: boolean);
  55035. private _cascadeBlendPercentage;
  55036. /**
  55037. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  55038. * It defaults to 0.1 (10% blending).
  55039. */
  55040. get cascadeBlendPercentage(): number;
  55041. set cascadeBlendPercentage(value: number);
  55042. private _lambda;
  55043. /**
  55044. * Gets or set the lambda parameter.
  55045. * This parameter is used to split the camera frustum and create the cascades.
  55046. * 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.
  55047. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  55048. */
  55049. get lambda(): number;
  55050. set lambda(value: number);
  55051. /**
  55052. * Gets the view matrix corresponding to a given cascade
  55053. * @param cascadeNum cascade to retrieve the view matrix from
  55054. * @returns the cascade view matrix
  55055. */
  55056. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  55057. /**
  55058. * Gets the projection matrix corresponding to a given cascade
  55059. * @param cascadeNum cascade to retrieve the projection matrix from
  55060. * @returns the cascade projection matrix
  55061. */
  55062. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  55063. /**
  55064. * Gets the transformation matrix corresponding to a given cascade
  55065. * @param cascadeNum cascade to retrieve the transformation matrix from
  55066. * @returns the cascade transformation matrix
  55067. */
  55068. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  55069. private _depthRenderer;
  55070. /**
  55071. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  55072. *
  55073. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  55074. *
  55075. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  55076. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  55077. * @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
  55078. */
  55079. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  55080. private _depthReducer;
  55081. private _autoCalcDepthBounds;
  55082. /**
  55083. * Gets or sets the autoCalcDepthBounds property.
  55084. *
  55085. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  55086. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  55087. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  55088. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  55089. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  55090. */
  55091. get autoCalcDepthBounds(): boolean;
  55092. set autoCalcDepthBounds(value: boolean);
  55093. /**
  55094. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  55095. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55096. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  55097. * for setting the refresh rate on the renderer yourself!
  55098. */
  55099. get autoCalcDepthBoundsRefreshRate(): number;
  55100. set autoCalcDepthBoundsRefreshRate(value: number);
  55101. /**
  55102. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  55103. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  55104. * you change the camera near/far planes!
  55105. */
  55106. splitFrustum(): void;
  55107. private _splitFrustum;
  55108. private _computeMatrices;
  55109. private _computeFrustumInWorldSpace;
  55110. private _computeCascadeFrustum;
  55111. /**
  55112. * Support test.
  55113. */
  55114. static get IsSupported(): boolean;
  55115. /** @hidden */
  55116. static _SceneComponentInitialization: (scene: Scene) => void;
  55117. /**
  55118. * Creates a Cascaded Shadow Generator object.
  55119. * A ShadowGenerator is the required tool to use the shadows.
  55120. * Each directional light casting shadows needs to use its own ShadowGenerator.
  55121. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55122. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  55123. * @param light The directional light object generating the shadows.
  55124. * @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.
  55125. */
  55126. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  55127. protected _initializeGenerator(): void;
  55128. protected _createTargetRenderTexture(): void;
  55129. protected _initializeShadowMap(): void;
  55130. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  55131. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  55132. /**
  55133. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  55134. * @param defines Defines of the material we want to update
  55135. * @param lightIndex Index of the light in the enabled light list of the material
  55136. */
  55137. prepareDefines(defines: any, lightIndex: number): void;
  55138. /**
  55139. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  55140. * defined in the generator but impacting the effect).
  55141. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  55142. * @param effect The effect we are binfing the information for
  55143. */
  55144. bindShadowLight(lightIndex: string, effect: Effect): void;
  55145. /**
  55146. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  55147. * (eq to view projection * shadow projection matrices)
  55148. * @returns The transform matrix used to create the shadow map
  55149. */
  55150. getTransformMatrix(): Matrix;
  55151. /**
  55152. * Disposes the ShadowGenerator.
  55153. * Returns nothing.
  55154. */
  55155. dispose(): void;
  55156. /**
  55157. * Serializes the shadow generator setup to a json object.
  55158. * @returns The serialized JSON object
  55159. */
  55160. serialize(): any;
  55161. /**
  55162. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55163. * @param parsedShadowGenerator The JSON object to parse
  55164. * @param scene The scene to create the shadow map for
  55165. * @returns The parsed shadow generator
  55166. */
  55167. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55168. }
  55169. }
  55170. declare module BABYLON {
  55171. /**
  55172. * Defines the shadow generator component responsible to manage any shadow generators
  55173. * in a given scene.
  55174. */
  55175. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55176. /**
  55177. * The component name helpfull to identify the component in the list of scene components.
  55178. */
  55179. readonly name: string;
  55180. /**
  55181. * The scene the component belongs to.
  55182. */
  55183. scene: Scene;
  55184. /**
  55185. * Creates a new instance of the component for the given scene
  55186. * @param scene Defines the scene to register the component in
  55187. */
  55188. constructor(scene: Scene);
  55189. /**
  55190. * Registers the component in a given scene
  55191. */
  55192. register(): void;
  55193. /**
  55194. * Rebuilds the elements related to this component in case of
  55195. * context lost for instance.
  55196. */
  55197. rebuild(): void;
  55198. /**
  55199. * Serializes the component data to the specified json object
  55200. * @param serializationObject The object to serialize to
  55201. */
  55202. serialize(serializationObject: any): void;
  55203. /**
  55204. * Adds all the elements from the container to the scene
  55205. * @param container the container holding the elements
  55206. */
  55207. addFromContainer(container: AbstractScene): void;
  55208. /**
  55209. * Removes all the elements in the container from the scene
  55210. * @param container contains the elements to remove
  55211. * @param dispose if the removed element should be disposed (default: false)
  55212. */
  55213. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55214. /**
  55215. * Rebuilds the elements related to this component in case of
  55216. * context lost for instance.
  55217. */
  55218. dispose(): void;
  55219. private _gatherRenderTargets;
  55220. }
  55221. }
  55222. declare module BABYLON {
  55223. /**
  55224. * A point light is a light defined by an unique point in world space.
  55225. * The light is emitted in every direction from this point.
  55226. * A good example of a point light is a standard light bulb.
  55227. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55228. */
  55229. export class PointLight extends ShadowLight {
  55230. private _shadowAngle;
  55231. /**
  55232. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55233. * This specifies what angle the shadow will use to be created.
  55234. *
  55235. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55236. */
  55237. get shadowAngle(): number;
  55238. /**
  55239. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55240. * This specifies what angle the shadow will use to be created.
  55241. *
  55242. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55243. */
  55244. set shadowAngle(value: number);
  55245. /**
  55246. * Gets the direction if it has been set.
  55247. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55248. */
  55249. get direction(): Vector3;
  55250. /**
  55251. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55252. */
  55253. set direction(value: Vector3);
  55254. /**
  55255. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55256. * A PointLight emits the light in every direction.
  55257. * It can cast shadows.
  55258. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55259. * ```javascript
  55260. * var pointLight = new PointLight("pl", camera.position, scene);
  55261. * ```
  55262. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55263. * @param name The light friendly name
  55264. * @param position The position of the point light in the scene
  55265. * @param scene The scene the lights belongs to
  55266. */
  55267. constructor(name: string, position: Vector3, scene: Scene);
  55268. /**
  55269. * Returns the string "PointLight"
  55270. * @returns the class name
  55271. */
  55272. getClassName(): string;
  55273. /**
  55274. * Returns the integer 0.
  55275. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55276. */
  55277. getTypeID(): number;
  55278. /**
  55279. * Specifies wether or not the shadowmap should be a cube texture.
  55280. * @returns true if the shadowmap needs to be a cube texture.
  55281. */
  55282. needCube(): boolean;
  55283. /**
  55284. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55285. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55286. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55287. */
  55288. getShadowDirection(faceIndex?: number): Vector3;
  55289. /**
  55290. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55291. * - fov = PI / 2
  55292. * - aspect ratio : 1.0
  55293. * - z-near and far equal to the active camera minZ and maxZ.
  55294. * Returns the PointLight.
  55295. */
  55296. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55297. protected _buildUniformLayout(): void;
  55298. /**
  55299. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55300. * @param effect The effect to update
  55301. * @param lightIndex The index of the light in the effect to update
  55302. * @returns The point light
  55303. */
  55304. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55305. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55306. /**
  55307. * Prepares the list of defines specific to the light type.
  55308. * @param defines the list of defines
  55309. * @param lightIndex defines the index of the light for the effect
  55310. */
  55311. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55312. }
  55313. }
  55314. declare module BABYLON {
  55315. /**
  55316. * Header information of HDR texture files.
  55317. */
  55318. export interface HDRInfo {
  55319. /**
  55320. * The height of the texture in pixels.
  55321. */
  55322. height: number;
  55323. /**
  55324. * The width of the texture in pixels.
  55325. */
  55326. width: number;
  55327. /**
  55328. * The index of the beginning of the data in the binary file.
  55329. */
  55330. dataPosition: number;
  55331. }
  55332. /**
  55333. * This groups tools to convert HDR texture to native colors array.
  55334. */
  55335. export class HDRTools {
  55336. private static Ldexp;
  55337. private static Rgbe2float;
  55338. private static readStringLine;
  55339. /**
  55340. * Reads header information from an RGBE texture stored in a native array.
  55341. * More information on this format are available here:
  55342. * https://en.wikipedia.org/wiki/RGBE_image_format
  55343. *
  55344. * @param uint8array The binary file stored in native array.
  55345. * @return The header information.
  55346. */
  55347. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55348. /**
  55349. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55350. * This RGBE texture needs to store the information as a panorama.
  55351. *
  55352. * More information on this format are available here:
  55353. * https://en.wikipedia.org/wiki/RGBE_image_format
  55354. *
  55355. * @param buffer The binary file stored in an array buffer.
  55356. * @param size The expected size of the extracted cubemap.
  55357. * @return The Cube Map information.
  55358. */
  55359. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55360. /**
  55361. * Returns the pixels data extracted from an RGBE texture.
  55362. * This pixels will be stored left to right up to down in the R G B order in one array.
  55363. *
  55364. * More information on this format are available here:
  55365. * https://en.wikipedia.org/wiki/RGBE_image_format
  55366. *
  55367. * @param uint8array The binary file stored in an array buffer.
  55368. * @param hdrInfo The header information of the file.
  55369. * @return The pixels data in RGB right to left up to down order.
  55370. */
  55371. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55372. private static RGBE_ReadPixels_RLE;
  55373. }
  55374. }
  55375. declare module BABYLON {
  55376. /**
  55377. * This represents a texture coming from an HDR input.
  55378. *
  55379. * The only supported format is currently panorama picture stored in RGBE format.
  55380. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55381. */
  55382. export class HDRCubeTexture extends BaseTexture {
  55383. private static _facesMapping;
  55384. private _generateHarmonics;
  55385. private _noMipmap;
  55386. private _textureMatrix;
  55387. private _size;
  55388. private _onLoad;
  55389. private _onError;
  55390. /**
  55391. * The texture URL.
  55392. */
  55393. url: string;
  55394. /**
  55395. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55396. */
  55397. coordinatesMode: number;
  55398. protected _isBlocking: boolean;
  55399. /**
  55400. * Sets wether or not the texture is blocking during loading.
  55401. */
  55402. set isBlocking(value: boolean);
  55403. /**
  55404. * Gets wether or not the texture is blocking during loading.
  55405. */
  55406. get isBlocking(): boolean;
  55407. protected _rotationY: number;
  55408. /**
  55409. * Sets texture matrix rotation angle around Y axis in radians.
  55410. */
  55411. set rotationY(value: number);
  55412. /**
  55413. * Gets texture matrix rotation angle around Y axis radians.
  55414. */
  55415. get rotationY(): number;
  55416. /**
  55417. * Gets or sets the center of the bounding box associated with the cube texture
  55418. * It must define where the camera used to render the texture was set
  55419. */
  55420. boundingBoxPosition: Vector3;
  55421. private _boundingBoxSize;
  55422. /**
  55423. * Gets or sets the size of the bounding box associated with the cube texture
  55424. * When defined, the cubemap will switch to local mode
  55425. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55426. * @example https://www.babylonjs-playground.com/#RNASML
  55427. */
  55428. set boundingBoxSize(value: Vector3);
  55429. get boundingBoxSize(): Vector3;
  55430. /**
  55431. * Instantiates an HDRTexture from the following parameters.
  55432. *
  55433. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55434. * @param scene The scene the texture will be used in
  55435. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55436. * @param noMipmap Forces to not generate the mipmap if true
  55437. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55438. * @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)
  55439. * @param reserved Reserved flag for internal use.
  55440. */
  55441. 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>);
  55442. /**
  55443. * Get the current class name of the texture useful for serialization or dynamic coding.
  55444. * @returns "HDRCubeTexture"
  55445. */
  55446. getClassName(): string;
  55447. /**
  55448. * Occurs when the file is raw .hdr file.
  55449. */
  55450. private loadTexture;
  55451. clone(): HDRCubeTexture;
  55452. delayLoad(): void;
  55453. /**
  55454. * Get the texture reflection matrix used to rotate/transform the reflection.
  55455. * @returns the reflection matrix
  55456. */
  55457. getReflectionTextureMatrix(): Matrix;
  55458. /**
  55459. * Set the texture reflection matrix used to rotate/transform the reflection.
  55460. * @param value Define the reflection matrix to set
  55461. */
  55462. setReflectionTextureMatrix(value: Matrix): void;
  55463. /**
  55464. * Parses a JSON representation of an HDR Texture in order to create the texture
  55465. * @param parsedTexture Define the JSON representation
  55466. * @param scene Define the scene the texture should be created in
  55467. * @param rootUrl Define the root url in case we need to load relative dependencies
  55468. * @returns the newly created texture after parsing
  55469. */
  55470. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55471. serialize(): any;
  55472. }
  55473. }
  55474. declare module BABYLON {
  55475. /**
  55476. * Class used to control physics engine
  55477. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55478. */
  55479. export class PhysicsEngine implements IPhysicsEngine {
  55480. private _physicsPlugin;
  55481. /**
  55482. * Global value used to control the smallest number supported by the simulation
  55483. */
  55484. static Epsilon: number;
  55485. private _impostors;
  55486. private _joints;
  55487. private _subTimeStep;
  55488. /**
  55489. * Gets the gravity vector used by the simulation
  55490. */
  55491. gravity: Vector3;
  55492. /**
  55493. * Factory used to create the default physics plugin.
  55494. * @returns The default physics plugin
  55495. */
  55496. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55497. /**
  55498. * Creates a new Physics Engine
  55499. * @param gravity defines the gravity vector used by the simulation
  55500. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55501. */
  55502. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55503. /**
  55504. * Sets the gravity vector used by the simulation
  55505. * @param gravity defines the gravity vector to use
  55506. */
  55507. setGravity(gravity: Vector3): void;
  55508. /**
  55509. * Set the time step of the physics engine.
  55510. * Default is 1/60.
  55511. * To slow it down, enter 1/600 for example.
  55512. * To speed it up, 1/30
  55513. * @param newTimeStep defines the new timestep to apply to this world.
  55514. */
  55515. setTimeStep(newTimeStep?: number): void;
  55516. /**
  55517. * Get the time step of the physics engine.
  55518. * @returns the current time step
  55519. */
  55520. getTimeStep(): number;
  55521. /**
  55522. * Set the sub time step of the physics engine.
  55523. * Default is 0 meaning there is no sub steps
  55524. * To increase physics resolution precision, set a small value (like 1 ms)
  55525. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55526. */
  55527. setSubTimeStep(subTimeStep?: number): void;
  55528. /**
  55529. * Get the sub time step of the physics engine.
  55530. * @returns the current sub time step
  55531. */
  55532. getSubTimeStep(): number;
  55533. /**
  55534. * Release all resources
  55535. */
  55536. dispose(): void;
  55537. /**
  55538. * Gets the name of the current physics plugin
  55539. * @returns the name of the plugin
  55540. */
  55541. getPhysicsPluginName(): string;
  55542. /**
  55543. * Adding a new impostor for the impostor tracking.
  55544. * This will be done by the impostor itself.
  55545. * @param impostor the impostor to add
  55546. */
  55547. addImpostor(impostor: PhysicsImpostor): void;
  55548. /**
  55549. * Remove an impostor from the engine.
  55550. * This impostor and its mesh will not longer be updated by the physics engine.
  55551. * @param impostor the impostor to remove
  55552. */
  55553. removeImpostor(impostor: PhysicsImpostor): void;
  55554. /**
  55555. * Add a joint to the physics engine
  55556. * @param mainImpostor defines the main impostor to which the joint is added.
  55557. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55558. * @param joint defines the joint that will connect both impostors.
  55559. */
  55560. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55561. /**
  55562. * Removes a joint from the simulation
  55563. * @param mainImpostor defines the impostor used with the joint
  55564. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55565. * @param joint defines the joint to remove
  55566. */
  55567. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55568. /**
  55569. * Called by the scene. No need to call it.
  55570. * @param delta defines the timespam between frames
  55571. */
  55572. _step(delta: number): void;
  55573. /**
  55574. * Gets the current plugin used to run the simulation
  55575. * @returns current plugin
  55576. */
  55577. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55578. /**
  55579. * Gets the list of physic impostors
  55580. * @returns an array of PhysicsImpostor
  55581. */
  55582. getImpostors(): Array<PhysicsImpostor>;
  55583. /**
  55584. * Gets the impostor for a physics enabled object
  55585. * @param object defines the object impersonated by the impostor
  55586. * @returns the PhysicsImpostor or null if not found
  55587. */
  55588. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55589. /**
  55590. * Gets the impostor for a physics body object
  55591. * @param body defines physics body used by the impostor
  55592. * @returns the PhysicsImpostor or null if not found
  55593. */
  55594. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55595. /**
  55596. * Does a raycast in the physics world
  55597. * @param from when should the ray start?
  55598. * @param to when should the ray end?
  55599. * @returns PhysicsRaycastResult
  55600. */
  55601. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55602. }
  55603. }
  55604. declare module BABYLON {
  55605. /** @hidden */
  55606. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55607. private _useDeltaForWorldStep;
  55608. world: any;
  55609. name: string;
  55610. private _physicsMaterials;
  55611. private _fixedTimeStep;
  55612. private _cannonRaycastResult;
  55613. private _raycastResult;
  55614. private _physicsBodysToRemoveAfterStep;
  55615. BJSCANNON: any;
  55616. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55617. setGravity(gravity: Vector3): void;
  55618. setTimeStep(timeStep: number): void;
  55619. getTimeStep(): number;
  55620. executeStep(delta: number): void;
  55621. private _removeMarkedPhysicsBodiesFromWorld;
  55622. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55623. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55624. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55625. private _processChildMeshes;
  55626. removePhysicsBody(impostor: PhysicsImpostor): void;
  55627. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55628. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55629. private _addMaterial;
  55630. private _checkWithEpsilon;
  55631. private _createShape;
  55632. private _createHeightmap;
  55633. private _minus90X;
  55634. private _plus90X;
  55635. private _tmpPosition;
  55636. private _tmpDeltaPosition;
  55637. private _tmpUnityRotation;
  55638. private _updatePhysicsBodyTransformation;
  55639. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55640. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55641. isSupported(): boolean;
  55642. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55643. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55644. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55645. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55646. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55647. getBodyMass(impostor: PhysicsImpostor): number;
  55648. getBodyFriction(impostor: PhysicsImpostor): number;
  55649. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55650. getBodyRestitution(impostor: PhysicsImpostor): number;
  55651. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55652. sleepBody(impostor: PhysicsImpostor): void;
  55653. wakeUpBody(impostor: PhysicsImpostor): void;
  55654. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55655. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55656. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55657. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55658. getRadius(impostor: PhysicsImpostor): number;
  55659. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55660. dispose(): void;
  55661. private _extendNamespace;
  55662. /**
  55663. * Does a raycast in the physics world
  55664. * @param from when should the ray start?
  55665. * @param to when should the ray end?
  55666. * @returns PhysicsRaycastResult
  55667. */
  55668. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55669. }
  55670. }
  55671. declare module BABYLON {
  55672. /** @hidden */
  55673. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55674. private _useDeltaForWorldStep;
  55675. world: any;
  55676. name: string;
  55677. BJSOIMO: any;
  55678. private _raycastResult;
  55679. private _fixedTimeStep;
  55680. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  55681. setGravity(gravity: Vector3): void;
  55682. setTimeStep(timeStep: number): void;
  55683. getTimeStep(): number;
  55684. private _tmpImpostorsArray;
  55685. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55686. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55687. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55688. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55689. private _tmpPositionVector;
  55690. removePhysicsBody(impostor: PhysicsImpostor): void;
  55691. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55692. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55693. isSupported(): boolean;
  55694. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55695. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55696. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55697. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55698. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55699. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55700. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55701. getBodyMass(impostor: PhysicsImpostor): number;
  55702. getBodyFriction(impostor: PhysicsImpostor): number;
  55703. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55704. getBodyRestitution(impostor: PhysicsImpostor): number;
  55705. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55706. sleepBody(impostor: PhysicsImpostor): void;
  55707. wakeUpBody(impostor: PhysicsImpostor): void;
  55708. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55709. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55710. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55711. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55712. getRadius(impostor: PhysicsImpostor): number;
  55713. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55714. dispose(): void;
  55715. /**
  55716. * Does a raycast in the physics world
  55717. * @param from when should the ray start?
  55718. * @param to when should the ray end?
  55719. * @returns PhysicsRaycastResult
  55720. */
  55721. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55722. }
  55723. }
  55724. declare module BABYLON {
  55725. /**
  55726. * Class containing static functions to help procedurally build meshes
  55727. */
  55728. export class RibbonBuilder {
  55729. /**
  55730. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55731. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55732. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55733. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55734. * * 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
  55735. * * 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
  55736. * * 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
  55737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55738. * * 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
  55739. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55740. * * 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
  55741. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55742. * * 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
  55743. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55745. * @param name defines the name of the mesh
  55746. * @param options defines the options used to create the mesh
  55747. * @param scene defines the hosting scene
  55748. * @returns the ribbon mesh
  55749. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55750. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55751. */
  55752. static CreateRibbon(name: string, options: {
  55753. pathArray: Vector3[][];
  55754. closeArray?: boolean;
  55755. closePath?: boolean;
  55756. offset?: number;
  55757. updatable?: boolean;
  55758. sideOrientation?: number;
  55759. frontUVs?: Vector4;
  55760. backUVs?: Vector4;
  55761. instance?: Mesh;
  55762. invertUV?: boolean;
  55763. uvs?: Vector2[];
  55764. colors?: Color4[];
  55765. }, scene?: Nullable<Scene>): Mesh;
  55766. }
  55767. }
  55768. declare module BABYLON {
  55769. /**
  55770. * Class containing static functions to help procedurally build meshes
  55771. */
  55772. export class ShapeBuilder {
  55773. /**
  55774. * 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.
  55775. * * 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.
  55776. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55777. * * 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.
  55778. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55779. * * 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
  55780. * * 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
  55781. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55783. * * 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
  55784. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55786. * @param name defines the name of the mesh
  55787. * @param options defines the options used to create the mesh
  55788. * @param scene defines the hosting scene
  55789. * @returns the extruded shape mesh
  55790. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55792. */
  55793. static ExtrudeShape(name: string, options: {
  55794. shape: Vector3[];
  55795. path: Vector3[];
  55796. scale?: number;
  55797. rotation?: number;
  55798. cap?: number;
  55799. updatable?: boolean;
  55800. sideOrientation?: number;
  55801. frontUVs?: Vector4;
  55802. backUVs?: Vector4;
  55803. instance?: Mesh;
  55804. invertUV?: boolean;
  55805. }, scene?: Nullable<Scene>): Mesh;
  55806. /**
  55807. * Creates an custom extruded shape mesh.
  55808. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55809. * * 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.
  55810. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55811. * * 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
  55812. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55813. * * 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
  55814. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55815. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55816. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55817. * * 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
  55818. * * 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
  55819. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55821. * * 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
  55822. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55824. * @param name defines the name of the mesh
  55825. * @param options defines the options used to create the mesh
  55826. * @param scene defines the hosting scene
  55827. * @returns the custom extruded shape mesh
  55828. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55829. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55831. */
  55832. static ExtrudeShapeCustom(name: string, options: {
  55833. shape: Vector3[];
  55834. path: Vector3[];
  55835. scaleFunction?: any;
  55836. rotationFunction?: any;
  55837. ribbonCloseArray?: boolean;
  55838. ribbonClosePath?: boolean;
  55839. cap?: number;
  55840. updatable?: boolean;
  55841. sideOrientation?: number;
  55842. frontUVs?: Vector4;
  55843. backUVs?: Vector4;
  55844. instance?: Mesh;
  55845. invertUV?: boolean;
  55846. }, scene?: Nullable<Scene>): Mesh;
  55847. private static _ExtrudeShapeGeneric;
  55848. }
  55849. }
  55850. declare module BABYLON {
  55851. /**
  55852. * AmmoJS Physics plugin
  55853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55854. * @see https://github.com/kripken/ammo.js/
  55855. */
  55856. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55857. private _useDeltaForWorldStep;
  55858. /**
  55859. * Reference to the Ammo library
  55860. */
  55861. bjsAMMO: any;
  55862. /**
  55863. * Created ammoJS world which physics bodies are added to
  55864. */
  55865. world: any;
  55866. /**
  55867. * Name of the plugin
  55868. */
  55869. name: string;
  55870. private _timeStep;
  55871. private _fixedTimeStep;
  55872. private _maxSteps;
  55873. private _tmpQuaternion;
  55874. private _tmpAmmoTransform;
  55875. private _tmpAmmoQuaternion;
  55876. private _tmpAmmoConcreteContactResultCallback;
  55877. private _collisionConfiguration;
  55878. private _dispatcher;
  55879. private _overlappingPairCache;
  55880. private _solver;
  55881. private _softBodySolver;
  55882. private _tmpAmmoVectorA;
  55883. private _tmpAmmoVectorB;
  55884. private _tmpAmmoVectorC;
  55885. private _tmpAmmoVectorD;
  55886. private _tmpContactCallbackResult;
  55887. private _tmpAmmoVectorRCA;
  55888. private _tmpAmmoVectorRCB;
  55889. private _raycastResult;
  55890. private static readonly DISABLE_COLLISION_FLAG;
  55891. private static readonly KINEMATIC_FLAG;
  55892. private static readonly DISABLE_DEACTIVATION_FLAG;
  55893. /**
  55894. * Initializes the ammoJS plugin
  55895. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55896. * @param ammoInjection can be used to inject your own ammo reference
  55897. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55898. */
  55899. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55900. /**
  55901. * Sets the gravity of the physics world (m/(s^2))
  55902. * @param gravity Gravity to set
  55903. */
  55904. setGravity(gravity: Vector3): void;
  55905. /**
  55906. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55907. * @param timeStep timestep to use in seconds
  55908. */
  55909. setTimeStep(timeStep: number): void;
  55910. /**
  55911. * 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)
  55912. * @param fixedTimeStep fixedTimeStep to use in seconds
  55913. */
  55914. setFixedTimeStep(fixedTimeStep: number): void;
  55915. /**
  55916. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55917. * @param maxSteps the maximum number of steps by the physics engine per frame
  55918. */
  55919. setMaxSteps(maxSteps: number): void;
  55920. /**
  55921. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55922. * @returns the current timestep in seconds
  55923. */
  55924. getTimeStep(): number;
  55925. /**
  55926. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55927. */
  55928. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55929. private _isImpostorInContact;
  55930. private _isImpostorPairInContact;
  55931. private _stepSimulation;
  55932. /**
  55933. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55934. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55935. * After the step the babylon meshes are set to the position of the physics imposters
  55936. * @param delta amount of time to step forward
  55937. * @param impostors array of imposters to update before/after the step
  55938. */
  55939. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55940. /**
  55941. * Update babylon mesh to match physics world object
  55942. * @param impostor imposter to match
  55943. */
  55944. private _afterSoftStep;
  55945. /**
  55946. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55947. * @param impostor imposter to match
  55948. */
  55949. private _ropeStep;
  55950. /**
  55951. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55952. * @param impostor imposter to match
  55953. */
  55954. private _softbodyOrClothStep;
  55955. private _tmpMatrix;
  55956. /**
  55957. * Applies an impulse on the imposter
  55958. * @param impostor imposter to apply impulse to
  55959. * @param force amount of force to be applied to the imposter
  55960. * @param contactPoint the location to apply the impulse on the imposter
  55961. */
  55962. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55963. /**
  55964. * Applies a force on the imposter
  55965. * @param impostor imposter to apply force
  55966. * @param force amount of force to be applied to the imposter
  55967. * @param contactPoint the location to apply the force on the imposter
  55968. */
  55969. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55970. /**
  55971. * Creates a physics body using the plugin
  55972. * @param impostor the imposter to create the physics body on
  55973. */
  55974. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55975. /**
  55976. * Removes the physics body from the imposter and disposes of the body's memory
  55977. * @param impostor imposter to remove the physics body from
  55978. */
  55979. removePhysicsBody(impostor: PhysicsImpostor): void;
  55980. /**
  55981. * Generates a joint
  55982. * @param impostorJoint the imposter joint to create the joint with
  55983. */
  55984. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55985. /**
  55986. * Removes a joint
  55987. * @param impostorJoint the imposter joint to remove the joint from
  55988. */
  55989. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55990. private _addMeshVerts;
  55991. /**
  55992. * Initialise the soft body vertices to match its object's (mesh) vertices
  55993. * Softbody vertices (nodes) are in world space and to match this
  55994. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55995. * @param impostor to create the softbody for
  55996. */
  55997. private _softVertexData;
  55998. /**
  55999. * Create an impostor's soft body
  56000. * @param impostor to create the softbody for
  56001. */
  56002. private _createSoftbody;
  56003. /**
  56004. * Create cloth for an impostor
  56005. * @param impostor to create the softbody for
  56006. */
  56007. private _createCloth;
  56008. /**
  56009. * Create rope for an impostor
  56010. * @param impostor to create the softbody for
  56011. */
  56012. private _createRope;
  56013. /**
  56014. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56015. * @param impostor to create the custom physics shape for
  56016. */
  56017. private _createCustom;
  56018. private _addHullVerts;
  56019. private _createShape;
  56020. /**
  56021. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56022. * @param impostor imposter containing the physics body and babylon object
  56023. */
  56024. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56025. /**
  56026. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56027. * @param impostor imposter containing the physics body and babylon object
  56028. * @param newPosition new position
  56029. * @param newRotation new rotation
  56030. */
  56031. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56032. /**
  56033. * If this plugin is supported
  56034. * @returns true if its supported
  56035. */
  56036. isSupported(): boolean;
  56037. /**
  56038. * Sets the linear velocity of the physics body
  56039. * @param impostor imposter to set the velocity on
  56040. * @param velocity velocity to set
  56041. */
  56042. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56043. /**
  56044. * Sets the angular velocity of the physics body
  56045. * @param impostor imposter to set the velocity on
  56046. * @param velocity velocity to set
  56047. */
  56048. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56049. /**
  56050. * gets the linear velocity
  56051. * @param impostor imposter to get linear velocity from
  56052. * @returns linear velocity
  56053. */
  56054. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56055. /**
  56056. * gets the angular velocity
  56057. * @param impostor imposter to get angular velocity from
  56058. * @returns angular velocity
  56059. */
  56060. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56061. /**
  56062. * Sets the mass of physics body
  56063. * @param impostor imposter to set the mass on
  56064. * @param mass mass to set
  56065. */
  56066. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56067. /**
  56068. * Gets the mass of the physics body
  56069. * @param impostor imposter to get the mass from
  56070. * @returns mass
  56071. */
  56072. getBodyMass(impostor: PhysicsImpostor): number;
  56073. /**
  56074. * Gets friction of the impostor
  56075. * @param impostor impostor to get friction from
  56076. * @returns friction value
  56077. */
  56078. getBodyFriction(impostor: PhysicsImpostor): number;
  56079. /**
  56080. * Sets friction of the impostor
  56081. * @param impostor impostor to set friction on
  56082. * @param friction friction value
  56083. */
  56084. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56085. /**
  56086. * Gets restitution of the impostor
  56087. * @param impostor impostor to get restitution from
  56088. * @returns restitution value
  56089. */
  56090. getBodyRestitution(impostor: PhysicsImpostor): number;
  56091. /**
  56092. * Sets resitution of the impostor
  56093. * @param impostor impostor to set resitution on
  56094. * @param restitution resitution value
  56095. */
  56096. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56097. /**
  56098. * Gets pressure inside the impostor
  56099. * @param impostor impostor to get pressure from
  56100. * @returns pressure value
  56101. */
  56102. getBodyPressure(impostor: PhysicsImpostor): number;
  56103. /**
  56104. * Sets pressure inside a soft body impostor
  56105. * Cloth and rope must remain 0 pressure
  56106. * @param impostor impostor to set pressure on
  56107. * @param pressure pressure value
  56108. */
  56109. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56110. /**
  56111. * Gets stiffness of the impostor
  56112. * @param impostor impostor to get stiffness from
  56113. * @returns pressure value
  56114. */
  56115. getBodyStiffness(impostor: PhysicsImpostor): number;
  56116. /**
  56117. * Sets stiffness of the impostor
  56118. * @param impostor impostor to set stiffness on
  56119. * @param stiffness stiffness value from 0 to 1
  56120. */
  56121. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56122. /**
  56123. * Gets velocityIterations of the impostor
  56124. * @param impostor impostor to get velocity iterations from
  56125. * @returns velocityIterations value
  56126. */
  56127. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56128. /**
  56129. * Sets velocityIterations of the impostor
  56130. * @param impostor impostor to set velocity iterations on
  56131. * @param velocityIterations velocityIterations value
  56132. */
  56133. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56134. /**
  56135. * Gets positionIterations of the impostor
  56136. * @param impostor impostor to get position iterations from
  56137. * @returns positionIterations value
  56138. */
  56139. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56140. /**
  56141. * Sets positionIterations of the impostor
  56142. * @param impostor impostor to set position on
  56143. * @param positionIterations positionIterations value
  56144. */
  56145. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56146. /**
  56147. * Append an anchor to a cloth object
  56148. * @param impostor is the cloth impostor to add anchor to
  56149. * @param otherImpostor is the rigid impostor to anchor to
  56150. * @param width ratio across width from 0 to 1
  56151. * @param height ratio up height from 0 to 1
  56152. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56153. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56154. */
  56155. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56156. /**
  56157. * Append an hook to a rope object
  56158. * @param impostor is the rope impostor to add hook to
  56159. * @param otherImpostor is the rigid impostor to hook to
  56160. * @param length ratio along the rope from 0 to 1
  56161. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56162. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56163. */
  56164. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56165. /**
  56166. * Sleeps the physics body and stops it from being active
  56167. * @param impostor impostor to sleep
  56168. */
  56169. sleepBody(impostor: PhysicsImpostor): void;
  56170. /**
  56171. * Activates the physics body
  56172. * @param impostor impostor to activate
  56173. */
  56174. wakeUpBody(impostor: PhysicsImpostor): void;
  56175. /**
  56176. * Updates the distance parameters of the joint
  56177. * @param joint joint to update
  56178. * @param maxDistance maximum distance of the joint
  56179. * @param minDistance minimum distance of the joint
  56180. */
  56181. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56182. /**
  56183. * Sets a motor on the joint
  56184. * @param joint joint to set motor on
  56185. * @param speed speed of the motor
  56186. * @param maxForce maximum force of the motor
  56187. * @param motorIndex index of the motor
  56188. */
  56189. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56190. /**
  56191. * Sets the motors limit
  56192. * @param joint joint to set limit on
  56193. * @param upperLimit upper limit
  56194. * @param lowerLimit lower limit
  56195. */
  56196. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56197. /**
  56198. * Syncs the position and rotation of a mesh with the impostor
  56199. * @param mesh mesh to sync
  56200. * @param impostor impostor to update the mesh with
  56201. */
  56202. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56203. /**
  56204. * Gets the radius of the impostor
  56205. * @param impostor impostor to get radius from
  56206. * @returns the radius
  56207. */
  56208. getRadius(impostor: PhysicsImpostor): number;
  56209. /**
  56210. * Gets the box size of the impostor
  56211. * @param impostor impostor to get box size from
  56212. * @param result the resulting box size
  56213. */
  56214. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56215. /**
  56216. * Disposes of the impostor
  56217. */
  56218. dispose(): void;
  56219. /**
  56220. * Does a raycast in the physics world
  56221. * @param from when should the ray start?
  56222. * @param to when should the ray end?
  56223. * @returns PhysicsRaycastResult
  56224. */
  56225. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56226. }
  56227. }
  56228. declare module BABYLON {
  56229. interface AbstractScene {
  56230. /**
  56231. * The list of reflection probes added to the scene
  56232. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56233. */
  56234. reflectionProbes: Array<ReflectionProbe>;
  56235. /**
  56236. * Removes the given reflection probe from this scene.
  56237. * @param toRemove The reflection probe to remove
  56238. * @returns The index of the removed reflection probe
  56239. */
  56240. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56241. /**
  56242. * Adds the given reflection probe to this scene.
  56243. * @param newReflectionProbe The reflection probe to add
  56244. */
  56245. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56246. }
  56247. /**
  56248. * Class used to generate realtime reflection / refraction cube textures
  56249. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56250. */
  56251. export class ReflectionProbe {
  56252. /** defines the name of the probe */
  56253. name: string;
  56254. private _scene;
  56255. private _renderTargetTexture;
  56256. private _projectionMatrix;
  56257. private _viewMatrix;
  56258. private _target;
  56259. private _add;
  56260. private _attachedMesh;
  56261. private _invertYAxis;
  56262. /** Gets or sets probe position (center of the cube map) */
  56263. position: Vector3;
  56264. /**
  56265. * Creates a new reflection probe
  56266. * @param name defines the name of the probe
  56267. * @param size defines the texture resolution (for each face)
  56268. * @param scene defines the hosting scene
  56269. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56270. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56271. */
  56272. constructor(
  56273. /** defines the name of the probe */
  56274. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56275. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56276. get samples(): number;
  56277. set samples(value: number);
  56278. /** Gets or sets the refresh rate to use (on every frame by default) */
  56279. get refreshRate(): number;
  56280. set refreshRate(value: number);
  56281. /**
  56282. * Gets the hosting scene
  56283. * @returns a Scene
  56284. */
  56285. getScene(): Scene;
  56286. /** Gets the internal CubeTexture used to render to */
  56287. get cubeTexture(): RenderTargetTexture;
  56288. /** Gets the list of meshes to render */
  56289. get renderList(): Nullable<AbstractMesh[]>;
  56290. /**
  56291. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56292. * @param mesh defines the mesh to attach to
  56293. */
  56294. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56295. /**
  56296. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56297. * @param renderingGroupId The rendering group id corresponding to its index
  56298. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56299. */
  56300. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56301. /**
  56302. * Clean all associated resources
  56303. */
  56304. dispose(): void;
  56305. /**
  56306. * Converts the reflection probe information to a readable string for debug purpose.
  56307. * @param fullDetails Supports for multiple levels of logging within scene loading
  56308. * @returns the human readable reflection probe info
  56309. */
  56310. toString(fullDetails?: boolean): string;
  56311. /**
  56312. * Get the class name of the relfection probe.
  56313. * @returns "ReflectionProbe"
  56314. */
  56315. getClassName(): string;
  56316. /**
  56317. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56318. * @returns The JSON representation of the texture
  56319. */
  56320. serialize(): any;
  56321. /**
  56322. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56323. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56324. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56325. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56326. * @returns The parsed reflection probe if successful
  56327. */
  56328. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56329. }
  56330. }
  56331. declare module BABYLON {
  56332. /** @hidden */
  56333. export var _BabylonLoaderRegistered: boolean;
  56334. /**
  56335. * Helps setting up some configuration for the babylon file loader.
  56336. */
  56337. export class BabylonFileLoaderConfiguration {
  56338. /**
  56339. * The loader does not allow injecting custom physix engine into the plugins.
  56340. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56341. * So you could set this variable to your engine import to make it work.
  56342. */
  56343. static LoaderInjectedPhysicsEngine: any;
  56344. }
  56345. }
  56346. declare module BABYLON {
  56347. /**
  56348. * The Physically based simple base material of BJS.
  56349. *
  56350. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56351. * It is used as the base class for both the specGloss and metalRough conventions.
  56352. */
  56353. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56354. /**
  56355. * Number of Simultaneous lights allowed on the material.
  56356. */
  56357. maxSimultaneousLights: number;
  56358. /**
  56359. * If sets to true, disables all the lights affecting the material.
  56360. */
  56361. disableLighting: boolean;
  56362. /**
  56363. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56364. */
  56365. environmentTexture: BaseTexture;
  56366. /**
  56367. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56368. */
  56369. invertNormalMapX: boolean;
  56370. /**
  56371. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56372. */
  56373. invertNormalMapY: boolean;
  56374. /**
  56375. * Normal map used in the model.
  56376. */
  56377. normalTexture: BaseTexture;
  56378. /**
  56379. * Emissivie color used to self-illuminate the model.
  56380. */
  56381. emissiveColor: Color3;
  56382. /**
  56383. * Emissivie texture used to self-illuminate the model.
  56384. */
  56385. emissiveTexture: BaseTexture;
  56386. /**
  56387. * Occlusion Channel Strenght.
  56388. */
  56389. occlusionStrength: number;
  56390. /**
  56391. * Occlusion Texture of the material (adding extra occlusion effects).
  56392. */
  56393. occlusionTexture: BaseTexture;
  56394. /**
  56395. * Defines the alpha limits in alpha test mode.
  56396. */
  56397. alphaCutOff: number;
  56398. /**
  56399. * Gets the current double sided mode.
  56400. */
  56401. get doubleSided(): boolean;
  56402. /**
  56403. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56404. */
  56405. set doubleSided(value: boolean);
  56406. /**
  56407. * Stores the pre-calculated light information of a mesh in a texture.
  56408. */
  56409. lightmapTexture: BaseTexture;
  56410. /**
  56411. * If true, the light map contains occlusion information instead of lighting info.
  56412. */
  56413. useLightmapAsShadowmap: boolean;
  56414. /**
  56415. * Instantiates a new PBRMaterial instance.
  56416. *
  56417. * @param name The material name
  56418. * @param scene The scene the material will be use in.
  56419. */
  56420. constructor(name: string, scene: Scene);
  56421. getClassName(): string;
  56422. }
  56423. }
  56424. declare module BABYLON {
  56425. /**
  56426. * The PBR material of BJS following the metal roughness convention.
  56427. *
  56428. * This fits to the PBR convention in the GLTF definition:
  56429. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56430. */
  56431. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56432. /**
  56433. * The base color has two different interpretations depending on the value of metalness.
  56434. * When the material is a metal, the base color is the specific measured reflectance value
  56435. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56436. * of the material.
  56437. */
  56438. baseColor: Color3;
  56439. /**
  56440. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56441. * well as opacity information in the alpha channel.
  56442. */
  56443. baseTexture: BaseTexture;
  56444. /**
  56445. * Specifies the metallic scalar value of the material.
  56446. * Can also be used to scale the metalness values of the metallic texture.
  56447. */
  56448. metallic: number;
  56449. /**
  56450. * Specifies the roughness scalar value of the material.
  56451. * Can also be used to scale the roughness values of the metallic texture.
  56452. */
  56453. roughness: number;
  56454. /**
  56455. * Texture containing both the metallic value in the B channel and the
  56456. * roughness value in the G channel to keep better precision.
  56457. */
  56458. metallicRoughnessTexture: BaseTexture;
  56459. /**
  56460. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56461. *
  56462. * @param name The material name
  56463. * @param scene The scene the material will be use in.
  56464. */
  56465. constructor(name: string, scene: Scene);
  56466. /**
  56467. * Return the currrent class name of the material.
  56468. */
  56469. getClassName(): string;
  56470. /**
  56471. * Makes a duplicate of the current material.
  56472. * @param name - name to use for the new material.
  56473. */
  56474. clone(name: string): PBRMetallicRoughnessMaterial;
  56475. /**
  56476. * Serialize the material to a parsable JSON object.
  56477. */
  56478. serialize(): any;
  56479. /**
  56480. * Parses a JSON object correponding to the serialize function.
  56481. */
  56482. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56483. }
  56484. }
  56485. declare module BABYLON {
  56486. /**
  56487. * The PBR material of BJS following the specular glossiness convention.
  56488. *
  56489. * This fits to the PBR convention in the GLTF definition:
  56490. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56491. */
  56492. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56493. /**
  56494. * Specifies the diffuse color of the material.
  56495. */
  56496. diffuseColor: Color3;
  56497. /**
  56498. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56499. * channel.
  56500. */
  56501. diffuseTexture: BaseTexture;
  56502. /**
  56503. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56504. */
  56505. specularColor: Color3;
  56506. /**
  56507. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56508. */
  56509. glossiness: number;
  56510. /**
  56511. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56512. */
  56513. specularGlossinessTexture: BaseTexture;
  56514. /**
  56515. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56516. *
  56517. * @param name The material name
  56518. * @param scene The scene the material will be use in.
  56519. */
  56520. constructor(name: string, scene: Scene);
  56521. /**
  56522. * Return the currrent class name of the material.
  56523. */
  56524. getClassName(): string;
  56525. /**
  56526. * Makes a duplicate of the current material.
  56527. * @param name - name to use for the new material.
  56528. */
  56529. clone(name: string): PBRSpecularGlossinessMaterial;
  56530. /**
  56531. * Serialize the material to a parsable JSON object.
  56532. */
  56533. serialize(): any;
  56534. /**
  56535. * Parses a JSON object correponding to the serialize function.
  56536. */
  56537. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56538. }
  56539. }
  56540. declare module BABYLON {
  56541. /**
  56542. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56543. * It can help converting any input color in a desired output one. This can then be used to create effects
  56544. * from sepia, black and white to sixties or futuristic rendering...
  56545. *
  56546. * The only supported format is currently 3dl.
  56547. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56548. */
  56549. export class ColorGradingTexture extends BaseTexture {
  56550. /**
  56551. * The texture URL.
  56552. */
  56553. url: string;
  56554. /**
  56555. * Empty line regex stored for GC.
  56556. */
  56557. private static _noneEmptyLineRegex;
  56558. private _textureMatrix;
  56559. private _engine;
  56560. private _onLoad;
  56561. /**
  56562. * Instantiates a ColorGradingTexture from the following parameters.
  56563. *
  56564. * @param url The location of the color gradind data (currently only supporting 3dl)
  56565. * @param sceneOrEngine The scene or engine the texture will be used in
  56566. * @param onLoad defines a callback triggered when the texture has been loaded
  56567. */
  56568. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  56569. /**
  56570. * Fires the onload event from the constructor if requested.
  56571. */
  56572. private _triggerOnLoad;
  56573. /**
  56574. * Returns the texture matrix used in most of the material.
  56575. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56576. */
  56577. getTextureMatrix(): Matrix;
  56578. /**
  56579. * Occurs when the file being loaded is a .3dl LUT file.
  56580. */
  56581. private load3dlTexture;
  56582. /**
  56583. * Starts the loading process of the texture.
  56584. */
  56585. private loadTexture;
  56586. /**
  56587. * Clones the color gradind texture.
  56588. */
  56589. clone(): ColorGradingTexture;
  56590. /**
  56591. * Called during delayed load for textures.
  56592. */
  56593. delayLoad(): void;
  56594. /**
  56595. * Parses a color grading texture serialized by Babylon.
  56596. * @param parsedTexture The texture information being parsedTexture
  56597. * @param scene The scene to load the texture in
  56598. * @param rootUrl The root url of the data assets to load
  56599. * @return A color gradind texture
  56600. */
  56601. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56602. /**
  56603. * Serializes the LUT texture to json format.
  56604. */
  56605. serialize(): any;
  56606. /**
  56607. * Returns true if the passed parameter is a scene object (can be use for typings)
  56608. * @param sceneOrEngine The object to test.
  56609. */
  56610. private static _isScene;
  56611. }
  56612. }
  56613. declare module BABYLON {
  56614. /**
  56615. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56616. */
  56617. export class EquiRectangularCubeTexture extends BaseTexture {
  56618. /** The six faces of the cube. */
  56619. private static _FacesMapping;
  56620. private _noMipmap;
  56621. private _onLoad;
  56622. private _onError;
  56623. /** The size of the cubemap. */
  56624. private _size;
  56625. /** The buffer of the image. */
  56626. private _buffer;
  56627. /** The width of the input image. */
  56628. private _width;
  56629. /** The height of the input image. */
  56630. private _height;
  56631. /** The URL to the image. */
  56632. url: string;
  56633. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56634. coordinatesMode: number;
  56635. /**
  56636. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56637. * @param url The location of the image
  56638. * @param scene The scene the texture will be used in
  56639. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56640. * @param noMipmap Forces to not generate the mipmap if true
  56641. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56642. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56643. * @param onLoad — defines a callback called when texture is loaded
  56644. * @param onError — defines a callback called if there is an error
  56645. */
  56646. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56647. /**
  56648. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56649. */
  56650. private loadImage;
  56651. /**
  56652. * Convert the image buffer into a cubemap and create a CubeTexture.
  56653. */
  56654. private loadTexture;
  56655. /**
  56656. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56657. * @param buffer The ArrayBuffer that should be converted.
  56658. * @returns The buffer as Float32Array.
  56659. */
  56660. private getFloat32ArrayFromArrayBuffer;
  56661. /**
  56662. * Get the current class name of the texture useful for serialization or dynamic coding.
  56663. * @returns "EquiRectangularCubeTexture"
  56664. */
  56665. getClassName(): string;
  56666. /**
  56667. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56668. * @returns A clone of the current EquiRectangularCubeTexture.
  56669. */
  56670. clone(): EquiRectangularCubeTexture;
  56671. }
  56672. }
  56673. declare module BABYLON {
  56674. /**
  56675. * Based on jsTGALoader - Javascript loader for TGA file
  56676. * By Vincent Thibault
  56677. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56678. */
  56679. export class TGATools {
  56680. private static _TYPE_INDEXED;
  56681. private static _TYPE_RGB;
  56682. private static _TYPE_GREY;
  56683. private static _TYPE_RLE_INDEXED;
  56684. private static _TYPE_RLE_RGB;
  56685. private static _TYPE_RLE_GREY;
  56686. private static _ORIGIN_MASK;
  56687. private static _ORIGIN_SHIFT;
  56688. private static _ORIGIN_BL;
  56689. private static _ORIGIN_BR;
  56690. private static _ORIGIN_UL;
  56691. private static _ORIGIN_UR;
  56692. /**
  56693. * Gets the header of a TGA file
  56694. * @param data defines the TGA data
  56695. * @returns the header
  56696. */
  56697. static GetTGAHeader(data: Uint8Array): any;
  56698. /**
  56699. * Uploads TGA content to a Babylon Texture
  56700. * @hidden
  56701. */
  56702. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56703. /** @hidden */
  56704. 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;
  56705. /** @hidden */
  56706. 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;
  56707. /** @hidden */
  56708. 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;
  56709. /** @hidden */
  56710. 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;
  56711. /** @hidden */
  56712. 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;
  56713. /** @hidden */
  56714. 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;
  56715. }
  56716. }
  56717. declare module BABYLON {
  56718. /**
  56719. * Implementation of the TGA Texture Loader.
  56720. * @hidden
  56721. */
  56722. export class _TGATextureLoader implements IInternalTextureLoader {
  56723. /**
  56724. * Defines wether the loader supports cascade loading the different faces.
  56725. */
  56726. readonly supportCascades: boolean;
  56727. /**
  56728. * This returns if the loader support the current file information.
  56729. * @param extension defines the file extension of the file being loaded
  56730. * @returns true if the loader can load the specified file
  56731. */
  56732. canLoad(extension: string): boolean;
  56733. /**
  56734. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56735. * @param data contains the texture data
  56736. * @param texture defines the BabylonJS internal texture
  56737. * @param createPolynomials will be true if polynomials have been requested
  56738. * @param onLoad defines the callback to trigger once the texture is ready
  56739. * @param onError defines the callback to trigger in case of error
  56740. */
  56741. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56742. /**
  56743. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56744. * @param data contains the texture data
  56745. * @param texture defines the BabylonJS internal texture
  56746. * @param callback defines the method to call once ready to upload
  56747. */
  56748. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56749. }
  56750. }
  56751. declare module BABYLON {
  56752. /**
  56753. * Info about the .basis files
  56754. */
  56755. class BasisFileInfo {
  56756. /**
  56757. * If the file has alpha
  56758. */
  56759. hasAlpha: boolean;
  56760. /**
  56761. * Info about each image of the basis file
  56762. */
  56763. images: Array<{
  56764. levels: Array<{
  56765. width: number;
  56766. height: number;
  56767. transcodedPixels: ArrayBufferView;
  56768. }>;
  56769. }>;
  56770. }
  56771. /**
  56772. * Result of transcoding a basis file
  56773. */
  56774. class TranscodeResult {
  56775. /**
  56776. * Info about the .basis file
  56777. */
  56778. fileInfo: BasisFileInfo;
  56779. /**
  56780. * Format to use when loading the file
  56781. */
  56782. format: number;
  56783. }
  56784. /**
  56785. * Configuration options for the Basis transcoder
  56786. */
  56787. export class BasisTranscodeConfiguration {
  56788. /**
  56789. * Supported compression formats used to determine the supported output format of the transcoder
  56790. */
  56791. supportedCompressionFormats?: {
  56792. /**
  56793. * etc1 compression format
  56794. */
  56795. etc1?: boolean;
  56796. /**
  56797. * s3tc compression format
  56798. */
  56799. s3tc?: boolean;
  56800. /**
  56801. * pvrtc compression format
  56802. */
  56803. pvrtc?: boolean;
  56804. /**
  56805. * etc2 compression format
  56806. */
  56807. etc2?: boolean;
  56808. };
  56809. /**
  56810. * If mipmap levels should be loaded for transcoded images (Default: true)
  56811. */
  56812. loadMipmapLevels?: boolean;
  56813. /**
  56814. * Index of a single image to load (Default: all images)
  56815. */
  56816. loadSingleImage?: number;
  56817. }
  56818. /**
  56819. * Used to load .Basis files
  56820. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56821. */
  56822. export class BasisTools {
  56823. private static _IgnoreSupportedFormats;
  56824. /**
  56825. * URL to use when loading the basis transcoder
  56826. */
  56827. static JSModuleURL: string;
  56828. /**
  56829. * URL to use when loading the wasm module for the transcoder
  56830. */
  56831. static WasmModuleURL: string;
  56832. /**
  56833. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56834. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56835. * @returns internal format corresponding to the Basis format
  56836. */
  56837. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56838. private static _WorkerPromise;
  56839. private static _Worker;
  56840. private static _actionId;
  56841. private static _CreateWorkerAsync;
  56842. /**
  56843. * Transcodes a loaded image file to compressed pixel data
  56844. * @param data image data to transcode
  56845. * @param config configuration options for the transcoding
  56846. * @returns a promise resulting in the transcoded image
  56847. */
  56848. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56849. /**
  56850. * Loads a texture from the transcode result
  56851. * @param texture texture load to
  56852. * @param transcodeResult the result of transcoding the basis file to load from
  56853. */
  56854. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56855. }
  56856. }
  56857. declare module BABYLON {
  56858. /**
  56859. * Loader for .basis file format
  56860. */
  56861. export class _BasisTextureLoader implements IInternalTextureLoader {
  56862. /**
  56863. * Defines whether the loader supports cascade loading the different faces.
  56864. */
  56865. readonly supportCascades: boolean;
  56866. /**
  56867. * This returns if the loader support the current file information.
  56868. * @param extension defines the file extension of the file being loaded
  56869. * @returns true if the loader can load the specified file
  56870. */
  56871. canLoad(extension: string): boolean;
  56872. /**
  56873. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56874. * @param data contains the texture data
  56875. * @param texture defines the BabylonJS internal texture
  56876. * @param createPolynomials will be true if polynomials have been requested
  56877. * @param onLoad defines the callback to trigger once the texture is ready
  56878. * @param onError defines the callback to trigger in case of error
  56879. */
  56880. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56881. /**
  56882. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56883. * @param data contains the texture data
  56884. * @param texture defines the BabylonJS internal texture
  56885. * @param callback defines the method to call once ready to upload
  56886. */
  56887. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56888. }
  56889. }
  56890. declare module BABYLON {
  56891. /**
  56892. * 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.
  56893. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56894. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56895. */
  56896. export class CustomProceduralTexture extends ProceduralTexture {
  56897. private _animate;
  56898. private _time;
  56899. private _config;
  56900. private _texturePath;
  56901. /**
  56902. * Instantiates a new Custom Procedural Texture.
  56903. * 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.
  56904. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56905. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56906. * @param name Define the name of the texture
  56907. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56908. * @param size Define the size of the texture to create
  56909. * @param scene Define the scene the texture belongs to
  56910. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56911. * @param generateMipMaps Define if the texture should creates mip maps or not
  56912. */
  56913. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56914. private _loadJson;
  56915. /**
  56916. * Is the texture ready to be used ? (rendered at least once)
  56917. * @returns true if ready, otherwise, false.
  56918. */
  56919. isReady(): boolean;
  56920. /**
  56921. * Render the texture to its associated render target.
  56922. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56923. */
  56924. render(useCameraPostProcess?: boolean): void;
  56925. /**
  56926. * Update the list of dependant textures samplers in the shader.
  56927. */
  56928. updateTextures(): void;
  56929. /**
  56930. * Update the uniform values of the procedural texture in the shader.
  56931. */
  56932. updateShaderUniforms(): void;
  56933. /**
  56934. * Define if the texture animates or not.
  56935. */
  56936. get animate(): boolean;
  56937. set animate(value: boolean);
  56938. }
  56939. }
  56940. declare module BABYLON {
  56941. /** @hidden */
  56942. export var noisePixelShader: {
  56943. name: string;
  56944. shader: string;
  56945. };
  56946. }
  56947. declare module BABYLON {
  56948. /**
  56949. * Class used to generate noise procedural textures
  56950. */
  56951. export class NoiseProceduralTexture extends ProceduralTexture {
  56952. private _time;
  56953. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56954. brightness: number;
  56955. /** Defines the number of octaves to process */
  56956. octaves: number;
  56957. /** Defines the level of persistence (0.8 by default) */
  56958. persistence: number;
  56959. /** Gets or sets animation speed factor (default is 1) */
  56960. animationSpeedFactor: number;
  56961. /**
  56962. * Creates a new NoiseProceduralTexture
  56963. * @param name defines the name fo the texture
  56964. * @param size defines the size of the texture (default is 256)
  56965. * @param scene defines the hosting scene
  56966. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56967. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56968. */
  56969. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56970. private _updateShaderUniforms;
  56971. protected _getDefines(): string;
  56972. /** Generate the current state of the procedural texture */
  56973. render(useCameraPostProcess?: boolean): void;
  56974. /**
  56975. * Serializes this noise procedural texture
  56976. * @returns a serialized noise procedural texture object
  56977. */
  56978. serialize(): any;
  56979. /**
  56980. * Clone the texture.
  56981. * @returns the cloned texture
  56982. */
  56983. clone(): NoiseProceduralTexture;
  56984. /**
  56985. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56986. * @param parsedTexture defines parsed texture data
  56987. * @param scene defines the current scene
  56988. * @param rootUrl defines the root URL containing noise procedural texture information
  56989. * @returns a parsed NoiseProceduralTexture
  56990. */
  56991. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56992. }
  56993. }
  56994. declare module BABYLON {
  56995. /**
  56996. * Raw cube texture where the raw buffers are passed in
  56997. */
  56998. export class RawCubeTexture extends CubeTexture {
  56999. /**
  57000. * Creates a cube texture where the raw buffers are passed in.
  57001. * @param scene defines the scene the texture is attached to
  57002. * @param data defines the array of data to use to create each face
  57003. * @param size defines the size of the textures
  57004. * @param format defines the format of the data
  57005. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57006. * @param generateMipMaps defines if the engine should generate the mip levels
  57007. * @param invertY defines if data must be stored with Y axis inverted
  57008. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57009. * @param compression defines the compression used (null by default)
  57010. */
  57011. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57012. /**
  57013. * Updates the raw cube texture.
  57014. * @param data defines the data to store
  57015. * @param format defines the data format
  57016. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57017. * @param invertY defines if data must be stored with Y axis inverted
  57018. * @param compression defines the compression used (null by default)
  57019. * @param level defines which level of the texture to update
  57020. */
  57021. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57022. /**
  57023. * Updates a raw cube texture with RGBD encoded data.
  57024. * @param data defines the array of data [mipmap][face] to use to create each face
  57025. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57026. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57027. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57028. * @returns a promsie that resolves when the operation is complete
  57029. */
  57030. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57031. /**
  57032. * Clones the raw cube texture.
  57033. * @return a new cube texture
  57034. */
  57035. clone(): CubeTexture;
  57036. /** @hidden */
  57037. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57038. }
  57039. }
  57040. declare module BABYLON {
  57041. /**
  57042. * Class used to store 3D textures containing user data
  57043. */
  57044. export class RawTexture3D extends Texture {
  57045. /** Gets or sets the texture format to use */
  57046. format: number;
  57047. private _engine;
  57048. /**
  57049. * Create a new RawTexture3D
  57050. * @param data defines the data of the texture
  57051. * @param width defines the width of the texture
  57052. * @param height defines the height of the texture
  57053. * @param depth defines the depth of the texture
  57054. * @param format defines the texture format to use
  57055. * @param scene defines the hosting scene
  57056. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57057. * @param invertY defines if texture must be stored with Y axis inverted
  57058. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57059. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57060. */
  57061. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57062. /** Gets or sets the texture format to use */
  57063. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57064. /**
  57065. * Update the texture with new data
  57066. * @param data defines the data to store in the texture
  57067. */
  57068. update(data: ArrayBufferView): void;
  57069. }
  57070. }
  57071. declare module BABYLON {
  57072. /**
  57073. * Class used to store 2D array textures containing user data
  57074. */
  57075. export class RawTexture2DArray extends Texture {
  57076. /** Gets or sets the texture format to use */
  57077. format: number;
  57078. private _engine;
  57079. /**
  57080. * Create a new RawTexture2DArray
  57081. * @param data defines the data of the texture
  57082. * @param width defines the width of the texture
  57083. * @param height defines the height of the texture
  57084. * @param depth defines the number of layers of the texture
  57085. * @param format defines the texture format to use
  57086. * @param scene defines the hosting scene
  57087. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57088. * @param invertY defines if texture must be stored with Y axis inverted
  57089. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57090. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57091. */
  57092. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57093. /** Gets or sets the texture format to use */
  57094. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57095. /**
  57096. * Update the texture with new data
  57097. * @param data defines the data to store in the texture
  57098. */
  57099. update(data: ArrayBufferView): void;
  57100. }
  57101. }
  57102. declare module BABYLON {
  57103. /**
  57104. * Creates a refraction texture used by refraction channel of the standard material.
  57105. * It is like a mirror but to see through a material.
  57106. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57107. */
  57108. export class RefractionTexture extends RenderTargetTexture {
  57109. /**
  57110. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57111. * 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.
  57112. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57113. */
  57114. refractionPlane: Plane;
  57115. /**
  57116. * Define how deep under the surface we should see.
  57117. */
  57118. depth: number;
  57119. /**
  57120. * Creates a refraction texture used by refraction channel of the standard material.
  57121. * It is like a mirror but to see through a material.
  57122. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57123. * @param name Define the texture name
  57124. * @param size Define the size of the underlying texture
  57125. * @param scene Define the scene the refraction belongs to
  57126. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57127. */
  57128. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57129. /**
  57130. * Clone the refraction texture.
  57131. * @returns the cloned texture
  57132. */
  57133. clone(): RefractionTexture;
  57134. /**
  57135. * Serialize the texture to a JSON representation you could use in Parse later on
  57136. * @returns the serialized JSON representation
  57137. */
  57138. serialize(): any;
  57139. }
  57140. }
  57141. declare module BABYLON {
  57142. /**
  57143. * Defines the options related to the creation of an HtmlElementTexture
  57144. */
  57145. export interface IHtmlElementTextureOptions {
  57146. /**
  57147. * Defines wether mip maps should be created or not.
  57148. */
  57149. generateMipMaps?: boolean;
  57150. /**
  57151. * Defines the sampling mode of the texture.
  57152. */
  57153. samplingMode?: number;
  57154. /**
  57155. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57156. */
  57157. engine: Nullable<ThinEngine>;
  57158. /**
  57159. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57160. */
  57161. scene: Nullable<Scene>;
  57162. }
  57163. /**
  57164. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57165. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57166. * is automatically managed.
  57167. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57168. * in your application.
  57169. *
  57170. * As the update is not automatic, you need to call them manually.
  57171. */
  57172. export class HtmlElementTexture extends BaseTexture {
  57173. /**
  57174. * The texture URL.
  57175. */
  57176. element: HTMLVideoElement | HTMLCanvasElement;
  57177. private static readonly DefaultOptions;
  57178. private _textureMatrix;
  57179. private _engine;
  57180. private _isVideo;
  57181. private _generateMipMaps;
  57182. private _samplingMode;
  57183. /**
  57184. * Instantiates a HtmlElementTexture from the following parameters.
  57185. *
  57186. * @param name Defines the name of the texture
  57187. * @param element Defines the video or canvas the texture is filled with
  57188. * @param options Defines the other none mandatory texture creation options
  57189. */
  57190. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57191. private _createInternalTexture;
  57192. /**
  57193. * Returns the texture matrix used in most of the material.
  57194. */
  57195. getTextureMatrix(): Matrix;
  57196. /**
  57197. * Updates the content of the texture.
  57198. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57199. */
  57200. update(invertY?: Nullable<boolean>): void;
  57201. }
  57202. }
  57203. declare module BABYLON {
  57204. /**
  57205. * Defines the basic options interface of a TexturePacker Frame
  57206. */
  57207. export interface ITexturePackerFrame {
  57208. /**
  57209. * The frame ID
  57210. */
  57211. id: number;
  57212. /**
  57213. * The frames Scale
  57214. */
  57215. scale: Vector2;
  57216. /**
  57217. * The Frames offset
  57218. */
  57219. offset: Vector2;
  57220. }
  57221. /**
  57222. * This is a support class for frame Data on texture packer sets.
  57223. */
  57224. export class TexturePackerFrame implements ITexturePackerFrame {
  57225. /**
  57226. * The frame ID
  57227. */
  57228. id: number;
  57229. /**
  57230. * The frames Scale
  57231. */
  57232. scale: Vector2;
  57233. /**
  57234. * The Frames offset
  57235. */
  57236. offset: Vector2;
  57237. /**
  57238. * Initializes a texture package frame.
  57239. * @param id The numerical frame identifier
  57240. * @param scale Scalar Vector2 for UV frame
  57241. * @param offset Vector2 for the frame position in UV units.
  57242. * @returns TexturePackerFrame
  57243. */
  57244. constructor(id: number, scale: Vector2, offset: Vector2);
  57245. }
  57246. }
  57247. declare module BABYLON {
  57248. /**
  57249. * Defines the basic options interface of a TexturePacker
  57250. */
  57251. export interface ITexturePackerOptions {
  57252. /**
  57253. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57254. */
  57255. map?: string[];
  57256. /**
  57257. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57258. */
  57259. uvsIn?: string;
  57260. /**
  57261. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57262. */
  57263. uvsOut?: string;
  57264. /**
  57265. * number representing the layout style. Defaults to LAYOUT_STRIP
  57266. */
  57267. layout?: number;
  57268. /**
  57269. * number of columns if using custom column count layout(2). This defaults to 4.
  57270. */
  57271. colnum?: number;
  57272. /**
  57273. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57274. */
  57275. updateInputMeshes?: boolean;
  57276. /**
  57277. * boolean flag to dispose all the source textures. Defaults to true.
  57278. */
  57279. disposeSources?: boolean;
  57280. /**
  57281. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57282. */
  57283. fillBlanks?: boolean;
  57284. /**
  57285. * string value representing the context fill style color. Defaults to 'black'.
  57286. */
  57287. customFillColor?: string;
  57288. /**
  57289. * Width and Height Value of each Frame in the TexturePacker Sets
  57290. */
  57291. frameSize?: number;
  57292. /**
  57293. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57294. */
  57295. paddingRatio?: number;
  57296. /**
  57297. * Number that declares the fill method for the padding gutter.
  57298. */
  57299. paddingMode?: number;
  57300. /**
  57301. * If in SUBUV_COLOR padding mode what color to use.
  57302. */
  57303. paddingColor?: Color3 | Color4;
  57304. }
  57305. /**
  57306. * Defines the basic interface of a TexturePacker JSON File
  57307. */
  57308. export interface ITexturePackerJSON {
  57309. /**
  57310. * The frame ID
  57311. */
  57312. name: string;
  57313. /**
  57314. * The base64 channel data
  57315. */
  57316. sets: any;
  57317. /**
  57318. * The options of the Packer
  57319. */
  57320. options: ITexturePackerOptions;
  57321. /**
  57322. * The frame data of the Packer
  57323. */
  57324. frames: Array<number>;
  57325. }
  57326. /**
  57327. * This is a support class that generates a series of packed texture sets.
  57328. * @see https://doc.babylonjs.com/babylon101/materials
  57329. */
  57330. export class TexturePacker {
  57331. /** Packer Layout Constant 0 */
  57332. static readonly LAYOUT_STRIP: number;
  57333. /** Packer Layout Constant 1 */
  57334. static readonly LAYOUT_POWER2: number;
  57335. /** Packer Layout Constant 2 */
  57336. static readonly LAYOUT_COLNUM: number;
  57337. /** Packer Layout Constant 0 */
  57338. static readonly SUBUV_WRAP: number;
  57339. /** Packer Layout Constant 1 */
  57340. static readonly SUBUV_EXTEND: number;
  57341. /** Packer Layout Constant 2 */
  57342. static readonly SUBUV_COLOR: number;
  57343. /** The Name of the Texture Package */
  57344. name: string;
  57345. /** The scene scope of the TexturePacker */
  57346. scene: Scene;
  57347. /** The Meshes to target */
  57348. meshes: AbstractMesh[];
  57349. /** Arguments passed with the Constructor */
  57350. options: ITexturePackerOptions;
  57351. /** The promise that is started upon initialization */
  57352. promise: Nullable<Promise<TexturePacker | string>>;
  57353. /** The Container object for the channel sets that are generated */
  57354. sets: object;
  57355. /** The Container array for the frames that are generated */
  57356. frames: TexturePackerFrame[];
  57357. /** The expected number of textures the system is parsing. */
  57358. private _expecting;
  57359. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57360. private _paddingValue;
  57361. /**
  57362. * Initializes a texture package series from an array of meshes or a single mesh.
  57363. * @param name The name of the package
  57364. * @param meshes The target meshes to compose the package from
  57365. * @param options The arguments that texture packer should follow while building.
  57366. * @param scene The scene which the textures are scoped to.
  57367. * @returns TexturePacker
  57368. */
  57369. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57370. /**
  57371. * Starts the package process
  57372. * @param resolve The promises resolution function
  57373. * @returns TexturePacker
  57374. */
  57375. private _createFrames;
  57376. /**
  57377. * Calculates the Size of the Channel Sets
  57378. * @returns Vector2
  57379. */
  57380. private _calculateSize;
  57381. /**
  57382. * Calculates the UV data for the frames.
  57383. * @param baseSize the base frameSize
  57384. * @param padding the base frame padding
  57385. * @param dtSize size of the Dynamic Texture for that channel
  57386. * @param dtUnits is 1/dtSize
  57387. * @param update flag to update the input meshes
  57388. */
  57389. private _calculateMeshUVFrames;
  57390. /**
  57391. * Calculates the frames Offset.
  57392. * @param index of the frame
  57393. * @returns Vector2
  57394. */
  57395. private _getFrameOffset;
  57396. /**
  57397. * Updates a Mesh to the frame data
  57398. * @param mesh that is the target
  57399. * @param frameID or the frame index
  57400. */
  57401. private _updateMeshUV;
  57402. /**
  57403. * Updates a Meshes materials to use the texture packer channels
  57404. * @param m is the mesh to target
  57405. * @param force all channels on the packer to be set.
  57406. */
  57407. private _updateTextureReferences;
  57408. /**
  57409. * Public method to set a Mesh to a frame
  57410. * @param m that is the target
  57411. * @param frameID or the frame index
  57412. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57413. */
  57414. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57415. /**
  57416. * Starts the async promise to compile the texture packer.
  57417. * @returns Promise<void>
  57418. */
  57419. processAsync(): Promise<void>;
  57420. /**
  57421. * Disposes all textures associated with this packer
  57422. */
  57423. dispose(): void;
  57424. /**
  57425. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57426. * @param imageType is the image type to use.
  57427. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57428. */
  57429. download(imageType?: string, quality?: number): void;
  57430. /**
  57431. * Public method to load a texturePacker JSON file.
  57432. * @param data of the JSON file in string format.
  57433. */
  57434. updateFromJSON(data: string): void;
  57435. }
  57436. }
  57437. declare module BABYLON {
  57438. /**
  57439. * Enum used to define the target of a block
  57440. */
  57441. export enum NodeMaterialBlockTargets {
  57442. /** Vertex shader */
  57443. Vertex = 1,
  57444. /** Fragment shader */
  57445. Fragment = 2,
  57446. /** Neutral */
  57447. Neutral = 4,
  57448. /** Vertex and Fragment */
  57449. VertexAndFragment = 3
  57450. }
  57451. }
  57452. declare module BABYLON {
  57453. /**
  57454. * Defines the kind of connection point for node based material
  57455. */
  57456. export enum NodeMaterialBlockConnectionPointTypes {
  57457. /** Float */
  57458. Float = 1,
  57459. /** Int */
  57460. Int = 2,
  57461. /** Vector2 */
  57462. Vector2 = 4,
  57463. /** Vector3 */
  57464. Vector3 = 8,
  57465. /** Vector4 */
  57466. Vector4 = 16,
  57467. /** Color3 */
  57468. Color3 = 32,
  57469. /** Color4 */
  57470. Color4 = 64,
  57471. /** Matrix */
  57472. Matrix = 128,
  57473. /** Detect type based on connection */
  57474. AutoDetect = 1024,
  57475. /** Output type that will be defined by input type */
  57476. BasedOnInput = 2048
  57477. }
  57478. }
  57479. declare module BABYLON {
  57480. /**
  57481. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57482. */
  57483. export enum NodeMaterialBlockConnectionPointMode {
  57484. /** Value is an uniform */
  57485. Uniform = 0,
  57486. /** Value is a mesh attribute */
  57487. Attribute = 1,
  57488. /** Value is a varying between vertex and fragment shaders */
  57489. Varying = 2,
  57490. /** Mode is undefined */
  57491. Undefined = 3
  57492. }
  57493. }
  57494. declare module BABYLON {
  57495. /**
  57496. * Enum used to define system values e.g. values automatically provided by the system
  57497. */
  57498. export enum NodeMaterialSystemValues {
  57499. /** World */
  57500. World = 1,
  57501. /** View */
  57502. View = 2,
  57503. /** Projection */
  57504. Projection = 3,
  57505. /** ViewProjection */
  57506. ViewProjection = 4,
  57507. /** WorldView */
  57508. WorldView = 5,
  57509. /** WorldViewProjection */
  57510. WorldViewProjection = 6,
  57511. /** CameraPosition */
  57512. CameraPosition = 7,
  57513. /** Fog Color */
  57514. FogColor = 8,
  57515. /** Delta time */
  57516. DeltaTime = 9
  57517. }
  57518. }
  57519. declare module BABYLON {
  57520. /**
  57521. * Root class for all node material optimizers
  57522. */
  57523. export class NodeMaterialOptimizer {
  57524. /**
  57525. * Function used to optimize a NodeMaterial graph
  57526. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57527. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57528. */
  57529. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57530. }
  57531. }
  57532. declare module BABYLON {
  57533. /**
  57534. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57535. */
  57536. export class TransformBlock extends NodeMaterialBlock {
  57537. /**
  57538. * Defines the value to use to complement W value to transform it to a Vector4
  57539. */
  57540. complementW: number;
  57541. /**
  57542. * Defines the value to use to complement z value to transform it to a Vector4
  57543. */
  57544. complementZ: number;
  57545. /**
  57546. * Creates a new TransformBlock
  57547. * @param name defines the block name
  57548. */
  57549. constructor(name: string);
  57550. /**
  57551. * Gets the current class name
  57552. * @returns the class name
  57553. */
  57554. getClassName(): string;
  57555. /**
  57556. * Gets the vector input
  57557. */
  57558. get vector(): NodeMaterialConnectionPoint;
  57559. /**
  57560. * Gets the output component
  57561. */
  57562. get output(): NodeMaterialConnectionPoint;
  57563. /**
  57564. * Gets the xyz output component
  57565. */
  57566. get xyz(): NodeMaterialConnectionPoint;
  57567. /**
  57568. * Gets the matrix transform input
  57569. */
  57570. get transform(): NodeMaterialConnectionPoint;
  57571. protected _buildBlock(state: NodeMaterialBuildState): this;
  57572. serialize(): any;
  57573. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57574. protected _dumpPropertiesCode(): string;
  57575. }
  57576. }
  57577. declare module BABYLON {
  57578. /**
  57579. * Block used to output the vertex position
  57580. */
  57581. export class VertexOutputBlock extends NodeMaterialBlock {
  57582. /**
  57583. * Creates a new VertexOutputBlock
  57584. * @param name defines the block name
  57585. */
  57586. constructor(name: string);
  57587. /**
  57588. * Gets the current class name
  57589. * @returns the class name
  57590. */
  57591. getClassName(): string;
  57592. /**
  57593. * Gets the vector input component
  57594. */
  57595. get vector(): NodeMaterialConnectionPoint;
  57596. protected _buildBlock(state: NodeMaterialBuildState): this;
  57597. }
  57598. }
  57599. declare module BABYLON {
  57600. /**
  57601. * Block used to output the final color
  57602. */
  57603. export class FragmentOutputBlock extends NodeMaterialBlock {
  57604. /**
  57605. * Create a new FragmentOutputBlock
  57606. * @param name defines the block name
  57607. */
  57608. constructor(name: string);
  57609. /**
  57610. * Gets the current class name
  57611. * @returns the class name
  57612. */
  57613. getClassName(): string;
  57614. /**
  57615. * Gets the rgba input component
  57616. */
  57617. get rgba(): NodeMaterialConnectionPoint;
  57618. /**
  57619. * Gets the rgb input component
  57620. */
  57621. get rgb(): NodeMaterialConnectionPoint;
  57622. /**
  57623. * Gets the a input component
  57624. */
  57625. get a(): NodeMaterialConnectionPoint;
  57626. protected _buildBlock(state: NodeMaterialBuildState): this;
  57627. }
  57628. }
  57629. declare module BABYLON {
  57630. /**
  57631. * Block used to read a reflection texture from a sampler
  57632. */
  57633. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57634. private _define3DName;
  57635. private _defineCubicName;
  57636. private _defineExplicitName;
  57637. private _defineProjectionName;
  57638. private _defineLocalCubicName;
  57639. private _defineSphericalName;
  57640. private _definePlanarName;
  57641. private _defineEquirectangularName;
  57642. private _defineMirroredEquirectangularFixedName;
  57643. private _defineEquirectangularFixedName;
  57644. private _defineSkyboxName;
  57645. private _cubeSamplerName;
  57646. private _2DSamplerName;
  57647. private _positionUVWName;
  57648. private _directionWName;
  57649. private _reflectionCoordsName;
  57650. private _reflection2DCoordsName;
  57651. private _reflectionColorName;
  57652. private _reflectionMatrixName;
  57653. /**
  57654. * Gets or sets the texture associated with the node
  57655. */
  57656. texture: Nullable<BaseTexture>;
  57657. /**
  57658. * Create a new TextureBlock
  57659. * @param name defines the block name
  57660. */
  57661. constructor(name: string);
  57662. /**
  57663. * Gets the current class name
  57664. * @returns the class name
  57665. */
  57666. getClassName(): string;
  57667. /**
  57668. * Gets the world position input component
  57669. */
  57670. get position(): NodeMaterialConnectionPoint;
  57671. /**
  57672. * Gets the world position input component
  57673. */
  57674. get worldPosition(): NodeMaterialConnectionPoint;
  57675. /**
  57676. * Gets the world normal input component
  57677. */
  57678. get worldNormal(): NodeMaterialConnectionPoint;
  57679. /**
  57680. * Gets the world input component
  57681. */
  57682. get world(): NodeMaterialConnectionPoint;
  57683. /**
  57684. * Gets the camera (or eye) position component
  57685. */
  57686. get cameraPosition(): NodeMaterialConnectionPoint;
  57687. /**
  57688. * Gets the view input component
  57689. */
  57690. get view(): NodeMaterialConnectionPoint;
  57691. /**
  57692. * Gets the rgb output component
  57693. */
  57694. get rgb(): NodeMaterialConnectionPoint;
  57695. /**
  57696. * Gets the r output component
  57697. */
  57698. get r(): NodeMaterialConnectionPoint;
  57699. /**
  57700. * Gets the g output component
  57701. */
  57702. get g(): NodeMaterialConnectionPoint;
  57703. /**
  57704. * Gets the b output component
  57705. */
  57706. get b(): NodeMaterialConnectionPoint;
  57707. autoConfigure(material: NodeMaterial): void;
  57708. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57709. isReady(): boolean;
  57710. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57711. private _injectVertexCode;
  57712. private _writeOutput;
  57713. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57714. protected _dumpPropertiesCode(): string;
  57715. serialize(): any;
  57716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57717. }
  57718. }
  57719. declare module BABYLON {
  57720. /**
  57721. * Interface used to configure the node material editor
  57722. */
  57723. export interface INodeMaterialEditorOptions {
  57724. /** Define the URl to load node editor script */
  57725. editorURL?: string;
  57726. }
  57727. /** @hidden */
  57728. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57729. NORMAL: boolean;
  57730. TANGENT: boolean;
  57731. UV1: boolean;
  57732. /** BONES */
  57733. NUM_BONE_INFLUENCERS: number;
  57734. BonesPerMesh: number;
  57735. BONETEXTURE: boolean;
  57736. /** MORPH TARGETS */
  57737. MORPHTARGETS: boolean;
  57738. MORPHTARGETS_NORMAL: boolean;
  57739. MORPHTARGETS_TANGENT: boolean;
  57740. MORPHTARGETS_UV: boolean;
  57741. NUM_MORPH_INFLUENCERS: number;
  57742. /** IMAGE PROCESSING */
  57743. IMAGEPROCESSING: boolean;
  57744. VIGNETTE: boolean;
  57745. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57746. VIGNETTEBLENDMODEOPAQUE: boolean;
  57747. TONEMAPPING: boolean;
  57748. TONEMAPPING_ACES: boolean;
  57749. CONTRAST: boolean;
  57750. EXPOSURE: boolean;
  57751. COLORCURVES: boolean;
  57752. COLORGRADING: boolean;
  57753. COLORGRADING3D: boolean;
  57754. SAMPLER3DGREENDEPTH: boolean;
  57755. SAMPLER3DBGRMAP: boolean;
  57756. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57757. /** MISC. */
  57758. BUMPDIRECTUV: number;
  57759. constructor();
  57760. setValue(name: string, value: boolean): void;
  57761. }
  57762. /**
  57763. * Class used to configure NodeMaterial
  57764. */
  57765. export interface INodeMaterialOptions {
  57766. /**
  57767. * Defines if blocks should emit comments
  57768. */
  57769. emitComments: boolean;
  57770. }
  57771. /**
  57772. * Class used to create a node based material built by assembling shader blocks
  57773. */
  57774. export class NodeMaterial extends PushMaterial {
  57775. private static _BuildIdGenerator;
  57776. private _options;
  57777. private _vertexCompilationState;
  57778. private _fragmentCompilationState;
  57779. private _sharedData;
  57780. private _buildId;
  57781. private _buildWasSuccessful;
  57782. private _cachedWorldViewMatrix;
  57783. private _cachedWorldViewProjectionMatrix;
  57784. private _optimizers;
  57785. private _animationFrame;
  57786. /** Define the Url to load node editor script */
  57787. static EditorURL: string;
  57788. /** Define the Url to load snippets */
  57789. static SnippetUrl: string;
  57790. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  57791. static IgnoreTexturesAtLoadTime: boolean;
  57792. private BJSNODEMATERIALEDITOR;
  57793. /** Get the inspector from bundle or global */
  57794. private _getGlobalNodeMaterialEditor;
  57795. /**
  57796. * Snippet ID if the material was created from the snippet server
  57797. */
  57798. snippetId: string;
  57799. /**
  57800. * Gets or sets data used by visual editor
  57801. * @see https://nme.babylonjs.com
  57802. */
  57803. editorData: any;
  57804. /**
  57805. * 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)
  57806. */
  57807. ignoreAlpha: boolean;
  57808. /**
  57809. * Defines the maximum number of lights that can be used in the material
  57810. */
  57811. maxSimultaneousLights: number;
  57812. /**
  57813. * Observable raised when the material is built
  57814. */
  57815. onBuildObservable: Observable<NodeMaterial>;
  57816. /**
  57817. * Gets or sets the root nodes of the material vertex shader
  57818. */
  57819. _vertexOutputNodes: NodeMaterialBlock[];
  57820. /**
  57821. * Gets or sets the root nodes of the material fragment (pixel) shader
  57822. */
  57823. _fragmentOutputNodes: NodeMaterialBlock[];
  57824. /** Gets or sets options to control the node material overall behavior */
  57825. get options(): INodeMaterialOptions;
  57826. set options(options: INodeMaterialOptions);
  57827. /**
  57828. * Default configuration related to image processing available in the standard Material.
  57829. */
  57830. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57831. /**
  57832. * Gets the image processing configuration used either in this material.
  57833. */
  57834. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57835. /**
  57836. * Sets the Default image processing configuration used either in the this material.
  57837. *
  57838. * If sets to null, the scene one is in use.
  57839. */
  57840. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57841. /**
  57842. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57843. */
  57844. attachedBlocks: NodeMaterialBlock[];
  57845. /**
  57846. * Create a new node based material
  57847. * @param name defines the material name
  57848. * @param scene defines the hosting scene
  57849. * @param options defines creation option
  57850. */
  57851. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57852. /**
  57853. * Gets the current class name of the material e.g. "NodeMaterial"
  57854. * @returns the class name
  57855. */
  57856. getClassName(): string;
  57857. /**
  57858. * Keep track of the image processing observer to allow dispose and replace.
  57859. */
  57860. private _imageProcessingObserver;
  57861. /**
  57862. * Attaches a new image processing configuration to the Standard Material.
  57863. * @param configuration
  57864. */
  57865. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57866. /**
  57867. * Get a block by its name
  57868. * @param name defines the name of the block to retrieve
  57869. * @returns the required block or null if not found
  57870. */
  57871. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57872. /**
  57873. * Get a block by its name
  57874. * @param predicate defines the predicate used to find the good candidate
  57875. * @returns the required block or null if not found
  57876. */
  57877. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57878. /**
  57879. * Get an input block by its name
  57880. * @param predicate defines the predicate used to find the good candidate
  57881. * @returns the required input block or null if not found
  57882. */
  57883. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57884. /**
  57885. * Gets the list of input blocks attached to this material
  57886. * @returns an array of InputBlocks
  57887. */
  57888. getInputBlocks(): InputBlock[];
  57889. /**
  57890. * Adds a new optimizer to the list of optimizers
  57891. * @param optimizer defines the optimizers to add
  57892. * @returns the current material
  57893. */
  57894. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57895. /**
  57896. * Remove an optimizer from the list of optimizers
  57897. * @param optimizer defines the optimizers to remove
  57898. * @returns the current material
  57899. */
  57900. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57901. /**
  57902. * Add a new block to the list of output nodes
  57903. * @param node defines the node to add
  57904. * @returns the current material
  57905. */
  57906. addOutputNode(node: NodeMaterialBlock): this;
  57907. /**
  57908. * Remove a block from the list of root nodes
  57909. * @param node defines the node to remove
  57910. * @returns the current material
  57911. */
  57912. removeOutputNode(node: NodeMaterialBlock): this;
  57913. private _addVertexOutputNode;
  57914. private _removeVertexOutputNode;
  57915. private _addFragmentOutputNode;
  57916. private _removeFragmentOutputNode;
  57917. /**
  57918. * Specifies if the material will require alpha blending
  57919. * @returns a boolean specifying if alpha blending is needed
  57920. */
  57921. needAlphaBlending(): boolean;
  57922. /**
  57923. * Specifies if this material should be rendered in alpha test mode
  57924. * @returns a boolean specifying if an alpha test is needed.
  57925. */
  57926. needAlphaTesting(): boolean;
  57927. private _initializeBlock;
  57928. private _resetDualBlocks;
  57929. /**
  57930. * Remove a block from the current node material
  57931. * @param block defines the block to remove
  57932. */
  57933. removeBlock(block: NodeMaterialBlock): void;
  57934. /**
  57935. * Build the material and generates the inner effect
  57936. * @param verbose defines if the build should log activity
  57937. */
  57938. build(verbose?: boolean): void;
  57939. /**
  57940. * Runs an otpimization phase to try to improve the shader code
  57941. */
  57942. optimize(): void;
  57943. private _prepareDefinesForAttributes;
  57944. /**
  57945. * Get if the submesh is ready to be used and all its information available.
  57946. * Child classes can use it to update shaders
  57947. * @param mesh defines the mesh to check
  57948. * @param subMesh defines which submesh to check
  57949. * @param useInstances specifies that instances should be used
  57950. * @returns a boolean indicating that the submesh is ready or not
  57951. */
  57952. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57953. /**
  57954. * Get a string representing the shaders built by the current node graph
  57955. */
  57956. get compiledShaders(): string;
  57957. /**
  57958. * Binds the world matrix to the material
  57959. * @param world defines the world transformation matrix
  57960. */
  57961. bindOnlyWorldMatrix(world: Matrix): void;
  57962. /**
  57963. * Binds the submesh to this material by preparing the effect and shader to draw
  57964. * @param world defines the world transformation matrix
  57965. * @param mesh defines the mesh containing the submesh
  57966. * @param subMesh defines the submesh to bind the material to
  57967. */
  57968. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57969. /**
  57970. * Gets the active textures from the material
  57971. * @returns an array of textures
  57972. */
  57973. getActiveTextures(): BaseTexture[];
  57974. /**
  57975. * Gets the list of texture blocks
  57976. * @returns an array of texture blocks
  57977. */
  57978. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57979. /**
  57980. * Specifies if the material uses a texture
  57981. * @param texture defines the texture to check against the material
  57982. * @returns a boolean specifying if the material uses the texture
  57983. */
  57984. hasTexture(texture: BaseTexture): boolean;
  57985. /**
  57986. * Disposes the material
  57987. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57988. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57989. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57990. */
  57991. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57992. /** Creates the node editor window. */
  57993. private _createNodeEditor;
  57994. /**
  57995. * Launch the node material editor
  57996. * @param config Define the configuration of the editor
  57997. * @return a promise fulfilled when the node editor is visible
  57998. */
  57999. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58000. /**
  58001. * Clear the current material
  58002. */
  58003. clear(): void;
  58004. /**
  58005. * Clear the current material and set it to a default state
  58006. */
  58007. setToDefault(): void;
  58008. /**
  58009. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58010. * @param url defines the url to load from
  58011. * @returns a promise that will fullfil when the material is fully loaded
  58012. */
  58013. loadAsync(url: string): Promise<void>;
  58014. private _gatherBlocks;
  58015. /**
  58016. * Generate a string containing the code declaration required to create an equivalent of this material
  58017. * @returns a string
  58018. */
  58019. generateCode(): string;
  58020. /**
  58021. * Serializes this material in a JSON representation
  58022. * @returns the serialized material object
  58023. */
  58024. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58025. private _restoreConnections;
  58026. /**
  58027. * Clear the current graph and load a new one from a serialization object
  58028. * @param source defines the JSON representation of the material
  58029. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58030. */
  58031. loadFromSerialization(source: any, rootUrl?: string): void;
  58032. /**
  58033. * Makes a duplicate of the current material.
  58034. * @param name - name to use for the new material.
  58035. */
  58036. clone(name: string): NodeMaterial;
  58037. /**
  58038. * Creates a node material from parsed material data
  58039. * @param source defines the JSON representation of the material
  58040. * @param scene defines the hosting scene
  58041. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58042. * @returns a new node material
  58043. */
  58044. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58045. /**
  58046. * Creates a node material from a snippet saved in a remote file
  58047. * @param name defines the name of the material to create
  58048. * @param url defines the url to load from
  58049. * @param scene defines the hosting scene
  58050. * @returns a promise that will resolve to the new node material
  58051. */
  58052. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  58053. /**
  58054. * Creates a node material from a snippet saved by the node material editor
  58055. * @param snippetId defines the snippet to load
  58056. * @param scene defines the hosting scene
  58057. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58058. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  58059. * @returns a promise that will resolve to the new node material
  58060. */
  58061. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  58062. /**
  58063. * Creates a new node material set to default basic configuration
  58064. * @param name defines the name of the material
  58065. * @param scene defines the hosting scene
  58066. * @returns a new NodeMaterial
  58067. */
  58068. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58069. }
  58070. }
  58071. declare module BABYLON {
  58072. /**
  58073. * Block used to read a texture from a sampler
  58074. */
  58075. export class TextureBlock extends NodeMaterialBlock {
  58076. private _defineName;
  58077. private _linearDefineName;
  58078. private _tempTextureRead;
  58079. private _samplerName;
  58080. private _transformedUVName;
  58081. private _textureTransformName;
  58082. private _textureInfoName;
  58083. private _mainUVName;
  58084. private _mainUVDefineName;
  58085. /**
  58086. * Gets or sets the texture associated with the node
  58087. */
  58088. texture: Nullable<Texture>;
  58089. /**
  58090. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58091. */
  58092. convertToGammaSpace: boolean;
  58093. /**
  58094. * Create a new TextureBlock
  58095. * @param name defines the block name
  58096. */
  58097. constructor(name: string);
  58098. /**
  58099. * Gets the current class name
  58100. * @returns the class name
  58101. */
  58102. getClassName(): string;
  58103. /**
  58104. * Gets the uv input component
  58105. */
  58106. get uv(): NodeMaterialConnectionPoint;
  58107. /**
  58108. * Gets the rgba output component
  58109. */
  58110. get rgba(): NodeMaterialConnectionPoint;
  58111. /**
  58112. * Gets the rgb output component
  58113. */
  58114. get rgb(): NodeMaterialConnectionPoint;
  58115. /**
  58116. * Gets the r output component
  58117. */
  58118. get r(): NodeMaterialConnectionPoint;
  58119. /**
  58120. * Gets the g output component
  58121. */
  58122. get g(): NodeMaterialConnectionPoint;
  58123. /**
  58124. * Gets the b output component
  58125. */
  58126. get b(): NodeMaterialConnectionPoint;
  58127. /**
  58128. * Gets the a output component
  58129. */
  58130. get a(): NodeMaterialConnectionPoint;
  58131. get target(): NodeMaterialBlockTargets;
  58132. autoConfigure(material: NodeMaterial): void;
  58133. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58134. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58135. isReady(): boolean;
  58136. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58137. private get _isMixed();
  58138. private _injectVertexCode;
  58139. private _writeTextureRead;
  58140. private _writeOutput;
  58141. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58142. protected _dumpPropertiesCode(): string;
  58143. serialize(): any;
  58144. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58145. }
  58146. }
  58147. declare module BABYLON {
  58148. /**
  58149. * Class used to store shared data between 2 NodeMaterialBuildState
  58150. */
  58151. export class NodeMaterialBuildStateSharedData {
  58152. /**
  58153. * Gets the list of emitted varyings
  58154. */
  58155. temps: string[];
  58156. /**
  58157. * Gets the list of emitted varyings
  58158. */
  58159. varyings: string[];
  58160. /**
  58161. * Gets the varying declaration string
  58162. */
  58163. varyingDeclaration: string;
  58164. /**
  58165. * Input blocks
  58166. */
  58167. inputBlocks: InputBlock[];
  58168. /**
  58169. * Input blocks
  58170. */
  58171. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58172. /**
  58173. * Bindable blocks (Blocks that need to set data to the effect)
  58174. */
  58175. bindableBlocks: NodeMaterialBlock[];
  58176. /**
  58177. * List of blocks that can provide a compilation fallback
  58178. */
  58179. blocksWithFallbacks: NodeMaterialBlock[];
  58180. /**
  58181. * List of blocks that can provide a define update
  58182. */
  58183. blocksWithDefines: NodeMaterialBlock[];
  58184. /**
  58185. * List of blocks that can provide a repeatable content
  58186. */
  58187. repeatableContentBlocks: NodeMaterialBlock[];
  58188. /**
  58189. * List of blocks that can provide a dynamic list of uniforms
  58190. */
  58191. dynamicUniformBlocks: NodeMaterialBlock[];
  58192. /**
  58193. * List of blocks that can block the isReady function for the material
  58194. */
  58195. blockingBlocks: NodeMaterialBlock[];
  58196. /**
  58197. * Gets the list of animated inputs
  58198. */
  58199. animatedInputs: InputBlock[];
  58200. /**
  58201. * Build Id used to avoid multiple recompilations
  58202. */
  58203. buildId: number;
  58204. /** List of emitted variables */
  58205. variableNames: {
  58206. [key: string]: number;
  58207. };
  58208. /** List of emitted defines */
  58209. defineNames: {
  58210. [key: string]: number;
  58211. };
  58212. /** Should emit comments? */
  58213. emitComments: boolean;
  58214. /** Emit build activity */
  58215. verbose: boolean;
  58216. /** Gets or sets the hosting scene */
  58217. scene: Scene;
  58218. /**
  58219. * Gets the compilation hints emitted at compilation time
  58220. */
  58221. hints: {
  58222. needWorldViewMatrix: boolean;
  58223. needWorldViewProjectionMatrix: boolean;
  58224. needAlphaBlending: boolean;
  58225. needAlphaTesting: boolean;
  58226. };
  58227. /**
  58228. * List of compilation checks
  58229. */
  58230. checks: {
  58231. emitVertex: boolean;
  58232. emitFragment: boolean;
  58233. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58234. };
  58235. /** Creates a new shared data */
  58236. constructor();
  58237. /**
  58238. * Emits console errors and exceptions if there is a failing check
  58239. */
  58240. emitErrors(): void;
  58241. }
  58242. }
  58243. declare module BABYLON {
  58244. /**
  58245. * Class used to store node based material build state
  58246. */
  58247. export class NodeMaterialBuildState {
  58248. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58249. supportUniformBuffers: boolean;
  58250. /**
  58251. * Gets the list of emitted attributes
  58252. */
  58253. attributes: string[];
  58254. /**
  58255. * Gets the list of emitted uniforms
  58256. */
  58257. uniforms: string[];
  58258. /**
  58259. * Gets the list of emitted constants
  58260. */
  58261. constants: string[];
  58262. /**
  58263. * Gets the list of emitted samplers
  58264. */
  58265. samplers: string[];
  58266. /**
  58267. * Gets the list of emitted functions
  58268. */
  58269. functions: {
  58270. [key: string]: string;
  58271. };
  58272. /**
  58273. * Gets the list of emitted extensions
  58274. */
  58275. extensions: {
  58276. [key: string]: string;
  58277. };
  58278. /**
  58279. * Gets the target of the compilation state
  58280. */
  58281. target: NodeMaterialBlockTargets;
  58282. /**
  58283. * Gets the list of emitted counters
  58284. */
  58285. counters: {
  58286. [key: string]: number;
  58287. };
  58288. /**
  58289. * Shared data between multiple NodeMaterialBuildState instances
  58290. */
  58291. sharedData: NodeMaterialBuildStateSharedData;
  58292. /** @hidden */
  58293. _vertexState: NodeMaterialBuildState;
  58294. /** @hidden */
  58295. _attributeDeclaration: string;
  58296. /** @hidden */
  58297. _uniformDeclaration: string;
  58298. /** @hidden */
  58299. _constantDeclaration: string;
  58300. /** @hidden */
  58301. _samplerDeclaration: string;
  58302. /** @hidden */
  58303. _varyingTransfer: string;
  58304. private _repeatableContentAnchorIndex;
  58305. /** @hidden */
  58306. _builtCompilationString: string;
  58307. /**
  58308. * Gets the emitted compilation strings
  58309. */
  58310. compilationString: string;
  58311. /**
  58312. * Finalize the compilation strings
  58313. * @param state defines the current compilation state
  58314. */
  58315. finalize(state: NodeMaterialBuildState): void;
  58316. /** @hidden */
  58317. get _repeatableContentAnchor(): string;
  58318. /** @hidden */
  58319. _getFreeVariableName(prefix: string): string;
  58320. /** @hidden */
  58321. _getFreeDefineName(prefix: string): string;
  58322. /** @hidden */
  58323. _excludeVariableName(name: string): void;
  58324. /** @hidden */
  58325. _emit2DSampler(name: string): void;
  58326. /** @hidden */
  58327. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58328. /** @hidden */
  58329. _emitExtension(name: string, extension: string): void;
  58330. /** @hidden */
  58331. _emitFunction(name: string, code: string, comments: string): void;
  58332. /** @hidden */
  58333. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58334. replaceStrings?: {
  58335. search: RegExp;
  58336. replace: string;
  58337. }[];
  58338. repeatKey?: string;
  58339. }): string;
  58340. /** @hidden */
  58341. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58342. repeatKey?: string;
  58343. removeAttributes?: boolean;
  58344. removeUniforms?: boolean;
  58345. removeVaryings?: boolean;
  58346. removeIfDef?: boolean;
  58347. replaceStrings?: {
  58348. search: RegExp;
  58349. replace: string;
  58350. }[];
  58351. }, storeKey?: string): void;
  58352. /** @hidden */
  58353. _registerTempVariable(name: string): boolean;
  58354. /** @hidden */
  58355. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58356. /** @hidden */
  58357. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58358. /** @hidden */
  58359. _emitFloat(value: number): string;
  58360. }
  58361. }
  58362. declare module BABYLON {
  58363. /**
  58364. * Defines a block that can be used inside a node based material
  58365. */
  58366. export class NodeMaterialBlock {
  58367. private _buildId;
  58368. private _buildTarget;
  58369. private _target;
  58370. private _isFinalMerger;
  58371. private _isInput;
  58372. protected _isUnique: boolean;
  58373. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58374. inputsAreExclusive: boolean;
  58375. /** @hidden */
  58376. _codeVariableName: string;
  58377. /** @hidden */
  58378. _inputs: NodeMaterialConnectionPoint[];
  58379. /** @hidden */
  58380. _outputs: NodeMaterialConnectionPoint[];
  58381. /** @hidden */
  58382. _preparationId: number;
  58383. /**
  58384. * Gets or sets the name of the block
  58385. */
  58386. name: string;
  58387. /**
  58388. * Gets or sets the unique id of the node
  58389. */
  58390. uniqueId: number;
  58391. /**
  58392. * Gets or sets the comments associated with this block
  58393. */
  58394. comments: string;
  58395. /**
  58396. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58397. */
  58398. get isUnique(): boolean;
  58399. /**
  58400. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58401. */
  58402. get isFinalMerger(): boolean;
  58403. /**
  58404. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58405. */
  58406. get isInput(): boolean;
  58407. /**
  58408. * Gets or sets the build Id
  58409. */
  58410. get buildId(): number;
  58411. set buildId(value: number);
  58412. /**
  58413. * Gets or sets the target of the block
  58414. */
  58415. get target(): NodeMaterialBlockTargets;
  58416. set target(value: NodeMaterialBlockTargets);
  58417. /**
  58418. * Gets the list of input points
  58419. */
  58420. get inputs(): NodeMaterialConnectionPoint[];
  58421. /** Gets the list of output points */
  58422. get outputs(): NodeMaterialConnectionPoint[];
  58423. /**
  58424. * Find an input by its name
  58425. * @param name defines the name of the input to look for
  58426. * @returns the input or null if not found
  58427. */
  58428. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58429. /**
  58430. * Find an output by its name
  58431. * @param name defines the name of the outputto look for
  58432. * @returns the output or null if not found
  58433. */
  58434. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58435. /**
  58436. * Creates a new NodeMaterialBlock
  58437. * @param name defines the block name
  58438. * @param target defines the target of that block (Vertex by default)
  58439. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58440. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58441. */
  58442. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58443. /**
  58444. * Initialize the block and prepare the context for build
  58445. * @param state defines the state that will be used for the build
  58446. */
  58447. initialize(state: NodeMaterialBuildState): void;
  58448. /**
  58449. * Bind data to effect. Will only be called for blocks with isBindable === true
  58450. * @param effect defines the effect to bind data to
  58451. * @param nodeMaterial defines the hosting NodeMaterial
  58452. * @param mesh defines the mesh that will be rendered
  58453. */
  58454. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58455. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58456. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58457. protected _writeFloat(value: number): string;
  58458. /**
  58459. * Gets the current class name e.g. "NodeMaterialBlock"
  58460. * @returns the class name
  58461. */
  58462. getClassName(): string;
  58463. /**
  58464. * Register a new input. Must be called inside a block constructor
  58465. * @param name defines the connection point name
  58466. * @param type defines the connection point type
  58467. * @param isOptional defines a boolean indicating that this input can be omitted
  58468. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58469. * @returns the current block
  58470. */
  58471. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58472. /**
  58473. * Register a new output. Must be called inside a block constructor
  58474. * @param name defines the connection point name
  58475. * @param type defines the connection point type
  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. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58480. /**
  58481. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58482. * @param forOutput defines an optional connection point to check compatibility with
  58483. * @returns the first available input or null
  58484. */
  58485. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58486. /**
  58487. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58488. * @param forBlock defines an optional block to check compatibility with
  58489. * @returns the first available input or null
  58490. */
  58491. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58492. /**
  58493. * Gets the sibling of the given output
  58494. * @param current defines the current output
  58495. * @returns the next output in the list or null
  58496. */
  58497. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58498. /**
  58499. * Connect current block with another block
  58500. * @param other defines the block to connect with
  58501. * @param options define the various options to help pick the right connections
  58502. * @returns the current block
  58503. */
  58504. connectTo(other: NodeMaterialBlock, options?: {
  58505. input?: string;
  58506. output?: string;
  58507. outputSwizzle?: string;
  58508. }): this | undefined;
  58509. protected _buildBlock(state: NodeMaterialBuildState): void;
  58510. /**
  58511. * Add uniforms, samplers and uniform buffers at compilation time
  58512. * @param state defines the state to update
  58513. * @param nodeMaterial defines the node material requesting the update
  58514. * @param defines defines the material defines to update
  58515. * @param uniformBuffers defines the list of uniform buffer names
  58516. */
  58517. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58518. /**
  58519. * Add potential fallbacks if shader compilation fails
  58520. * @param mesh defines the mesh to be rendered
  58521. * @param fallbacks defines the current prioritized list of fallbacks
  58522. */
  58523. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58524. /**
  58525. * Initialize defines for shader compilation
  58526. * @param mesh defines the mesh to be rendered
  58527. * @param nodeMaterial defines the node material requesting the update
  58528. * @param defines defines the material defines to update
  58529. * @param useInstances specifies that instances should be used
  58530. */
  58531. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58532. /**
  58533. * Update 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. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58540. /**
  58541. * Lets the block try to connect some inputs automatically
  58542. * @param material defines the hosting NodeMaterial
  58543. */
  58544. autoConfigure(material: NodeMaterial): void;
  58545. /**
  58546. * Function called when a block is declared as repeatable content generator
  58547. * @param vertexShaderState defines the current compilation state for the vertex shader
  58548. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58549. * @param mesh defines the mesh to be rendered
  58550. * @param defines defines the material defines to update
  58551. */
  58552. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58553. /**
  58554. * Checks if the block is ready
  58555. * @param mesh defines the mesh to be rendered
  58556. * @param nodeMaterial defines the node material requesting the update
  58557. * @param defines defines the material defines to update
  58558. * @param useInstances specifies that instances should be used
  58559. * @returns true if the block is ready
  58560. */
  58561. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58562. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58563. private _processBuild;
  58564. /**
  58565. * Compile the current node and generate the shader code
  58566. * @param state defines the current compilation state (uniforms, samplers, current string)
  58567. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58568. * @returns true if already built
  58569. */
  58570. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58571. protected _inputRename(name: string): string;
  58572. protected _outputRename(name: string): string;
  58573. protected _dumpPropertiesCode(): string;
  58574. /** @hidden */
  58575. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58576. /** @hidden */
  58577. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58578. /**
  58579. * Clone the current block to a new identical block
  58580. * @param scene defines the hosting scene
  58581. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58582. * @returns a copy of the current block
  58583. */
  58584. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58585. /**
  58586. * Serializes this block in a JSON representation
  58587. * @returns the serialized block object
  58588. */
  58589. serialize(): any;
  58590. /** @hidden */
  58591. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58592. private _deserializePortDisplayNames;
  58593. /**
  58594. * Release resources
  58595. */
  58596. dispose(): void;
  58597. }
  58598. }
  58599. declare module BABYLON {
  58600. /**
  58601. * Enum defining the type of animations supported by InputBlock
  58602. */
  58603. export enum AnimatedInputBlockTypes {
  58604. /** No animation */
  58605. None = 0,
  58606. /** Time based animation. Will only work for floats */
  58607. Time = 1
  58608. }
  58609. }
  58610. declare module BABYLON {
  58611. /**
  58612. * Block used to expose an input value
  58613. */
  58614. export class InputBlock extends NodeMaterialBlock {
  58615. private _mode;
  58616. private _associatedVariableName;
  58617. private _storedValue;
  58618. private _valueCallback;
  58619. private _type;
  58620. private _animationType;
  58621. /** Gets or set a value used to limit the range of float values */
  58622. min: number;
  58623. /** Gets or set a value used to limit the range of float values */
  58624. max: number;
  58625. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58626. isBoolean: boolean;
  58627. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58628. matrixMode: number;
  58629. /** @hidden */
  58630. _systemValue: Nullable<NodeMaterialSystemValues>;
  58631. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58632. visibleInInspector: boolean;
  58633. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58634. isConstant: boolean;
  58635. /** Gets or sets the group to use to display this block in the Inspector */
  58636. groupInInspector: string;
  58637. /** Gets an observable raised when the value is changed */
  58638. onValueChangedObservable: Observable<InputBlock>;
  58639. /**
  58640. * Gets or sets the connection point type (default is float)
  58641. */
  58642. get type(): NodeMaterialBlockConnectionPointTypes;
  58643. /**
  58644. * Creates a new InputBlock
  58645. * @param name defines the block name
  58646. * @param target defines the target of that block (Vertex by default)
  58647. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58648. */
  58649. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58650. /**
  58651. * Gets the output component
  58652. */
  58653. get output(): NodeMaterialConnectionPoint;
  58654. /**
  58655. * Set the source of this connection point to a vertex attribute
  58656. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58657. * @returns the current connection point
  58658. */
  58659. setAsAttribute(attributeName?: string): InputBlock;
  58660. /**
  58661. * Set the source of this connection point to a system value
  58662. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58663. * @returns the current connection point
  58664. */
  58665. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58666. /**
  58667. * Gets or sets the value of that point.
  58668. * Please note that this value will be ignored if valueCallback is defined
  58669. */
  58670. get value(): any;
  58671. set value(value: any);
  58672. /**
  58673. * Gets or sets a callback used to get the value of that point.
  58674. * Please note that setting this value will force the connection point to ignore the value property
  58675. */
  58676. get valueCallback(): () => any;
  58677. set valueCallback(value: () => any);
  58678. /**
  58679. * Gets or sets the associated variable name in the shader
  58680. */
  58681. get associatedVariableName(): string;
  58682. set associatedVariableName(value: string);
  58683. /** Gets or sets the type of animation applied to the input */
  58684. get animationType(): AnimatedInputBlockTypes;
  58685. set animationType(value: AnimatedInputBlockTypes);
  58686. /**
  58687. * Gets a boolean indicating that this connection point not defined yet
  58688. */
  58689. get isUndefined(): boolean;
  58690. /**
  58691. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58692. * In this case the connection point name must be the name of the uniform to use.
  58693. * Can only be set on inputs
  58694. */
  58695. get isUniform(): boolean;
  58696. set isUniform(value: boolean);
  58697. /**
  58698. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58699. * In this case the connection point name must be the name of the attribute to use
  58700. * Can only be set on inputs
  58701. */
  58702. get isAttribute(): boolean;
  58703. set isAttribute(value: boolean);
  58704. /**
  58705. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58706. * Can only be set on exit points
  58707. */
  58708. get isVarying(): boolean;
  58709. set isVarying(value: boolean);
  58710. /**
  58711. * Gets a boolean indicating that the current connection point is a system value
  58712. */
  58713. get isSystemValue(): boolean;
  58714. /**
  58715. * Gets or sets the current well known value or null if not defined as a system value
  58716. */
  58717. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58718. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58719. /**
  58720. * Gets the current class name
  58721. * @returns the class name
  58722. */
  58723. getClassName(): string;
  58724. /**
  58725. * Animate the input if animationType !== None
  58726. * @param scene defines the rendering scene
  58727. */
  58728. animate(scene: Scene): void;
  58729. private _emitDefine;
  58730. initialize(state: NodeMaterialBuildState): void;
  58731. /**
  58732. * Set the input block to its default value (based on its type)
  58733. */
  58734. setDefaultValue(): void;
  58735. private _emitConstant;
  58736. private _emit;
  58737. /** @hidden */
  58738. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58739. /** @hidden */
  58740. _transmit(effect: Effect, scene: Scene): void;
  58741. protected _buildBlock(state: NodeMaterialBuildState): void;
  58742. protected _dumpPropertiesCode(): string;
  58743. dispose(): void;
  58744. serialize(): any;
  58745. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58746. }
  58747. }
  58748. declare module BABYLON {
  58749. /**
  58750. * Enum used to define the compatibility state between two connection points
  58751. */
  58752. export enum NodeMaterialConnectionPointCompatibilityStates {
  58753. /** Points are compatibles */
  58754. Compatible = 0,
  58755. /** Points are incompatible because of their types */
  58756. TypeIncompatible = 1,
  58757. /** Points are incompatible because of their targets (vertex vs fragment) */
  58758. TargetIncompatible = 2
  58759. }
  58760. /**
  58761. * Defines the direction of a connection point
  58762. */
  58763. export enum NodeMaterialConnectionPointDirection {
  58764. /** Input */
  58765. Input = 0,
  58766. /** Output */
  58767. Output = 1
  58768. }
  58769. /**
  58770. * Defines a connection point for a block
  58771. */
  58772. export class NodeMaterialConnectionPoint {
  58773. /** @hidden */
  58774. _ownerBlock: NodeMaterialBlock;
  58775. /** @hidden */
  58776. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58777. private _endpoints;
  58778. private _associatedVariableName;
  58779. private _direction;
  58780. /** @hidden */
  58781. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58782. /** @hidden */
  58783. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58784. private _type;
  58785. /** @hidden */
  58786. _enforceAssociatedVariableName: boolean;
  58787. /** Gets the direction of the point */
  58788. get direction(): NodeMaterialConnectionPointDirection;
  58789. /**
  58790. * Gets or sets the additional types supported by this connection point
  58791. */
  58792. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58793. /**
  58794. * Gets or sets the additional types excluded by this connection point
  58795. */
  58796. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58797. /**
  58798. * Observable triggered when this point is connected
  58799. */
  58800. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58801. /**
  58802. * Gets or sets the associated variable name in the shader
  58803. */
  58804. get associatedVariableName(): string;
  58805. set associatedVariableName(value: string);
  58806. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58807. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58808. /**
  58809. * Gets or sets the connection point type (default is float)
  58810. */
  58811. get type(): NodeMaterialBlockConnectionPointTypes;
  58812. set type(value: NodeMaterialBlockConnectionPointTypes);
  58813. /**
  58814. * Gets or sets the connection point name
  58815. */
  58816. name: string;
  58817. /**
  58818. * Gets or sets the connection point name
  58819. */
  58820. displayName: string;
  58821. /**
  58822. * Gets or sets a boolean indicating that this connection point can be omitted
  58823. */
  58824. isOptional: boolean;
  58825. /**
  58826. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58827. */
  58828. define: string;
  58829. /** @hidden */
  58830. _prioritizeVertex: boolean;
  58831. private _target;
  58832. /** Gets or sets the target of that connection point */
  58833. get target(): NodeMaterialBlockTargets;
  58834. set target(value: NodeMaterialBlockTargets);
  58835. /**
  58836. * Gets a boolean indicating that the current point is connected
  58837. */
  58838. get isConnected(): boolean;
  58839. /**
  58840. * Gets a boolean indicating that the current point is connected to an input block
  58841. */
  58842. get isConnectedToInputBlock(): boolean;
  58843. /**
  58844. * Gets a the connected input block (if any)
  58845. */
  58846. get connectInputBlock(): Nullable<InputBlock>;
  58847. /** Get the other side of the connection (if any) */
  58848. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58849. /** Get the block that owns this connection point */
  58850. get ownerBlock(): NodeMaterialBlock;
  58851. /** Get the block connected on the other side of this connection (if any) */
  58852. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58853. /** Get the block connected on the endpoints of this connection (if any) */
  58854. get connectedBlocks(): Array<NodeMaterialBlock>;
  58855. /** Gets the list of connected endpoints */
  58856. get endpoints(): NodeMaterialConnectionPoint[];
  58857. /** Gets a boolean indicating if that output point is connected to at least one input */
  58858. get hasEndpoints(): boolean;
  58859. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58860. get isConnectedInVertexShader(): boolean;
  58861. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58862. get isConnectedInFragmentShader(): boolean;
  58863. /**
  58864. * Creates a new connection point
  58865. * @param name defines the connection point name
  58866. * @param ownerBlock defines the block hosting this connection point
  58867. * @param direction defines the direction of the connection point
  58868. */
  58869. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58870. /**
  58871. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58872. * @returns the class name
  58873. */
  58874. getClassName(): string;
  58875. /**
  58876. * Gets a boolean indicating if the current point can be connected to another point
  58877. * @param connectionPoint defines the other connection point
  58878. * @returns a boolean
  58879. */
  58880. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58881. /**
  58882. * Gets a number indicating if the current point can be connected to another point
  58883. * @param connectionPoint defines the other connection point
  58884. * @returns a number defining the compatibility state
  58885. */
  58886. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58887. /**
  58888. * Connect this point to another connection point
  58889. * @param connectionPoint defines the other connection point
  58890. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58891. * @returns the current connection point
  58892. */
  58893. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58894. /**
  58895. * Disconnect this point from one of his endpoint
  58896. * @param endpoint defines the other connection point
  58897. * @returns the current connection point
  58898. */
  58899. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58900. /**
  58901. * Serializes this point in a JSON representation
  58902. * @param isInput defines if the connection point is an input (default is true)
  58903. * @returns the serialized point object
  58904. */
  58905. serialize(isInput?: boolean): any;
  58906. /**
  58907. * Release resources
  58908. */
  58909. dispose(): void;
  58910. }
  58911. }
  58912. declare module BABYLON {
  58913. /**
  58914. * Block used to add support for vertex skinning (bones)
  58915. */
  58916. export class BonesBlock extends NodeMaterialBlock {
  58917. /**
  58918. * Creates a new BonesBlock
  58919. * @param name defines the block name
  58920. */
  58921. constructor(name: string);
  58922. /**
  58923. * Initialize the block and prepare the context for build
  58924. * @param state defines the state that will be used for the build
  58925. */
  58926. initialize(state: NodeMaterialBuildState): void;
  58927. /**
  58928. * Gets the current class name
  58929. * @returns the class name
  58930. */
  58931. getClassName(): string;
  58932. /**
  58933. * Gets the matrix indices input component
  58934. */
  58935. get matricesIndices(): NodeMaterialConnectionPoint;
  58936. /**
  58937. * Gets the matrix weights input component
  58938. */
  58939. get matricesWeights(): NodeMaterialConnectionPoint;
  58940. /**
  58941. * Gets the extra matrix indices input component
  58942. */
  58943. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58944. /**
  58945. * Gets the extra matrix weights input component
  58946. */
  58947. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58948. /**
  58949. * Gets the world input component
  58950. */
  58951. get world(): NodeMaterialConnectionPoint;
  58952. /**
  58953. * Gets the output component
  58954. */
  58955. get output(): NodeMaterialConnectionPoint;
  58956. autoConfigure(material: NodeMaterial): void;
  58957. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58958. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58959. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58960. protected _buildBlock(state: NodeMaterialBuildState): this;
  58961. }
  58962. }
  58963. declare module BABYLON {
  58964. /**
  58965. * Block used to add support for instances
  58966. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58967. */
  58968. export class InstancesBlock extends NodeMaterialBlock {
  58969. /**
  58970. * Creates a new InstancesBlock
  58971. * @param name defines the block name
  58972. */
  58973. constructor(name: string);
  58974. /**
  58975. * Gets the current class name
  58976. * @returns the class name
  58977. */
  58978. getClassName(): string;
  58979. /**
  58980. * Gets the first world row input component
  58981. */
  58982. get world0(): NodeMaterialConnectionPoint;
  58983. /**
  58984. * Gets the second world row input component
  58985. */
  58986. get world1(): NodeMaterialConnectionPoint;
  58987. /**
  58988. * Gets the third world row input component
  58989. */
  58990. get world2(): NodeMaterialConnectionPoint;
  58991. /**
  58992. * Gets the forth world row input component
  58993. */
  58994. get world3(): NodeMaterialConnectionPoint;
  58995. /**
  58996. * Gets the world input component
  58997. */
  58998. get world(): NodeMaterialConnectionPoint;
  58999. /**
  59000. * Gets the output component
  59001. */
  59002. get output(): NodeMaterialConnectionPoint;
  59003. /**
  59004. * Gets the isntanceID component
  59005. */
  59006. get instanceID(): NodeMaterialConnectionPoint;
  59007. autoConfigure(material: NodeMaterial): void;
  59008. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59009. protected _buildBlock(state: NodeMaterialBuildState): this;
  59010. }
  59011. }
  59012. declare module BABYLON {
  59013. /**
  59014. * Block used to add morph targets support to vertex shader
  59015. */
  59016. export class MorphTargetsBlock extends NodeMaterialBlock {
  59017. private _repeatableContentAnchor;
  59018. /**
  59019. * Create a new MorphTargetsBlock
  59020. * @param name defines the block name
  59021. */
  59022. constructor(name: string);
  59023. /**
  59024. * Gets the current class name
  59025. * @returns the class name
  59026. */
  59027. getClassName(): string;
  59028. /**
  59029. * Gets the position input component
  59030. */
  59031. get position(): NodeMaterialConnectionPoint;
  59032. /**
  59033. * Gets the normal input component
  59034. */
  59035. get normal(): NodeMaterialConnectionPoint;
  59036. /**
  59037. * Gets the tangent input component
  59038. */
  59039. get tangent(): NodeMaterialConnectionPoint;
  59040. /**
  59041. * Gets the tangent input component
  59042. */
  59043. get uv(): NodeMaterialConnectionPoint;
  59044. /**
  59045. * Gets the position output component
  59046. */
  59047. get positionOutput(): NodeMaterialConnectionPoint;
  59048. /**
  59049. * Gets the normal output component
  59050. */
  59051. get normalOutput(): NodeMaterialConnectionPoint;
  59052. /**
  59053. * Gets the tangent output component
  59054. */
  59055. get tangentOutput(): NodeMaterialConnectionPoint;
  59056. /**
  59057. * Gets the tangent output component
  59058. */
  59059. get uvOutput(): NodeMaterialConnectionPoint;
  59060. initialize(state: NodeMaterialBuildState): void;
  59061. autoConfigure(material: NodeMaterial): void;
  59062. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59063. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59064. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59065. protected _buildBlock(state: NodeMaterialBuildState): this;
  59066. }
  59067. }
  59068. declare module BABYLON {
  59069. /**
  59070. * Block used to get data information from a light
  59071. */
  59072. export class LightInformationBlock extends NodeMaterialBlock {
  59073. private _lightDataUniformName;
  59074. private _lightColorUniformName;
  59075. private _lightTypeDefineName;
  59076. /**
  59077. * Gets or sets the light associated with this block
  59078. */
  59079. light: Nullable<Light>;
  59080. /**
  59081. * Creates a new LightInformationBlock
  59082. * @param name defines the block name
  59083. */
  59084. constructor(name: string);
  59085. /**
  59086. * Gets the current class name
  59087. * @returns the class name
  59088. */
  59089. getClassName(): string;
  59090. /**
  59091. * Gets the world position input component
  59092. */
  59093. get worldPosition(): NodeMaterialConnectionPoint;
  59094. /**
  59095. * Gets the direction output component
  59096. */
  59097. get direction(): NodeMaterialConnectionPoint;
  59098. /**
  59099. * Gets the direction output component
  59100. */
  59101. get color(): NodeMaterialConnectionPoint;
  59102. /**
  59103. * Gets the direction output component
  59104. */
  59105. get intensity(): NodeMaterialConnectionPoint;
  59106. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59107. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59108. protected _buildBlock(state: NodeMaterialBuildState): this;
  59109. serialize(): any;
  59110. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59111. }
  59112. }
  59113. declare module BABYLON {
  59114. /**
  59115. * Block used to add image processing support to fragment shader
  59116. */
  59117. export class ImageProcessingBlock extends NodeMaterialBlock {
  59118. /**
  59119. * Create a new ImageProcessingBlock
  59120. * @param name defines the block name
  59121. */
  59122. constructor(name: string);
  59123. /**
  59124. * Gets the current class name
  59125. * @returns the class name
  59126. */
  59127. getClassName(): string;
  59128. /**
  59129. * Gets the color input component
  59130. */
  59131. get color(): NodeMaterialConnectionPoint;
  59132. /**
  59133. * Gets the output component
  59134. */
  59135. get output(): NodeMaterialConnectionPoint;
  59136. /**
  59137. * Initialize the block and prepare the context for build
  59138. * @param state defines the state that will be used for the build
  59139. */
  59140. initialize(state: NodeMaterialBuildState): void;
  59141. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59142. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59143. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59144. protected _buildBlock(state: NodeMaterialBuildState): this;
  59145. }
  59146. }
  59147. declare module BABYLON {
  59148. /**
  59149. * Block used to pertub normals based on a normal map
  59150. */
  59151. export class PerturbNormalBlock extends NodeMaterialBlock {
  59152. private _tangentSpaceParameterName;
  59153. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59154. invertX: boolean;
  59155. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59156. invertY: boolean;
  59157. /**
  59158. * Create a new PerturbNormalBlock
  59159. * @param name defines the block name
  59160. */
  59161. constructor(name: string);
  59162. /**
  59163. * Gets the current class name
  59164. * @returns the class name
  59165. */
  59166. getClassName(): string;
  59167. /**
  59168. * Gets the world position input component
  59169. */
  59170. get worldPosition(): NodeMaterialConnectionPoint;
  59171. /**
  59172. * Gets the world normal input component
  59173. */
  59174. get worldNormal(): NodeMaterialConnectionPoint;
  59175. /**
  59176. * Gets the world tangent input component
  59177. */
  59178. get worldTangent(): NodeMaterialConnectionPoint;
  59179. /**
  59180. * Gets the uv input component
  59181. */
  59182. get uv(): NodeMaterialConnectionPoint;
  59183. /**
  59184. * Gets the normal map color input component
  59185. */
  59186. get normalMapColor(): NodeMaterialConnectionPoint;
  59187. /**
  59188. * Gets the strength input component
  59189. */
  59190. get strength(): NodeMaterialConnectionPoint;
  59191. /**
  59192. * Gets the output component
  59193. */
  59194. get output(): NodeMaterialConnectionPoint;
  59195. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59196. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59197. autoConfigure(material: NodeMaterial): void;
  59198. protected _buildBlock(state: NodeMaterialBuildState): this;
  59199. protected _dumpPropertiesCode(): string;
  59200. serialize(): any;
  59201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59202. }
  59203. }
  59204. declare module BABYLON {
  59205. /**
  59206. * Block used to discard a pixel if a value is smaller than a cutoff
  59207. */
  59208. export class DiscardBlock extends NodeMaterialBlock {
  59209. /**
  59210. * Create a new DiscardBlock
  59211. * @param name defines the block name
  59212. */
  59213. constructor(name: string);
  59214. /**
  59215. * Gets the current class name
  59216. * @returns the class name
  59217. */
  59218. getClassName(): string;
  59219. /**
  59220. * Gets the color input component
  59221. */
  59222. get value(): NodeMaterialConnectionPoint;
  59223. /**
  59224. * Gets the cutoff input component
  59225. */
  59226. get cutoff(): NodeMaterialConnectionPoint;
  59227. protected _buildBlock(state: NodeMaterialBuildState): this;
  59228. }
  59229. }
  59230. declare module BABYLON {
  59231. /**
  59232. * Block used to test if the fragment shader is front facing
  59233. */
  59234. export class FrontFacingBlock extends NodeMaterialBlock {
  59235. /**
  59236. * Creates a new FrontFacingBlock
  59237. * @param name defines the block name
  59238. */
  59239. constructor(name: string);
  59240. /**
  59241. * Gets the current class name
  59242. * @returns the class name
  59243. */
  59244. getClassName(): string;
  59245. /**
  59246. * Gets the output component
  59247. */
  59248. get output(): NodeMaterialConnectionPoint;
  59249. protected _buildBlock(state: NodeMaterialBuildState): this;
  59250. }
  59251. }
  59252. declare module BABYLON {
  59253. /**
  59254. * Block used to get the derivative value on x and y of a given input
  59255. */
  59256. export class DerivativeBlock extends NodeMaterialBlock {
  59257. /**
  59258. * Create a new DerivativeBlock
  59259. * @param name defines the block name
  59260. */
  59261. constructor(name: string);
  59262. /**
  59263. * Gets the current class name
  59264. * @returns the class name
  59265. */
  59266. getClassName(): string;
  59267. /**
  59268. * Gets the input component
  59269. */
  59270. get input(): NodeMaterialConnectionPoint;
  59271. /**
  59272. * Gets the derivative output on x
  59273. */
  59274. get dx(): NodeMaterialConnectionPoint;
  59275. /**
  59276. * Gets the derivative output on y
  59277. */
  59278. get dy(): NodeMaterialConnectionPoint;
  59279. protected _buildBlock(state: NodeMaterialBuildState): this;
  59280. }
  59281. }
  59282. declare module BABYLON {
  59283. /**
  59284. * Block used to add support for scene fog
  59285. */
  59286. export class FogBlock extends NodeMaterialBlock {
  59287. private _fogDistanceName;
  59288. private _fogParameters;
  59289. /**
  59290. * Create a new FogBlock
  59291. * @param name defines the block name
  59292. */
  59293. constructor(name: string);
  59294. /**
  59295. * Gets the current class name
  59296. * @returns the class name
  59297. */
  59298. getClassName(): string;
  59299. /**
  59300. * Gets the world position input component
  59301. */
  59302. get worldPosition(): NodeMaterialConnectionPoint;
  59303. /**
  59304. * Gets the view input component
  59305. */
  59306. get view(): NodeMaterialConnectionPoint;
  59307. /**
  59308. * Gets the color input component
  59309. */
  59310. get input(): NodeMaterialConnectionPoint;
  59311. /**
  59312. * Gets the fog color input component
  59313. */
  59314. get fogColor(): NodeMaterialConnectionPoint;
  59315. /**
  59316. * Gets the output component
  59317. */
  59318. get output(): NodeMaterialConnectionPoint;
  59319. autoConfigure(material: NodeMaterial): void;
  59320. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59321. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59322. protected _buildBlock(state: NodeMaterialBuildState): this;
  59323. }
  59324. }
  59325. declare module BABYLON {
  59326. /**
  59327. * Block used to add light in the fragment shader
  59328. */
  59329. export class LightBlock extends NodeMaterialBlock {
  59330. private _lightId;
  59331. /**
  59332. * Gets or sets the light associated with this block
  59333. */
  59334. light: Nullable<Light>;
  59335. /**
  59336. * Create a new LightBlock
  59337. * @param name defines the block name
  59338. */
  59339. constructor(name: string);
  59340. /**
  59341. * Gets the current class name
  59342. * @returns the class name
  59343. */
  59344. getClassName(): string;
  59345. /**
  59346. * Gets the world position input component
  59347. */
  59348. get worldPosition(): NodeMaterialConnectionPoint;
  59349. /**
  59350. * Gets the world normal input component
  59351. */
  59352. get worldNormal(): NodeMaterialConnectionPoint;
  59353. /**
  59354. * Gets the camera (or eye) position component
  59355. */
  59356. get cameraPosition(): NodeMaterialConnectionPoint;
  59357. /**
  59358. * Gets the glossiness component
  59359. */
  59360. get glossiness(): NodeMaterialConnectionPoint;
  59361. /**
  59362. * Gets the glossinness power component
  59363. */
  59364. get glossPower(): NodeMaterialConnectionPoint;
  59365. /**
  59366. * Gets the diffuse color component
  59367. */
  59368. get diffuseColor(): NodeMaterialConnectionPoint;
  59369. /**
  59370. * Gets the specular color component
  59371. */
  59372. get specularColor(): NodeMaterialConnectionPoint;
  59373. /**
  59374. * Gets the diffuse output component
  59375. */
  59376. get diffuseOutput(): NodeMaterialConnectionPoint;
  59377. /**
  59378. * Gets the specular output component
  59379. */
  59380. get specularOutput(): NodeMaterialConnectionPoint;
  59381. /**
  59382. * Gets the shadow output component
  59383. */
  59384. get shadow(): NodeMaterialConnectionPoint;
  59385. autoConfigure(material: NodeMaterial): void;
  59386. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59387. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59388. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59389. private _injectVertexCode;
  59390. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59391. serialize(): any;
  59392. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59393. }
  59394. }
  59395. declare module BABYLON {
  59396. /**
  59397. * Block used to multiply 2 values
  59398. */
  59399. export class MultiplyBlock extends NodeMaterialBlock {
  59400. /**
  59401. * Creates a new MultiplyBlock
  59402. * @param name defines the block name
  59403. */
  59404. constructor(name: string);
  59405. /**
  59406. * Gets the current class name
  59407. * @returns the class name
  59408. */
  59409. getClassName(): string;
  59410. /**
  59411. * Gets the left operand input component
  59412. */
  59413. get left(): NodeMaterialConnectionPoint;
  59414. /**
  59415. * Gets the right operand input component
  59416. */
  59417. get right(): NodeMaterialConnectionPoint;
  59418. /**
  59419. * Gets the output component
  59420. */
  59421. get output(): NodeMaterialConnectionPoint;
  59422. protected _buildBlock(state: NodeMaterialBuildState): this;
  59423. }
  59424. }
  59425. declare module BABYLON {
  59426. /**
  59427. * Block used to add 2 vectors
  59428. */
  59429. export class AddBlock extends NodeMaterialBlock {
  59430. /**
  59431. * Creates a new AddBlock
  59432. * @param name defines the block name
  59433. */
  59434. constructor(name: string);
  59435. /**
  59436. * Gets the current class name
  59437. * @returns the class name
  59438. */
  59439. getClassName(): string;
  59440. /**
  59441. * Gets the left operand input component
  59442. */
  59443. get left(): NodeMaterialConnectionPoint;
  59444. /**
  59445. * Gets the right operand input component
  59446. */
  59447. get right(): NodeMaterialConnectionPoint;
  59448. /**
  59449. * Gets the output component
  59450. */
  59451. get output(): NodeMaterialConnectionPoint;
  59452. protected _buildBlock(state: NodeMaterialBuildState): this;
  59453. }
  59454. }
  59455. declare module BABYLON {
  59456. /**
  59457. * Block used to scale a vector by a float
  59458. */
  59459. export class ScaleBlock extends NodeMaterialBlock {
  59460. /**
  59461. * Creates a new ScaleBlock
  59462. * @param name defines the block name
  59463. */
  59464. constructor(name: string);
  59465. /**
  59466. * Gets the current class name
  59467. * @returns the class name
  59468. */
  59469. getClassName(): string;
  59470. /**
  59471. * Gets the input component
  59472. */
  59473. get input(): NodeMaterialConnectionPoint;
  59474. /**
  59475. * Gets the factor input component
  59476. */
  59477. get factor(): NodeMaterialConnectionPoint;
  59478. /**
  59479. * Gets the output component
  59480. */
  59481. get output(): NodeMaterialConnectionPoint;
  59482. protected _buildBlock(state: NodeMaterialBuildState): this;
  59483. }
  59484. }
  59485. declare module BABYLON {
  59486. /**
  59487. * Block used to clamp a float
  59488. */
  59489. export class ClampBlock extends NodeMaterialBlock {
  59490. /** Gets or sets the minimum range */
  59491. minimum: number;
  59492. /** Gets or sets the maximum range */
  59493. maximum: number;
  59494. /**
  59495. * Creates a new ClampBlock
  59496. * @param name defines the block name
  59497. */
  59498. constructor(name: string);
  59499. /**
  59500. * Gets the current class name
  59501. * @returns the class name
  59502. */
  59503. getClassName(): string;
  59504. /**
  59505. * Gets the value input component
  59506. */
  59507. get value(): NodeMaterialConnectionPoint;
  59508. /**
  59509. * Gets the output component
  59510. */
  59511. get output(): NodeMaterialConnectionPoint;
  59512. protected _buildBlock(state: NodeMaterialBuildState): this;
  59513. protected _dumpPropertiesCode(): string;
  59514. serialize(): any;
  59515. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59516. }
  59517. }
  59518. declare module BABYLON {
  59519. /**
  59520. * Block used to apply a cross product between 2 vectors
  59521. */
  59522. export class CrossBlock extends NodeMaterialBlock {
  59523. /**
  59524. * Creates a new CrossBlock
  59525. * @param name defines the block name
  59526. */
  59527. constructor(name: string);
  59528. /**
  59529. * Gets the current class name
  59530. * @returns the class name
  59531. */
  59532. getClassName(): string;
  59533. /**
  59534. * Gets the left operand input component
  59535. */
  59536. get left(): NodeMaterialConnectionPoint;
  59537. /**
  59538. * Gets the right operand input component
  59539. */
  59540. get right(): NodeMaterialConnectionPoint;
  59541. /**
  59542. * Gets the output component
  59543. */
  59544. get output(): NodeMaterialConnectionPoint;
  59545. protected _buildBlock(state: NodeMaterialBuildState): this;
  59546. }
  59547. }
  59548. declare module BABYLON {
  59549. /**
  59550. * Block used to apply a dot product between 2 vectors
  59551. */
  59552. export class DotBlock extends NodeMaterialBlock {
  59553. /**
  59554. * Creates a new DotBlock
  59555. * @param name defines the block name
  59556. */
  59557. constructor(name: string);
  59558. /**
  59559. * Gets the current class name
  59560. * @returns the class name
  59561. */
  59562. getClassName(): string;
  59563. /**
  59564. * Gets the left operand input component
  59565. */
  59566. get left(): NodeMaterialConnectionPoint;
  59567. /**
  59568. * Gets the right operand input component
  59569. */
  59570. get right(): NodeMaterialConnectionPoint;
  59571. /**
  59572. * Gets the output component
  59573. */
  59574. get output(): NodeMaterialConnectionPoint;
  59575. protected _buildBlock(state: NodeMaterialBuildState): this;
  59576. }
  59577. }
  59578. declare module BABYLON {
  59579. /**
  59580. * Block used to remap a float from a range to a new one
  59581. */
  59582. export class RemapBlock extends NodeMaterialBlock {
  59583. /**
  59584. * Gets or sets the source range
  59585. */
  59586. sourceRange: Vector2;
  59587. /**
  59588. * Gets or sets the target range
  59589. */
  59590. targetRange: Vector2;
  59591. /**
  59592. * Creates a new RemapBlock
  59593. * @param name defines the block name
  59594. */
  59595. constructor(name: string);
  59596. /**
  59597. * Gets the current class name
  59598. * @returns the class name
  59599. */
  59600. getClassName(): string;
  59601. /**
  59602. * Gets the input component
  59603. */
  59604. get input(): NodeMaterialConnectionPoint;
  59605. /**
  59606. * Gets the source min input component
  59607. */
  59608. get sourceMin(): NodeMaterialConnectionPoint;
  59609. /**
  59610. * Gets the source max input component
  59611. */
  59612. get sourceMax(): NodeMaterialConnectionPoint;
  59613. /**
  59614. * Gets the target min input component
  59615. */
  59616. get targetMin(): NodeMaterialConnectionPoint;
  59617. /**
  59618. * Gets the target max input component
  59619. */
  59620. get targetMax(): NodeMaterialConnectionPoint;
  59621. /**
  59622. * Gets the output component
  59623. */
  59624. get output(): NodeMaterialConnectionPoint;
  59625. protected _buildBlock(state: NodeMaterialBuildState): this;
  59626. protected _dumpPropertiesCode(): string;
  59627. serialize(): any;
  59628. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59629. }
  59630. }
  59631. declare module BABYLON {
  59632. /**
  59633. * Block used to normalize a vector
  59634. */
  59635. export class NormalizeBlock extends NodeMaterialBlock {
  59636. /**
  59637. * Creates a new NormalizeBlock
  59638. * @param name defines the block name
  59639. */
  59640. constructor(name: string);
  59641. /**
  59642. * Gets the current class name
  59643. * @returns the class name
  59644. */
  59645. getClassName(): string;
  59646. /**
  59647. * Gets the input component
  59648. */
  59649. get input(): NodeMaterialConnectionPoint;
  59650. /**
  59651. * Gets the output component
  59652. */
  59653. get output(): NodeMaterialConnectionPoint;
  59654. protected _buildBlock(state: NodeMaterialBuildState): this;
  59655. }
  59656. }
  59657. declare module BABYLON {
  59658. /**
  59659. * Operations supported by the Trigonometry block
  59660. */
  59661. export enum TrigonometryBlockOperations {
  59662. /** Cos */
  59663. Cos = 0,
  59664. /** Sin */
  59665. Sin = 1,
  59666. /** Abs */
  59667. Abs = 2,
  59668. /** Exp */
  59669. Exp = 3,
  59670. /** Exp2 */
  59671. Exp2 = 4,
  59672. /** Round */
  59673. Round = 5,
  59674. /** Floor */
  59675. Floor = 6,
  59676. /** Ceiling */
  59677. Ceiling = 7,
  59678. /** Square root */
  59679. Sqrt = 8,
  59680. /** Log */
  59681. Log = 9,
  59682. /** Tangent */
  59683. Tan = 10,
  59684. /** Arc tangent */
  59685. ArcTan = 11,
  59686. /** Arc cosinus */
  59687. ArcCos = 12,
  59688. /** Arc sinus */
  59689. ArcSin = 13,
  59690. /** Fraction */
  59691. Fract = 14,
  59692. /** Sign */
  59693. Sign = 15,
  59694. /** To radians (from degrees) */
  59695. Radians = 16,
  59696. /** To degrees (from radians) */
  59697. Degrees = 17
  59698. }
  59699. /**
  59700. * Block used to apply trigonometry operation to floats
  59701. */
  59702. export class TrigonometryBlock extends NodeMaterialBlock {
  59703. /**
  59704. * Gets or sets the operation applied by the block
  59705. */
  59706. operation: TrigonometryBlockOperations;
  59707. /**
  59708. * Creates a new TrigonometryBlock
  59709. * @param name defines the block name
  59710. */
  59711. constructor(name: string);
  59712. /**
  59713. * Gets the current class name
  59714. * @returns the class name
  59715. */
  59716. getClassName(): string;
  59717. /**
  59718. * Gets the input component
  59719. */
  59720. get input(): NodeMaterialConnectionPoint;
  59721. /**
  59722. * Gets the output component
  59723. */
  59724. get output(): NodeMaterialConnectionPoint;
  59725. protected _buildBlock(state: NodeMaterialBuildState): this;
  59726. serialize(): any;
  59727. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59728. protected _dumpPropertiesCode(): string;
  59729. }
  59730. }
  59731. declare module BABYLON {
  59732. /**
  59733. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59734. */
  59735. export class ColorMergerBlock extends NodeMaterialBlock {
  59736. /**
  59737. * Create a new ColorMergerBlock
  59738. * @param name defines the block name
  59739. */
  59740. constructor(name: string);
  59741. /**
  59742. * Gets the current class name
  59743. * @returns the class name
  59744. */
  59745. getClassName(): string;
  59746. /**
  59747. * Gets the rgb component (input)
  59748. */
  59749. get rgbIn(): NodeMaterialConnectionPoint;
  59750. /**
  59751. * Gets the r component (input)
  59752. */
  59753. get r(): NodeMaterialConnectionPoint;
  59754. /**
  59755. * Gets the g component (input)
  59756. */
  59757. get g(): NodeMaterialConnectionPoint;
  59758. /**
  59759. * Gets the b component (input)
  59760. */
  59761. get b(): NodeMaterialConnectionPoint;
  59762. /**
  59763. * Gets the a component (input)
  59764. */
  59765. get a(): NodeMaterialConnectionPoint;
  59766. /**
  59767. * Gets the rgba component (output)
  59768. */
  59769. get rgba(): NodeMaterialConnectionPoint;
  59770. /**
  59771. * Gets the rgb component (output)
  59772. */
  59773. get rgbOut(): NodeMaterialConnectionPoint;
  59774. /**
  59775. * Gets the rgb component (output)
  59776. * @deprecated Please use rgbOut instead.
  59777. */
  59778. get rgb(): NodeMaterialConnectionPoint;
  59779. protected _buildBlock(state: NodeMaterialBuildState): this;
  59780. }
  59781. }
  59782. declare module BABYLON {
  59783. /**
  59784. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59785. */
  59786. export class VectorMergerBlock extends NodeMaterialBlock {
  59787. /**
  59788. * Create a new VectorMergerBlock
  59789. * @param name defines the block name
  59790. */
  59791. constructor(name: string);
  59792. /**
  59793. * Gets the current class name
  59794. * @returns the class name
  59795. */
  59796. getClassName(): string;
  59797. /**
  59798. * Gets the xyz component (input)
  59799. */
  59800. get xyzIn(): NodeMaterialConnectionPoint;
  59801. /**
  59802. * Gets the xy component (input)
  59803. */
  59804. get xyIn(): NodeMaterialConnectionPoint;
  59805. /**
  59806. * Gets the x component (input)
  59807. */
  59808. get x(): NodeMaterialConnectionPoint;
  59809. /**
  59810. * Gets the y component (input)
  59811. */
  59812. get y(): NodeMaterialConnectionPoint;
  59813. /**
  59814. * Gets the z component (input)
  59815. */
  59816. get z(): NodeMaterialConnectionPoint;
  59817. /**
  59818. * Gets the w component (input)
  59819. */
  59820. get w(): NodeMaterialConnectionPoint;
  59821. /**
  59822. * Gets the xyzw component (output)
  59823. */
  59824. get xyzw(): NodeMaterialConnectionPoint;
  59825. /**
  59826. * Gets the xyz component (output)
  59827. */
  59828. get xyzOut(): NodeMaterialConnectionPoint;
  59829. /**
  59830. * Gets the xy component (output)
  59831. */
  59832. get xyOut(): NodeMaterialConnectionPoint;
  59833. /**
  59834. * Gets the xy component (output)
  59835. * @deprecated Please use xyOut instead.
  59836. */
  59837. get xy(): NodeMaterialConnectionPoint;
  59838. /**
  59839. * Gets the xyz component (output)
  59840. * @deprecated Please use xyzOut instead.
  59841. */
  59842. get xyz(): NodeMaterialConnectionPoint;
  59843. protected _buildBlock(state: NodeMaterialBuildState): this;
  59844. }
  59845. }
  59846. declare module BABYLON {
  59847. /**
  59848. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59849. */
  59850. export class ColorSplitterBlock extends NodeMaterialBlock {
  59851. /**
  59852. * Create a new ColorSplitterBlock
  59853. * @param name defines the block name
  59854. */
  59855. constructor(name: string);
  59856. /**
  59857. * Gets the current class name
  59858. * @returns the class name
  59859. */
  59860. getClassName(): string;
  59861. /**
  59862. * Gets the rgba component (input)
  59863. */
  59864. get rgba(): NodeMaterialConnectionPoint;
  59865. /**
  59866. * Gets the rgb component (input)
  59867. */
  59868. get rgbIn(): NodeMaterialConnectionPoint;
  59869. /**
  59870. * Gets the rgb component (output)
  59871. */
  59872. get rgbOut(): NodeMaterialConnectionPoint;
  59873. /**
  59874. * Gets the r component (output)
  59875. */
  59876. get r(): NodeMaterialConnectionPoint;
  59877. /**
  59878. * Gets the g component (output)
  59879. */
  59880. get g(): NodeMaterialConnectionPoint;
  59881. /**
  59882. * Gets the b component (output)
  59883. */
  59884. get b(): NodeMaterialConnectionPoint;
  59885. /**
  59886. * Gets the a component (output)
  59887. */
  59888. get a(): NodeMaterialConnectionPoint;
  59889. protected _inputRename(name: string): string;
  59890. protected _outputRename(name: string): string;
  59891. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59892. }
  59893. }
  59894. declare module BABYLON {
  59895. /**
  59896. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59897. */
  59898. export class VectorSplitterBlock extends NodeMaterialBlock {
  59899. /**
  59900. * Create a new VectorSplitterBlock
  59901. * @param name defines the block name
  59902. */
  59903. constructor(name: string);
  59904. /**
  59905. * Gets the current class name
  59906. * @returns the class name
  59907. */
  59908. getClassName(): string;
  59909. /**
  59910. * Gets the xyzw component (input)
  59911. */
  59912. get xyzw(): NodeMaterialConnectionPoint;
  59913. /**
  59914. * Gets the xyz component (input)
  59915. */
  59916. get xyzIn(): NodeMaterialConnectionPoint;
  59917. /**
  59918. * Gets the xy component (input)
  59919. */
  59920. get xyIn(): NodeMaterialConnectionPoint;
  59921. /**
  59922. * Gets the xyz component (output)
  59923. */
  59924. get xyzOut(): NodeMaterialConnectionPoint;
  59925. /**
  59926. * Gets the xy component (output)
  59927. */
  59928. get xyOut(): NodeMaterialConnectionPoint;
  59929. /**
  59930. * Gets the x component (output)
  59931. */
  59932. get x(): NodeMaterialConnectionPoint;
  59933. /**
  59934. * Gets the y component (output)
  59935. */
  59936. get y(): NodeMaterialConnectionPoint;
  59937. /**
  59938. * Gets the z component (output)
  59939. */
  59940. get z(): NodeMaterialConnectionPoint;
  59941. /**
  59942. * Gets the w component (output)
  59943. */
  59944. get w(): NodeMaterialConnectionPoint;
  59945. protected _inputRename(name: string): string;
  59946. protected _outputRename(name: string): string;
  59947. protected _buildBlock(state: NodeMaterialBuildState): this;
  59948. }
  59949. }
  59950. declare module BABYLON {
  59951. /**
  59952. * Block used to lerp between 2 values
  59953. */
  59954. export class LerpBlock extends NodeMaterialBlock {
  59955. /**
  59956. * Creates a new LerpBlock
  59957. * @param name defines the block name
  59958. */
  59959. constructor(name: string);
  59960. /**
  59961. * Gets the current class name
  59962. * @returns the class name
  59963. */
  59964. getClassName(): string;
  59965. /**
  59966. * Gets the left operand input component
  59967. */
  59968. get left(): NodeMaterialConnectionPoint;
  59969. /**
  59970. * Gets the right operand input component
  59971. */
  59972. get right(): NodeMaterialConnectionPoint;
  59973. /**
  59974. * Gets the gradient operand input component
  59975. */
  59976. get gradient(): NodeMaterialConnectionPoint;
  59977. /**
  59978. * Gets the output component
  59979. */
  59980. get output(): NodeMaterialConnectionPoint;
  59981. protected _buildBlock(state: NodeMaterialBuildState): this;
  59982. }
  59983. }
  59984. declare module BABYLON {
  59985. /**
  59986. * Block used to divide 2 vectors
  59987. */
  59988. export class DivideBlock extends NodeMaterialBlock {
  59989. /**
  59990. * Creates a new DivideBlock
  59991. * @param name defines the block name
  59992. */
  59993. constructor(name: string);
  59994. /**
  59995. * Gets the current class name
  59996. * @returns the class name
  59997. */
  59998. getClassName(): string;
  59999. /**
  60000. * Gets the left operand input component
  60001. */
  60002. get left(): NodeMaterialConnectionPoint;
  60003. /**
  60004. * Gets the right operand input component
  60005. */
  60006. get right(): NodeMaterialConnectionPoint;
  60007. /**
  60008. * Gets the output component
  60009. */
  60010. get output(): NodeMaterialConnectionPoint;
  60011. protected _buildBlock(state: NodeMaterialBuildState): this;
  60012. }
  60013. }
  60014. declare module BABYLON {
  60015. /**
  60016. * Block used to subtract 2 vectors
  60017. */
  60018. export class SubtractBlock extends NodeMaterialBlock {
  60019. /**
  60020. * Creates a new SubtractBlock
  60021. * @param name defines the block name
  60022. */
  60023. constructor(name: string);
  60024. /**
  60025. * Gets the current class name
  60026. * @returns the class name
  60027. */
  60028. getClassName(): string;
  60029. /**
  60030. * Gets the left operand input component
  60031. */
  60032. get left(): NodeMaterialConnectionPoint;
  60033. /**
  60034. * Gets the right operand input component
  60035. */
  60036. get right(): NodeMaterialConnectionPoint;
  60037. /**
  60038. * Gets the output component
  60039. */
  60040. get output(): NodeMaterialConnectionPoint;
  60041. protected _buildBlock(state: NodeMaterialBuildState): this;
  60042. }
  60043. }
  60044. declare module BABYLON {
  60045. /**
  60046. * Block used to step a value
  60047. */
  60048. export class StepBlock extends NodeMaterialBlock {
  60049. /**
  60050. * Creates a new StepBlock
  60051. * @param name defines the block name
  60052. */
  60053. constructor(name: string);
  60054. /**
  60055. * Gets the current class name
  60056. * @returns the class name
  60057. */
  60058. getClassName(): string;
  60059. /**
  60060. * Gets the value operand input component
  60061. */
  60062. get value(): NodeMaterialConnectionPoint;
  60063. /**
  60064. * Gets the edge operand input component
  60065. */
  60066. get edge(): NodeMaterialConnectionPoint;
  60067. /**
  60068. * Gets the output component
  60069. */
  60070. get output(): NodeMaterialConnectionPoint;
  60071. protected _buildBlock(state: NodeMaterialBuildState): this;
  60072. }
  60073. }
  60074. declare module BABYLON {
  60075. /**
  60076. * Block used to get the opposite (1 - x) of a value
  60077. */
  60078. export class OneMinusBlock extends NodeMaterialBlock {
  60079. /**
  60080. * Creates a new OneMinusBlock
  60081. * @param name defines the block name
  60082. */
  60083. constructor(name: string);
  60084. /**
  60085. * Gets the current class name
  60086. * @returns the class name
  60087. */
  60088. getClassName(): string;
  60089. /**
  60090. * Gets the input component
  60091. */
  60092. get input(): NodeMaterialConnectionPoint;
  60093. /**
  60094. * Gets the output component
  60095. */
  60096. get output(): NodeMaterialConnectionPoint;
  60097. protected _buildBlock(state: NodeMaterialBuildState): this;
  60098. }
  60099. }
  60100. declare module BABYLON {
  60101. /**
  60102. * Block used to get the view direction
  60103. */
  60104. export class ViewDirectionBlock extends NodeMaterialBlock {
  60105. /**
  60106. * Creates a new ViewDirectionBlock
  60107. * @param name defines the block name
  60108. */
  60109. constructor(name: string);
  60110. /**
  60111. * Gets the current class name
  60112. * @returns the class name
  60113. */
  60114. getClassName(): string;
  60115. /**
  60116. * Gets the world position component
  60117. */
  60118. get worldPosition(): NodeMaterialConnectionPoint;
  60119. /**
  60120. * Gets the camera position component
  60121. */
  60122. get cameraPosition(): NodeMaterialConnectionPoint;
  60123. /**
  60124. * Gets the output component
  60125. */
  60126. get output(): NodeMaterialConnectionPoint;
  60127. autoConfigure(material: NodeMaterial): void;
  60128. protected _buildBlock(state: NodeMaterialBuildState): this;
  60129. }
  60130. }
  60131. declare module BABYLON {
  60132. /**
  60133. * Block used to compute fresnel value
  60134. */
  60135. export class FresnelBlock extends NodeMaterialBlock {
  60136. /**
  60137. * Create a new FresnelBlock
  60138. * @param name defines the block name
  60139. */
  60140. constructor(name: string);
  60141. /**
  60142. * Gets the current class name
  60143. * @returns the class name
  60144. */
  60145. getClassName(): string;
  60146. /**
  60147. * Gets the world normal input component
  60148. */
  60149. get worldNormal(): NodeMaterialConnectionPoint;
  60150. /**
  60151. * Gets the view direction input component
  60152. */
  60153. get viewDirection(): NodeMaterialConnectionPoint;
  60154. /**
  60155. * Gets the bias input component
  60156. */
  60157. get bias(): NodeMaterialConnectionPoint;
  60158. /**
  60159. * Gets the camera (or eye) position component
  60160. */
  60161. get power(): NodeMaterialConnectionPoint;
  60162. /**
  60163. * Gets the fresnel output component
  60164. */
  60165. get fresnel(): NodeMaterialConnectionPoint;
  60166. autoConfigure(material: NodeMaterial): void;
  60167. protected _buildBlock(state: NodeMaterialBuildState): this;
  60168. }
  60169. }
  60170. declare module BABYLON {
  60171. /**
  60172. * Block used to get the max of 2 values
  60173. */
  60174. export class MaxBlock extends NodeMaterialBlock {
  60175. /**
  60176. * Creates a new MaxBlock
  60177. * @param name defines the block name
  60178. */
  60179. constructor(name: string);
  60180. /**
  60181. * Gets the current class name
  60182. * @returns the class name
  60183. */
  60184. getClassName(): string;
  60185. /**
  60186. * Gets the left operand input component
  60187. */
  60188. get left(): NodeMaterialConnectionPoint;
  60189. /**
  60190. * Gets the right operand input component
  60191. */
  60192. get right(): NodeMaterialConnectionPoint;
  60193. /**
  60194. * Gets the output component
  60195. */
  60196. get output(): NodeMaterialConnectionPoint;
  60197. protected _buildBlock(state: NodeMaterialBuildState): this;
  60198. }
  60199. }
  60200. declare module BABYLON {
  60201. /**
  60202. * Block used to get the min of 2 values
  60203. */
  60204. export class MinBlock extends NodeMaterialBlock {
  60205. /**
  60206. * Creates a new MinBlock
  60207. * @param name defines the block name
  60208. */
  60209. constructor(name: string);
  60210. /**
  60211. * Gets the current class name
  60212. * @returns the class name
  60213. */
  60214. getClassName(): string;
  60215. /**
  60216. * Gets the left operand input component
  60217. */
  60218. get left(): NodeMaterialConnectionPoint;
  60219. /**
  60220. * Gets the right operand input component
  60221. */
  60222. get right(): NodeMaterialConnectionPoint;
  60223. /**
  60224. * Gets the output component
  60225. */
  60226. get output(): NodeMaterialConnectionPoint;
  60227. protected _buildBlock(state: NodeMaterialBuildState): this;
  60228. }
  60229. }
  60230. declare module BABYLON {
  60231. /**
  60232. * Block used to get the distance between 2 values
  60233. */
  60234. export class DistanceBlock extends NodeMaterialBlock {
  60235. /**
  60236. * Creates a new DistanceBlock
  60237. * @param name defines the block name
  60238. */
  60239. constructor(name: string);
  60240. /**
  60241. * Gets the current class name
  60242. * @returns the class name
  60243. */
  60244. getClassName(): string;
  60245. /**
  60246. * Gets the left operand input component
  60247. */
  60248. get left(): NodeMaterialConnectionPoint;
  60249. /**
  60250. * Gets the right operand input component
  60251. */
  60252. get right(): NodeMaterialConnectionPoint;
  60253. /**
  60254. * Gets the output component
  60255. */
  60256. get output(): NodeMaterialConnectionPoint;
  60257. protected _buildBlock(state: NodeMaterialBuildState): this;
  60258. }
  60259. }
  60260. declare module BABYLON {
  60261. /**
  60262. * Block used to get the length of a vector
  60263. */
  60264. export class LengthBlock extends NodeMaterialBlock {
  60265. /**
  60266. * Creates a new LengthBlock
  60267. * @param name defines the block name
  60268. */
  60269. constructor(name: string);
  60270. /**
  60271. * Gets the current class name
  60272. * @returns the class name
  60273. */
  60274. getClassName(): string;
  60275. /**
  60276. * Gets the value input component
  60277. */
  60278. get value(): NodeMaterialConnectionPoint;
  60279. /**
  60280. * Gets the output component
  60281. */
  60282. get output(): NodeMaterialConnectionPoint;
  60283. protected _buildBlock(state: NodeMaterialBuildState): this;
  60284. }
  60285. }
  60286. declare module BABYLON {
  60287. /**
  60288. * Block used to get negative version of a value (i.e. x * -1)
  60289. */
  60290. export class NegateBlock extends NodeMaterialBlock {
  60291. /**
  60292. * Creates a new NegateBlock
  60293. * @param name defines the block name
  60294. */
  60295. constructor(name: string);
  60296. /**
  60297. * Gets the current class name
  60298. * @returns the class name
  60299. */
  60300. getClassName(): string;
  60301. /**
  60302. * Gets the value input component
  60303. */
  60304. get value(): NodeMaterialConnectionPoint;
  60305. /**
  60306. * Gets the output component
  60307. */
  60308. get output(): NodeMaterialConnectionPoint;
  60309. protected _buildBlock(state: NodeMaterialBuildState): this;
  60310. }
  60311. }
  60312. declare module BABYLON {
  60313. /**
  60314. * Block used to get the value of the first parameter raised to the power of the second
  60315. */
  60316. export class PowBlock extends NodeMaterialBlock {
  60317. /**
  60318. * Creates a new PowBlock
  60319. * @param name defines the block name
  60320. */
  60321. constructor(name: string);
  60322. /**
  60323. * Gets the current class name
  60324. * @returns the class name
  60325. */
  60326. getClassName(): string;
  60327. /**
  60328. * Gets the value operand input component
  60329. */
  60330. get value(): NodeMaterialConnectionPoint;
  60331. /**
  60332. * Gets the power operand input component
  60333. */
  60334. get power(): NodeMaterialConnectionPoint;
  60335. /**
  60336. * Gets the output component
  60337. */
  60338. get output(): NodeMaterialConnectionPoint;
  60339. protected _buildBlock(state: NodeMaterialBuildState): this;
  60340. }
  60341. }
  60342. declare module BABYLON {
  60343. /**
  60344. * Block used to get a random number
  60345. */
  60346. export class RandomNumberBlock extends NodeMaterialBlock {
  60347. /**
  60348. * Creates a new RandomNumberBlock
  60349. * @param name defines the block name
  60350. */
  60351. constructor(name: string);
  60352. /**
  60353. * Gets the current class name
  60354. * @returns the class name
  60355. */
  60356. getClassName(): string;
  60357. /**
  60358. * Gets the seed input component
  60359. */
  60360. get seed(): NodeMaterialConnectionPoint;
  60361. /**
  60362. * Gets the output component
  60363. */
  60364. get output(): NodeMaterialConnectionPoint;
  60365. protected _buildBlock(state: NodeMaterialBuildState): this;
  60366. }
  60367. }
  60368. declare module BABYLON {
  60369. /**
  60370. * Block used to compute arc tangent of 2 values
  60371. */
  60372. export class ArcTan2Block extends NodeMaterialBlock {
  60373. /**
  60374. * Creates a new ArcTan2Block
  60375. * @param name defines the block name
  60376. */
  60377. constructor(name: string);
  60378. /**
  60379. * Gets the current class name
  60380. * @returns the class name
  60381. */
  60382. getClassName(): string;
  60383. /**
  60384. * Gets the x operand input component
  60385. */
  60386. get x(): NodeMaterialConnectionPoint;
  60387. /**
  60388. * Gets the y operand input component
  60389. */
  60390. get y(): NodeMaterialConnectionPoint;
  60391. /**
  60392. * Gets the output component
  60393. */
  60394. get output(): NodeMaterialConnectionPoint;
  60395. protected _buildBlock(state: NodeMaterialBuildState): this;
  60396. }
  60397. }
  60398. declare module BABYLON {
  60399. /**
  60400. * Block used to smooth step a value
  60401. */
  60402. export class SmoothStepBlock extends NodeMaterialBlock {
  60403. /**
  60404. * Creates a new SmoothStepBlock
  60405. * @param name defines the block name
  60406. */
  60407. constructor(name: string);
  60408. /**
  60409. * Gets the current class name
  60410. * @returns the class name
  60411. */
  60412. getClassName(): string;
  60413. /**
  60414. * Gets the value operand input component
  60415. */
  60416. get value(): NodeMaterialConnectionPoint;
  60417. /**
  60418. * Gets the first edge operand input component
  60419. */
  60420. get edge0(): NodeMaterialConnectionPoint;
  60421. /**
  60422. * Gets the second edge operand input component
  60423. */
  60424. get edge1(): NodeMaterialConnectionPoint;
  60425. /**
  60426. * Gets the output component
  60427. */
  60428. get output(): NodeMaterialConnectionPoint;
  60429. protected _buildBlock(state: NodeMaterialBuildState): this;
  60430. }
  60431. }
  60432. declare module BABYLON {
  60433. /**
  60434. * Block used to get the reciprocal (1 / x) of a value
  60435. */
  60436. export class ReciprocalBlock extends NodeMaterialBlock {
  60437. /**
  60438. * Creates a new ReciprocalBlock
  60439. * @param name defines the block name
  60440. */
  60441. constructor(name: string);
  60442. /**
  60443. * Gets the current class name
  60444. * @returns the class name
  60445. */
  60446. getClassName(): string;
  60447. /**
  60448. * Gets the input component
  60449. */
  60450. get input(): NodeMaterialConnectionPoint;
  60451. /**
  60452. * Gets the output component
  60453. */
  60454. get output(): NodeMaterialConnectionPoint;
  60455. protected _buildBlock(state: NodeMaterialBuildState): this;
  60456. }
  60457. }
  60458. declare module BABYLON {
  60459. /**
  60460. * Block used to replace a color by another one
  60461. */
  60462. export class ReplaceColorBlock extends NodeMaterialBlock {
  60463. /**
  60464. * Creates a new ReplaceColorBlock
  60465. * @param name defines the block name
  60466. */
  60467. constructor(name: string);
  60468. /**
  60469. * Gets the current class name
  60470. * @returns the class name
  60471. */
  60472. getClassName(): string;
  60473. /**
  60474. * Gets the value input component
  60475. */
  60476. get value(): NodeMaterialConnectionPoint;
  60477. /**
  60478. * Gets the reference input component
  60479. */
  60480. get reference(): NodeMaterialConnectionPoint;
  60481. /**
  60482. * Gets the distance input component
  60483. */
  60484. get distance(): NodeMaterialConnectionPoint;
  60485. /**
  60486. * Gets the replacement input component
  60487. */
  60488. get replacement(): NodeMaterialConnectionPoint;
  60489. /**
  60490. * Gets the output component
  60491. */
  60492. get output(): NodeMaterialConnectionPoint;
  60493. protected _buildBlock(state: NodeMaterialBuildState): this;
  60494. }
  60495. }
  60496. declare module BABYLON {
  60497. /**
  60498. * Block used to posterize a value
  60499. * @see https://en.wikipedia.org/wiki/Posterization
  60500. */
  60501. export class PosterizeBlock extends NodeMaterialBlock {
  60502. /**
  60503. * Creates a new PosterizeBlock
  60504. * @param name defines the block name
  60505. */
  60506. constructor(name: string);
  60507. /**
  60508. * Gets the current class name
  60509. * @returns the class name
  60510. */
  60511. getClassName(): string;
  60512. /**
  60513. * Gets the value input component
  60514. */
  60515. get value(): NodeMaterialConnectionPoint;
  60516. /**
  60517. * Gets the steps input component
  60518. */
  60519. get steps(): NodeMaterialConnectionPoint;
  60520. /**
  60521. * Gets the output component
  60522. */
  60523. get output(): NodeMaterialConnectionPoint;
  60524. protected _buildBlock(state: NodeMaterialBuildState): this;
  60525. }
  60526. }
  60527. declare module BABYLON {
  60528. /**
  60529. * Operations supported by the Wave block
  60530. */
  60531. export enum WaveBlockKind {
  60532. /** SawTooth */
  60533. SawTooth = 0,
  60534. /** Square */
  60535. Square = 1,
  60536. /** Triangle */
  60537. Triangle = 2
  60538. }
  60539. /**
  60540. * Block used to apply wave operation to floats
  60541. */
  60542. export class WaveBlock extends NodeMaterialBlock {
  60543. /**
  60544. * Gets or sets the kibnd of wave to be applied by the block
  60545. */
  60546. kind: WaveBlockKind;
  60547. /**
  60548. * Creates a new WaveBlock
  60549. * @param name defines the block name
  60550. */
  60551. constructor(name: string);
  60552. /**
  60553. * Gets the current class name
  60554. * @returns the class name
  60555. */
  60556. getClassName(): string;
  60557. /**
  60558. * Gets the input component
  60559. */
  60560. get input(): NodeMaterialConnectionPoint;
  60561. /**
  60562. * Gets the output component
  60563. */
  60564. get output(): NodeMaterialConnectionPoint;
  60565. protected _buildBlock(state: NodeMaterialBuildState): this;
  60566. serialize(): any;
  60567. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60568. }
  60569. }
  60570. declare module BABYLON {
  60571. /**
  60572. * Class used to store a color step for the GradientBlock
  60573. */
  60574. export class GradientBlockColorStep {
  60575. /**
  60576. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60577. */
  60578. step: number;
  60579. /**
  60580. * Gets or sets the color associated with this step
  60581. */
  60582. color: Color3;
  60583. /**
  60584. * Creates a new GradientBlockColorStep
  60585. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60586. * @param color defines the color associated with this step
  60587. */
  60588. constructor(
  60589. /**
  60590. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60591. */
  60592. step: number,
  60593. /**
  60594. * Gets or sets the color associated with this step
  60595. */
  60596. color: Color3);
  60597. }
  60598. /**
  60599. * Block used to return a color from a gradient based on an input value between 0 and 1
  60600. */
  60601. export class GradientBlock extends NodeMaterialBlock {
  60602. /**
  60603. * Gets or sets the list of color steps
  60604. */
  60605. colorSteps: GradientBlockColorStep[];
  60606. /**
  60607. * Creates a new GradientBlock
  60608. * @param name defines the block name
  60609. */
  60610. constructor(name: string);
  60611. /**
  60612. * Gets the current class name
  60613. * @returns the class name
  60614. */
  60615. getClassName(): string;
  60616. /**
  60617. * Gets the gradient input component
  60618. */
  60619. get gradient(): NodeMaterialConnectionPoint;
  60620. /**
  60621. * Gets the output component
  60622. */
  60623. get output(): NodeMaterialConnectionPoint;
  60624. private _writeColorConstant;
  60625. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60626. serialize(): any;
  60627. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60628. protected _dumpPropertiesCode(): string;
  60629. }
  60630. }
  60631. declare module BABYLON {
  60632. /**
  60633. * Block used to normalize lerp between 2 values
  60634. */
  60635. export class NLerpBlock extends NodeMaterialBlock {
  60636. /**
  60637. * Creates a new NLerpBlock
  60638. * @param name defines the block name
  60639. */
  60640. constructor(name: string);
  60641. /**
  60642. * Gets the current class name
  60643. * @returns the class name
  60644. */
  60645. getClassName(): string;
  60646. /**
  60647. * Gets the left operand input component
  60648. */
  60649. get left(): NodeMaterialConnectionPoint;
  60650. /**
  60651. * Gets the right operand input component
  60652. */
  60653. get right(): NodeMaterialConnectionPoint;
  60654. /**
  60655. * Gets the gradient operand input component
  60656. */
  60657. get gradient(): NodeMaterialConnectionPoint;
  60658. /**
  60659. * Gets the output component
  60660. */
  60661. get output(): NodeMaterialConnectionPoint;
  60662. protected _buildBlock(state: NodeMaterialBuildState): this;
  60663. }
  60664. }
  60665. declare module BABYLON {
  60666. /**
  60667. * block used to Generate a Worley Noise 3D Noise Pattern
  60668. */
  60669. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60670. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60671. manhattanDistance: boolean;
  60672. /**
  60673. * Creates a new WorleyNoise3DBlock
  60674. * @param name defines the block name
  60675. */
  60676. constructor(name: string);
  60677. /**
  60678. * Gets the current class name
  60679. * @returns the class name
  60680. */
  60681. getClassName(): string;
  60682. /**
  60683. * Gets the seed input component
  60684. */
  60685. get seed(): NodeMaterialConnectionPoint;
  60686. /**
  60687. * Gets the jitter input component
  60688. */
  60689. get jitter(): NodeMaterialConnectionPoint;
  60690. /**
  60691. * Gets the output component
  60692. */
  60693. get output(): NodeMaterialConnectionPoint;
  60694. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60695. /**
  60696. * Exposes the properties to the UI?
  60697. */
  60698. protected _dumpPropertiesCode(): string;
  60699. /**
  60700. * Exposes the properties to the Seralize?
  60701. */
  60702. serialize(): any;
  60703. /**
  60704. * Exposes the properties to the deseralize?
  60705. */
  60706. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60707. }
  60708. }
  60709. declare module BABYLON {
  60710. /**
  60711. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60712. */
  60713. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60714. /**
  60715. * Creates a new SimplexPerlin3DBlock
  60716. * @param name defines the block name
  60717. */
  60718. constructor(name: string);
  60719. /**
  60720. * Gets the current class name
  60721. * @returns the class name
  60722. */
  60723. getClassName(): string;
  60724. /**
  60725. * Gets the seed operand input component
  60726. */
  60727. get seed(): NodeMaterialConnectionPoint;
  60728. /**
  60729. * Gets the output component
  60730. */
  60731. get output(): NodeMaterialConnectionPoint;
  60732. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60733. }
  60734. }
  60735. declare module BABYLON {
  60736. /**
  60737. * Block used to blend normals
  60738. */
  60739. export class NormalBlendBlock extends NodeMaterialBlock {
  60740. /**
  60741. * Creates a new NormalBlendBlock
  60742. * @param name defines the block name
  60743. */
  60744. constructor(name: string);
  60745. /**
  60746. * Gets the current class name
  60747. * @returns the class name
  60748. */
  60749. getClassName(): string;
  60750. /**
  60751. * Gets the first input component
  60752. */
  60753. get normalMap0(): NodeMaterialConnectionPoint;
  60754. /**
  60755. * Gets the second input component
  60756. */
  60757. get normalMap1(): NodeMaterialConnectionPoint;
  60758. /**
  60759. * Gets the output component
  60760. */
  60761. get output(): NodeMaterialConnectionPoint;
  60762. protected _buildBlock(state: NodeMaterialBuildState): this;
  60763. }
  60764. }
  60765. declare module BABYLON {
  60766. /**
  60767. * Block used to rotate a 2d vector by a given angle
  60768. */
  60769. export class Rotate2dBlock extends NodeMaterialBlock {
  60770. /**
  60771. * Creates a new Rotate2dBlock
  60772. * @param name defines the block name
  60773. */
  60774. constructor(name: string);
  60775. /**
  60776. * Gets the current class name
  60777. * @returns the class name
  60778. */
  60779. getClassName(): string;
  60780. /**
  60781. * Gets the input vector
  60782. */
  60783. get input(): NodeMaterialConnectionPoint;
  60784. /**
  60785. * Gets the input angle
  60786. */
  60787. get angle(): NodeMaterialConnectionPoint;
  60788. /**
  60789. * Gets the output component
  60790. */
  60791. get output(): NodeMaterialConnectionPoint;
  60792. autoConfigure(material: NodeMaterial): void;
  60793. protected _buildBlock(state: NodeMaterialBuildState): this;
  60794. }
  60795. }
  60796. declare module BABYLON {
  60797. /**
  60798. * Block used to get the reflected vector from a direction and a normal
  60799. */
  60800. export class ReflectBlock extends NodeMaterialBlock {
  60801. /**
  60802. * Creates a new ReflectBlock
  60803. * @param name defines the block name
  60804. */
  60805. constructor(name: string);
  60806. /**
  60807. * Gets the current class name
  60808. * @returns the class name
  60809. */
  60810. getClassName(): string;
  60811. /**
  60812. * Gets the incident component
  60813. */
  60814. get incident(): NodeMaterialConnectionPoint;
  60815. /**
  60816. * Gets the normal component
  60817. */
  60818. get normal(): NodeMaterialConnectionPoint;
  60819. /**
  60820. * Gets the output component
  60821. */
  60822. get output(): NodeMaterialConnectionPoint;
  60823. protected _buildBlock(state: NodeMaterialBuildState): this;
  60824. }
  60825. }
  60826. declare module BABYLON {
  60827. /**
  60828. * Block used to get the refracted vector from a direction and a normal
  60829. */
  60830. export class RefractBlock extends NodeMaterialBlock {
  60831. /**
  60832. * Creates a new RefractBlock
  60833. * @param name defines the block name
  60834. */
  60835. constructor(name: string);
  60836. /**
  60837. * Gets the current class name
  60838. * @returns the class name
  60839. */
  60840. getClassName(): string;
  60841. /**
  60842. * Gets the incident component
  60843. */
  60844. get incident(): NodeMaterialConnectionPoint;
  60845. /**
  60846. * Gets the normal component
  60847. */
  60848. get normal(): NodeMaterialConnectionPoint;
  60849. /**
  60850. * Gets the index of refraction component
  60851. */
  60852. get ior(): NodeMaterialConnectionPoint;
  60853. /**
  60854. * Gets the output component
  60855. */
  60856. get output(): NodeMaterialConnectionPoint;
  60857. protected _buildBlock(state: NodeMaterialBuildState): this;
  60858. }
  60859. }
  60860. declare module BABYLON {
  60861. /**
  60862. * Block used to desaturate a color
  60863. */
  60864. export class DesaturateBlock extends NodeMaterialBlock {
  60865. /**
  60866. * Creates a new DesaturateBlock
  60867. * @param name defines the block name
  60868. */
  60869. constructor(name: string);
  60870. /**
  60871. * Gets the current class name
  60872. * @returns the class name
  60873. */
  60874. getClassName(): string;
  60875. /**
  60876. * Gets the color operand input component
  60877. */
  60878. get color(): NodeMaterialConnectionPoint;
  60879. /**
  60880. * Gets the level operand input component
  60881. */
  60882. get level(): NodeMaterialConnectionPoint;
  60883. /**
  60884. * Gets the output component
  60885. */
  60886. get output(): NodeMaterialConnectionPoint;
  60887. protected _buildBlock(state: NodeMaterialBuildState): this;
  60888. }
  60889. }
  60890. declare module BABYLON {
  60891. /**
  60892. * Effect Render Options
  60893. */
  60894. export interface IEffectRendererOptions {
  60895. /**
  60896. * Defines the vertices positions.
  60897. */
  60898. positions?: number[];
  60899. /**
  60900. * Defines the indices.
  60901. */
  60902. indices?: number[];
  60903. }
  60904. /**
  60905. * Helper class to render one or more effects.
  60906. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60907. */
  60908. export class EffectRenderer {
  60909. private engine;
  60910. private static _DefaultOptions;
  60911. private _vertexBuffers;
  60912. private _indexBuffer;
  60913. private _fullscreenViewport;
  60914. /**
  60915. * Creates an effect renderer
  60916. * @param engine the engine to use for rendering
  60917. * @param options defines the options of the effect renderer
  60918. */
  60919. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60920. /**
  60921. * Sets the current viewport in normalized coordinates 0-1
  60922. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60923. */
  60924. setViewport(viewport?: Viewport): void;
  60925. /**
  60926. * Binds the embedded attributes buffer to the effect.
  60927. * @param effect Defines the effect to bind the attributes for
  60928. */
  60929. bindBuffers(effect: Effect): void;
  60930. /**
  60931. * Sets the current effect wrapper to use during draw.
  60932. * The effect needs to be ready before calling this api.
  60933. * This also sets the default full screen position attribute.
  60934. * @param effectWrapper Defines the effect to draw with
  60935. */
  60936. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60937. /**
  60938. * Draws a full screen quad.
  60939. */
  60940. draw(): void;
  60941. private isRenderTargetTexture;
  60942. /**
  60943. * renders one or more effects to a specified texture
  60944. * @param effectWrapper the effect to renderer
  60945. * @param outputTexture texture to draw to, if null it will render to the screen.
  60946. */
  60947. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60948. /**
  60949. * Disposes of the effect renderer
  60950. */
  60951. dispose(): void;
  60952. }
  60953. /**
  60954. * Options to create an EffectWrapper
  60955. */
  60956. interface EffectWrapperCreationOptions {
  60957. /**
  60958. * Engine to use to create the effect
  60959. */
  60960. engine: ThinEngine;
  60961. /**
  60962. * Fragment shader for the effect
  60963. */
  60964. fragmentShader: string;
  60965. /**
  60966. * Vertex shader for the effect
  60967. */
  60968. vertexShader?: string;
  60969. /**
  60970. * Attributes to use in the shader
  60971. */
  60972. attributeNames?: Array<string>;
  60973. /**
  60974. * Uniforms to use in the shader
  60975. */
  60976. uniformNames?: Array<string>;
  60977. /**
  60978. * Texture sampler names to use in the shader
  60979. */
  60980. samplerNames?: Array<string>;
  60981. /**
  60982. * The friendly name of the effect displayed in Spector.
  60983. */
  60984. name?: string;
  60985. }
  60986. /**
  60987. * Wraps an effect to be used for rendering
  60988. */
  60989. export class EffectWrapper {
  60990. /**
  60991. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60992. */
  60993. onApplyObservable: Observable<{}>;
  60994. /**
  60995. * The underlying effect
  60996. */
  60997. effect: Effect;
  60998. /**
  60999. * Creates an effect to be renderer
  61000. * @param creationOptions options to create the effect
  61001. */
  61002. constructor(creationOptions: EffectWrapperCreationOptions);
  61003. /**
  61004. * Disposes of the effect wrapper
  61005. */
  61006. dispose(): void;
  61007. }
  61008. }
  61009. declare module BABYLON {
  61010. /**
  61011. * Helper class to push actions to a pool of workers.
  61012. */
  61013. export class WorkerPool implements IDisposable {
  61014. private _workerInfos;
  61015. private _pendingActions;
  61016. /**
  61017. * Constructor
  61018. * @param workers Array of workers to use for actions
  61019. */
  61020. constructor(workers: Array<Worker>);
  61021. /**
  61022. * Terminates all workers and clears any pending actions.
  61023. */
  61024. dispose(): void;
  61025. /**
  61026. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61027. * pended until a worker has completed its action.
  61028. * @param action The action to perform. Call onComplete when the action is complete.
  61029. */
  61030. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61031. private _execute;
  61032. }
  61033. }
  61034. declare module BABYLON {
  61035. /**
  61036. * Configuration for Draco compression
  61037. */
  61038. export interface IDracoCompressionConfiguration {
  61039. /**
  61040. * Configuration for the decoder.
  61041. */
  61042. decoder: {
  61043. /**
  61044. * The url to the WebAssembly module.
  61045. */
  61046. wasmUrl?: string;
  61047. /**
  61048. * The url to the WebAssembly binary.
  61049. */
  61050. wasmBinaryUrl?: string;
  61051. /**
  61052. * The url to the fallback JavaScript module.
  61053. */
  61054. fallbackUrl?: string;
  61055. };
  61056. }
  61057. /**
  61058. * Draco compression (https://google.github.io/draco/)
  61059. *
  61060. * This class wraps the Draco module.
  61061. *
  61062. * **Encoder**
  61063. *
  61064. * The encoder is not currently implemented.
  61065. *
  61066. * **Decoder**
  61067. *
  61068. * 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.
  61069. *
  61070. * To update the configuration, use the following code:
  61071. * ```javascript
  61072. * DracoCompression.Configuration = {
  61073. * decoder: {
  61074. * wasmUrl: "<url to the WebAssembly library>",
  61075. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61076. * fallbackUrl: "<url to the fallback JavaScript library>",
  61077. * }
  61078. * };
  61079. * ```
  61080. *
  61081. * 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.
  61082. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61083. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61084. *
  61085. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61086. * ```javascript
  61087. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61088. * ```
  61089. *
  61090. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61091. */
  61092. export class DracoCompression implements IDisposable {
  61093. private _workerPoolPromise?;
  61094. private _decoderModulePromise?;
  61095. /**
  61096. * The configuration. Defaults to the following urls:
  61097. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61098. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61099. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61100. */
  61101. static Configuration: IDracoCompressionConfiguration;
  61102. /**
  61103. * Returns true if the decoder configuration is available.
  61104. */
  61105. static get DecoderAvailable(): boolean;
  61106. /**
  61107. * Default number of workers to create when creating the draco compression object.
  61108. */
  61109. static DefaultNumWorkers: number;
  61110. private static GetDefaultNumWorkers;
  61111. private static _Default;
  61112. /**
  61113. * Default instance for the draco compression object.
  61114. */
  61115. static get Default(): DracoCompression;
  61116. /**
  61117. * Constructor
  61118. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61119. */
  61120. constructor(numWorkers?: number);
  61121. /**
  61122. * Stop all async operations and release resources.
  61123. */
  61124. dispose(): void;
  61125. /**
  61126. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61127. * @returns a promise that resolves when ready
  61128. */
  61129. whenReadyAsync(): Promise<void>;
  61130. /**
  61131. * Decode Draco compressed mesh data to vertex data.
  61132. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61133. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61134. * @returns A promise that resolves with the decoded vertex data
  61135. */
  61136. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61137. [kind: string]: number;
  61138. }): Promise<VertexData>;
  61139. }
  61140. }
  61141. declare module BABYLON {
  61142. /**
  61143. * Class for building Constructive Solid Geometry
  61144. */
  61145. export class CSG {
  61146. private polygons;
  61147. /**
  61148. * The world matrix
  61149. */
  61150. matrix: Matrix;
  61151. /**
  61152. * Stores the position
  61153. */
  61154. position: Vector3;
  61155. /**
  61156. * Stores the rotation
  61157. */
  61158. rotation: Vector3;
  61159. /**
  61160. * Stores the rotation quaternion
  61161. */
  61162. rotationQuaternion: Nullable<Quaternion>;
  61163. /**
  61164. * Stores the scaling vector
  61165. */
  61166. scaling: Vector3;
  61167. /**
  61168. * Convert the Mesh to CSG
  61169. * @param mesh The Mesh to convert to CSG
  61170. * @returns A new CSG from the Mesh
  61171. */
  61172. static FromMesh(mesh: Mesh): CSG;
  61173. /**
  61174. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61175. * @param polygons Polygons used to construct a CSG solid
  61176. */
  61177. private static FromPolygons;
  61178. /**
  61179. * Clones, or makes a deep copy, of the CSG
  61180. * @returns A new CSG
  61181. */
  61182. clone(): CSG;
  61183. /**
  61184. * Unions this CSG with another CSG
  61185. * @param csg The CSG to union against this CSG
  61186. * @returns The unioned CSG
  61187. */
  61188. union(csg: CSG): CSG;
  61189. /**
  61190. * Unions this CSG with another CSG in place
  61191. * @param csg The CSG to union against this CSG
  61192. */
  61193. unionInPlace(csg: CSG): void;
  61194. /**
  61195. * Subtracts this CSG with another CSG
  61196. * @param csg The CSG to subtract against this CSG
  61197. * @returns A new CSG
  61198. */
  61199. subtract(csg: CSG): CSG;
  61200. /**
  61201. * Subtracts this CSG with another CSG in place
  61202. * @param csg The CSG to subtact against this CSG
  61203. */
  61204. subtractInPlace(csg: CSG): void;
  61205. /**
  61206. * Intersect this CSG with another CSG
  61207. * @param csg The CSG to intersect against this CSG
  61208. * @returns A new CSG
  61209. */
  61210. intersect(csg: CSG): CSG;
  61211. /**
  61212. * Intersects this CSG with another CSG in place
  61213. * @param csg The CSG to intersect against this CSG
  61214. */
  61215. intersectInPlace(csg: CSG): void;
  61216. /**
  61217. * Return a new CSG solid with solid and empty space switched. This solid is
  61218. * not modified.
  61219. * @returns A new CSG solid with solid and empty space switched
  61220. */
  61221. inverse(): CSG;
  61222. /**
  61223. * Inverses the CSG in place
  61224. */
  61225. inverseInPlace(): void;
  61226. /**
  61227. * This is used to keep meshes transformations so they can be restored
  61228. * when we build back a Babylon Mesh
  61229. * NB : All CSG operations are performed in world coordinates
  61230. * @param csg The CSG to copy the transform attributes from
  61231. * @returns This CSG
  61232. */
  61233. copyTransformAttributes(csg: CSG): CSG;
  61234. /**
  61235. * Build Raw mesh from CSG
  61236. * Coordinates here are in world space
  61237. * @param name The name of the mesh geometry
  61238. * @param scene The Scene
  61239. * @param keepSubMeshes Specifies if the submeshes should be kept
  61240. * @returns A new Mesh
  61241. */
  61242. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61243. /**
  61244. * Build Mesh from CSG taking material and transforms into account
  61245. * @param name The name of the Mesh
  61246. * @param material The material of the Mesh
  61247. * @param scene The Scene
  61248. * @param keepSubMeshes Specifies if submeshes should be kept
  61249. * @returns The new Mesh
  61250. */
  61251. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61252. }
  61253. }
  61254. declare module BABYLON {
  61255. /**
  61256. * Class used to create a trail following a mesh
  61257. */
  61258. export class TrailMesh extends Mesh {
  61259. private _generator;
  61260. private _autoStart;
  61261. private _running;
  61262. private _diameter;
  61263. private _length;
  61264. private _sectionPolygonPointsCount;
  61265. private _sectionVectors;
  61266. private _sectionNormalVectors;
  61267. private _beforeRenderObserver;
  61268. /**
  61269. * @constructor
  61270. * @param name The value used by scene.getMeshByName() to do a lookup.
  61271. * @param generator The mesh or transform node to generate a trail.
  61272. * @param scene The scene to add this mesh to.
  61273. * @param diameter Diameter of trailing mesh. Default is 1.
  61274. * @param length Length of trailing mesh. Default is 60.
  61275. * @param autoStart Automatically start trailing mesh. Default true.
  61276. */
  61277. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61278. /**
  61279. * "TrailMesh"
  61280. * @returns "TrailMesh"
  61281. */
  61282. getClassName(): string;
  61283. private _createMesh;
  61284. /**
  61285. * Start trailing mesh.
  61286. */
  61287. start(): void;
  61288. /**
  61289. * Stop trailing mesh.
  61290. */
  61291. stop(): void;
  61292. /**
  61293. * Update trailing mesh geometry.
  61294. */
  61295. update(): void;
  61296. /**
  61297. * Returns a new TrailMesh object.
  61298. * @param name is a string, the name given to the new mesh
  61299. * @param newGenerator use new generator object for cloned trail mesh
  61300. * @returns a new mesh
  61301. */
  61302. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61303. /**
  61304. * Serializes this trail mesh
  61305. * @param serializationObject object to write serialization to
  61306. */
  61307. serialize(serializationObject: any): void;
  61308. /**
  61309. * Parses a serialized trail mesh
  61310. * @param parsedMesh the serialized mesh
  61311. * @param scene the scene to create the trail mesh in
  61312. * @returns the created trail mesh
  61313. */
  61314. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61315. }
  61316. }
  61317. declare module BABYLON {
  61318. /**
  61319. * Class containing static functions to help procedurally build meshes
  61320. */
  61321. export class TiledBoxBuilder {
  61322. /**
  61323. * Creates a box mesh
  61324. * 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)
  61325. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61327. * * 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
  61328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61329. * @param name defines the name of the mesh
  61330. * @param options defines the options used to create the mesh
  61331. * @param scene defines the hosting scene
  61332. * @returns the box mesh
  61333. */
  61334. static CreateTiledBox(name: string, options: {
  61335. pattern?: number;
  61336. width?: number;
  61337. height?: number;
  61338. depth?: number;
  61339. tileSize?: number;
  61340. tileWidth?: number;
  61341. tileHeight?: number;
  61342. alignHorizontal?: number;
  61343. alignVertical?: number;
  61344. faceUV?: Vector4[];
  61345. faceColors?: Color4[];
  61346. sideOrientation?: number;
  61347. updatable?: boolean;
  61348. }, scene?: Nullable<Scene>): Mesh;
  61349. }
  61350. }
  61351. declare module BABYLON {
  61352. /**
  61353. * Class containing static functions to help procedurally build meshes
  61354. */
  61355. export class TorusKnotBuilder {
  61356. /**
  61357. * Creates a torus knot mesh
  61358. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61359. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61360. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61361. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61363. * * 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
  61364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61365. * @param name defines the name of the mesh
  61366. * @param options defines the options used to create the mesh
  61367. * @param scene defines the hosting scene
  61368. * @returns the torus knot mesh
  61369. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61370. */
  61371. static CreateTorusKnot(name: string, options: {
  61372. radius?: number;
  61373. tube?: number;
  61374. radialSegments?: number;
  61375. tubularSegments?: number;
  61376. p?: number;
  61377. q?: number;
  61378. updatable?: boolean;
  61379. sideOrientation?: number;
  61380. frontUVs?: Vector4;
  61381. backUVs?: Vector4;
  61382. }, scene: any): Mesh;
  61383. }
  61384. }
  61385. declare module BABYLON {
  61386. /**
  61387. * Polygon
  61388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61389. */
  61390. export class Polygon {
  61391. /**
  61392. * Creates a rectangle
  61393. * @param xmin bottom X coord
  61394. * @param ymin bottom Y coord
  61395. * @param xmax top X coord
  61396. * @param ymax top Y coord
  61397. * @returns points that make the resulting rectation
  61398. */
  61399. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61400. /**
  61401. * Creates a circle
  61402. * @param radius radius of circle
  61403. * @param cx scale in x
  61404. * @param cy scale in y
  61405. * @param numberOfSides number of sides that make up the circle
  61406. * @returns points that make the resulting circle
  61407. */
  61408. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61409. /**
  61410. * Creates a polygon from input string
  61411. * @param input Input polygon data
  61412. * @returns the parsed points
  61413. */
  61414. static Parse(input: string): Vector2[];
  61415. /**
  61416. * Starts building a polygon from x and y coordinates
  61417. * @param x x coordinate
  61418. * @param y y coordinate
  61419. * @returns the started path2
  61420. */
  61421. static StartingAt(x: number, y: number): Path2;
  61422. }
  61423. /**
  61424. * Builds a polygon
  61425. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61426. */
  61427. export class PolygonMeshBuilder {
  61428. private _points;
  61429. private _outlinepoints;
  61430. private _holes;
  61431. private _name;
  61432. private _scene;
  61433. private _epoints;
  61434. private _eholes;
  61435. private _addToepoint;
  61436. /**
  61437. * Babylon reference to the earcut plugin.
  61438. */
  61439. bjsEarcut: any;
  61440. /**
  61441. * Creates a PolygonMeshBuilder
  61442. * @param name name of the builder
  61443. * @param contours Path of the polygon
  61444. * @param scene scene to add to when creating the mesh
  61445. * @param earcutInjection can be used to inject your own earcut reference
  61446. */
  61447. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61448. /**
  61449. * Adds a whole within the polygon
  61450. * @param hole Array of points defining the hole
  61451. * @returns this
  61452. */
  61453. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61454. /**
  61455. * Creates the polygon
  61456. * @param updatable If the mesh should be updatable
  61457. * @param depth The depth of the mesh created
  61458. * @returns the created mesh
  61459. */
  61460. build(updatable?: boolean, depth?: number): Mesh;
  61461. /**
  61462. * Creates the polygon
  61463. * @param depth The depth of the mesh created
  61464. * @returns the created VertexData
  61465. */
  61466. buildVertexData(depth?: number): VertexData;
  61467. /**
  61468. * Adds a side to the polygon
  61469. * @param positions points that make the polygon
  61470. * @param normals normals of the polygon
  61471. * @param uvs uvs of the polygon
  61472. * @param indices indices of the polygon
  61473. * @param bounds bounds of the polygon
  61474. * @param points points of the polygon
  61475. * @param depth depth of the polygon
  61476. * @param flip flip of the polygon
  61477. */
  61478. private addSide;
  61479. }
  61480. }
  61481. declare module BABYLON {
  61482. /**
  61483. * Class containing static functions to help procedurally build meshes
  61484. */
  61485. export class PolygonBuilder {
  61486. /**
  61487. * Creates a polygon mesh
  61488. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61489. * * 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
  61490. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61492. * * 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)
  61493. * * Remember you can only change the shape positions, not their number when updating a polygon
  61494. * @param name defines the name of the mesh
  61495. * @param options defines the options used to create the mesh
  61496. * @param scene defines the hosting scene
  61497. * @param earcutInjection can be used to inject your own earcut reference
  61498. * @returns the polygon mesh
  61499. */
  61500. static CreatePolygon(name: string, options: {
  61501. shape: Vector3[];
  61502. holes?: Vector3[][];
  61503. depth?: number;
  61504. faceUV?: Vector4[];
  61505. faceColors?: Color4[];
  61506. updatable?: boolean;
  61507. sideOrientation?: number;
  61508. frontUVs?: Vector4;
  61509. backUVs?: Vector4;
  61510. wrap?: boolean;
  61511. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61512. /**
  61513. * Creates an extruded polygon mesh, with depth in the Y direction.
  61514. * * 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)
  61515. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61516. * @param name defines the name of the mesh
  61517. * @param options defines the options used to create the mesh
  61518. * @param scene defines the hosting scene
  61519. * @param earcutInjection can be used to inject your own earcut reference
  61520. * @returns the polygon mesh
  61521. */
  61522. static ExtrudePolygon(name: string, options: {
  61523. shape: Vector3[];
  61524. holes?: Vector3[][];
  61525. depth?: number;
  61526. faceUV?: Vector4[];
  61527. faceColors?: Color4[];
  61528. updatable?: boolean;
  61529. sideOrientation?: number;
  61530. frontUVs?: Vector4;
  61531. backUVs?: Vector4;
  61532. wrap?: boolean;
  61533. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61534. }
  61535. }
  61536. declare module BABYLON {
  61537. /**
  61538. * Class containing static functions to help procedurally build meshes
  61539. */
  61540. export class LatheBuilder {
  61541. /**
  61542. * Creates lathe mesh.
  61543. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61544. * * 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
  61545. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61546. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61547. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61548. * * 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
  61549. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61550. * * 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
  61551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61552. * * 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
  61553. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61555. * @param name defines the name of the mesh
  61556. * @param options defines the options used to create the mesh
  61557. * @param scene defines the hosting scene
  61558. * @returns the lathe mesh
  61559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61560. */
  61561. static CreateLathe(name: string, options: {
  61562. shape: Vector3[];
  61563. radius?: number;
  61564. tessellation?: number;
  61565. clip?: number;
  61566. arc?: number;
  61567. closed?: boolean;
  61568. updatable?: boolean;
  61569. sideOrientation?: number;
  61570. frontUVs?: Vector4;
  61571. backUVs?: Vector4;
  61572. cap?: number;
  61573. invertUV?: boolean;
  61574. }, scene?: Nullable<Scene>): Mesh;
  61575. }
  61576. }
  61577. declare module BABYLON {
  61578. /**
  61579. * Class containing static functions to help procedurally build meshes
  61580. */
  61581. export class TiledPlaneBuilder {
  61582. /**
  61583. * Creates a tiled plane mesh
  61584. * * The parameter `pattern` will, depending on value, do nothing or
  61585. * * * flip (reflect about central vertical) alternate tiles across and up
  61586. * * * flip every tile on alternate rows
  61587. * * * rotate (180 degs) alternate tiles across and up
  61588. * * * rotate every tile on alternate rows
  61589. * * * flip and rotate alternate tiles across and up
  61590. * * * flip and rotate every tile on alternate rows
  61591. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61592. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61593. * * 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
  61594. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61595. * * 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)
  61596. * * 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)
  61597. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61598. * @param name defines the name of the mesh
  61599. * @param options defines the options used to create the mesh
  61600. * @param scene defines the hosting scene
  61601. * @returns the box mesh
  61602. */
  61603. static CreateTiledPlane(name: string, options: {
  61604. pattern?: number;
  61605. tileSize?: number;
  61606. tileWidth?: number;
  61607. tileHeight?: number;
  61608. size?: number;
  61609. width?: number;
  61610. height?: number;
  61611. alignHorizontal?: number;
  61612. alignVertical?: number;
  61613. sideOrientation?: number;
  61614. frontUVs?: Vector4;
  61615. backUVs?: Vector4;
  61616. updatable?: boolean;
  61617. }, scene?: Nullable<Scene>): Mesh;
  61618. }
  61619. }
  61620. declare module BABYLON {
  61621. /**
  61622. * Class containing static functions to help procedurally build meshes
  61623. */
  61624. export class TubeBuilder {
  61625. /**
  61626. * Creates a tube mesh.
  61627. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61628. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61629. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61630. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61631. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61632. * * 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)
  61633. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61634. * * 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
  61635. * * 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
  61636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61637. * * 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
  61638. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61640. * @param name defines the name of the mesh
  61641. * @param options defines the options used to create the mesh
  61642. * @param scene defines the hosting scene
  61643. * @returns the tube mesh
  61644. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61645. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61646. */
  61647. static CreateTube(name: string, options: {
  61648. path: Vector3[];
  61649. radius?: number;
  61650. tessellation?: number;
  61651. radiusFunction?: {
  61652. (i: number, distance: number): number;
  61653. };
  61654. cap?: number;
  61655. arc?: number;
  61656. updatable?: boolean;
  61657. sideOrientation?: number;
  61658. frontUVs?: Vector4;
  61659. backUVs?: Vector4;
  61660. instance?: Mesh;
  61661. invertUV?: boolean;
  61662. }, scene?: Nullable<Scene>): Mesh;
  61663. }
  61664. }
  61665. declare module BABYLON {
  61666. /**
  61667. * Class containing static functions to help procedurally build meshes
  61668. */
  61669. export class IcoSphereBuilder {
  61670. /**
  61671. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61672. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61673. * * 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`)
  61674. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61675. * * 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
  61676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61677. * * 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
  61678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61679. * @param name defines the name of the mesh
  61680. * @param options defines the options used to create the mesh
  61681. * @param scene defines the hosting scene
  61682. * @returns the icosahedron mesh
  61683. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61684. */
  61685. static CreateIcoSphere(name: string, options: {
  61686. radius?: number;
  61687. radiusX?: number;
  61688. radiusY?: number;
  61689. radiusZ?: number;
  61690. flat?: boolean;
  61691. subdivisions?: number;
  61692. sideOrientation?: number;
  61693. frontUVs?: Vector4;
  61694. backUVs?: Vector4;
  61695. updatable?: boolean;
  61696. }, scene?: Nullable<Scene>): Mesh;
  61697. }
  61698. }
  61699. declare module BABYLON {
  61700. /**
  61701. * Class containing static functions to help procedurally build meshes
  61702. */
  61703. export class DecalBuilder {
  61704. /**
  61705. * Creates a decal mesh.
  61706. * 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
  61707. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61708. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61709. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61710. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61711. * @param name defines the name of the mesh
  61712. * @param sourceMesh defines the mesh where the decal must be applied
  61713. * @param options defines the options used to create the mesh
  61714. * @param scene defines the hosting scene
  61715. * @returns the decal mesh
  61716. * @see https://doc.babylonjs.com/how_to/decals
  61717. */
  61718. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61719. position?: Vector3;
  61720. normal?: Vector3;
  61721. size?: Vector3;
  61722. angle?: number;
  61723. }): Mesh;
  61724. }
  61725. }
  61726. declare module BABYLON {
  61727. /**
  61728. * Class containing static functions to help procedurally build meshes
  61729. */
  61730. export class MeshBuilder {
  61731. /**
  61732. * Creates a box mesh
  61733. * * The parameter `size` sets the size (float) of each box side (default 1)
  61734. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61735. * * 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)
  61736. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61738. * * 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
  61739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61740. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61741. * @param name defines the name of the mesh
  61742. * @param options defines the options used to create the mesh
  61743. * @param scene defines the hosting scene
  61744. * @returns the box mesh
  61745. */
  61746. static CreateBox(name: string, options: {
  61747. size?: number;
  61748. width?: number;
  61749. height?: number;
  61750. depth?: number;
  61751. faceUV?: Vector4[];
  61752. faceColors?: Color4[];
  61753. sideOrientation?: number;
  61754. frontUVs?: Vector4;
  61755. backUVs?: Vector4;
  61756. wrap?: boolean;
  61757. topBaseAt?: number;
  61758. bottomBaseAt?: number;
  61759. updatable?: boolean;
  61760. }, scene?: Nullable<Scene>): Mesh;
  61761. /**
  61762. * Creates a tiled box mesh
  61763. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61765. * @param name defines the name of the mesh
  61766. * @param options defines the options used to create the mesh
  61767. * @param scene defines the hosting scene
  61768. * @returns the tiled box mesh
  61769. */
  61770. static CreateTiledBox(name: string, options: {
  61771. pattern?: number;
  61772. size?: number;
  61773. width?: number;
  61774. height?: number;
  61775. depth: number;
  61776. tileSize?: number;
  61777. tileWidth?: number;
  61778. tileHeight?: number;
  61779. faceUV?: Vector4[];
  61780. faceColors?: Color4[];
  61781. alignHorizontal?: number;
  61782. alignVertical?: number;
  61783. sideOrientation?: number;
  61784. updatable?: boolean;
  61785. }, scene?: Nullable<Scene>): Mesh;
  61786. /**
  61787. * Creates a sphere mesh
  61788. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61789. * * 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`)
  61790. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61791. * * 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
  61792. * * 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)
  61793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61794. * * 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
  61795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61796. * @param name defines the name of the mesh
  61797. * @param options defines the options used to create the mesh
  61798. * @param scene defines the hosting scene
  61799. * @returns the sphere mesh
  61800. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61801. */
  61802. static CreateSphere(name: string, options: {
  61803. segments?: number;
  61804. diameter?: number;
  61805. diameterX?: number;
  61806. diameterY?: number;
  61807. diameterZ?: number;
  61808. arc?: number;
  61809. slice?: number;
  61810. sideOrientation?: number;
  61811. frontUVs?: Vector4;
  61812. backUVs?: Vector4;
  61813. updatable?: boolean;
  61814. }, scene?: Nullable<Scene>): Mesh;
  61815. /**
  61816. * Creates a plane polygonal mesh. By default, this is a disc
  61817. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61818. * * 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
  61819. * * 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
  61820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61821. * * 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
  61822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61823. * @param name defines the name of the mesh
  61824. * @param options defines the options used to create the mesh
  61825. * @param scene defines the hosting scene
  61826. * @returns the plane polygonal mesh
  61827. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61828. */
  61829. static CreateDisc(name: string, options: {
  61830. radius?: number;
  61831. tessellation?: number;
  61832. arc?: number;
  61833. updatable?: boolean;
  61834. sideOrientation?: number;
  61835. frontUVs?: Vector4;
  61836. backUVs?: Vector4;
  61837. }, scene?: Nullable<Scene>): Mesh;
  61838. /**
  61839. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61840. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61841. * * 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`)
  61842. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61843. * * 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
  61844. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61845. * * 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
  61846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61847. * @param name defines the name of the mesh
  61848. * @param options defines the options used to create the mesh
  61849. * @param scene defines the hosting scene
  61850. * @returns the icosahedron mesh
  61851. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61852. */
  61853. static CreateIcoSphere(name: string, options: {
  61854. radius?: number;
  61855. radiusX?: number;
  61856. radiusY?: number;
  61857. radiusZ?: number;
  61858. flat?: boolean;
  61859. subdivisions?: number;
  61860. sideOrientation?: number;
  61861. frontUVs?: Vector4;
  61862. backUVs?: Vector4;
  61863. updatable?: boolean;
  61864. }, scene?: Nullable<Scene>): Mesh;
  61865. /**
  61866. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61867. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61868. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61869. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61870. * * 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
  61871. * * 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
  61872. * * 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
  61873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61874. * * 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
  61875. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61876. * * 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
  61877. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61878. * * 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
  61879. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61881. * @param name defines the name of the mesh
  61882. * @param options defines the options used to create the mesh
  61883. * @param scene defines the hosting scene
  61884. * @returns the ribbon mesh
  61885. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61886. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61887. */
  61888. static CreateRibbon(name: string, options: {
  61889. pathArray: Vector3[][];
  61890. closeArray?: boolean;
  61891. closePath?: boolean;
  61892. offset?: number;
  61893. updatable?: boolean;
  61894. sideOrientation?: number;
  61895. frontUVs?: Vector4;
  61896. backUVs?: Vector4;
  61897. instance?: Mesh;
  61898. invertUV?: boolean;
  61899. uvs?: Vector2[];
  61900. colors?: Color4[];
  61901. }, scene?: Nullable<Scene>): Mesh;
  61902. /**
  61903. * Creates a cylinder or a cone mesh
  61904. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61905. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61906. * * 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.
  61907. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61908. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61909. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61910. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61911. * * 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).
  61912. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61913. * * 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).
  61914. * * 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
  61915. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61916. * * 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
  61917. * * 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.
  61918. * * If `enclose` is false, a ring surface is one element.
  61919. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61920. * * 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
  61921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61922. * * 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
  61923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61924. * @param name defines the name of the mesh
  61925. * @param options defines the options used to create the mesh
  61926. * @param scene defines the hosting scene
  61927. * @returns the cylinder mesh
  61928. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61929. */
  61930. static CreateCylinder(name: string, options: {
  61931. height?: number;
  61932. diameterTop?: number;
  61933. diameterBottom?: number;
  61934. diameter?: number;
  61935. tessellation?: number;
  61936. subdivisions?: number;
  61937. arc?: number;
  61938. faceColors?: Color4[];
  61939. faceUV?: Vector4[];
  61940. updatable?: boolean;
  61941. hasRings?: boolean;
  61942. enclose?: boolean;
  61943. cap?: number;
  61944. sideOrientation?: number;
  61945. frontUVs?: Vector4;
  61946. backUVs?: Vector4;
  61947. }, scene?: Nullable<Scene>): Mesh;
  61948. /**
  61949. * Creates a torus mesh
  61950. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61951. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61952. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61954. * * 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
  61955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61956. * @param name defines the name of the mesh
  61957. * @param options defines the options used to create the mesh
  61958. * @param scene defines the hosting scene
  61959. * @returns the torus mesh
  61960. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61961. */
  61962. static CreateTorus(name: string, options: {
  61963. diameter?: number;
  61964. thickness?: number;
  61965. tessellation?: number;
  61966. updatable?: boolean;
  61967. sideOrientation?: number;
  61968. frontUVs?: Vector4;
  61969. backUVs?: Vector4;
  61970. }, scene?: Nullable<Scene>): Mesh;
  61971. /**
  61972. * Creates a torus knot mesh
  61973. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61974. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61975. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61976. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61978. * * 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
  61979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61980. * @param name defines the name of the mesh
  61981. * @param options defines the options used to create the mesh
  61982. * @param scene defines the hosting scene
  61983. * @returns the torus knot mesh
  61984. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61985. */
  61986. static CreateTorusKnot(name: string, options: {
  61987. radius?: number;
  61988. tube?: number;
  61989. radialSegments?: number;
  61990. tubularSegments?: number;
  61991. p?: number;
  61992. q?: number;
  61993. updatable?: boolean;
  61994. sideOrientation?: number;
  61995. frontUVs?: Vector4;
  61996. backUVs?: Vector4;
  61997. }, scene?: Nullable<Scene>): Mesh;
  61998. /**
  61999. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  62000. * * 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
  62001. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  62002. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  62003. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  62004. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  62005. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  62006. * * 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
  62007. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  62008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62009. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  62010. * @param name defines the name of the new line system
  62011. * @param options defines the options used to create the line system
  62012. * @param scene defines the hosting scene
  62013. * @returns a new line system mesh
  62014. */
  62015. static CreateLineSystem(name: string, options: {
  62016. lines: Vector3[][];
  62017. updatable?: boolean;
  62018. instance?: Nullable<LinesMesh>;
  62019. colors?: Nullable<Color4[][]>;
  62020. useVertexAlpha?: boolean;
  62021. }, scene: Nullable<Scene>): LinesMesh;
  62022. /**
  62023. * Creates a line mesh
  62024. * 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
  62025. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62026. * * The parameter `points` is an array successive Vector3
  62027. * * 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
  62028. * * The optional parameter `colors` is an array of successive Color4, one per line point
  62029. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  62030. * * When updating an instance, remember that only point positions can change, not the number of points
  62031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62032. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  62033. * @param name defines the name of the new line system
  62034. * @param options defines the options used to create the line system
  62035. * @param scene defines the hosting scene
  62036. * @returns a new line mesh
  62037. */
  62038. static CreateLines(name: string, options: {
  62039. points: Vector3[];
  62040. updatable?: boolean;
  62041. instance?: Nullable<LinesMesh>;
  62042. colors?: Color4[];
  62043. useVertexAlpha?: boolean;
  62044. }, scene?: Nullable<Scene>): LinesMesh;
  62045. /**
  62046. * Creates a dashed line mesh
  62047. * * 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
  62048. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62049. * * The parameter `points` is an array successive Vector3
  62050. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  62051. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  62052. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  62053. * * 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
  62054. * * When updating an instance, remember that only point positions can change, not the number of points
  62055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62056. * @param name defines the name of the mesh
  62057. * @param options defines the options used to create the mesh
  62058. * @param scene defines the hosting scene
  62059. * @returns the dashed line mesh
  62060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62061. */
  62062. static CreateDashedLines(name: string, options: {
  62063. points: Vector3[];
  62064. dashSize?: number;
  62065. gapSize?: number;
  62066. dashNb?: number;
  62067. updatable?: boolean;
  62068. instance?: LinesMesh;
  62069. }, scene?: Nullable<Scene>): LinesMesh;
  62070. /**
  62071. * 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.
  62072. * * 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.
  62073. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62074. * * 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.
  62075. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62076. * * 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
  62077. * * 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
  62078. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62080. * * 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
  62081. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62083. * @param name defines the name of the mesh
  62084. * @param options defines the options used to create the mesh
  62085. * @param scene defines the hosting scene
  62086. * @returns the extruded shape mesh
  62087. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62088. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62089. */
  62090. static ExtrudeShape(name: string, options: {
  62091. shape: Vector3[];
  62092. path: Vector3[];
  62093. scale?: number;
  62094. rotation?: number;
  62095. cap?: number;
  62096. updatable?: boolean;
  62097. sideOrientation?: number;
  62098. frontUVs?: Vector4;
  62099. backUVs?: Vector4;
  62100. instance?: Mesh;
  62101. invertUV?: boolean;
  62102. }, scene?: Nullable<Scene>): Mesh;
  62103. /**
  62104. * Creates an custom extruded shape mesh.
  62105. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62106. * * 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.
  62107. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62108. * * 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
  62109. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62110. * * 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
  62111. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62112. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62113. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62114. * * 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
  62115. * * 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
  62116. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62118. * * 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
  62119. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62121. * @param name defines the name of the mesh
  62122. * @param options defines the options used to create the mesh
  62123. * @param scene defines the hosting scene
  62124. * @returns the custom extruded shape mesh
  62125. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62126. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62127. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62128. */
  62129. static ExtrudeShapeCustom(name: string, options: {
  62130. shape: Vector3[];
  62131. path: Vector3[];
  62132. scaleFunction?: any;
  62133. rotationFunction?: any;
  62134. ribbonCloseArray?: boolean;
  62135. ribbonClosePath?: boolean;
  62136. cap?: number;
  62137. updatable?: boolean;
  62138. sideOrientation?: number;
  62139. frontUVs?: Vector4;
  62140. backUVs?: Vector4;
  62141. instance?: Mesh;
  62142. invertUV?: boolean;
  62143. }, scene?: Nullable<Scene>): Mesh;
  62144. /**
  62145. * Creates lathe mesh.
  62146. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62147. * * 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
  62148. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62149. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62150. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62151. * * 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
  62152. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62153. * * 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
  62154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62155. * * 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
  62156. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62158. * @param name defines the name of the mesh
  62159. * @param options defines the options used to create the mesh
  62160. * @param scene defines the hosting scene
  62161. * @returns the lathe mesh
  62162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62163. */
  62164. static CreateLathe(name: string, options: {
  62165. shape: Vector3[];
  62166. radius?: number;
  62167. tessellation?: number;
  62168. clip?: number;
  62169. arc?: number;
  62170. closed?: boolean;
  62171. updatable?: boolean;
  62172. sideOrientation?: number;
  62173. frontUVs?: Vector4;
  62174. backUVs?: Vector4;
  62175. cap?: number;
  62176. invertUV?: boolean;
  62177. }, scene?: Nullable<Scene>): Mesh;
  62178. /**
  62179. * Creates a tiled plane mesh
  62180. * * You can set a limited pattern arrangement with the tiles
  62181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62182. * * 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
  62183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62184. * @param name defines the name of the mesh
  62185. * @param options defines the options used to create the mesh
  62186. * @param scene defines the hosting scene
  62187. * @returns the plane mesh
  62188. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62189. */
  62190. static CreateTiledPlane(name: string, options: {
  62191. pattern?: number;
  62192. tileSize?: number;
  62193. tileWidth?: number;
  62194. tileHeight?: number;
  62195. size?: number;
  62196. width?: number;
  62197. height?: number;
  62198. alignHorizontal?: number;
  62199. alignVertical?: number;
  62200. sideOrientation?: number;
  62201. frontUVs?: Vector4;
  62202. backUVs?: Vector4;
  62203. updatable?: boolean;
  62204. }, scene?: Nullable<Scene>): Mesh;
  62205. /**
  62206. * Creates a plane mesh
  62207. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62208. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62209. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62210. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62211. * * 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
  62212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62213. * @param name defines the name of the mesh
  62214. * @param options defines the options used to create the mesh
  62215. * @param scene defines the hosting scene
  62216. * @returns the plane mesh
  62217. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62218. */
  62219. static CreatePlane(name: string, options: {
  62220. size?: number;
  62221. width?: number;
  62222. height?: number;
  62223. sideOrientation?: number;
  62224. frontUVs?: Vector4;
  62225. backUVs?: Vector4;
  62226. updatable?: boolean;
  62227. sourcePlane?: Plane;
  62228. }, scene?: Nullable<Scene>): Mesh;
  62229. /**
  62230. * Creates a ground mesh
  62231. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62232. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62234. * @param name defines the name of the mesh
  62235. * @param options defines the options used to create the mesh
  62236. * @param scene defines the hosting scene
  62237. * @returns the ground mesh
  62238. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62239. */
  62240. static CreateGround(name: string, options: {
  62241. width?: number;
  62242. height?: number;
  62243. subdivisions?: number;
  62244. subdivisionsX?: number;
  62245. subdivisionsY?: number;
  62246. updatable?: boolean;
  62247. }, scene?: Nullable<Scene>): Mesh;
  62248. /**
  62249. * Creates a tiled ground mesh
  62250. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62251. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62252. * * 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
  62253. * * 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
  62254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62255. * @param name defines the name of the mesh
  62256. * @param options defines the options used to create the mesh
  62257. * @param scene defines the hosting scene
  62258. * @returns the tiled ground mesh
  62259. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62260. */
  62261. static CreateTiledGround(name: string, options: {
  62262. xmin: number;
  62263. zmin: number;
  62264. xmax: number;
  62265. zmax: number;
  62266. subdivisions?: {
  62267. w: number;
  62268. h: number;
  62269. };
  62270. precision?: {
  62271. w: number;
  62272. h: number;
  62273. };
  62274. updatable?: boolean;
  62275. }, scene?: Nullable<Scene>): Mesh;
  62276. /**
  62277. * Creates a ground mesh from a height map
  62278. * * The parameter `url` sets the URL of the height map image resource.
  62279. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62280. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62281. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62282. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62283. * * 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.
  62284. * * 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).
  62285. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62287. * @param name defines the name of the mesh
  62288. * @param url defines the url to the height map
  62289. * @param options defines the options used to create the mesh
  62290. * @param scene defines the hosting scene
  62291. * @returns the ground mesh
  62292. * @see https://doc.babylonjs.com/babylon101/height_map
  62293. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62294. */
  62295. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62296. width?: number;
  62297. height?: number;
  62298. subdivisions?: number;
  62299. minHeight?: number;
  62300. maxHeight?: number;
  62301. colorFilter?: Color3;
  62302. alphaFilter?: number;
  62303. updatable?: boolean;
  62304. onReady?: (mesh: GroundMesh) => void;
  62305. }, scene?: Nullable<Scene>): GroundMesh;
  62306. /**
  62307. * Creates a polygon mesh
  62308. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62309. * * 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
  62310. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62312. * * 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)
  62313. * * Remember you can only change the shape positions, not their number when updating a polygon
  62314. * @param name defines the name of the mesh
  62315. * @param options defines the options used to create the mesh
  62316. * @param scene defines the hosting scene
  62317. * @param earcutInjection can be used to inject your own earcut reference
  62318. * @returns the polygon mesh
  62319. */
  62320. static CreatePolygon(name: string, options: {
  62321. shape: Vector3[];
  62322. holes?: Vector3[][];
  62323. depth?: number;
  62324. faceUV?: Vector4[];
  62325. faceColors?: Color4[];
  62326. updatable?: boolean;
  62327. sideOrientation?: number;
  62328. frontUVs?: Vector4;
  62329. backUVs?: Vector4;
  62330. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62331. /**
  62332. * Creates an extruded polygon mesh, with depth in the Y direction.
  62333. * * 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)
  62334. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62335. * @param name defines the name of the mesh
  62336. * @param options defines the options used to create the mesh
  62337. * @param scene defines the hosting scene
  62338. * @param earcutInjection can be used to inject your own earcut reference
  62339. * @returns the polygon mesh
  62340. */
  62341. static ExtrudePolygon(name: string, options: {
  62342. shape: Vector3[];
  62343. holes?: Vector3[][];
  62344. depth?: number;
  62345. faceUV?: Vector4[];
  62346. faceColors?: Color4[];
  62347. updatable?: boolean;
  62348. sideOrientation?: number;
  62349. frontUVs?: Vector4;
  62350. backUVs?: Vector4;
  62351. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62352. /**
  62353. * Creates a tube mesh.
  62354. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62355. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62356. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62357. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62358. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62359. * * 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)
  62360. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62361. * * 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
  62362. * * 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
  62363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62364. * * 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
  62365. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62367. * @param name defines the name of the mesh
  62368. * @param options defines the options used to create the mesh
  62369. * @param scene defines the hosting scene
  62370. * @returns the tube mesh
  62371. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62372. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62373. */
  62374. static CreateTube(name: string, options: {
  62375. path: Vector3[];
  62376. radius?: number;
  62377. tessellation?: number;
  62378. radiusFunction?: {
  62379. (i: number, distance: number): number;
  62380. };
  62381. cap?: number;
  62382. arc?: number;
  62383. updatable?: boolean;
  62384. sideOrientation?: number;
  62385. frontUVs?: Vector4;
  62386. backUVs?: Vector4;
  62387. instance?: Mesh;
  62388. invertUV?: boolean;
  62389. }, scene?: Nullable<Scene>): Mesh;
  62390. /**
  62391. * Creates a polyhedron mesh
  62392. * * 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
  62393. * * The parameter `size` (positive float, default 1) sets the polygon size
  62394. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62395. * * 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`
  62396. * * 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
  62397. * * 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)`)
  62398. * * 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
  62399. * * 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
  62400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62401. * * 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
  62402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62403. * @param name defines the name of the mesh
  62404. * @param options defines the options used to create the mesh
  62405. * @param scene defines the hosting scene
  62406. * @returns the polyhedron mesh
  62407. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62408. */
  62409. static CreatePolyhedron(name: string, options: {
  62410. type?: number;
  62411. size?: number;
  62412. sizeX?: number;
  62413. sizeY?: number;
  62414. sizeZ?: number;
  62415. custom?: any;
  62416. faceUV?: Vector4[];
  62417. faceColors?: Color4[];
  62418. flat?: boolean;
  62419. updatable?: boolean;
  62420. sideOrientation?: number;
  62421. frontUVs?: Vector4;
  62422. backUVs?: Vector4;
  62423. }, scene?: Nullable<Scene>): Mesh;
  62424. /**
  62425. * Creates a decal mesh.
  62426. * 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
  62427. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62428. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62429. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62430. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62431. * @param name defines the name of the mesh
  62432. * @param sourceMesh defines the mesh where the decal must be applied
  62433. * @param options defines the options used to create the mesh
  62434. * @param scene defines the hosting scene
  62435. * @returns the decal mesh
  62436. * @see https://doc.babylonjs.com/how_to/decals
  62437. */
  62438. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62439. position?: Vector3;
  62440. normal?: Vector3;
  62441. size?: Vector3;
  62442. angle?: number;
  62443. }): Mesh;
  62444. }
  62445. }
  62446. declare module BABYLON {
  62447. /**
  62448. * A simplifier interface for future simplification implementations
  62449. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62450. */
  62451. export interface ISimplifier {
  62452. /**
  62453. * Simplification of a given mesh according to the given settings.
  62454. * Since this requires computation, it is assumed that the function runs async.
  62455. * @param settings The settings of the simplification, including quality and distance
  62456. * @param successCallback A callback that will be called after the mesh was simplified.
  62457. * @param errorCallback in case of an error, this callback will be called. optional.
  62458. */
  62459. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62460. }
  62461. /**
  62462. * Expected simplification settings.
  62463. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62464. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62465. */
  62466. export interface ISimplificationSettings {
  62467. /**
  62468. * Gets or sets the expected quality
  62469. */
  62470. quality: number;
  62471. /**
  62472. * Gets or sets the distance when this optimized version should be used
  62473. */
  62474. distance: number;
  62475. /**
  62476. * Gets an already optimized mesh
  62477. */
  62478. optimizeMesh?: boolean;
  62479. }
  62480. /**
  62481. * Class used to specify simplification options
  62482. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62483. */
  62484. export class SimplificationSettings implements ISimplificationSettings {
  62485. /** expected quality */
  62486. quality: number;
  62487. /** distance when this optimized version should be used */
  62488. distance: number;
  62489. /** already optimized mesh */
  62490. optimizeMesh?: boolean | undefined;
  62491. /**
  62492. * Creates a SimplificationSettings
  62493. * @param quality expected quality
  62494. * @param distance distance when this optimized version should be used
  62495. * @param optimizeMesh already optimized mesh
  62496. */
  62497. constructor(
  62498. /** expected quality */
  62499. quality: number,
  62500. /** distance when this optimized version should be used */
  62501. distance: number,
  62502. /** already optimized mesh */
  62503. optimizeMesh?: boolean | undefined);
  62504. }
  62505. /**
  62506. * Interface used to define a simplification task
  62507. */
  62508. export interface ISimplificationTask {
  62509. /**
  62510. * Array of settings
  62511. */
  62512. settings: Array<ISimplificationSettings>;
  62513. /**
  62514. * Simplification type
  62515. */
  62516. simplificationType: SimplificationType;
  62517. /**
  62518. * Mesh to simplify
  62519. */
  62520. mesh: Mesh;
  62521. /**
  62522. * Callback called on success
  62523. */
  62524. successCallback?: () => void;
  62525. /**
  62526. * Defines if parallel processing can be used
  62527. */
  62528. parallelProcessing: boolean;
  62529. }
  62530. /**
  62531. * Queue used to order the simplification tasks
  62532. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62533. */
  62534. export class SimplificationQueue {
  62535. private _simplificationArray;
  62536. /**
  62537. * Gets a boolean indicating that the process is still running
  62538. */
  62539. running: boolean;
  62540. /**
  62541. * Creates a new queue
  62542. */
  62543. constructor();
  62544. /**
  62545. * Adds a new simplification task
  62546. * @param task defines a task to add
  62547. */
  62548. addTask(task: ISimplificationTask): void;
  62549. /**
  62550. * Execute next task
  62551. */
  62552. executeNext(): void;
  62553. /**
  62554. * Execute a simplification task
  62555. * @param task defines the task to run
  62556. */
  62557. runSimplification(task: ISimplificationTask): void;
  62558. private getSimplifier;
  62559. }
  62560. /**
  62561. * The implemented types of simplification
  62562. * At the moment only Quadratic Error Decimation is implemented
  62563. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62564. */
  62565. export enum SimplificationType {
  62566. /** Quadratic error decimation */
  62567. QUADRATIC = 0
  62568. }
  62569. /**
  62570. * An implementation of the Quadratic Error simplification algorithm.
  62571. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62572. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62573. * @author RaananW
  62574. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62575. */
  62576. export class QuadraticErrorSimplification implements ISimplifier {
  62577. private _mesh;
  62578. private triangles;
  62579. private vertices;
  62580. private references;
  62581. private _reconstructedMesh;
  62582. /** Gets or sets the number pf sync interations */
  62583. syncIterations: number;
  62584. /** Gets or sets the aggressiveness of the simplifier */
  62585. aggressiveness: number;
  62586. /** Gets or sets the number of allowed iterations for decimation */
  62587. decimationIterations: number;
  62588. /** Gets or sets the espilon to use for bounding box computation */
  62589. boundingBoxEpsilon: number;
  62590. /**
  62591. * Creates a new QuadraticErrorSimplification
  62592. * @param _mesh defines the target mesh
  62593. */
  62594. constructor(_mesh: Mesh);
  62595. /**
  62596. * Simplification of a given mesh according to the given settings.
  62597. * Since this requires computation, it is assumed that the function runs async.
  62598. * @param settings The settings of the simplification, including quality and distance
  62599. * @param successCallback A callback that will be called after the mesh was simplified.
  62600. */
  62601. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62602. private runDecimation;
  62603. private initWithMesh;
  62604. private init;
  62605. private reconstructMesh;
  62606. private initDecimatedMesh;
  62607. private isFlipped;
  62608. private updateTriangles;
  62609. private identifyBorder;
  62610. private updateMesh;
  62611. private vertexError;
  62612. private calculateError;
  62613. }
  62614. }
  62615. declare module BABYLON {
  62616. interface Scene {
  62617. /** @hidden (Backing field) */
  62618. _simplificationQueue: SimplificationQueue;
  62619. /**
  62620. * Gets or sets the simplification queue attached to the scene
  62621. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62622. */
  62623. simplificationQueue: SimplificationQueue;
  62624. }
  62625. interface Mesh {
  62626. /**
  62627. * Simplify the mesh according to the given array of settings.
  62628. * Function will return immediately and will simplify async
  62629. * @param settings a collection of simplification settings
  62630. * @param parallelProcessing should all levels calculate parallel or one after the other
  62631. * @param simplificationType the type of simplification to run
  62632. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62633. * @returns the current mesh
  62634. */
  62635. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62636. }
  62637. /**
  62638. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62639. * created in a scene
  62640. */
  62641. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62642. /**
  62643. * The component name helpfull to identify the component in the list of scene components.
  62644. */
  62645. readonly name: string;
  62646. /**
  62647. * The scene the component belongs to.
  62648. */
  62649. scene: Scene;
  62650. /**
  62651. * Creates a new instance of the component for the given scene
  62652. * @param scene Defines the scene to register the component in
  62653. */
  62654. constructor(scene: Scene);
  62655. /**
  62656. * Registers the component in a given scene
  62657. */
  62658. register(): void;
  62659. /**
  62660. * Rebuilds the elements related to this component in case of
  62661. * context lost for instance.
  62662. */
  62663. rebuild(): void;
  62664. /**
  62665. * Disposes the component and the associated ressources
  62666. */
  62667. dispose(): void;
  62668. private _beforeCameraUpdate;
  62669. }
  62670. }
  62671. declare module BABYLON {
  62672. /**
  62673. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62674. */
  62675. export interface INavigationEnginePlugin {
  62676. /**
  62677. * plugin name
  62678. */
  62679. name: string;
  62680. /**
  62681. * Creates a navigation mesh
  62682. * @param meshes array of all the geometry used to compute the navigatio mesh
  62683. * @param parameters bunch of parameters used to filter geometry
  62684. */
  62685. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62686. /**
  62687. * Create a navigation mesh debug mesh
  62688. * @param scene is where the mesh will be added
  62689. * @returns debug display mesh
  62690. */
  62691. createDebugNavMesh(scene: Scene): Mesh;
  62692. /**
  62693. * Get a navigation mesh constrained position, closest to the parameter position
  62694. * @param position world position
  62695. * @returns the closest point to position constrained by the navigation mesh
  62696. */
  62697. getClosestPoint(position: Vector3): Vector3;
  62698. /**
  62699. * Get a navigation mesh constrained position, closest to the parameter position
  62700. * @param position world position
  62701. * @param result output the closest point to position constrained by the navigation mesh
  62702. */
  62703. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62704. /**
  62705. * Get a navigation mesh constrained position, within a particular radius
  62706. * @param position world position
  62707. * @param maxRadius the maximum distance to the constrained world position
  62708. * @returns the closest point to position constrained by the navigation mesh
  62709. */
  62710. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62711. /**
  62712. * Get a navigation mesh constrained position, within a particular radius
  62713. * @param position world position
  62714. * @param maxRadius the maximum distance to the constrained world position
  62715. * @param result output the closest point to position constrained by the navigation mesh
  62716. */
  62717. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62718. /**
  62719. * Compute the final position from a segment made of destination-position
  62720. * @param position world position
  62721. * @param destination world position
  62722. * @returns the resulting point along the navmesh
  62723. */
  62724. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62725. /**
  62726. * Compute the final position from a segment made of destination-position
  62727. * @param position world position
  62728. * @param destination world position
  62729. * @param result output the resulting point along the navmesh
  62730. */
  62731. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62732. /**
  62733. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62734. * @param start world position
  62735. * @param end world position
  62736. * @returns array containing world position composing the path
  62737. */
  62738. computePath(start: Vector3, end: Vector3): Vector3[];
  62739. /**
  62740. * If this plugin is supported
  62741. * @returns true if plugin is supported
  62742. */
  62743. isSupported(): boolean;
  62744. /**
  62745. * Create a new Crowd so you can add agents
  62746. * @param maxAgents the maximum agent count in the crowd
  62747. * @param maxAgentRadius the maximum radius an agent can have
  62748. * @param scene to attach the crowd to
  62749. * @returns the crowd you can add agents to
  62750. */
  62751. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62752. /**
  62753. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62754. * The queries will try to find a solution within those bounds
  62755. * default is (1,1,1)
  62756. * @param extent x,y,z value that define the extent around the queries point of reference
  62757. */
  62758. setDefaultQueryExtent(extent: Vector3): void;
  62759. /**
  62760. * Get the Bounding box extent specified by setDefaultQueryExtent
  62761. * @returns the box extent values
  62762. */
  62763. getDefaultQueryExtent(): Vector3;
  62764. /**
  62765. * build the navmesh from a previously saved state using getNavmeshData
  62766. * @param data the Uint8Array returned by getNavmeshData
  62767. */
  62768. buildFromNavmeshData(data: Uint8Array): void;
  62769. /**
  62770. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62771. * @returns data the Uint8Array that can be saved and reused
  62772. */
  62773. getNavmeshData(): Uint8Array;
  62774. /**
  62775. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62776. * @param result output the box extent values
  62777. */
  62778. getDefaultQueryExtentToRef(result: Vector3): void;
  62779. /**
  62780. * Release all resources
  62781. */
  62782. dispose(): void;
  62783. }
  62784. /**
  62785. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62786. */
  62787. export interface ICrowd {
  62788. /**
  62789. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62790. * You can attach anything to that node. The node position is updated in the scene update tick.
  62791. * @param pos world position that will be constrained by the navigation mesh
  62792. * @param parameters agent parameters
  62793. * @param transform hooked to the agent that will be update by the scene
  62794. * @returns agent index
  62795. */
  62796. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62797. /**
  62798. * Returns the agent position in world space
  62799. * @param index agent index returned by addAgent
  62800. * @returns world space position
  62801. */
  62802. getAgentPosition(index: number): Vector3;
  62803. /**
  62804. * Gets the agent position result in world space
  62805. * @param index agent index returned by addAgent
  62806. * @param result output world space position
  62807. */
  62808. getAgentPositionToRef(index: number, result: Vector3): void;
  62809. /**
  62810. * Gets the agent velocity in world space
  62811. * @param index agent index returned by addAgent
  62812. * @returns world space velocity
  62813. */
  62814. getAgentVelocity(index: number): Vector3;
  62815. /**
  62816. * Gets the agent velocity result in world space
  62817. * @param index agent index returned by addAgent
  62818. * @param result output world space velocity
  62819. */
  62820. getAgentVelocityToRef(index: number, result: Vector3): void;
  62821. /**
  62822. * remove a particular agent previously created
  62823. * @param index agent index returned by addAgent
  62824. */
  62825. removeAgent(index: number): void;
  62826. /**
  62827. * get the list of all agents attached to this crowd
  62828. * @returns list of agent indices
  62829. */
  62830. getAgents(): number[];
  62831. /**
  62832. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62833. * @param deltaTime in seconds
  62834. */
  62835. update(deltaTime: number): void;
  62836. /**
  62837. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62838. * @param index agent index returned by addAgent
  62839. * @param destination targeted world position
  62840. */
  62841. agentGoto(index: number, destination: Vector3): void;
  62842. /**
  62843. * Teleport the agent to a new position
  62844. * @param index agent index returned by addAgent
  62845. * @param destination targeted world position
  62846. */
  62847. agentTeleport(index: number, destination: Vector3): void;
  62848. /**
  62849. * Update agent parameters
  62850. * @param index agent index returned by addAgent
  62851. * @param parameters agent parameters
  62852. */
  62853. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62854. /**
  62855. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62856. * The queries will try to find a solution within those bounds
  62857. * default is (1,1,1)
  62858. * @param extent x,y,z value that define the extent around the queries point of reference
  62859. */
  62860. setDefaultQueryExtent(extent: Vector3): void;
  62861. /**
  62862. * Get the Bounding box extent specified by setDefaultQueryExtent
  62863. * @returns the box extent values
  62864. */
  62865. getDefaultQueryExtent(): Vector3;
  62866. /**
  62867. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62868. * @param result output the box extent values
  62869. */
  62870. getDefaultQueryExtentToRef(result: Vector3): void;
  62871. /**
  62872. * Release all resources
  62873. */
  62874. dispose(): void;
  62875. }
  62876. /**
  62877. * Configures an agent
  62878. */
  62879. export interface IAgentParameters {
  62880. /**
  62881. * Agent radius. [Limit: >= 0]
  62882. */
  62883. radius: number;
  62884. /**
  62885. * Agent height. [Limit: > 0]
  62886. */
  62887. height: number;
  62888. /**
  62889. * Maximum allowed acceleration. [Limit: >= 0]
  62890. */
  62891. maxAcceleration: number;
  62892. /**
  62893. * Maximum allowed speed. [Limit: >= 0]
  62894. */
  62895. maxSpeed: number;
  62896. /**
  62897. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62898. */
  62899. collisionQueryRange: number;
  62900. /**
  62901. * The path visibility optimization range. [Limit: > 0]
  62902. */
  62903. pathOptimizationRange: number;
  62904. /**
  62905. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62906. */
  62907. separationWeight: number;
  62908. }
  62909. /**
  62910. * Configures the navigation mesh creation
  62911. */
  62912. export interface INavMeshParameters {
  62913. /**
  62914. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62915. */
  62916. cs: number;
  62917. /**
  62918. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62919. */
  62920. ch: number;
  62921. /**
  62922. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62923. */
  62924. walkableSlopeAngle: number;
  62925. /**
  62926. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62927. * be considered walkable. [Limit: >= 3] [Units: vx]
  62928. */
  62929. walkableHeight: number;
  62930. /**
  62931. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62932. */
  62933. walkableClimb: number;
  62934. /**
  62935. * The distance to erode/shrink the walkable area of the heightfield away from
  62936. * obstructions. [Limit: >=0] [Units: vx]
  62937. */
  62938. walkableRadius: number;
  62939. /**
  62940. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62941. */
  62942. maxEdgeLen: number;
  62943. /**
  62944. * The maximum distance a simplfied contour's border edges should deviate
  62945. * the original raw contour. [Limit: >=0] [Units: vx]
  62946. */
  62947. maxSimplificationError: number;
  62948. /**
  62949. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62950. */
  62951. minRegionArea: number;
  62952. /**
  62953. * Any regions with a span count smaller than this value will, if possible,
  62954. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62955. */
  62956. mergeRegionArea: number;
  62957. /**
  62958. * The maximum number of vertices allowed for polygons generated during the
  62959. * contour to polygon conversion process. [Limit: >= 3]
  62960. */
  62961. maxVertsPerPoly: number;
  62962. /**
  62963. * Sets the sampling distance to use when generating the detail mesh.
  62964. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62965. */
  62966. detailSampleDist: number;
  62967. /**
  62968. * The maximum distance the detail mesh surface should deviate from heightfield
  62969. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62970. */
  62971. detailSampleMaxError: number;
  62972. }
  62973. }
  62974. declare module BABYLON {
  62975. /**
  62976. * RecastJS navigation plugin
  62977. */
  62978. export class RecastJSPlugin implements INavigationEnginePlugin {
  62979. /**
  62980. * Reference to the Recast library
  62981. */
  62982. bjsRECAST: any;
  62983. /**
  62984. * plugin name
  62985. */
  62986. name: string;
  62987. /**
  62988. * the first navmesh created. We might extend this to support multiple navmeshes
  62989. */
  62990. navMesh: any;
  62991. /**
  62992. * Initializes the recastJS plugin
  62993. * @param recastInjection can be used to inject your own recast reference
  62994. */
  62995. constructor(recastInjection?: any);
  62996. /**
  62997. * Creates a navigation mesh
  62998. * @param meshes array of all the geometry used to compute the navigatio mesh
  62999. * @param parameters bunch of parameters used to filter geometry
  63000. */
  63001. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63002. /**
  63003. * Create a navigation mesh debug mesh
  63004. * @param scene is where the mesh will be added
  63005. * @returns debug display mesh
  63006. */
  63007. createDebugNavMesh(scene: Scene): Mesh;
  63008. /**
  63009. * Get a navigation mesh constrained position, closest to the parameter position
  63010. * @param position world position
  63011. * @returns the closest point to position constrained by the navigation mesh
  63012. */
  63013. getClosestPoint(position: Vector3): Vector3;
  63014. /**
  63015. * Get a navigation mesh constrained position, closest to the parameter position
  63016. * @param position world position
  63017. * @param result output the closest point to position constrained by the navigation mesh
  63018. */
  63019. getClosestPointToRef(position: Vector3, result: Vector3): void;
  63020. /**
  63021. * Get a navigation mesh constrained position, within a particular radius
  63022. * @param position world position
  63023. * @param maxRadius the maximum distance to the constrained world position
  63024. * @returns the closest point to position constrained by the navigation mesh
  63025. */
  63026. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63027. /**
  63028. * Get a navigation mesh constrained position, within a particular radius
  63029. * @param position world position
  63030. * @param maxRadius the maximum distance to the constrained world position
  63031. * @param result output the closest point to position constrained by the navigation mesh
  63032. */
  63033. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  63034. /**
  63035. * Compute the final position from a segment made of destination-position
  63036. * @param position world position
  63037. * @param destination world position
  63038. * @returns the resulting point along the navmesh
  63039. */
  63040. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63041. /**
  63042. * Compute the final position from a segment made of destination-position
  63043. * @param position world position
  63044. * @param destination world position
  63045. * @param result output the resulting point along the navmesh
  63046. */
  63047. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  63048. /**
  63049. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63050. * @param start world position
  63051. * @param end world position
  63052. * @returns array containing world position composing the path
  63053. */
  63054. computePath(start: Vector3, end: Vector3): Vector3[];
  63055. /**
  63056. * Create a new Crowd so you can add agents
  63057. * @param maxAgents the maximum agent count in the crowd
  63058. * @param maxAgentRadius the maximum radius an agent can have
  63059. * @param scene to attach the crowd to
  63060. * @returns the crowd you can add agents to
  63061. */
  63062. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63063. /**
  63064. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63065. * The queries will try to find a solution within those bounds
  63066. * default is (1,1,1)
  63067. * @param extent x,y,z value that define the extent around the queries point of reference
  63068. */
  63069. setDefaultQueryExtent(extent: Vector3): void;
  63070. /**
  63071. * Get the Bounding box extent specified by setDefaultQueryExtent
  63072. * @returns the box extent values
  63073. */
  63074. getDefaultQueryExtent(): Vector3;
  63075. /**
  63076. * build the navmesh from a previously saved state using getNavmeshData
  63077. * @param data the Uint8Array returned by getNavmeshData
  63078. */
  63079. buildFromNavmeshData(data: Uint8Array): void;
  63080. /**
  63081. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  63082. * @returns data the Uint8Array that can be saved and reused
  63083. */
  63084. getNavmeshData(): Uint8Array;
  63085. /**
  63086. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63087. * @param result output the box extent values
  63088. */
  63089. getDefaultQueryExtentToRef(result: Vector3): void;
  63090. /**
  63091. * Disposes
  63092. */
  63093. dispose(): void;
  63094. /**
  63095. * If this plugin is supported
  63096. * @returns true if plugin is supported
  63097. */
  63098. isSupported(): boolean;
  63099. }
  63100. /**
  63101. * Recast detour crowd implementation
  63102. */
  63103. export class RecastJSCrowd implements ICrowd {
  63104. /**
  63105. * Recast/detour plugin
  63106. */
  63107. bjsRECASTPlugin: RecastJSPlugin;
  63108. /**
  63109. * Link to the detour crowd
  63110. */
  63111. recastCrowd: any;
  63112. /**
  63113. * One transform per agent
  63114. */
  63115. transforms: TransformNode[];
  63116. /**
  63117. * All agents created
  63118. */
  63119. agents: number[];
  63120. /**
  63121. * Link to the scene is kept to unregister the crowd from the scene
  63122. */
  63123. private _scene;
  63124. /**
  63125. * Observer for crowd updates
  63126. */
  63127. private _onBeforeAnimationsObserver;
  63128. /**
  63129. * Constructor
  63130. * @param plugin recastJS plugin
  63131. * @param maxAgents the maximum agent count in the crowd
  63132. * @param maxAgentRadius the maximum radius an agent can have
  63133. * @param scene to attach the crowd to
  63134. * @returns the crowd you can add agents to
  63135. */
  63136. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63137. /**
  63138. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63139. * You can attach anything to that node. The node position is updated in the scene update tick.
  63140. * @param pos world position that will be constrained by the navigation mesh
  63141. * @param parameters agent parameters
  63142. * @param transform hooked to the agent that will be update by the scene
  63143. * @returns agent index
  63144. */
  63145. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63146. /**
  63147. * Returns the agent position in world space
  63148. * @param index agent index returned by addAgent
  63149. * @returns world space position
  63150. */
  63151. getAgentPosition(index: number): Vector3;
  63152. /**
  63153. * Returns the agent position result in world space
  63154. * @param index agent index returned by addAgent
  63155. * @param result output world space position
  63156. */
  63157. getAgentPositionToRef(index: number, result: Vector3): void;
  63158. /**
  63159. * Returns the agent velocity in world space
  63160. * @param index agent index returned by addAgent
  63161. * @returns world space velocity
  63162. */
  63163. getAgentVelocity(index: number): Vector3;
  63164. /**
  63165. * Returns the agent velocity result in world space
  63166. * @param index agent index returned by addAgent
  63167. * @param result output world space velocity
  63168. */
  63169. getAgentVelocityToRef(index: number, result: Vector3): void;
  63170. /**
  63171. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63172. * @param index agent index returned by addAgent
  63173. * @param destination targeted world position
  63174. */
  63175. agentGoto(index: number, destination: Vector3): void;
  63176. /**
  63177. * Teleport the agent to a new position
  63178. * @param index agent index returned by addAgent
  63179. * @param destination targeted world position
  63180. */
  63181. agentTeleport(index: number, destination: Vector3): void;
  63182. /**
  63183. * Update agent parameters
  63184. * @param index agent index returned by addAgent
  63185. * @param parameters agent parameters
  63186. */
  63187. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  63188. /**
  63189. * remove a particular agent previously created
  63190. * @param index agent index returned by addAgent
  63191. */
  63192. removeAgent(index: number): void;
  63193. /**
  63194. * get the list of all agents attached to this crowd
  63195. * @returns list of agent indices
  63196. */
  63197. getAgents(): number[];
  63198. /**
  63199. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63200. * @param deltaTime in seconds
  63201. */
  63202. update(deltaTime: number): void;
  63203. /**
  63204. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63205. * The queries will try to find a solution within those bounds
  63206. * default is (1,1,1)
  63207. * @param extent x,y,z value that define the extent around the queries point of reference
  63208. */
  63209. setDefaultQueryExtent(extent: Vector3): void;
  63210. /**
  63211. * Get the Bounding box extent specified by setDefaultQueryExtent
  63212. * @returns the box extent values
  63213. */
  63214. getDefaultQueryExtent(): Vector3;
  63215. /**
  63216. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63217. * @param result output the box extent values
  63218. */
  63219. getDefaultQueryExtentToRef(result: Vector3): void;
  63220. /**
  63221. * Release all resources
  63222. */
  63223. dispose(): void;
  63224. }
  63225. }
  63226. declare module BABYLON {
  63227. /**
  63228. * Class used to enable access to IndexedDB
  63229. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63230. */
  63231. export class Database implements IOfflineProvider {
  63232. private _callbackManifestChecked;
  63233. private _currentSceneUrl;
  63234. private _db;
  63235. private _enableSceneOffline;
  63236. private _enableTexturesOffline;
  63237. private _manifestVersionFound;
  63238. private _mustUpdateRessources;
  63239. private _hasReachedQuota;
  63240. private _isSupported;
  63241. private _idbFactory;
  63242. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63243. private static IsUASupportingBlobStorage;
  63244. /**
  63245. * Gets a boolean indicating if Database storate is enabled (off by default)
  63246. */
  63247. static IDBStorageEnabled: boolean;
  63248. /**
  63249. * Gets a boolean indicating if scene must be saved in the database
  63250. */
  63251. get enableSceneOffline(): boolean;
  63252. /**
  63253. * Gets a boolean indicating if textures must be saved in the database
  63254. */
  63255. get enableTexturesOffline(): boolean;
  63256. /**
  63257. * Creates a new Database
  63258. * @param urlToScene defines the url to load the scene
  63259. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63260. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63261. */
  63262. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63263. private static _ParseURL;
  63264. private static _ReturnFullUrlLocation;
  63265. private _checkManifestFile;
  63266. /**
  63267. * Open the database and make it available
  63268. * @param successCallback defines the callback to call on success
  63269. * @param errorCallback defines the callback to call on error
  63270. */
  63271. open(successCallback: () => void, errorCallback: () => void): void;
  63272. /**
  63273. * Loads an image from the database
  63274. * @param url defines the url to load from
  63275. * @param image defines the target DOM image
  63276. */
  63277. loadImage(url: string, image: HTMLImageElement): void;
  63278. private _loadImageFromDBAsync;
  63279. private _saveImageIntoDBAsync;
  63280. private _checkVersionFromDB;
  63281. private _loadVersionFromDBAsync;
  63282. private _saveVersionIntoDBAsync;
  63283. /**
  63284. * Loads a file from database
  63285. * @param url defines the URL to load from
  63286. * @param sceneLoaded defines a callback to call on success
  63287. * @param progressCallBack defines a callback to call when progress changed
  63288. * @param errorCallback defines a callback to call on error
  63289. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63290. */
  63291. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63292. private _loadFileAsync;
  63293. private _saveFileAsync;
  63294. /**
  63295. * Validates if xhr data is correct
  63296. * @param xhr defines the request to validate
  63297. * @param dataType defines the expected data type
  63298. * @returns true if data is correct
  63299. */
  63300. private static _ValidateXHRData;
  63301. }
  63302. }
  63303. declare module BABYLON {
  63304. /** @hidden */
  63305. export var gpuUpdateParticlesPixelShader: {
  63306. name: string;
  63307. shader: string;
  63308. };
  63309. }
  63310. declare module BABYLON {
  63311. /** @hidden */
  63312. export var gpuUpdateParticlesVertexShader: {
  63313. name: string;
  63314. shader: string;
  63315. };
  63316. }
  63317. declare module BABYLON {
  63318. /** @hidden */
  63319. export var clipPlaneFragmentDeclaration2: {
  63320. name: string;
  63321. shader: string;
  63322. };
  63323. }
  63324. declare module BABYLON {
  63325. /** @hidden */
  63326. export var gpuRenderParticlesPixelShader: {
  63327. name: string;
  63328. shader: string;
  63329. };
  63330. }
  63331. declare module BABYLON {
  63332. /** @hidden */
  63333. export var clipPlaneVertexDeclaration2: {
  63334. name: string;
  63335. shader: string;
  63336. };
  63337. }
  63338. declare module BABYLON {
  63339. /** @hidden */
  63340. export var gpuRenderParticlesVertexShader: {
  63341. name: string;
  63342. shader: string;
  63343. };
  63344. }
  63345. declare module BABYLON {
  63346. /**
  63347. * This represents a GPU particle system in Babylon
  63348. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63349. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63350. */
  63351. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63352. /**
  63353. * The layer mask we are rendering the particles through.
  63354. */
  63355. layerMask: number;
  63356. private _capacity;
  63357. private _activeCount;
  63358. private _currentActiveCount;
  63359. private _accumulatedCount;
  63360. private _renderEffect;
  63361. private _updateEffect;
  63362. private _buffer0;
  63363. private _buffer1;
  63364. private _spriteBuffer;
  63365. private _updateVAO;
  63366. private _renderVAO;
  63367. private _targetIndex;
  63368. private _sourceBuffer;
  63369. private _targetBuffer;
  63370. private _engine;
  63371. private _currentRenderId;
  63372. private _started;
  63373. private _stopped;
  63374. private _timeDelta;
  63375. private _randomTexture;
  63376. private _randomTexture2;
  63377. private _attributesStrideSize;
  63378. private _updateEffectOptions;
  63379. private _randomTextureSize;
  63380. private _actualFrame;
  63381. private readonly _rawTextureWidth;
  63382. /**
  63383. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63384. */
  63385. static get IsSupported(): boolean;
  63386. /**
  63387. * An event triggered when the system is disposed.
  63388. */
  63389. onDisposeObservable: Observable<GPUParticleSystem>;
  63390. /**
  63391. * Gets the maximum number of particles active at the same time.
  63392. * @returns The max number of active particles.
  63393. */
  63394. getCapacity(): number;
  63395. /**
  63396. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63397. * to override the particles.
  63398. */
  63399. forceDepthWrite: boolean;
  63400. /**
  63401. * Gets or set the number of active particles
  63402. */
  63403. get activeParticleCount(): number;
  63404. set activeParticleCount(value: number);
  63405. private _preWarmDone;
  63406. /**
  63407. * Specifies if the particles are updated in emitter local space or world space.
  63408. */
  63409. isLocal: boolean;
  63410. /**
  63411. * Is this system ready to be used/rendered
  63412. * @return true if the system is ready
  63413. */
  63414. isReady(): boolean;
  63415. /**
  63416. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63417. * @returns True if it has been started, otherwise false.
  63418. */
  63419. isStarted(): boolean;
  63420. /**
  63421. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63422. * @returns True if it has been stopped, otherwise false.
  63423. */
  63424. isStopped(): boolean;
  63425. /**
  63426. * Gets a boolean indicating that the system is stopping
  63427. * @returns true if the system is currently stopping
  63428. */
  63429. isStopping(): boolean;
  63430. /**
  63431. * Gets the number of particles active at the same time.
  63432. * @returns The number of active particles.
  63433. */
  63434. getActiveCount(): number;
  63435. /**
  63436. * Starts the particle system and begins to emit
  63437. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63438. */
  63439. start(delay?: number): void;
  63440. /**
  63441. * Stops the particle system.
  63442. */
  63443. stop(): void;
  63444. /**
  63445. * Remove all active particles
  63446. */
  63447. reset(): void;
  63448. /**
  63449. * Returns the string "GPUParticleSystem"
  63450. * @returns a string containing the class name
  63451. */
  63452. getClassName(): string;
  63453. private _colorGradientsTexture;
  63454. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63455. /**
  63456. * Adds a new color gradient
  63457. * @param gradient defines the gradient to use (between 0 and 1)
  63458. * @param color1 defines the color to affect to the specified gradient
  63459. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63460. * @returns the current particle system
  63461. */
  63462. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63463. private _refreshColorGradient;
  63464. /** Force the system to rebuild all gradients that need to be resync */
  63465. forceRefreshGradients(): void;
  63466. /**
  63467. * Remove a specific color gradient
  63468. * @param gradient defines the gradient to remove
  63469. * @returns the current particle system
  63470. */
  63471. removeColorGradient(gradient: number): GPUParticleSystem;
  63472. private _angularSpeedGradientsTexture;
  63473. private _sizeGradientsTexture;
  63474. private _velocityGradientsTexture;
  63475. private _limitVelocityGradientsTexture;
  63476. private _dragGradientsTexture;
  63477. private _addFactorGradient;
  63478. /**
  63479. * Adds a new size gradient
  63480. * @param gradient defines the gradient to use (between 0 and 1)
  63481. * @param factor defines the size factor to affect to the specified gradient
  63482. * @returns the current particle system
  63483. */
  63484. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63485. /**
  63486. * Remove a specific size gradient
  63487. * @param gradient defines the gradient to remove
  63488. * @returns the current particle system
  63489. */
  63490. removeSizeGradient(gradient: number): GPUParticleSystem;
  63491. private _refreshFactorGradient;
  63492. /**
  63493. * Adds a new angular speed gradient
  63494. * @param gradient defines the gradient to use (between 0 and 1)
  63495. * @param factor defines the angular speed to affect to the specified gradient
  63496. * @returns the current particle system
  63497. */
  63498. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63499. /**
  63500. * Remove a specific angular speed gradient
  63501. * @param gradient defines the gradient to remove
  63502. * @returns the current particle system
  63503. */
  63504. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63505. /**
  63506. * Adds a new velocity gradient
  63507. * @param gradient defines the gradient to use (between 0 and 1)
  63508. * @param factor defines the velocity to affect to the specified gradient
  63509. * @returns the current particle system
  63510. */
  63511. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63512. /**
  63513. * Remove a specific velocity gradient
  63514. * @param gradient defines the gradient to remove
  63515. * @returns the current particle system
  63516. */
  63517. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63518. /**
  63519. * Adds a new limit velocity gradient
  63520. * @param gradient defines the gradient to use (between 0 and 1)
  63521. * @param factor defines the limit velocity value to affect to the specified gradient
  63522. * @returns the current particle system
  63523. */
  63524. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63525. /**
  63526. * Remove a specific limit velocity gradient
  63527. * @param gradient defines the gradient to remove
  63528. * @returns the current particle system
  63529. */
  63530. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63531. /**
  63532. * Adds a new drag gradient
  63533. * @param gradient defines the gradient to use (between 0 and 1)
  63534. * @param factor defines the drag value to affect to the specified gradient
  63535. * @returns the current particle system
  63536. */
  63537. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63538. /**
  63539. * Remove a specific drag gradient
  63540. * @param gradient defines the gradient to remove
  63541. * @returns the current particle system
  63542. */
  63543. removeDragGradient(gradient: number): GPUParticleSystem;
  63544. /**
  63545. * Not supported by GPUParticleSystem
  63546. * @param gradient defines the gradient to use (between 0 and 1)
  63547. * @param factor defines the emit rate value to affect to the specified gradient
  63548. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63549. * @returns the current particle system
  63550. */
  63551. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63552. /**
  63553. * Not supported by GPUParticleSystem
  63554. * @param gradient defines the gradient to remove
  63555. * @returns the current particle system
  63556. */
  63557. removeEmitRateGradient(gradient: number): IParticleSystem;
  63558. /**
  63559. * Not supported by GPUParticleSystem
  63560. * @param gradient defines the gradient to use (between 0 and 1)
  63561. * @param factor defines the start size value to affect to the specified gradient
  63562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63563. * @returns the current particle system
  63564. */
  63565. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63566. /**
  63567. * Not supported by GPUParticleSystem
  63568. * @param gradient defines the gradient to remove
  63569. * @returns the current particle system
  63570. */
  63571. removeStartSizeGradient(gradient: number): IParticleSystem;
  63572. /**
  63573. * Not supported by GPUParticleSystem
  63574. * @param gradient defines the gradient to use (between 0 and 1)
  63575. * @param min defines the color remap minimal range
  63576. * @param max defines the color remap maximal range
  63577. * @returns the current particle system
  63578. */
  63579. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63580. /**
  63581. * Not supported by GPUParticleSystem
  63582. * @param gradient defines the gradient to remove
  63583. * @returns the current particle system
  63584. */
  63585. removeColorRemapGradient(): IParticleSystem;
  63586. /**
  63587. * Not supported by GPUParticleSystem
  63588. * @param gradient defines the gradient to use (between 0 and 1)
  63589. * @param min defines the alpha remap minimal range
  63590. * @param max defines the alpha remap maximal range
  63591. * @returns the current particle system
  63592. */
  63593. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63594. /**
  63595. * Not supported by GPUParticleSystem
  63596. * @param gradient defines the gradient to remove
  63597. * @returns the current particle system
  63598. */
  63599. removeAlphaRemapGradient(): IParticleSystem;
  63600. /**
  63601. * Not supported by GPUParticleSystem
  63602. * @param gradient defines the gradient to use (between 0 and 1)
  63603. * @param color defines the color to affect to the specified gradient
  63604. * @returns the current particle system
  63605. */
  63606. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63607. /**
  63608. * Not supported by GPUParticleSystem
  63609. * @param gradient defines the gradient to remove
  63610. * @returns the current particle system
  63611. */
  63612. removeRampGradient(): IParticleSystem;
  63613. /**
  63614. * Not supported by GPUParticleSystem
  63615. * @returns the list of ramp gradients
  63616. */
  63617. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63618. /**
  63619. * Not supported by GPUParticleSystem
  63620. * Gets or sets a boolean indicating that ramp gradients must be used
  63621. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63622. */
  63623. get useRampGradients(): boolean;
  63624. set useRampGradients(value: boolean);
  63625. /**
  63626. * Not supported by GPUParticleSystem
  63627. * @param gradient defines the gradient to use (between 0 and 1)
  63628. * @param factor defines the life time factor to affect to the specified gradient
  63629. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63630. * @returns the current particle system
  63631. */
  63632. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63633. /**
  63634. * Not supported by GPUParticleSystem
  63635. * @param gradient defines the gradient to remove
  63636. * @returns the current particle system
  63637. */
  63638. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63639. /**
  63640. * Instantiates a GPU particle system.
  63641. * 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.
  63642. * @param name The name of the particle system
  63643. * @param options The options used to create the system
  63644. * @param scene The scene the particle system belongs to
  63645. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63646. */
  63647. constructor(name: string, options: Partial<{
  63648. capacity: number;
  63649. randomTextureSize: number;
  63650. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63651. protected _reset(): void;
  63652. private _createUpdateVAO;
  63653. private _createRenderVAO;
  63654. private _initialize;
  63655. /** @hidden */
  63656. _recreateUpdateEffect(): void;
  63657. /** @hidden */
  63658. _recreateRenderEffect(): void;
  63659. /**
  63660. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63661. * @param preWarm defines if we are in the pre-warmimg phase
  63662. */
  63663. animate(preWarm?: boolean): void;
  63664. private _createFactorGradientTexture;
  63665. private _createSizeGradientTexture;
  63666. private _createAngularSpeedGradientTexture;
  63667. private _createVelocityGradientTexture;
  63668. private _createLimitVelocityGradientTexture;
  63669. private _createDragGradientTexture;
  63670. private _createColorGradientTexture;
  63671. /**
  63672. * Renders the particle system in its current state
  63673. * @param preWarm defines if the system should only update the particles but not render them
  63674. * @returns the current number of particles
  63675. */
  63676. render(preWarm?: boolean): number;
  63677. /**
  63678. * Rebuilds the particle system
  63679. */
  63680. rebuild(): void;
  63681. private _releaseBuffers;
  63682. private _releaseVAOs;
  63683. /**
  63684. * Disposes the particle system and free the associated resources
  63685. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63686. */
  63687. dispose(disposeTexture?: boolean): void;
  63688. /**
  63689. * Clones the particle system.
  63690. * @param name The name of the cloned object
  63691. * @param newEmitter The new emitter to use
  63692. * @returns the cloned particle system
  63693. */
  63694. clone(name: string, newEmitter: any): GPUParticleSystem;
  63695. /**
  63696. * Serializes the particle system to a JSON object
  63697. * @param serializeTexture defines if the texture must be serialized as well
  63698. * @returns the JSON object
  63699. */
  63700. serialize(serializeTexture?: boolean): any;
  63701. /**
  63702. * Parses a JSON object to create a GPU particle system.
  63703. * @param parsedParticleSystem The JSON object to parse
  63704. * @param scene The scene to create the particle system in
  63705. * @param rootUrl The root url to use to load external dependencies like texture
  63706. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63707. * @returns the parsed GPU particle system
  63708. */
  63709. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63710. }
  63711. }
  63712. declare module BABYLON {
  63713. /**
  63714. * Represents a set of particle systems working together to create a specific effect
  63715. */
  63716. export class ParticleSystemSet implements IDisposable {
  63717. /**
  63718. * Gets or sets base Assets URL
  63719. */
  63720. static BaseAssetsUrl: string;
  63721. private _emitterCreationOptions;
  63722. private _emitterNode;
  63723. /**
  63724. * Gets the particle system list
  63725. */
  63726. systems: IParticleSystem[];
  63727. /**
  63728. * Gets the emitter node used with this set
  63729. */
  63730. get emitterNode(): Nullable<TransformNode>;
  63731. /**
  63732. * Creates a new emitter mesh as a sphere
  63733. * @param options defines the options used to create the sphere
  63734. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63735. * @param scene defines the hosting scene
  63736. */
  63737. setEmitterAsSphere(options: {
  63738. diameter: number;
  63739. segments: number;
  63740. color: Color3;
  63741. }, renderingGroupId: number, scene: Scene): void;
  63742. /**
  63743. * Starts all particle systems of the set
  63744. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63745. */
  63746. start(emitter?: AbstractMesh): void;
  63747. /**
  63748. * Release all associated resources
  63749. */
  63750. dispose(): void;
  63751. /**
  63752. * Serialize the set into a JSON compatible object
  63753. * @param serializeTexture defines if the texture must be serialized as well
  63754. * @returns a JSON compatible representation of the set
  63755. */
  63756. serialize(serializeTexture?: boolean): any;
  63757. /**
  63758. * Parse a new ParticleSystemSet from a serialized source
  63759. * @param data defines a JSON compatible representation of the set
  63760. * @param scene defines the hosting scene
  63761. * @param gpu defines if we want GPU particles or CPU particles
  63762. * @returns a new ParticleSystemSet
  63763. */
  63764. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63765. }
  63766. }
  63767. declare module BABYLON {
  63768. /**
  63769. * This class is made for on one-liner static method to help creating particle system set.
  63770. */
  63771. export class ParticleHelper {
  63772. /**
  63773. * Gets or sets base Assets URL
  63774. */
  63775. static BaseAssetsUrl: string;
  63776. /** Define the Url to load snippets */
  63777. static SnippetUrl: string;
  63778. /**
  63779. * Create a default particle system that you can tweak
  63780. * @param emitter defines the emitter to use
  63781. * @param capacity defines the system capacity (default is 500 particles)
  63782. * @param scene defines the hosting scene
  63783. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63784. * @returns the new Particle system
  63785. */
  63786. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63787. /**
  63788. * This is the main static method (one-liner) of this helper to create different particle systems
  63789. * @param type This string represents the type to the particle system to create
  63790. * @param scene The scene where the particle system should live
  63791. * @param gpu If the system will use gpu
  63792. * @returns the ParticleSystemSet created
  63793. */
  63794. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63795. /**
  63796. * Static function used to export a particle system to a ParticleSystemSet variable.
  63797. * Please note that the emitter shape is not exported
  63798. * @param systems defines the particle systems to export
  63799. * @returns the created particle system set
  63800. */
  63801. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63802. /**
  63803. * Creates a particle system from a snippet saved in a remote file
  63804. * @param name defines the name of the particle system to create
  63805. * @param url defines the url to load from
  63806. * @param scene defines the hosting scene
  63807. * @param gpu If the system will use gpu
  63808. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63809. * @returns a promise that will resolve to the new particle system
  63810. */
  63811. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63812. /**
  63813. * Creates a particle system from a snippet saved by the particle system editor
  63814. * @param snippetId defines the snippet to load
  63815. * @param scene defines the hosting scene
  63816. * @param gpu If the system will use gpu
  63817. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63818. * @returns a promise that will resolve to the new particle system
  63819. */
  63820. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63821. }
  63822. }
  63823. declare module BABYLON {
  63824. interface Engine {
  63825. /**
  63826. * Create an effect to use with particle systems.
  63827. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63828. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63829. * @param uniformsNames defines a list of attribute names
  63830. * @param samplers defines an array of string used to represent textures
  63831. * @param defines defines the string containing the defines to use to compile the shaders
  63832. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63833. * @param onCompiled defines a function to call when the effect creation is successful
  63834. * @param onError defines a function to call when the effect creation has failed
  63835. * @returns the new Effect
  63836. */
  63837. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63838. }
  63839. interface Mesh {
  63840. /**
  63841. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63842. * @returns an array of IParticleSystem
  63843. */
  63844. getEmittedParticleSystems(): IParticleSystem[];
  63845. /**
  63846. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63847. * @returns an array of IParticleSystem
  63848. */
  63849. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63850. }
  63851. /**
  63852. * @hidden
  63853. */
  63854. export var _IDoNeedToBeInTheBuild: number;
  63855. }
  63856. declare module BABYLON {
  63857. /** Defines the 4 color options */
  63858. export enum PointColor {
  63859. /** color value */
  63860. Color = 2,
  63861. /** uv value */
  63862. UV = 1,
  63863. /** random value */
  63864. Random = 0,
  63865. /** stated value */
  63866. Stated = 3
  63867. }
  63868. /**
  63869. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63870. * 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.
  63871. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63872. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63873. *
  63874. * Full documentation here : TO BE ENTERED
  63875. */
  63876. export class PointsCloudSystem implements IDisposable {
  63877. /**
  63878. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63879. * Example : var p = SPS.particles[i];
  63880. */
  63881. particles: CloudPoint[];
  63882. /**
  63883. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63884. */
  63885. nbParticles: number;
  63886. /**
  63887. * This a counter for your own usage. It's not set by any SPS functions.
  63888. */
  63889. counter: number;
  63890. /**
  63891. * The PCS name. This name is also given to the underlying mesh.
  63892. */
  63893. name: string;
  63894. /**
  63895. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63896. */
  63897. mesh: Mesh;
  63898. /**
  63899. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63900. * Please read :
  63901. */
  63902. vars: any;
  63903. /**
  63904. * @hidden
  63905. */
  63906. _size: number;
  63907. private _scene;
  63908. private _promises;
  63909. private _positions;
  63910. private _indices;
  63911. private _normals;
  63912. private _colors;
  63913. private _uvs;
  63914. private _indices32;
  63915. private _positions32;
  63916. private _colors32;
  63917. private _uvs32;
  63918. private _updatable;
  63919. private _isVisibilityBoxLocked;
  63920. private _alwaysVisible;
  63921. private _groups;
  63922. private _groupCounter;
  63923. private _computeParticleColor;
  63924. private _computeParticleTexture;
  63925. private _computeParticleRotation;
  63926. private _computeBoundingBox;
  63927. private _isReady;
  63928. /**
  63929. * Creates a PCS (Points Cloud System) object
  63930. * @param name (String) is the PCS name, this will be the underlying mesh name
  63931. * @param pointSize (number) is the size for each point
  63932. * @param scene (Scene) is the scene in which the PCS is added
  63933. * @param options defines the options of the PCS e.g.
  63934. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63935. */
  63936. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63937. updatable?: boolean;
  63938. });
  63939. /**
  63940. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63941. * If no points were added to the PCS, the returned mesh is just a single point.
  63942. * @returns a promise for the created mesh
  63943. */
  63944. buildMeshAsync(): Promise<Mesh>;
  63945. /**
  63946. * @hidden
  63947. */
  63948. private _buildMesh;
  63949. private _addParticle;
  63950. private _randomUnitVector;
  63951. private _getColorIndicesForCoord;
  63952. private _setPointsColorOrUV;
  63953. private _colorFromTexture;
  63954. private _calculateDensity;
  63955. /**
  63956. * Adds points to the PCS in random positions within a unit sphere
  63957. * @param nb (positive integer) the number of particles to be created from this model
  63958. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63959. * @returns the number of groups in the system
  63960. */
  63961. addPoints(nb: number, pointFunction?: any): number;
  63962. /**
  63963. * Adds points to the PCS from the surface of the model shape
  63964. * @param mesh is any Mesh object that will be used as a surface model for the points
  63965. * @param nb (positive integer) the number of particles to be created from this model
  63966. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63967. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63968. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63969. * @returns the number of groups in the system
  63970. */
  63971. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63972. /**
  63973. * Adds points to the PCS inside the model shape
  63974. * @param mesh is any Mesh object that will be used as a surface model for the points
  63975. * @param nb (positive integer) the number of particles to be created from this model
  63976. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63977. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63978. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63979. * @returns the number of groups in the system
  63980. */
  63981. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63982. /**
  63983. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63984. * This method calls `updateParticle()` for each particle of the SPS.
  63985. * For an animated SPS, it is usually called within the render loop.
  63986. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63987. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63988. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63989. * @returns the PCS.
  63990. */
  63991. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63992. /**
  63993. * Disposes the PCS.
  63994. */
  63995. dispose(): void;
  63996. /**
  63997. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63998. * doc :
  63999. * @returns the PCS.
  64000. */
  64001. refreshVisibleSize(): PointsCloudSystem;
  64002. /**
  64003. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  64004. * @param size the size (float) of the visibility box
  64005. * note : this doesn't lock the PCS mesh bounding box.
  64006. * doc :
  64007. */
  64008. setVisibilityBox(size: number): void;
  64009. /**
  64010. * Gets whether the PCS is always visible or not
  64011. * doc :
  64012. */
  64013. get isAlwaysVisible(): boolean;
  64014. /**
  64015. * Sets the PCS as always visible or not
  64016. * doc :
  64017. */
  64018. set isAlwaysVisible(val: boolean);
  64019. /**
  64020. * Tells to `setParticles()` to compute the particle rotations or not
  64021. * Default value : false. The PCS is faster when it's set to false
  64022. * Note : particle rotations are only applied to parent particles
  64023. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  64024. */
  64025. set computeParticleRotation(val: boolean);
  64026. /**
  64027. * Tells to `setParticles()` to compute the particle colors or not.
  64028. * Default value : true. The PCS is faster when it's set to false.
  64029. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64030. */
  64031. set computeParticleColor(val: boolean);
  64032. set computeParticleTexture(val: boolean);
  64033. /**
  64034. * Gets if `setParticles()` computes the particle colors or not.
  64035. * Default value : false. The PCS is faster when it's set to false.
  64036. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64037. */
  64038. get computeParticleColor(): boolean;
  64039. /**
  64040. * Gets if `setParticles()` computes the particle textures or not.
  64041. * Default value : false. The PCS is faster when it's set to false.
  64042. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  64043. */
  64044. get computeParticleTexture(): boolean;
  64045. /**
  64046. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  64047. */
  64048. set computeBoundingBox(val: boolean);
  64049. /**
  64050. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  64051. */
  64052. get computeBoundingBox(): boolean;
  64053. /**
  64054. * This function does nothing. It may be overwritten to set all the particle first values.
  64055. * The PCS doesn't call this function, you may have to call it by your own.
  64056. * doc :
  64057. */
  64058. initParticles(): void;
  64059. /**
  64060. * This function does nothing. It may be overwritten to recycle a particle
  64061. * The PCS doesn't call this function, you can to call it
  64062. * doc :
  64063. * @param particle The particle to recycle
  64064. * @returns the recycled particle
  64065. */
  64066. recycleParticle(particle: CloudPoint): CloudPoint;
  64067. /**
  64068. * Updates a particle : this function should be overwritten by the user.
  64069. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  64070. * doc :
  64071. * @example : just set a particle position or velocity and recycle conditions
  64072. * @param particle The particle to update
  64073. * @returns the updated particle
  64074. */
  64075. updateParticle(particle: CloudPoint): CloudPoint;
  64076. /**
  64077. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64078. * This does nothing and may be overwritten by the user.
  64079. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64080. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64081. * @param update the boolean update value actually passed to setParticles()
  64082. */
  64083. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64084. /**
  64085. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64086. * This will be passed three parameters.
  64087. * This does nothing and may be overwritten by the user.
  64088. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64089. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64090. * @param update the boolean update value actually passed to setParticles()
  64091. */
  64092. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64093. }
  64094. }
  64095. declare module BABYLON {
  64096. /**
  64097. * Represents one particle of a points cloud system.
  64098. */
  64099. export class CloudPoint {
  64100. /**
  64101. * particle global index
  64102. */
  64103. idx: number;
  64104. /**
  64105. * The color of the particle
  64106. */
  64107. color: Nullable<Color4>;
  64108. /**
  64109. * The world space position of the particle.
  64110. */
  64111. position: Vector3;
  64112. /**
  64113. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64114. */
  64115. rotation: Vector3;
  64116. /**
  64117. * The world space rotation quaternion of the particle.
  64118. */
  64119. rotationQuaternion: Nullable<Quaternion>;
  64120. /**
  64121. * The uv of the particle.
  64122. */
  64123. uv: Nullable<Vector2>;
  64124. /**
  64125. * The current speed of the particle.
  64126. */
  64127. velocity: Vector3;
  64128. /**
  64129. * The pivot point in the particle local space.
  64130. */
  64131. pivot: Vector3;
  64132. /**
  64133. * Must the particle be translated from its pivot point in its local space ?
  64134. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64135. * Default : false
  64136. */
  64137. translateFromPivot: boolean;
  64138. /**
  64139. * Index of this particle in the global "positions" array (Internal use)
  64140. * @hidden
  64141. */
  64142. _pos: number;
  64143. /**
  64144. * @hidden Index of this particle in the global "indices" array (Internal use)
  64145. */
  64146. _ind: number;
  64147. /**
  64148. * Group this particle belongs to
  64149. */
  64150. _group: PointsGroup;
  64151. /**
  64152. * Group id of this particle
  64153. */
  64154. groupId: number;
  64155. /**
  64156. * Index of the particle in its group id (Internal use)
  64157. */
  64158. idxInGroup: number;
  64159. /**
  64160. * @hidden Particle BoundingInfo object (Internal use)
  64161. */
  64162. _boundingInfo: BoundingInfo;
  64163. /**
  64164. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64165. */
  64166. _pcs: PointsCloudSystem;
  64167. /**
  64168. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64169. */
  64170. _stillInvisible: boolean;
  64171. /**
  64172. * @hidden Last computed particle rotation matrix
  64173. */
  64174. _rotationMatrix: number[];
  64175. /**
  64176. * Parent particle Id, if any.
  64177. * Default null.
  64178. */
  64179. parentId: Nullable<number>;
  64180. /**
  64181. * @hidden Internal global position in the PCS.
  64182. */
  64183. _globalPosition: Vector3;
  64184. /**
  64185. * Creates a Point Cloud object.
  64186. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64187. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64188. * @param group (PointsGroup) is the group the particle belongs to
  64189. * @param groupId (integer) is the group identifier in the PCS.
  64190. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64191. * @param pcs defines the PCS it is associated to
  64192. */
  64193. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64194. /**
  64195. * get point size
  64196. */
  64197. get size(): Vector3;
  64198. /**
  64199. * Set point size
  64200. */
  64201. set size(scale: Vector3);
  64202. /**
  64203. * Legacy support, changed quaternion to rotationQuaternion
  64204. */
  64205. get quaternion(): Nullable<Quaternion>;
  64206. /**
  64207. * Legacy support, changed quaternion to rotationQuaternion
  64208. */
  64209. set quaternion(q: Nullable<Quaternion>);
  64210. /**
  64211. * Returns a boolean. True if the particle intersects a mesh, else false
  64212. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64213. * @param target is the object (point or mesh) what the intersection is computed against
  64214. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64215. * @returns true if it intersects
  64216. */
  64217. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64218. /**
  64219. * get the rotation matrix of the particle
  64220. * @hidden
  64221. */
  64222. getRotationMatrix(m: Matrix): void;
  64223. }
  64224. /**
  64225. * Represents a group of points in a points cloud system
  64226. * * PCS internal tool, don't use it manually.
  64227. */
  64228. export class PointsGroup {
  64229. /**
  64230. * The group id
  64231. * @hidden
  64232. */
  64233. groupID: number;
  64234. /**
  64235. * image data for group (internal use)
  64236. * @hidden
  64237. */
  64238. _groupImageData: Nullable<ArrayBufferView>;
  64239. /**
  64240. * Image Width (internal use)
  64241. * @hidden
  64242. */
  64243. _groupImgWidth: number;
  64244. /**
  64245. * Image Height (internal use)
  64246. * @hidden
  64247. */
  64248. _groupImgHeight: number;
  64249. /**
  64250. * Custom position function (internal use)
  64251. * @hidden
  64252. */
  64253. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64254. /**
  64255. * density per facet for surface points
  64256. * @hidden
  64257. */
  64258. _groupDensity: number[];
  64259. /**
  64260. * Only when points are colored by texture carries pointer to texture list array
  64261. * @hidden
  64262. */
  64263. _textureNb: number;
  64264. /**
  64265. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64266. * PCS internal tool, don't use it manually.
  64267. * @hidden
  64268. */
  64269. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64270. }
  64271. }
  64272. declare module BABYLON {
  64273. interface Scene {
  64274. /** @hidden (Backing field) */
  64275. _physicsEngine: Nullable<IPhysicsEngine>;
  64276. /** @hidden */
  64277. _physicsTimeAccumulator: number;
  64278. /**
  64279. * Gets the current physics engine
  64280. * @returns a IPhysicsEngine or null if none attached
  64281. */
  64282. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64283. /**
  64284. * Enables physics to the current scene
  64285. * @param gravity defines the scene's gravity for the physics engine
  64286. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64287. * @return a boolean indicating if the physics engine was initialized
  64288. */
  64289. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64290. /**
  64291. * Disables and disposes the physics engine associated with the scene
  64292. */
  64293. disablePhysicsEngine(): void;
  64294. /**
  64295. * Gets a boolean indicating if there is an active physics engine
  64296. * @returns a boolean indicating if there is an active physics engine
  64297. */
  64298. isPhysicsEnabled(): boolean;
  64299. /**
  64300. * Deletes a physics compound impostor
  64301. * @param compound defines the compound to delete
  64302. */
  64303. deleteCompoundImpostor(compound: any): void;
  64304. /**
  64305. * An event triggered when physic simulation is about to be run
  64306. */
  64307. onBeforePhysicsObservable: Observable<Scene>;
  64308. /**
  64309. * An event triggered when physic simulation has been done
  64310. */
  64311. onAfterPhysicsObservable: Observable<Scene>;
  64312. }
  64313. interface AbstractMesh {
  64314. /** @hidden */
  64315. _physicsImpostor: Nullable<PhysicsImpostor>;
  64316. /**
  64317. * Gets or sets impostor used for physic simulation
  64318. * @see http://doc.babylonjs.com/features/physics_engine
  64319. */
  64320. physicsImpostor: Nullable<PhysicsImpostor>;
  64321. /**
  64322. * Gets the current physics impostor
  64323. * @see http://doc.babylonjs.com/features/physics_engine
  64324. * @returns a physics impostor or null
  64325. */
  64326. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64327. /** Apply a physic impulse to the mesh
  64328. * @param force defines the force to apply
  64329. * @param contactPoint defines where to apply the force
  64330. * @returns the current mesh
  64331. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64332. */
  64333. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64334. /**
  64335. * Creates a physic joint between two meshes
  64336. * @param otherMesh defines the other mesh to use
  64337. * @param pivot1 defines the pivot to use on this mesh
  64338. * @param pivot2 defines the pivot to use on the other mesh
  64339. * @param options defines additional options (can be plugin dependent)
  64340. * @returns the current mesh
  64341. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64342. */
  64343. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64344. /** @hidden */
  64345. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64346. }
  64347. /**
  64348. * Defines the physics engine scene component responsible to manage a physics engine
  64349. */
  64350. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64351. /**
  64352. * The component name helpful to identify the component in the list of scene components.
  64353. */
  64354. readonly name: string;
  64355. /**
  64356. * The scene the component belongs to.
  64357. */
  64358. scene: Scene;
  64359. /**
  64360. * Creates a new instance of the component for the given scene
  64361. * @param scene Defines the scene to register the component in
  64362. */
  64363. constructor(scene: Scene);
  64364. /**
  64365. * Registers the component in a given scene
  64366. */
  64367. register(): void;
  64368. /**
  64369. * Rebuilds the elements related to this component in case of
  64370. * context lost for instance.
  64371. */
  64372. rebuild(): void;
  64373. /**
  64374. * Disposes the component and the associated ressources
  64375. */
  64376. dispose(): void;
  64377. }
  64378. }
  64379. declare module BABYLON {
  64380. /**
  64381. * A helper for physics simulations
  64382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64383. */
  64384. export class PhysicsHelper {
  64385. private _scene;
  64386. private _physicsEngine;
  64387. /**
  64388. * Initializes the Physics helper
  64389. * @param scene Babylon.js scene
  64390. */
  64391. constructor(scene: Scene);
  64392. /**
  64393. * Applies a radial explosion impulse
  64394. * @param origin the origin of the explosion
  64395. * @param radiusOrEventOptions the radius or the options of radial explosion
  64396. * @param strength the explosion strength
  64397. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64398. * @returns A physics radial explosion event, or null
  64399. */
  64400. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64401. /**
  64402. * Applies a radial explosion force
  64403. * @param origin the origin of the explosion
  64404. * @param radiusOrEventOptions the radius or the options of radial explosion
  64405. * @param strength the explosion strength
  64406. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64407. * @returns A physics radial explosion event, or null
  64408. */
  64409. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64410. /**
  64411. * Creates a gravitational field
  64412. * @param origin the origin of the explosion
  64413. * @param radiusOrEventOptions the radius or the options of radial explosion
  64414. * @param strength the explosion strength
  64415. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64416. * @returns A physics gravitational field event, or null
  64417. */
  64418. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64419. /**
  64420. * Creates a physics updraft event
  64421. * @param origin the origin of the updraft
  64422. * @param radiusOrEventOptions the radius or the options of the updraft
  64423. * @param strength the strength of the updraft
  64424. * @param height the height of the updraft
  64425. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64426. * @returns A physics updraft event, or null
  64427. */
  64428. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64429. /**
  64430. * Creates a physics vortex event
  64431. * @param origin the of the vortex
  64432. * @param radiusOrEventOptions the radius or the options of the vortex
  64433. * @param strength the strength of the vortex
  64434. * @param height the height of the vortex
  64435. * @returns a Physics vortex event, or null
  64436. * A physics vortex event or null
  64437. */
  64438. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64439. }
  64440. /**
  64441. * Represents a physics radial explosion event
  64442. */
  64443. class PhysicsRadialExplosionEvent {
  64444. private _scene;
  64445. private _options;
  64446. private _sphere;
  64447. private _dataFetched;
  64448. /**
  64449. * Initializes a radial explosioin event
  64450. * @param _scene BabylonJS scene
  64451. * @param _options The options for the vortex event
  64452. */
  64453. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64454. /**
  64455. * Returns the data related to the radial explosion event (sphere).
  64456. * @returns The radial explosion event data
  64457. */
  64458. getData(): PhysicsRadialExplosionEventData;
  64459. /**
  64460. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64461. * @param impostor A physics imposter
  64462. * @param origin the origin of the explosion
  64463. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64464. */
  64465. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64466. /**
  64467. * Triggers affecterd impostors callbacks
  64468. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64469. */
  64470. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64471. /**
  64472. * Disposes the sphere.
  64473. * @param force Specifies if the sphere should be disposed by force
  64474. */
  64475. dispose(force?: boolean): void;
  64476. /*** Helpers ***/
  64477. private _prepareSphere;
  64478. private _intersectsWithSphere;
  64479. }
  64480. /**
  64481. * Represents a gravitational field event
  64482. */
  64483. class PhysicsGravitationalFieldEvent {
  64484. private _physicsHelper;
  64485. private _scene;
  64486. private _origin;
  64487. private _options;
  64488. private _tickCallback;
  64489. private _sphere;
  64490. private _dataFetched;
  64491. /**
  64492. * Initializes the physics gravitational field event
  64493. * @param _physicsHelper A physics helper
  64494. * @param _scene BabylonJS scene
  64495. * @param _origin The origin position of the gravitational field event
  64496. * @param _options The options for the vortex event
  64497. */
  64498. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64499. /**
  64500. * Returns the data related to the gravitational field event (sphere).
  64501. * @returns A gravitational field event
  64502. */
  64503. getData(): PhysicsGravitationalFieldEventData;
  64504. /**
  64505. * Enables the gravitational field.
  64506. */
  64507. enable(): void;
  64508. /**
  64509. * Disables the gravitational field.
  64510. */
  64511. disable(): void;
  64512. /**
  64513. * Disposes the sphere.
  64514. * @param force The force to dispose from the gravitational field event
  64515. */
  64516. dispose(force?: boolean): void;
  64517. private _tick;
  64518. }
  64519. /**
  64520. * Represents a physics updraft event
  64521. */
  64522. class PhysicsUpdraftEvent {
  64523. private _scene;
  64524. private _origin;
  64525. private _options;
  64526. private _physicsEngine;
  64527. private _originTop;
  64528. private _originDirection;
  64529. private _tickCallback;
  64530. private _cylinder;
  64531. private _cylinderPosition;
  64532. private _dataFetched;
  64533. /**
  64534. * Initializes the physics updraft event
  64535. * @param _scene BabylonJS scene
  64536. * @param _origin The origin position of the updraft
  64537. * @param _options The options for the updraft event
  64538. */
  64539. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64540. /**
  64541. * Returns the data related to the updraft event (cylinder).
  64542. * @returns A physics updraft event
  64543. */
  64544. getData(): PhysicsUpdraftEventData;
  64545. /**
  64546. * Enables the updraft.
  64547. */
  64548. enable(): void;
  64549. /**
  64550. * Disables the updraft.
  64551. */
  64552. disable(): void;
  64553. /**
  64554. * Disposes the cylinder.
  64555. * @param force Specifies if the updraft should be disposed by force
  64556. */
  64557. dispose(force?: boolean): void;
  64558. private getImpostorHitData;
  64559. private _tick;
  64560. /*** Helpers ***/
  64561. private _prepareCylinder;
  64562. private _intersectsWithCylinder;
  64563. }
  64564. /**
  64565. * Represents a physics vortex event
  64566. */
  64567. class PhysicsVortexEvent {
  64568. private _scene;
  64569. private _origin;
  64570. private _options;
  64571. private _physicsEngine;
  64572. private _originTop;
  64573. private _tickCallback;
  64574. private _cylinder;
  64575. private _cylinderPosition;
  64576. private _dataFetched;
  64577. /**
  64578. * Initializes the physics vortex event
  64579. * @param _scene The BabylonJS scene
  64580. * @param _origin The origin position of the vortex
  64581. * @param _options The options for the vortex event
  64582. */
  64583. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64584. /**
  64585. * Returns the data related to the vortex event (cylinder).
  64586. * @returns The physics vortex event data
  64587. */
  64588. getData(): PhysicsVortexEventData;
  64589. /**
  64590. * Enables the vortex.
  64591. */
  64592. enable(): void;
  64593. /**
  64594. * Disables the cortex.
  64595. */
  64596. disable(): void;
  64597. /**
  64598. * Disposes the sphere.
  64599. * @param force
  64600. */
  64601. dispose(force?: boolean): void;
  64602. private getImpostorHitData;
  64603. private _tick;
  64604. /*** Helpers ***/
  64605. private _prepareCylinder;
  64606. private _intersectsWithCylinder;
  64607. }
  64608. /**
  64609. * Options fot the radial explosion event
  64610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64611. */
  64612. export class PhysicsRadialExplosionEventOptions {
  64613. /**
  64614. * The radius of the sphere for the radial explosion.
  64615. */
  64616. radius: number;
  64617. /**
  64618. * The strenth of the explosion.
  64619. */
  64620. strength: number;
  64621. /**
  64622. * The strenght of the force in correspondence to the distance of the affected object
  64623. */
  64624. falloff: PhysicsRadialImpulseFalloff;
  64625. /**
  64626. * Sphere options for the radial explosion.
  64627. */
  64628. sphere: {
  64629. segments: number;
  64630. diameter: number;
  64631. };
  64632. /**
  64633. * Sphere options for the radial explosion.
  64634. */
  64635. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64636. }
  64637. /**
  64638. * Options fot the updraft event
  64639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64640. */
  64641. export class PhysicsUpdraftEventOptions {
  64642. /**
  64643. * The radius of the cylinder for the vortex
  64644. */
  64645. radius: number;
  64646. /**
  64647. * The strenth of the updraft.
  64648. */
  64649. strength: number;
  64650. /**
  64651. * The height of the cylinder for the updraft.
  64652. */
  64653. height: number;
  64654. /**
  64655. * The mode for the the updraft.
  64656. */
  64657. updraftMode: PhysicsUpdraftMode;
  64658. }
  64659. /**
  64660. * Options fot the vortex event
  64661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64662. */
  64663. export class PhysicsVortexEventOptions {
  64664. /**
  64665. * The radius of the cylinder for the vortex
  64666. */
  64667. radius: number;
  64668. /**
  64669. * The strenth of the vortex.
  64670. */
  64671. strength: number;
  64672. /**
  64673. * The height of the cylinder for the vortex.
  64674. */
  64675. height: number;
  64676. /**
  64677. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64678. */
  64679. centripetalForceThreshold: number;
  64680. /**
  64681. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64682. */
  64683. centripetalForceMultiplier: number;
  64684. /**
  64685. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64686. */
  64687. centrifugalForceMultiplier: number;
  64688. /**
  64689. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64690. */
  64691. updraftForceMultiplier: number;
  64692. }
  64693. /**
  64694. * The strenght of the force in correspondence to the distance of the affected object
  64695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64696. */
  64697. export enum PhysicsRadialImpulseFalloff {
  64698. /** Defines that impulse is constant in strength across it's whole radius */
  64699. Constant = 0,
  64700. /** Defines that impulse gets weaker if it's further from the origin */
  64701. Linear = 1
  64702. }
  64703. /**
  64704. * The strength of the force in correspondence to the distance of the affected object
  64705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64706. */
  64707. export enum PhysicsUpdraftMode {
  64708. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64709. Center = 0,
  64710. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64711. Perpendicular = 1
  64712. }
  64713. /**
  64714. * Interface for a physics hit data
  64715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64716. */
  64717. export interface PhysicsHitData {
  64718. /**
  64719. * The force applied at the contact point
  64720. */
  64721. force: Vector3;
  64722. /**
  64723. * The contact point
  64724. */
  64725. contactPoint: Vector3;
  64726. /**
  64727. * The distance from the origin to the contact point
  64728. */
  64729. distanceFromOrigin: number;
  64730. }
  64731. /**
  64732. * Interface for radial explosion event data
  64733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64734. */
  64735. export interface PhysicsRadialExplosionEventData {
  64736. /**
  64737. * A sphere used for the radial explosion event
  64738. */
  64739. sphere: Mesh;
  64740. }
  64741. /**
  64742. * Interface for gravitational field event data
  64743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64744. */
  64745. export interface PhysicsGravitationalFieldEventData {
  64746. /**
  64747. * A sphere mesh used for the gravitational field event
  64748. */
  64749. sphere: Mesh;
  64750. }
  64751. /**
  64752. * Interface for updraft event data
  64753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64754. */
  64755. export interface PhysicsUpdraftEventData {
  64756. /**
  64757. * A cylinder used for the updraft event
  64758. */
  64759. cylinder: Mesh;
  64760. }
  64761. /**
  64762. * Interface for vortex event data
  64763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64764. */
  64765. export interface PhysicsVortexEventData {
  64766. /**
  64767. * A cylinder used for the vortex event
  64768. */
  64769. cylinder: Mesh;
  64770. }
  64771. /**
  64772. * Interface for an affected physics impostor
  64773. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64774. */
  64775. export interface PhysicsAffectedImpostorWithData {
  64776. /**
  64777. * The impostor affected by the effect
  64778. */
  64779. impostor: PhysicsImpostor;
  64780. /**
  64781. * The data about the hit/horce from the explosion
  64782. */
  64783. hitData: PhysicsHitData;
  64784. }
  64785. }
  64786. declare module BABYLON {
  64787. /** @hidden */
  64788. export var blackAndWhitePixelShader: {
  64789. name: string;
  64790. shader: string;
  64791. };
  64792. }
  64793. declare module BABYLON {
  64794. /**
  64795. * Post process used to render in black and white
  64796. */
  64797. export class BlackAndWhitePostProcess extends PostProcess {
  64798. /**
  64799. * Linear about to convert he result to black and white (default: 1)
  64800. */
  64801. degree: number;
  64802. /**
  64803. * Creates a black and white post process
  64804. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64805. * @param name The name of the effect.
  64806. * @param options The required width/height ratio to downsize to before computing the render pass.
  64807. * @param camera The camera to apply the render pass to.
  64808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64809. * @param engine The engine which the post process will be applied. (default: current engine)
  64810. * @param reusable If the post process can be reused on the same frame. (default: false)
  64811. */
  64812. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64813. }
  64814. }
  64815. declare module BABYLON {
  64816. /**
  64817. * This represents a set of one or more post processes in Babylon.
  64818. * A post process can be used to apply a shader to a texture after it is rendered.
  64819. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64820. */
  64821. export class PostProcessRenderEffect {
  64822. private _postProcesses;
  64823. private _getPostProcesses;
  64824. private _singleInstance;
  64825. private _cameras;
  64826. private _indicesForCamera;
  64827. /**
  64828. * Name of the effect
  64829. * @hidden
  64830. */
  64831. _name: string;
  64832. /**
  64833. * Instantiates a post process render effect.
  64834. * A post process can be used to apply a shader to a texture after it is rendered.
  64835. * @param engine The engine the effect is tied to
  64836. * @param name The name of the effect
  64837. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64838. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64839. */
  64840. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64841. /**
  64842. * Checks if all the post processes in the effect are supported.
  64843. */
  64844. get isSupported(): boolean;
  64845. /**
  64846. * Updates the current state of the effect
  64847. * @hidden
  64848. */
  64849. _update(): void;
  64850. /**
  64851. * Attaches the effect on cameras
  64852. * @param cameras The camera to attach to.
  64853. * @hidden
  64854. */
  64855. _attachCameras(cameras: Camera): void;
  64856. /**
  64857. * Attaches the effect on cameras
  64858. * @param cameras The camera to attach to.
  64859. * @hidden
  64860. */
  64861. _attachCameras(cameras: Camera[]): void;
  64862. /**
  64863. * Detaches the effect on cameras
  64864. * @param cameras The camera to detatch from.
  64865. * @hidden
  64866. */
  64867. _detachCameras(cameras: Camera): void;
  64868. /**
  64869. * Detatches the effect on cameras
  64870. * @param cameras The camera to detatch from.
  64871. * @hidden
  64872. */
  64873. _detachCameras(cameras: Camera[]): void;
  64874. /**
  64875. * Enables the effect on given cameras
  64876. * @param cameras The camera to enable.
  64877. * @hidden
  64878. */
  64879. _enable(cameras: Camera): void;
  64880. /**
  64881. * Enables the effect on given cameras
  64882. * @param cameras The camera to enable.
  64883. * @hidden
  64884. */
  64885. _enable(cameras: Nullable<Camera[]>): void;
  64886. /**
  64887. * Disables the effect on the given cameras
  64888. * @param cameras The camera to disable.
  64889. * @hidden
  64890. */
  64891. _disable(cameras: Camera): void;
  64892. /**
  64893. * Disables the effect on the given cameras
  64894. * @param cameras The camera to disable.
  64895. * @hidden
  64896. */
  64897. _disable(cameras: Nullable<Camera[]>): void;
  64898. /**
  64899. * Gets a list of the post processes contained in the effect.
  64900. * @param camera The camera to get the post processes on.
  64901. * @returns The list of the post processes in the effect.
  64902. */
  64903. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64904. }
  64905. }
  64906. declare module BABYLON {
  64907. /** @hidden */
  64908. export var extractHighlightsPixelShader: {
  64909. name: string;
  64910. shader: string;
  64911. };
  64912. }
  64913. declare module BABYLON {
  64914. /**
  64915. * 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.
  64916. */
  64917. export class ExtractHighlightsPostProcess extends PostProcess {
  64918. /**
  64919. * The luminance threshold, pixels below this value will be set to black.
  64920. */
  64921. threshold: number;
  64922. /** @hidden */
  64923. _exposure: number;
  64924. /**
  64925. * Post process which has the input texture to be used when performing highlight extraction
  64926. * @hidden
  64927. */
  64928. _inputPostProcess: Nullable<PostProcess>;
  64929. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64930. }
  64931. }
  64932. declare module BABYLON {
  64933. /** @hidden */
  64934. export var bloomMergePixelShader: {
  64935. name: string;
  64936. shader: string;
  64937. };
  64938. }
  64939. declare module BABYLON {
  64940. /**
  64941. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64942. */
  64943. export class BloomMergePostProcess extends PostProcess {
  64944. /** Weight of the bloom to be added to the original input. */
  64945. weight: number;
  64946. /**
  64947. * Creates a new instance of @see BloomMergePostProcess
  64948. * @param name The name of the effect.
  64949. * @param originalFromInput Post process which's input will be used for the merge.
  64950. * @param blurred Blurred highlights post process which's output will be used.
  64951. * @param weight Weight of the bloom to be added to the original input.
  64952. * @param options The required width/height ratio to downsize to before computing the render pass.
  64953. * @param camera The camera to apply the render pass to.
  64954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64955. * @param engine The engine which the post process will be applied. (default: current engine)
  64956. * @param reusable If the post process can be reused on the same frame. (default: false)
  64957. * @param textureType Type of textures used when performing the post process. (default: 0)
  64958. * @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)
  64959. */
  64960. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64961. /** Weight of the bloom to be added to the original input. */
  64962. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64963. }
  64964. }
  64965. declare module BABYLON {
  64966. /**
  64967. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64968. */
  64969. export class BloomEffect extends PostProcessRenderEffect {
  64970. private bloomScale;
  64971. /**
  64972. * @hidden Internal
  64973. */
  64974. _effects: Array<PostProcess>;
  64975. /**
  64976. * @hidden Internal
  64977. */
  64978. _downscale: ExtractHighlightsPostProcess;
  64979. private _blurX;
  64980. private _blurY;
  64981. private _merge;
  64982. /**
  64983. * The luminance threshold to find bright areas of the image to bloom.
  64984. */
  64985. get threshold(): number;
  64986. set threshold(value: number);
  64987. /**
  64988. * The strength of the bloom.
  64989. */
  64990. get weight(): number;
  64991. set weight(value: number);
  64992. /**
  64993. * Specifies the size of the bloom blur kernel, relative to the final output size
  64994. */
  64995. get kernel(): number;
  64996. set kernel(value: number);
  64997. /**
  64998. * Creates a new instance of @see BloomEffect
  64999. * @param scene The scene the effect belongs to.
  65000. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  65001. * @param bloomKernel The size of the kernel to be used when applying the blur.
  65002. * @param bloomWeight The the strength of bloom.
  65003. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65004. * @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)
  65005. */
  65006. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  65007. /**
  65008. * Disposes each of the internal effects for a given camera.
  65009. * @param camera The camera to dispose the effect on.
  65010. */
  65011. disposeEffects(camera: Camera): void;
  65012. /**
  65013. * @hidden Internal
  65014. */
  65015. _updateEffects(): void;
  65016. /**
  65017. * Internal
  65018. * @returns if all the contained post processes are ready.
  65019. * @hidden
  65020. */
  65021. _isReady(): boolean;
  65022. }
  65023. }
  65024. declare module BABYLON {
  65025. /** @hidden */
  65026. export var chromaticAberrationPixelShader: {
  65027. name: string;
  65028. shader: string;
  65029. };
  65030. }
  65031. declare module BABYLON {
  65032. /**
  65033. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  65034. */
  65035. export class ChromaticAberrationPostProcess extends PostProcess {
  65036. /**
  65037. * The amount of seperation of rgb channels (default: 30)
  65038. */
  65039. aberrationAmount: number;
  65040. /**
  65041. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  65042. */
  65043. radialIntensity: number;
  65044. /**
  65045. * 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))
  65046. */
  65047. direction: Vector2;
  65048. /**
  65049. * 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))
  65050. */
  65051. centerPosition: Vector2;
  65052. /**
  65053. * Creates a new instance ChromaticAberrationPostProcess
  65054. * @param name The name of the effect.
  65055. * @param screenWidth The width of the screen to apply the effect on.
  65056. * @param screenHeight The height of the screen to apply the effect on.
  65057. * @param options The required width/height ratio to downsize to before computing the render pass.
  65058. * @param camera The camera to apply the render pass to.
  65059. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65060. * @param engine The engine which the post process will be applied. (default: current engine)
  65061. * @param reusable If the post process can be reused on the same frame. (default: false)
  65062. * @param textureType Type of textures used when performing the post process. (default: 0)
  65063. * @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)
  65064. */
  65065. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65066. }
  65067. }
  65068. declare module BABYLON {
  65069. /** @hidden */
  65070. export var circleOfConfusionPixelShader: {
  65071. name: string;
  65072. shader: string;
  65073. };
  65074. }
  65075. declare module BABYLON {
  65076. /**
  65077. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65078. */
  65079. export class CircleOfConfusionPostProcess extends PostProcess {
  65080. /**
  65081. * 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.
  65082. */
  65083. lensSize: number;
  65084. /**
  65085. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65086. */
  65087. fStop: number;
  65088. /**
  65089. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65090. */
  65091. focusDistance: number;
  65092. /**
  65093. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65094. */
  65095. focalLength: number;
  65096. private _depthTexture;
  65097. /**
  65098. * Creates a new instance CircleOfConfusionPostProcess
  65099. * @param name The name of the effect.
  65100. * @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.
  65101. * @param options The required width/height ratio to downsize to before computing the render pass.
  65102. * @param camera The camera to apply the render pass to.
  65103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65104. * @param engine The engine which the post process will be applied. (default: current engine)
  65105. * @param reusable If the post process can be reused on the same frame. (default: false)
  65106. * @param textureType Type of textures used when performing the post process. (default: 0)
  65107. * @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)
  65108. */
  65109. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65110. /**
  65111. * 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.
  65112. */
  65113. set depthTexture(value: RenderTargetTexture);
  65114. }
  65115. }
  65116. declare module BABYLON {
  65117. /** @hidden */
  65118. export var colorCorrectionPixelShader: {
  65119. name: string;
  65120. shader: string;
  65121. };
  65122. }
  65123. declare module BABYLON {
  65124. /**
  65125. *
  65126. * This post-process allows the modification of rendered colors by using
  65127. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65128. *
  65129. * The object needs to be provided an url to a texture containing the color
  65130. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65131. * Use an image editing software to tweak the LUT to match your needs.
  65132. *
  65133. * For an example of a color LUT, see here:
  65134. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65135. * For explanations on color grading, see here:
  65136. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65137. *
  65138. */
  65139. export class ColorCorrectionPostProcess extends PostProcess {
  65140. private _colorTableTexture;
  65141. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65142. }
  65143. }
  65144. declare module BABYLON {
  65145. /** @hidden */
  65146. export var convolutionPixelShader: {
  65147. name: string;
  65148. shader: string;
  65149. };
  65150. }
  65151. declare module BABYLON {
  65152. /**
  65153. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65154. * input texture to perform effects such as edge detection or sharpening
  65155. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65156. */
  65157. export class ConvolutionPostProcess extends PostProcess {
  65158. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65159. kernel: number[];
  65160. /**
  65161. * Creates a new instance ConvolutionPostProcess
  65162. * @param name The name of the effect.
  65163. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65164. * @param options The required width/height ratio to downsize to before computing the render pass.
  65165. * @param camera The camera to apply the render pass to.
  65166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65167. * @param engine The engine which the post process will be applied. (default: current engine)
  65168. * @param reusable If the post process can be reused on the same frame. (default: false)
  65169. * @param textureType Type of textures used when performing the post process. (default: 0)
  65170. */
  65171. constructor(name: string,
  65172. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65173. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65174. /**
  65175. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65176. */
  65177. static EdgeDetect0Kernel: number[];
  65178. /**
  65179. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65180. */
  65181. static EdgeDetect1Kernel: number[];
  65182. /**
  65183. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65184. */
  65185. static EdgeDetect2Kernel: number[];
  65186. /**
  65187. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65188. */
  65189. static SharpenKernel: number[];
  65190. /**
  65191. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65192. */
  65193. static EmbossKernel: number[];
  65194. /**
  65195. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65196. */
  65197. static GaussianKernel: number[];
  65198. }
  65199. }
  65200. declare module BABYLON {
  65201. /**
  65202. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65203. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65204. * based on samples that have a large difference in distance than the center pixel.
  65205. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65206. */
  65207. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65208. direction: Vector2;
  65209. /**
  65210. * Creates a new instance CircleOfConfusionPostProcess
  65211. * @param name The name of the effect.
  65212. * @param scene The scene the effect belongs to.
  65213. * @param direction The direction the blur should be applied.
  65214. * @param kernel The size of the kernel used to blur.
  65215. * @param options The required width/height ratio to downsize to before computing the render pass.
  65216. * @param camera The camera to apply the render pass to.
  65217. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65218. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65220. * @param engine The engine which the post process will be applied. (default: current engine)
  65221. * @param reusable If the post process can be reused on the same frame. (default: false)
  65222. * @param textureType Type of textures used when performing the post process. (default: 0)
  65223. * @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)
  65224. */
  65225. 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);
  65226. }
  65227. }
  65228. declare module BABYLON {
  65229. /** @hidden */
  65230. export var depthOfFieldMergePixelShader: {
  65231. name: string;
  65232. shader: string;
  65233. };
  65234. }
  65235. declare module BABYLON {
  65236. /**
  65237. * Options to be set when merging outputs from the default pipeline.
  65238. */
  65239. export class DepthOfFieldMergePostProcessOptions {
  65240. /**
  65241. * The original image to merge on top of
  65242. */
  65243. originalFromInput: PostProcess;
  65244. /**
  65245. * Parameters to perform the merge of the depth of field effect
  65246. */
  65247. depthOfField?: {
  65248. circleOfConfusion: PostProcess;
  65249. blurSteps: Array<PostProcess>;
  65250. };
  65251. /**
  65252. * Parameters to perform the merge of bloom effect
  65253. */
  65254. bloom?: {
  65255. blurred: PostProcess;
  65256. weight: number;
  65257. };
  65258. }
  65259. /**
  65260. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65261. */
  65262. export class DepthOfFieldMergePostProcess extends PostProcess {
  65263. private blurSteps;
  65264. /**
  65265. * Creates a new instance of DepthOfFieldMergePostProcess
  65266. * @param name The name of the effect.
  65267. * @param originalFromInput Post process which's input will be used for the merge.
  65268. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65269. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65270. * @param options The required width/height ratio to downsize to before computing the render pass.
  65271. * @param camera The camera to apply the render pass to.
  65272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65273. * @param engine The engine which the post process will be applied. (default: current engine)
  65274. * @param reusable If the post process can be reused on the same frame. (default: false)
  65275. * @param textureType Type of textures used when performing the post process. (default: 0)
  65276. * @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)
  65277. */
  65278. 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);
  65279. /**
  65280. * Updates the effect with the current post process compile time values and recompiles the shader.
  65281. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65282. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65283. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65284. * @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
  65285. * @param onCompiled Called when the shader has been compiled.
  65286. * @param onError Called if there is an error when compiling a shader.
  65287. */
  65288. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65289. }
  65290. }
  65291. declare module BABYLON {
  65292. /**
  65293. * Specifies the level of max blur that should be applied when using the depth of field effect
  65294. */
  65295. export enum DepthOfFieldEffectBlurLevel {
  65296. /**
  65297. * Subtle blur
  65298. */
  65299. Low = 0,
  65300. /**
  65301. * Medium blur
  65302. */
  65303. Medium = 1,
  65304. /**
  65305. * Large blur
  65306. */
  65307. High = 2
  65308. }
  65309. /**
  65310. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65311. */
  65312. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65313. private _circleOfConfusion;
  65314. /**
  65315. * @hidden Internal, blurs from high to low
  65316. */
  65317. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65318. private _depthOfFieldBlurY;
  65319. private _dofMerge;
  65320. /**
  65321. * @hidden Internal post processes in depth of field effect
  65322. */
  65323. _effects: Array<PostProcess>;
  65324. /**
  65325. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65326. */
  65327. set focalLength(value: number);
  65328. get focalLength(): number;
  65329. /**
  65330. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65331. */
  65332. set fStop(value: number);
  65333. get fStop(): number;
  65334. /**
  65335. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65336. */
  65337. set focusDistance(value: number);
  65338. get focusDistance(): number;
  65339. /**
  65340. * 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.
  65341. */
  65342. set lensSize(value: number);
  65343. get lensSize(): number;
  65344. /**
  65345. * Creates a new instance DepthOfFieldEffect
  65346. * @param scene The scene the effect belongs to.
  65347. * @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.
  65348. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65349. * @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)
  65350. */
  65351. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65352. /**
  65353. * Get the current class name of the current effet
  65354. * @returns "DepthOfFieldEffect"
  65355. */
  65356. getClassName(): string;
  65357. /**
  65358. * 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.
  65359. */
  65360. set depthTexture(value: RenderTargetTexture);
  65361. /**
  65362. * Disposes each of the internal effects for a given camera.
  65363. * @param camera The camera to dispose the effect on.
  65364. */
  65365. disposeEffects(camera: Camera): void;
  65366. /**
  65367. * @hidden Internal
  65368. */
  65369. _updateEffects(): void;
  65370. /**
  65371. * Internal
  65372. * @returns if all the contained post processes are ready.
  65373. * @hidden
  65374. */
  65375. _isReady(): boolean;
  65376. }
  65377. }
  65378. declare module BABYLON {
  65379. /** @hidden */
  65380. export var displayPassPixelShader: {
  65381. name: string;
  65382. shader: string;
  65383. };
  65384. }
  65385. declare module BABYLON {
  65386. /**
  65387. * DisplayPassPostProcess which produces an output the same as it's input
  65388. */
  65389. export class DisplayPassPostProcess extends PostProcess {
  65390. /**
  65391. * Creates the DisplayPassPostProcess
  65392. * @param name The name of the effect.
  65393. * @param options The required width/height ratio to downsize to before computing the render pass.
  65394. * @param camera The camera to apply the render pass to.
  65395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65396. * @param engine The engine which the post process will be applied. (default: current engine)
  65397. * @param reusable If the post process can be reused on the same frame. (default: false)
  65398. */
  65399. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65400. }
  65401. }
  65402. declare module BABYLON {
  65403. /** @hidden */
  65404. export var filterPixelShader: {
  65405. name: string;
  65406. shader: string;
  65407. };
  65408. }
  65409. declare module BABYLON {
  65410. /**
  65411. * Applies a kernel filter to the image
  65412. */
  65413. export class FilterPostProcess extends PostProcess {
  65414. /** The matrix to be applied to the image */
  65415. kernelMatrix: Matrix;
  65416. /**
  65417. *
  65418. * @param name The name of the effect.
  65419. * @param kernelMatrix The matrix to be applied to the image
  65420. * @param options The required width/height ratio to downsize to before computing the render pass.
  65421. * @param camera The camera to apply the render pass to.
  65422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65423. * @param engine The engine which the post process will be applied. (default: current engine)
  65424. * @param reusable If the post process can be reused on the same frame. (default: false)
  65425. */
  65426. constructor(name: string,
  65427. /** The matrix to be applied to the image */
  65428. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65429. }
  65430. }
  65431. declare module BABYLON {
  65432. /** @hidden */
  65433. export var fxaaPixelShader: {
  65434. name: string;
  65435. shader: string;
  65436. };
  65437. }
  65438. declare module BABYLON {
  65439. /** @hidden */
  65440. export var fxaaVertexShader: {
  65441. name: string;
  65442. shader: string;
  65443. };
  65444. }
  65445. declare module BABYLON {
  65446. /**
  65447. * Fxaa post process
  65448. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65449. */
  65450. export class FxaaPostProcess extends PostProcess {
  65451. /** @hidden */
  65452. texelWidth: number;
  65453. /** @hidden */
  65454. texelHeight: number;
  65455. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65456. private _getDefines;
  65457. }
  65458. }
  65459. declare module BABYLON {
  65460. /** @hidden */
  65461. export var grainPixelShader: {
  65462. name: string;
  65463. shader: string;
  65464. };
  65465. }
  65466. declare module BABYLON {
  65467. /**
  65468. * The GrainPostProcess adds noise to the image at mid luminance levels
  65469. */
  65470. export class GrainPostProcess extends PostProcess {
  65471. /**
  65472. * The intensity of the grain added (default: 30)
  65473. */
  65474. intensity: number;
  65475. /**
  65476. * If the grain should be randomized on every frame
  65477. */
  65478. animated: boolean;
  65479. /**
  65480. * Creates a new instance of @see GrainPostProcess
  65481. * @param name The name of the effect.
  65482. * @param options The required width/height ratio to downsize to before computing the render pass.
  65483. * @param camera The camera to apply the render pass to.
  65484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65485. * @param engine The engine which the post process will be applied. (default: current engine)
  65486. * @param reusable If the post process can be reused on the same frame. (default: false)
  65487. * @param textureType Type of textures used when performing the post process. (default: 0)
  65488. * @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)
  65489. */
  65490. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65491. }
  65492. }
  65493. declare module BABYLON {
  65494. /** @hidden */
  65495. export var highlightsPixelShader: {
  65496. name: string;
  65497. shader: string;
  65498. };
  65499. }
  65500. declare module BABYLON {
  65501. /**
  65502. * Extracts highlights from the image
  65503. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65504. */
  65505. export class HighlightsPostProcess extends PostProcess {
  65506. /**
  65507. * Extracts highlights from the image
  65508. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65509. * @param name The name of the effect.
  65510. * @param options The required width/height ratio to downsize to before computing the render pass.
  65511. * @param camera The camera to apply the render pass to.
  65512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65513. * @param engine The engine which the post process will be applied. (default: current engine)
  65514. * @param reusable If the post process can be reused on the same frame. (default: false)
  65515. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65516. */
  65517. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65518. }
  65519. }
  65520. declare module BABYLON {
  65521. /** @hidden */
  65522. export var mrtFragmentDeclaration: {
  65523. name: string;
  65524. shader: string;
  65525. };
  65526. }
  65527. declare module BABYLON {
  65528. /** @hidden */
  65529. export var geometryPixelShader: {
  65530. name: string;
  65531. shader: string;
  65532. };
  65533. }
  65534. declare module BABYLON {
  65535. /** @hidden */
  65536. export var geometryVertexShader: {
  65537. name: string;
  65538. shader: string;
  65539. };
  65540. }
  65541. declare module BABYLON {
  65542. /** @hidden */
  65543. interface ISavedTransformationMatrix {
  65544. world: Matrix;
  65545. viewProjection: Matrix;
  65546. }
  65547. /**
  65548. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65549. */
  65550. export class GeometryBufferRenderer {
  65551. /**
  65552. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65553. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65554. */
  65555. static readonly POSITION_TEXTURE_TYPE: number;
  65556. /**
  65557. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65558. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65559. */
  65560. static readonly VELOCITY_TEXTURE_TYPE: number;
  65561. /**
  65562. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65563. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65564. */
  65565. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65566. /**
  65567. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65568. * in order to compute objects velocities when enableVelocity is set to "true"
  65569. * @hidden
  65570. */
  65571. _previousTransformationMatrices: {
  65572. [index: number]: ISavedTransformationMatrix;
  65573. };
  65574. /**
  65575. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65576. * in order to compute objects velocities when enableVelocity is set to "true"
  65577. * @hidden
  65578. */
  65579. _previousBonesTransformationMatrices: {
  65580. [index: number]: Float32Array;
  65581. };
  65582. /**
  65583. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65584. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65585. */
  65586. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65587. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65588. renderTransparentMeshes: boolean;
  65589. private _scene;
  65590. private _multiRenderTarget;
  65591. private _ratio;
  65592. private _enablePosition;
  65593. private _enableVelocity;
  65594. private _enableReflectivity;
  65595. private _positionIndex;
  65596. private _velocityIndex;
  65597. private _reflectivityIndex;
  65598. protected _effect: Effect;
  65599. protected _cachedDefines: string;
  65600. /**
  65601. * Set the render list (meshes to be rendered) used in the G buffer.
  65602. */
  65603. set renderList(meshes: Mesh[]);
  65604. /**
  65605. * Gets wether or not G buffer are supported by the running hardware.
  65606. * This requires draw buffer supports
  65607. */
  65608. get isSupported(): boolean;
  65609. /**
  65610. * Returns the index of the given texture type in the G-Buffer textures array
  65611. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65612. * @returns the index of the given texture type in the G-Buffer textures array
  65613. */
  65614. getTextureIndex(textureType: number): number;
  65615. /**
  65616. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65617. */
  65618. get enablePosition(): boolean;
  65619. /**
  65620. * Sets whether or not objects positions are enabled for the G buffer.
  65621. */
  65622. set enablePosition(enable: boolean);
  65623. /**
  65624. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65625. */
  65626. get enableVelocity(): boolean;
  65627. /**
  65628. * Sets wether or not objects velocities are enabled for the G buffer.
  65629. */
  65630. set enableVelocity(enable: boolean);
  65631. /**
  65632. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65633. */
  65634. get enableReflectivity(): boolean;
  65635. /**
  65636. * Sets wether or not objects roughness are enabled for the G buffer.
  65637. */
  65638. set enableReflectivity(enable: boolean);
  65639. /**
  65640. * Gets the scene associated with the buffer.
  65641. */
  65642. get scene(): Scene;
  65643. /**
  65644. * Gets the ratio used by the buffer during its creation.
  65645. * How big is the buffer related to the main canvas.
  65646. */
  65647. get ratio(): number;
  65648. /** @hidden */
  65649. static _SceneComponentInitialization: (scene: Scene) => void;
  65650. /**
  65651. * Creates a new G Buffer for the scene
  65652. * @param scene The scene the buffer belongs to
  65653. * @param ratio How big is the buffer related to the main canvas.
  65654. */
  65655. constructor(scene: Scene, ratio?: number);
  65656. /**
  65657. * Checks wether everything is ready to render a submesh to the G buffer.
  65658. * @param subMesh the submesh to check readiness for
  65659. * @param useInstances is the mesh drawn using instance or not
  65660. * @returns true if ready otherwise false
  65661. */
  65662. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65663. /**
  65664. * Gets the current underlying G Buffer.
  65665. * @returns the buffer
  65666. */
  65667. getGBuffer(): MultiRenderTarget;
  65668. /**
  65669. * Gets the number of samples used to render the buffer (anti aliasing).
  65670. */
  65671. get samples(): number;
  65672. /**
  65673. * Sets the number of samples used to render the buffer (anti aliasing).
  65674. */
  65675. set samples(value: number);
  65676. /**
  65677. * Disposes the renderer and frees up associated resources.
  65678. */
  65679. dispose(): void;
  65680. protected _createRenderTargets(): void;
  65681. private _copyBonesTransformationMatrices;
  65682. }
  65683. }
  65684. declare module BABYLON {
  65685. interface Scene {
  65686. /** @hidden (Backing field) */
  65687. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65688. /**
  65689. * Gets or Sets the current geometry buffer associated to the scene.
  65690. */
  65691. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65692. /**
  65693. * Enables a GeometryBufferRender and associates it with the scene
  65694. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65695. * @returns the GeometryBufferRenderer
  65696. */
  65697. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65698. /**
  65699. * Disables the GeometryBufferRender associated with the scene
  65700. */
  65701. disableGeometryBufferRenderer(): void;
  65702. }
  65703. /**
  65704. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65705. * in several rendering techniques.
  65706. */
  65707. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65708. /**
  65709. * The component name helpful to identify the component in the list of scene components.
  65710. */
  65711. readonly name: string;
  65712. /**
  65713. * The scene the component belongs to.
  65714. */
  65715. scene: Scene;
  65716. /**
  65717. * Creates a new instance of the component for the given scene
  65718. * @param scene Defines the scene to register the component in
  65719. */
  65720. constructor(scene: Scene);
  65721. /**
  65722. * Registers the component in a given scene
  65723. */
  65724. register(): void;
  65725. /**
  65726. * Rebuilds the elements related to this component in case of
  65727. * context lost for instance.
  65728. */
  65729. rebuild(): void;
  65730. /**
  65731. * Disposes the component and the associated ressources
  65732. */
  65733. dispose(): void;
  65734. private _gatherRenderTargets;
  65735. }
  65736. }
  65737. declare module BABYLON {
  65738. /** @hidden */
  65739. export var motionBlurPixelShader: {
  65740. name: string;
  65741. shader: string;
  65742. };
  65743. }
  65744. declare module BABYLON {
  65745. /**
  65746. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65747. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65748. * As an example, all you have to do is to create the post-process:
  65749. * var mb = new BABYLON.MotionBlurPostProcess(
  65750. * 'mb', // The name of the effect.
  65751. * scene, // The scene containing the objects to blur according to their velocity.
  65752. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65753. * camera // The camera to apply the render pass to.
  65754. * );
  65755. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65756. */
  65757. export class MotionBlurPostProcess extends PostProcess {
  65758. /**
  65759. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65760. */
  65761. motionStrength: number;
  65762. /**
  65763. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65764. */
  65765. get motionBlurSamples(): number;
  65766. /**
  65767. * Sets the number of iterations to be used for motion blur quality
  65768. */
  65769. set motionBlurSamples(samples: number);
  65770. private _motionBlurSamples;
  65771. private _geometryBufferRenderer;
  65772. /**
  65773. * Creates a new instance MotionBlurPostProcess
  65774. * @param name The name of the effect.
  65775. * @param scene The scene containing the objects to blur according to their velocity.
  65776. * @param options The required width/height ratio to downsize to before computing the render pass.
  65777. * @param camera The camera to apply the render pass to.
  65778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65779. * @param engine The engine which the post process will be applied. (default: current engine)
  65780. * @param reusable If the post process can be reused on the same frame. (default: false)
  65781. * @param textureType Type of textures used when performing the post process. (default: 0)
  65782. * @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)
  65783. */
  65784. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65785. /**
  65786. * Excludes the given skinned mesh from computing bones velocities.
  65787. * 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.
  65788. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65789. */
  65790. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65791. /**
  65792. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65793. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65794. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65795. */
  65796. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65797. /**
  65798. * Disposes the post process.
  65799. * @param camera The camera to dispose the post process on.
  65800. */
  65801. dispose(camera?: Camera): void;
  65802. }
  65803. }
  65804. declare module BABYLON {
  65805. /** @hidden */
  65806. export var refractionPixelShader: {
  65807. name: string;
  65808. shader: string;
  65809. };
  65810. }
  65811. declare module BABYLON {
  65812. /**
  65813. * Post process which applies a refractin texture
  65814. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65815. */
  65816. export class RefractionPostProcess extends PostProcess {
  65817. /** the base color of the refraction (used to taint the rendering) */
  65818. color: Color3;
  65819. /** simulated refraction depth */
  65820. depth: number;
  65821. /** the coefficient of the base color (0 to remove base color tainting) */
  65822. colorLevel: number;
  65823. private _refTexture;
  65824. private _ownRefractionTexture;
  65825. /**
  65826. * Gets or sets the refraction texture
  65827. * Please note that you are responsible for disposing the texture if you set it manually
  65828. */
  65829. get refractionTexture(): Texture;
  65830. set refractionTexture(value: Texture);
  65831. /**
  65832. * Initializes the RefractionPostProcess
  65833. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65834. * @param name The name of the effect.
  65835. * @param refractionTextureUrl Url of the refraction texture to use
  65836. * @param color the base color of the refraction (used to taint the rendering)
  65837. * @param depth simulated refraction depth
  65838. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65839. * @param camera The camera to apply the render pass to.
  65840. * @param options The required width/height ratio to downsize to before computing the render pass.
  65841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65842. * @param engine The engine which the post process will be applied. (default: current engine)
  65843. * @param reusable If the post process can be reused on the same frame. (default: false)
  65844. */
  65845. constructor(name: string, refractionTextureUrl: string,
  65846. /** the base color of the refraction (used to taint the rendering) */
  65847. color: Color3,
  65848. /** simulated refraction depth */
  65849. depth: number,
  65850. /** the coefficient of the base color (0 to remove base color tainting) */
  65851. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65852. /**
  65853. * Disposes of the post process
  65854. * @param camera Camera to dispose post process on
  65855. */
  65856. dispose(camera: Camera): void;
  65857. }
  65858. }
  65859. declare module BABYLON {
  65860. /** @hidden */
  65861. export var sharpenPixelShader: {
  65862. name: string;
  65863. shader: string;
  65864. };
  65865. }
  65866. declare module BABYLON {
  65867. /**
  65868. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65869. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65870. */
  65871. export class SharpenPostProcess extends PostProcess {
  65872. /**
  65873. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65874. */
  65875. colorAmount: number;
  65876. /**
  65877. * How much sharpness should be applied (default: 0.3)
  65878. */
  65879. edgeAmount: number;
  65880. /**
  65881. * Creates a new instance ConvolutionPostProcess
  65882. * @param name The name of the effect.
  65883. * @param options The required width/height ratio to downsize to before computing the render pass.
  65884. * @param camera The camera to apply the render pass to.
  65885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65886. * @param engine The engine which the post process will be applied. (default: current engine)
  65887. * @param reusable If the post process can be reused on the same frame. (default: false)
  65888. * @param textureType Type of textures used when performing the post process. (default: 0)
  65889. * @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)
  65890. */
  65891. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65892. }
  65893. }
  65894. declare module BABYLON {
  65895. /**
  65896. * PostProcessRenderPipeline
  65897. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65898. */
  65899. export class PostProcessRenderPipeline {
  65900. private engine;
  65901. private _renderEffects;
  65902. private _renderEffectsForIsolatedPass;
  65903. /**
  65904. * List of inspectable custom properties (used by the Inspector)
  65905. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65906. */
  65907. inspectableCustomProperties: IInspectable[];
  65908. /**
  65909. * @hidden
  65910. */
  65911. protected _cameras: Camera[];
  65912. /** @hidden */
  65913. _name: string;
  65914. /**
  65915. * Gets pipeline name
  65916. */
  65917. get name(): string;
  65918. /** Gets the list of attached cameras */
  65919. get cameras(): Camera[];
  65920. /**
  65921. * Initializes a PostProcessRenderPipeline
  65922. * @param engine engine to add the pipeline to
  65923. * @param name name of the pipeline
  65924. */
  65925. constructor(engine: Engine, name: string);
  65926. /**
  65927. * Gets the class name
  65928. * @returns "PostProcessRenderPipeline"
  65929. */
  65930. getClassName(): string;
  65931. /**
  65932. * If all the render effects in the pipeline are supported
  65933. */
  65934. get isSupported(): boolean;
  65935. /**
  65936. * Adds an effect to the pipeline
  65937. * @param renderEffect the effect to add
  65938. */
  65939. addEffect(renderEffect: PostProcessRenderEffect): void;
  65940. /** @hidden */
  65941. _rebuild(): void;
  65942. /** @hidden */
  65943. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65944. /** @hidden */
  65945. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65946. /** @hidden */
  65947. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65948. /** @hidden */
  65949. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65950. /** @hidden */
  65951. _attachCameras(cameras: Camera, unique: boolean): void;
  65952. /** @hidden */
  65953. _attachCameras(cameras: Camera[], unique: boolean): void;
  65954. /** @hidden */
  65955. _detachCameras(cameras: Camera): void;
  65956. /** @hidden */
  65957. _detachCameras(cameras: Nullable<Camera[]>): void;
  65958. /** @hidden */
  65959. _update(): void;
  65960. /** @hidden */
  65961. _reset(): void;
  65962. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65963. /**
  65964. * Disposes of the pipeline
  65965. */
  65966. dispose(): void;
  65967. }
  65968. }
  65969. declare module BABYLON {
  65970. /**
  65971. * PostProcessRenderPipelineManager class
  65972. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65973. */
  65974. export class PostProcessRenderPipelineManager {
  65975. private _renderPipelines;
  65976. /**
  65977. * Initializes a PostProcessRenderPipelineManager
  65978. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65979. */
  65980. constructor();
  65981. /**
  65982. * Gets the list of supported render pipelines
  65983. */
  65984. get supportedPipelines(): PostProcessRenderPipeline[];
  65985. /**
  65986. * Adds a pipeline to the manager
  65987. * @param renderPipeline The pipeline to add
  65988. */
  65989. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65990. /**
  65991. * Attaches a camera to the pipeline
  65992. * @param renderPipelineName The name of the pipeline to attach to
  65993. * @param cameras the camera to attach
  65994. * @param unique if the camera can be attached multiple times to the pipeline
  65995. */
  65996. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65997. /**
  65998. * Detaches a camera from the pipeline
  65999. * @param renderPipelineName The name of the pipeline to detach from
  66000. * @param cameras the camera to detach
  66001. */
  66002. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  66003. /**
  66004. * Enables an effect by name on a pipeline
  66005. * @param renderPipelineName the name of the pipeline to enable the effect in
  66006. * @param renderEffectName the name of the effect to enable
  66007. * @param cameras the cameras that the effect should be enabled on
  66008. */
  66009. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66010. /**
  66011. * Disables an effect by name on a pipeline
  66012. * @param renderPipelineName the name of the pipeline to disable the effect in
  66013. * @param renderEffectName the name of the effect to disable
  66014. * @param cameras the cameras that the effect should be disabled on
  66015. */
  66016. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66017. /**
  66018. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  66019. */
  66020. update(): void;
  66021. /** @hidden */
  66022. _rebuild(): void;
  66023. /**
  66024. * Disposes of the manager and pipelines
  66025. */
  66026. dispose(): void;
  66027. }
  66028. }
  66029. declare module BABYLON {
  66030. interface Scene {
  66031. /** @hidden (Backing field) */
  66032. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66033. /**
  66034. * Gets the postprocess render pipeline manager
  66035. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66036. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66037. */
  66038. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66039. }
  66040. /**
  66041. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66042. */
  66043. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66044. /**
  66045. * The component name helpfull to identify the component in the list of scene components.
  66046. */
  66047. readonly name: string;
  66048. /**
  66049. * The scene the component belongs to.
  66050. */
  66051. scene: Scene;
  66052. /**
  66053. * Creates a new instance of the component for the given scene
  66054. * @param scene Defines the scene to register the component in
  66055. */
  66056. constructor(scene: Scene);
  66057. /**
  66058. * Registers the component in a given scene
  66059. */
  66060. register(): void;
  66061. /**
  66062. * Rebuilds the elements related to this component in case of
  66063. * context lost for instance.
  66064. */
  66065. rebuild(): void;
  66066. /**
  66067. * Disposes the component and the associated ressources
  66068. */
  66069. dispose(): void;
  66070. private _gatherRenderTargets;
  66071. }
  66072. }
  66073. declare module BABYLON {
  66074. /**
  66075. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66076. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66077. */
  66078. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66079. private _scene;
  66080. private _camerasToBeAttached;
  66081. /**
  66082. * ID of the sharpen post process,
  66083. */
  66084. private readonly SharpenPostProcessId;
  66085. /**
  66086. * @ignore
  66087. * ID of the image processing post process;
  66088. */
  66089. readonly ImageProcessingPostProcessId: string;
  66090. /**
  66091. * @ignore
  66092. * ID of the Fast Approximate Anti-Aliasing post process;
  66093. */
  66094. readonly FxaaPostProcessId: string;
  66095. /**
  66096. * ID of the chromatic aberration post process,
  66097. */
  66098. private readonly ChromaticAberrationPostProcessId;
  66099. /**
  66100. * ID of the grain post process
  66101. */
  66102. private readonly GrainPostProcessId;
  66103. /**
  66104. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66105. */
  66106. sharpen: SharpenPostProcess;
  66107. private _sharpenEffect;
  66108. private bloom;
  66109. /**
  66110. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66111. */
  66112. depthOfField: DepthOfFieldEffect;
  66113. /**
  66114. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66115. */
  66116. fxaa: FxaaPostProcess;
  66117. /**
  66118. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66119. */
  66120. imageProcessing: ImageProcessingPostProcess;
  66121. /**
  66122. * Chromatic aberration post process which will shift rgb colors in the image
  66123. */
  66124. chromaticAberration: ChromaticAberrationPostProcess;
  66125. private _chromaticAberrationEffect;
  66126. /**
  66127. * Grain post process which add noise to the image
  66128. */
  66129. grain: GrainPostProcess;
  66130. private _grainEffect;
  66131. /**
  66132. * Glow post process which adds a glow to emissive areas of the image
  66133. */
  66134. private _glowLayer;
  66135. /**
  66136. * Animations which can be used to tweak settings over a period of time
  66137. */
  66138. animations: Animation[];
  66139. private _imageProcessingConfigurationObserver;
  66140. private _sharpenEnabled;
  66141. private _bloomEnabled;
  66142. private _depthOfFieldEnabled;
  66143. private _depthOfFieldBlurLevel;
  66144. private _fxaaEnabled;
  66145. private _imageProcessingEnabled;
  66146. private _defaultPipelineTextureType;
  66147. private _bloomScale;
  66148. private _chromaticAberrationEnabled;
  66149. private _grainEnabled;
  66150. private _buildAllowed;
  66151. /**
  66152. * Gets active scene
  66153. */
  66154. get scene(): Scene;
  66155. /**
  66156. * Enable or disable the sharpen process from the pipeline
  66157. */
  66158. set sharpenEnabled(enabled: boolean);
  66159. get sharpenEnabled(): boolean;
  66160. private _resizeObserver;
  66161. private _hardwareScaleLevel;
  66162. private _bloomKernel;
  66163. /**
  66164. * Specifies the size of the bloom blur kernel, relative to the final output size
  66165. */
  66166. get bloomKernel(): number;
  66167. set bloomKernel(value: number);
  66168. /**
  66169. * Specifies the weight of the bloom in the final rendering
  66170. */
  66171. private _bloomWeight;
  66172. /**
  66173. * Specifies the luma threshold for the area that will be blurred by the bloom
  66174. */
  66175. private _bloomThreshold;
  66176. private _hdr;
  66177. /**
  66178. * The strength of the bloom.
  66179. */
  66180. set bloomWeight(value: number);
  66181. get bloomWeight(): number;
  66182. /**
  66183. * The strength of the bloom.
  66184. */
  66185. set bloomThreshold(value: number);
  66186. get bloomThreshold(): number;
  66187. /**
  66188. * The scale of the bloom, lower value will provide better performance.
  66189. */
  66190. set bloomScale(value: number);
  66191. get bloomScale(): number;
  66192. /**
  66193. * Enable or disable the bloom from the pipeline
  66194. */
  66195. set bloomEnabled(enabled: boolean);
  66196. get bloomEnabled(): boolean;
  66197. private _rebuildBloom;
  66198. /**
  66199. * If the depth of field is enabled.
  66200. */
  66201. get depthOfFieldEnabled(): boolean;
  66202. set depthOfFieldEnabled(enabled: boolean);
  66203. /**
  66204. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66205. */
  66206. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66207. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66208. /**
  66209. * If the anti aliasing is enabled.
  66210. */
  66211. set fxaaEnabled(enabled: boolean);
  66212. get fxaaEnabled(): boolean;
  66213. private _samples;
  66214. /**
  66215. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66216. */
  66217. set samples(sampleCount: number);
  66218. get samples(): number;
  66219. /**
  66220. * If image processing is enabled.
  66221. */
  66222. set imageProcessingEnabled(enabled: boolean);
  66223. get imageProcessingEnabled(): boolean;
  66224. /**
  66225. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66226. */
  66227. set glowLayerEnabled(enabled: boolean);
  66228. get glowLayerEnabled(): boolean;
  66229. /**
  66230. * Gets the glow layer (or null if not defined)
  66231. */
  66232. get glowLayer(): Nullable<GlowLayer>;
  66233. /**
  66234. * Enable or disable the chromaticAberration process from the pipeline
  66235. */
  66236. set chromaticAberrationEnabled(enabled: boolean);
  66237. get chromaticAberrationEnabled(): boolean;
  66238. /**
  66239. * Enable or disable the grain process from the pipeline
  66240. */
  66241. set grainEnabled(enabled: boolean);
  66242. get grainEnabled(): boolean;
  66243. /**
  66244. * @constructor
  66245. * @param name - The rendering pipeline name (default: "")
  66246. * @param hdr - If high dynamic range textures should be used (default: true)
  66247. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66248. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66249. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66250. */
  66251. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66252. /**
  66253. * Get the class name
  66254. * @returns "DefaultRenderingPipeline"
  66255. */
  66256. getClassName(): string;
  66257. /**
  66258. * Force the compilation of the entire pipeline.
  66259. */
  66260. prepare(): void;
  66261. private _hasCleared;
  66262. private _prevPostProcess;
  66263. private _prevPrevPostProcess;
  66264. private _setAutoClearAndTextureSharing;
  66265. private _depthOfFieldSceneObserver;
  66266. private _buildPipeline;
  66267. private _disposePostProcesses;
  66268. /**
  66269. * Adds a camera to the pipeline
  66270. * @param camera the camera to be added
  66271. */
  66272. addCamera(camera: Camera): void;
  66273. /**
  66274. * Removes a camera from the pipeline
  66275. * @param camera the camera to remove
  66276. */
  66277. removeCamera(camera: Camera): void;
  66278. /**
  66279. * Dispose of the pipeline and stop all post processes
  66280. */
  66281. dispose(): void;
  66282. /**
  66283. * Serialize the rendering pipeline (Used when exporting)
  66284. * @returns the serialized object
  66285. */
  66286. serialize(): any;
  66287. /**
  66288. * Parse the serialized pipeline
  66289. * @param source Source pipeline.
  66290. * @param scene The scene to load the pipeline to.
  66291. * @param rootUrl The URL of the serialized pipeline.
  66292. * @returns An instantiated pipeline from the serialized object.
  66293. */
  66294. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66295. }
  66296. }
  66297. declare module BABYLON {
  66298. /** @hidden */
  66299. export var lensHighlightsPixelShader: {
  66300. name: string;
  66301. shader: string;
  66302. };
  66303. }
  66304. declare module BABYLON {
  66305. /** @hidden */
  66306. export var depthOfFieldPixelShader: {
  66307. name: string;
  66308. shader: string;
  66309. };
  66310. }
  66311. declare module BABYLON {
  66312. /**
  66313. * BABYLON.JS Chromatic Aberration GLSL Shader
  66314. * Author: Olivier Guyot
  66315. * Separates very slightly R, G and B colors on the edges of the screen
  66316. * Inspired by Francois Tarlier & Martins Upitis
  66317. */
  66318. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66319. /**
  66320. * @ignore
  66321. * The chromatic aberration PostProcess id in the pipeline
  66322. */
  66323. LensChromaticAberrationEffect: string;
  66324. /**
  66325. * @ignore
  66326. * The highlights enhancing PostProcess id in the pipeline
  66327. */
  66328. HighlightsEnhancingEffect: string;
  66329. /**
  66330. * @ignore
  66331. * The depth-of-field PostProcess id in the pipeline
  66332. */
  66333. LensDepthOfFieldEffect: string;
  66334. private _scene;
  66335. private _depthTexture;
  66336. private _grainTexture;
  66337. private _chromaticAberrationPostProcess;
  66338. private _highlightsPostProcess;
  66339. private _depthOfFieldPostProcess;
  66340. private _edgeBlur;
  66341. private _grainAmount;
  66342. private _chromaticAberration;
  66343. private _distortion;
  66344. private _highlightsGain;
  66345. private _highlightsThreshold;
  66346. private _dofDistance;
  66347. private _dofAperture;
  66348. private _dofDarken;
  66349. private _dofPentagon;
  66350. private _blurNoise;
  66351. /**
  66352. * @constructor
  66353. *
  66354. * Effect parameters are as follow:
  66355. * {
  66356. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66357. * edge_blur: number; // from 0 to x (1 for realism)
  66358. * distortion: number; // from 0 to x (1 for realism)
  66359. * grain_amount: number; // from 0 to 1
  66360. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66361. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66362. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66363. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66364. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66365. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66366. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66367. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66368. * }
  66369. * Note: if an effect parameter is unset, effect is disabled
  66370. *
  66371. * @param name The rendering pipeline name
  66372. * @param parameters - An object containing all parameters (see above)
  66373. * @param scene The scene linked to this pipeline
  66374. * @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)
  66375. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66376. */
  66377. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66378. /**
  66379. * Get the class name
  66380. * @returns "LensRenderingPipeline"
  66381. */
  66382. getClassName(): string;
  66383. /**
  66384. * Gets associated scene
  66385. */
  66386. get scene(): Scene;
  66387. /**
  66388. * Gets or sets the edge blur
  66389. */
  66390. get edgeBlur(): number;
  66391. set edgeBlur(value: number);
  66392. /**
  66393. * Gets or sets the grain amount
  66394. */
  66395. get grainAmount(): number;
  66396. set grainAmount(value: number);
  66397. /**
  66398. * Gets or sets the chromatic aberration amount
  66399. */
  66400. get chromaticAberration(): number;
  66401. set chromaticAberration(value: number);
  66402. /**
  66403. * Gets or sets the depth of field aperture
  66404. */
  66405. get dofAperture(): number;
  66406. set dofAperture(value: number);
  66407. /**
  66408. * Gets or sets the edge distortion
  66409. */
  66410. get edgeDistortion(): number;
  66411. set edgeDistortion(value: number);
  66412. /**
  66413. * Gets or sets the depth of field distortion
  66414. */
  66415. get dofDistortion(): number;
  66416. set dofDistortion(value: number);
  66417. /**
  66418. * Gets or sets the darken out of focus amount
  66419. */
  66420. get darkenOutOfFocus(): number;
  66421. set darkenOutOfFocus(value: number);
  66422. /**
  66423. * Gets or sets a boolean indicating if blur noise is enabled
  66424. */
  66425. get blurNoise(): boolean;
  66426. set blurNoise(value: boolean);
  66427. /**
  66428. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66429. */
  66430. get pentagonBokeh(): boolean;
  66431. set pentagonBokeh(value: boolean);
  66432. /**
  66433. * Gets or sets the highlight grain amount
  66434. */
  66435. get highlightsGain(): number;
  66436. set highlightsGain(value: number);
  66437. /**
  66438. * Gets or sets the highlight threshold
  66439. */
  66440. get highlightsThreshold(): number;
  66441. set highlightsThreshold(value: number);
  66442. /**
  66443. * Sets the amount of blur at the edges
  66444. * @param amount blur amount
  66445. */
  66446. setEdgeBlur(amount: number): void;
  66447. /**
  66448. * Sets edge blur to 0
  66449. */
  66450. disableEdgeBlur(): void;
  66451. /**
  66452. * Sets the amout of grain
  66453. * @param amount Amount of grain
  66454. */
  66455. setGrainAmount(amount: number): void;
  66456. /**
  66457. * Set grain amount to 0
  66458. */
  66459. disableGrain(): void;
  66460. /**
  66461. * Sets the chromatic aberration amount
  66462. * @param amount amount of chromatic aberration
  66463. */
  66464. setChromaticAberration(amount: number): void;
  66465. /**
  66466. * Sets chromatic aberration amount to 0
  66467. */
  66468. disableChromaticAberration(): void;
  66469. /**
  66470. * Sets the EdgeDistortion amount
  66471. * @param amount amount of EdgeDistortion
  66472. */
  66473. setEdgeDistortion(amount: number): void;
  66474. /**
  66475. * Sets edge distortion to 0
  66476. */
  66477. disableEdgeDistortion(): void;
  66478. /**
  66479. * Sets the FocusDistance amount
  66480. * @param amount amount of FocusDistance
  66481. */
  66482. setFocusDistance(amount: number): void;
  66483. /**
  66484. * Disables depth of field
  66485. */
  66486. disableDepthOfField(): void;
  66487. /**
  66488. * Sets the Aperture amount
  66489. * @param amount amount of Aperture
  66490. */
  66491. setAperture(amount: number): void;
  66492. /**
  66493. * Sets the DarkenOutOfFocus amount
  66494. * @param amount amount of DarkenOutOfFocus
  66495. */
  66496. setDarkenOutOfFocus(amount: number): void;
  66497. private _pentagonBokehIsEnabled;
  66498. /**
  66499. * Creates a pentagon bokeh effect
  66500. */
  66501. enablePentagonBokeh(): void;
  66502. /**
  66503. * Disables the pentagon bokeh effect
  66504. */
  66505. disablePentagonBokeh(): void;
  66506. /**
  66507. * Enables noise blur
  66508. */
  66509. enableNoiseBlur(): void;
  66510. /**
  66511. * Disables noise blur
  66512. */
  66513. disableNoiseBlur(): void;
  66514. /**
  66515. * Sets the HighlightsGain amount
  66516. * @param amount amount of HighlightsGain
  66517. */
  66518. setHighlightsGain(amount: number): void;
  66519. /**
  66520. * Sets the HighlightsThreshold amount
  66521. * @param amount amount of HighlightsThreshold
  66522. */
  66523. setHighlightsThreshold(amount: number): void;
  66524. /**
  66525. * Disables highlights
  66526. */
  66527. disableHighlights(): void;
  66528. /**
  66529. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66530. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66531. */
  66532. dispose(disableDepthRender?: boolean): void;
  66533. private _createChromaticAberrationPostProcess;
  66534. private _createHighlightsPostProcess;
  66535. private _createDepthOfFieldPostProcess;
  66536. private _createGrainTexture;
  66537. }
  66538. }
  66539. declare module BABYLON {
  66540. /** @hidden */
  66541. export var ssao2PixelShader: {
  66542. name: string;
  66543. shader: string;
  66544. };
  66545. }
  66546. declare module BABYLON {
  66547. /** @hidden */
  66548. export var ssaoCombinePixelShader: {
  66549. name: string;
  66550. shader: string;
  66551. };
  66552. }
  66553. declare module BABYLON {
  66554. /**
  66555. * Render pipeline to produce ssao effect
  66556. */
  66557. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66558. /**
  66559. * @ignore
  66560. * The PassPostProcess id in the pipeline that contains the original scene color
  66561. */
  66562. SSAOOriginalSceneColorEffect: string;
  66563. /**
  66564. * @ignore
  66565. * The SSAO PostProcess id in the pipeline
  66566. */
  66567. SSAORenderEffect: string;
  66568. /**
  66569. * @ignore
  66570. * The horizontal blur PostProcess id in the pipeline
  66571. */
  66572. SSAOBlurHRenderEffect: string;
  66573. /**
  66574. * @ignore
  66575. * The vertical blur PostProcess id in the pipeline
  66576. */
  66577. SSAOBlurVRenderEffect: string;
  66578. /**
  66579. * @ignore
  66580. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66581. */
  66582. SSAOCombineRenderEffect: string;
  66583. /**
  66584. * The output strength of the SSAO post-process. Default value is 1.0.
  66585. */
  66586. totalStrength: number;
  66587. /**
  66588. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66589. */
  66590. maxZ: number;
  66591. /**
  66592. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66593. */
  66594. minZAspect: number;
  66595. private _samples;
  66596. /**
  66597. * Number of samples used for the SSAO calculations. Default value is 8
  66598. */
  66599. set samples(n: number);
  66600. get samples(): number;
  66601. private _textureSamples;
  66602. /**
  66603. * Number of samples to use for antialiasing
  66604. */
  66605. set textureSamples(n: number);
  66606. get textureSamples(): number;
  66607. /**
  66608. * Ratio object used for SSAO ratio and blur ratio
  66609. */
  66610. private _ratio;
  66611. /**
  66612. * Dynamically generated sphere sampler.
  66613. */
  66614. private _sampleSphere;
  66615. /**
  66616. * Blur filter offsets
  66617. */
  66618. private _samplerOffsets;
  66619. private _expensiveBlur;
  66620. /**
  66621. * If bilateral blur should be used
  66622. */
  66623. set expensiveBlur(b: boolean);
  66624. get expensiveBlur(): boolean;
  66625. /**
  66626. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66627. */
  66628. radius: number;
  66629. /**
  66630. * The base color of the SSAO post-process
  66631. * The final result is "base + ssao" between [0, 1]
  66632. */
  66633. base: number;
  66634. /**
  66635. * Support test.
  66636. */
  66637. static get IsSupported(): boolean;
  66638. private _scene;
  66639. private _depthTexture;
  66640. private _normalTexture;
  66641. private _randomTexture;
  66642. private _originalColorPostProcess;
  66643. private _ssaoPostProcess;
  66644. private _blurHPostProcess;
  66645. private _blurVPostProcess;
  66646. private _ssaoCombinePostProcess;
  66647. /**
  66648. * Gets active scene
  66649. */
  66650. get scene(): Scene;
  66651. /**
  66652. * @constructor
  66653. * @param name The rendering pipeline name
  66654. * @param scene The scene linked to this pipeline
  66655. * @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 }
  66656. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66657. */
  66658. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66659. /**
  66660. * Get the class name
  66661. * @returns "SSAO2RenderingPipeline"
  66662. */
  66663. getClassName(): string;
  66664. /**
  66665. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66666. */
  66667. dispose(disableGeometryBufferRenderer?: boolean): void;
  66668. private _createBlurPostProcess;
  66669. /** @hidden */
  66670. _rebuild(): void;
  66671. private _bits;
  66672. private _radicalInverse_VdC;
  66673. private _hammersley;
  66674. private _hemisphereSample_uniform;
  66675. private _generateHemisphere;
  66676. private _createSSAOPostProcess;
  66677. private _createSSAOCombinePostProcess;
  66678. private _createRandomTexture;
  66679. /**
  66680. * Serialize the rendering pipeline (Used when exporting)
  66681. * @returns the serialized object
  66682. */
  66683. serialize(): any;
  66684. /**
  66685. * Parse the serialized pipeline
  66686. * @param source Source pipeline.
  66687. * @param scene The scene to load the pipeline to.
  66688. * @param rootUrl The URL of the serialized pipeline.
  66689. * @returns An instantiated pipeline from the serialized object.
  66690. */
  66691. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66692. }
  66693. }
  66694. declare module BABYLON {
  66695. /** @hidden */
  66696. export var ssaoPixelShader: {
  66697. name: string;
  66698. shader: string;
  66699. };
  66700. }
  66701. declare module BABYLON {
  66702. /**
  66703. * Render pipeline to produce ssao effect
  66704. */
  66705. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66706. /**
  66707. * @ignore
  66708. * The PassPostProcess id in the pipeline that contains the original scene color
  66709. */
  66710. SSAOOriginalSceneColorEffect: string;
  66711. /**
  66712. * @ignore
  66713. * The SSAO PostProcess id in the pipeline
  66714. */
  66715. SSAORenderEffect: string;
  66716. /**
  66717. * @ignore
  66718. * The horizontal blur PostProcess id in the pipeline
  66719. */
  66720. SSAOBlurHRenderEffect: string;
  66721. /**
  66722. * @ignore
  66723. * The vertical blur PostProcess id in the pipeline
  66724. */
  66725. SSAOBlurVRenderEffect: string;
  66726. /**
  66727. * @ignore
  66728. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66729. */
  66730. SSAOCombineRenderEffect: string;
  66731. /**
  66732. * The output strength of the SSAO post-process. Default value is 1.0.
  66733. */
  66734. totalStrength: number;
  66735. /**
  66736. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66737. */
  66738. radius: number;
  66739. /**
  66740. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66741. * Must not be equal to fallOff and superior to fallOff.
  66742. * Default value is 0.0075
  66743. */
  66744. area: number;
  66745. /**
  66746. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66747. * Must not be equal to area and inferior to area.
  66748. * Default value is 0.000001
  66749. */
  66750. fallOff: number;
  66751. /**
  66752. * The base color of the SSAO post-process
  66753. * The final result is "base + ssao" between [0, 1]
  66754. */
  66755. base: number;
  66756. private _scene;
  66757. private _depthTexture;
  66758. private _randomTexture;
  66759. private _originalColorPostProcess;
  66760. private _ssaoPostProcess;
  66761. private _blurHPostProcess;
  66762. private _blurVPostProcess;
  66763. private _ssaoCombinePostProcess;
  66764. private _firstUpdate;
  66765. /**
  66766. * Gets active scene
  66767. */
  66768. get scene(): Scene;
  66769. /**
  66770. * @constructor
  66771. * @param name - The rendering pipeline name
  66772. * @param scene - The scene linked to this pipeline
  66773. * @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 }
  66774. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66775. */
  66776. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66777. /**
  66778. * Get the class name
  66779. * @returns "SSAORenderingPipeline"
  66780. */
  66781. getClassName(): string;
  66782. /**
  66783. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66784. */
  66785. dispose(disableDepthRender?: boolean): void;
  66786. private _createBlurPostProcess;
  66787. /** @hidden */
  66788. _rebuild(): void;
  66789. private _createSSAOPostProcess;
  66790. private _createSSAOCombinePostProcess;
  66791. private _createRandomTexture;
  66792. }
  66793. }
  66794. declare module BABYLON {
  66795. /** @hidden */
  66796. export var screenSpaceReflectionPixelShader: {
  66797. name: string;
  66798. shader: string;
  66799. };
  66800. }
  66801. declare module BABYLON {
  66802. /**
  66803. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66804. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66805. */
  66806. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66807. /**
  66808. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66809. */
  66810. threshold: number;
  66811. /**
  66812. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66813. */
  66814. strength: number;
  66815. /**
  66816. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66817. */
  66818. reflectionSpecularFalloffExponent: number;
  66819. /**
  66820. * 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]
  66821. */
  66822. step: number;
  66823. /**
  66824. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66825. */
  66826. roughnessFactor: number;
  66827. private _geometryBufferRenderer;
  66828. private _enableSmoothReflections;
  66829. private _reflectionSamples;
  66830. private _smoothSteps;
  66831. /**
  66832. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66833. * @param name The name of the effect.
  66834. * @param scene The scene containing the objects to calculate reflections.
  66835. * @param options The required width/height ratio to downsize to before computing the render pass.
  66836. * @param camera The camera to apply the render pass to.
  66837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66838. * @param engine The engine which the post process will be applied. (default: current engine)
  66839. * @param reusable If the post process can be reused on the same frame. (default: false)
  66840. * @param textureType Type of textures used when performing the post process. (default: 0)
  66841. * @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)
  66842. */
  66843. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66844. /**
  66845. * Gets wether or not smoothing reflections is enabled.
  66846. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66847. */
  66848. get enableSmoothReflections(): boolean;
  66849. /**
  66850. * Sets wether or not smoothing reflections is enabled.
  66851. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66852. */
  66853. set enableSmoothReflections(enabled: boolean);
  66854. /**
  66855. * Gets the number of samples taken while computing reflections. More samples count is high,
  66856. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66857. */
  66858. get reflectionSamples(): number;
  66859. /**
  66860. * Sets the number of samples taken while computing reflections. More samples count is high,
  66861. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66862. */
  66863. set reflectionSamples(samples: number);
  66864. /**
  66865. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66866. * more the post-process will require GPU power and can generate a drop in FPS.
  66867. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66868. */
  66869. get smoothSteps(): number;
  66870. set smoothSteps(steps: number);
  66871. private _updateEffectDefines;
  66872. }
  66873. }
  66874. declare module BABYLON {
  66875. /** @hidden */
  66876. export var standardPixelShader: {
  66877. name: string;
  66878. shader: string;
  66879. };
  66880. }
  66881. declare module BABYLON {
  66882. /**
  66883. * Standard rendering pipeline
  66884. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66885. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66886. */
  66887. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66888. /**
  66889. * Public members
  66890. */
  66891. /**
  66892. * Post-process which contains the original scene color before the pipeline applies all the effects
  66893. */
  66894. originalPostProcess: Nullable<PostProcess>;
  66895. /**
  66896. * Post-process used to down scale an image x4
  66897. */
  66898. downSampleX4PostProcess: Nullable<PostProcess>;
  66899. /**
  66900. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66901. */
  66902. brightPassPostProcess: Nullable<PostProcess>;
  66903. /**
  66904. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66905. */
  66906. blurHPostProcesses: PostProcess[];
  66907. /**
  66908. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66909. */
  66910. blurVPostProcesses: PostProcess[];
  66911. /**
  66912. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66913. */
  66914. textureAdderPostProcess: Nullable<PostProcess>;
  66915. /**
  66916. * Post-process used to create volumetric lighting effect
  66917. */
  66918. volumetricLightPostProcess: Nullable<PostProcess>;
  66919. /**
  66920. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66921. */
  66922. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66923. /**
  66924. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66925. */
  66926. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66927. /**
  66928. * Post-process used to merge the volumetric light effect and the real scene color
  66929. */
  66930. volumetricLightMergePostProces: Nullable<PostProcess>;
  66931. /**
  66932. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66933. */
  66934. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66935. /**
  66936. * Base post-process used to calculate the average luminance of the final image for HDR
  66937. */
  66938. luminancePostProcess: Nullable<PostProcess>;
  66939. /**
  66940. * Post-processes used to create down sample post-processes in order to get
  66941. * the average luminance of the final image for HDR
  66942. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66943. */
  66944. luminanceDownSamplePostProcesses: PostProcess[];
  66945. /**
  66946. * Post-process used to create a HDR effect (light adaptation)
  66947. */
  66948. hdrPostProcess: Nullable<PostProcess>;
  66949. /**
  66950. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66951. */
  66952. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66953. /**
  66954. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66955. */
  66956. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66957. /**
  66958. * Post-process used to merge the final HDR post-process and the real scene color
  66959. */
  66960. hdrFinalPostProcess: Nullable<PostProcess>;
  66961. /**
  66962. * Post-process used to create a lens flare effect
  66963. */
  66964. lensFlarePostProcess: Nullable<PostProcess>;
  66965. /**
  66966. * Post-process that merges the result of the lens flare post-process and the real scene color
  66967. */
  66968. lensFlareComposePostProcess: Nullable<PostProcess>;
  66969. /**
  66970. * Post-process used to create a motion blur effect
  66971. */
  66972. motionBlurPostProcess: Nullable<PostProcess>;
  66973. /**
  66974. * Post-process used to create a depth of field effect
  66975. */
  66976. depthOfFieldPostProcess: Nullable<PostProcess>;
  66977. /**
  66978. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66979. */
  66980. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66981. /**
  66982. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66983. */
  66984. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66985. /**
  66986. * Represents the brightness threshold in order to configure the illuminated surfaces
  66987. */
  66988. brightThreshold: number;
  66989. /**
  66990. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66991. */
  66992. blurWidth: number;
  66993. /**
  66994. * Sets if the blur for highlighted surfaces must be only horizontal
  66995. */
  66996. horizontalBlur: boolean;
  66997. /**
  66998. * Gets the overall exposure used by the pipeline
  66999. */
  67000. get exposure(): number;
  67001. /**
  67002. * Sets the overall exposure used by the pipeline
  67003. */
  67004. set exposure(value: number);
  67005. /**
  67006. * Texture used typically to simulate "dirty" on camera lens
  67007. */
  67008. lensTexture: Nullable<Texture>;
  67009. /**
  67010. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  67011. */
  67012. volumetricLightCoefficient: number;
  67013. /**
  67014. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  67015. */
  67016. volumetricLightPower: number;
  67017. /**
  67018. * Used the set the blur intensity to smooth the volumetric lights
  67019. */
  67020. volumetricLightBlurScale: number;
  67021. /**
  67022. * Light (spot or directional) used to generate the volumetric lights rays
  67023. * The source light must have a shadow generate so the pipeline can get its
  67024. * depth map
  67025. */
  67026. sourceLight: Nullable<SpotLight | DirectionalLight>;
  67027. /**
  67028. * For eye adaptation, represents the minimum luminance the eye can see
  67029. */
  67030. hdrMinimumLuminance: number;
  67031. /**
  67032. * For eye adaptation, represents the decrease luminance speed
  67033. */
  67034. hdrDecreaseRate: number;
  67035. /**
  67036. * For eye adaptation, represents the increase luminance speed
  67037. */
  67038. hdrIncreaseRate: number;
  67039. /**
  67040. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67041. */
  67042. get hdrAutoExposure(): boolean;
  67043. /**
  67044. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67045. */
  67046. set hdrAutoExposure(value: boolean);
  67047. /**
  67048. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  67049. */
  67050. lensColorTexture: Nullable<Texture>;
  67051. /**
  67052. * The overall strengh for the lens flare effect
  67053. */
  67054. lensFlareStrength: number;
  67055. /**
  67056. * Dispersion coefficient for lens flare ghosts
  67057. */
  67058. lensFlareGhostDispersal: number;
  67059. /**
  67060. * Main lens flare halo width
  67061. */
  67062. lensFlareHaloWidth: number;
  67063. /**
  67064. * Based on the lens distortion effect, defines how much the lens flare result
  67065. * is distorted
  67066. */
  67067. lensFlareDistortionStrength: number;
  67068. /**
  67069. * Configures the blur intensity used for for lens flare (halo)
  67070. */
  67071. lensFlareBlurWidth: number;
  67072. /**
  67073. * Lens star texture must be used to simulate rays on the flares and is available
  67074. * in the documentation
  67075. */
  67076. lensStarTexture: Nullable<Texture>;
  67077. /**
  67078. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67079. * flare effect by taking account of the dirt texture
  67080. */
  67081. lensFlareDirtTexture: Nullable<Texture>;
  67082. /**
  67083. * Represents the focal length for the depth of field effect
  67084. */
  67085. depthOfFieldDistance: number;
  67086. /**
  67087. * Represents the blur intensity for the blurred part of the depth of field effect
  67088. */
  67089. depthOfFieldBlurWidth: number;
  67090. /**
  67091. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67092. */
  67093. get motionStrength(): number;
  67094. /**
  67095. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67096. */
  67097. set motionStrength(strength: number);
  67098. /**
  67099. * Gets wether or not the motion blur post-process is object based or screen based.
  67100. */
  67101. get objectBasedMotionBlur(): boolean;
  67102. /**
  67103. * Sets wether or not the motion blur post-process should be object based or screen based
  67104. */
  67105. set objectBasedMotionBlur(value: boolean);
  67106. /**
  67107. * List of animations for the pipeline (IAnimatable implementation)
  67108. */
  67109. animations: Animation[];
  67110. /**
  67111. * Private members
  67112. */
  67113. private _scene;
  67114. private _currentDepthOfFieldSource;
  67115. private _basePostProcess;
  67116. private _fixedExposure;
  67117. private _currentExposure;
  67118. private _hdrAutoExposure;
  67119. private _hdrCurrentLuminance;
  67120. private _motionStrength;
  67121. private _isObjectBasedMotionBlur;
  67122. private _floatTextureType;
  67123. private _camerasToBeAttached;
  67124. private _ratio;
  67125. private _bloomEnabled;
  67126. private _depthOfFieldEnabled;
  67127. private _vlsEnabled;
  67128. private _lensFlareEnabled;
  67129. private _hdrEnabled;
  67130. private _motionBlurEnabled;
  67131. private _fxaaEnabled;
  67132. private _screenSpaceReflectionsEnabled;
  67133. private _motionBlurSamples;
  67134. private _volumetricLightStepsCount;
  67135. private _samples;
  67136. /**
  67137. * @ignore
  67138. * Specifies if the bloom pipeline is enabled
  67139. */
  67140. get BloomEnabled(): boolean;
  67141. set BloomEnabled(enabled: boolean);
  67142. /**
  67143. * @ignore
  67144. * Specifies if the depth of field pipeline is enabed
  67145. */
  67146. get DepthOfFieldEnabled(): boolean;
  67147. set DepthOfFieldEnabled(enabled: boolean);
  67148. /**
  67149. * @ignore
  67150. * Specifies if the lens flare pipeline is enabed
  67151. */
  67152. get LensFlareEnabled(): boolean;
  67153. set LensFlareEnabled(enabled: boolean);
  67154. /**
  67155. * @ignore
  67156. * Specifies if the HDR pipeline is enabled
  67157. */
  67158. get HDREnabled(): boolean;
  67159. set HDREnabled(enabled: boolean);
  67160. /**
  67161. * @ignore
  67162. * Specifies if the volumetric lights scattering effect is enabled
  67163. */
  67164. get VLSEnabled(): boolean;
  67165. set VLSEnabled(enabled: boolean);
  67166. /**
  67167. * @ignore
  67168. * Specifies if the motion blur effect is enabled
  67169. */
  67170. get MotionBlurEnabled(): boolean;
  67171. set MotionBlurEnabled(enabled: boolean);
  67172. /**
  67173. * Specifies if anti-aliasing is enabled
  67174. */
  67175. get fxaaEnabled(): boolean;
  67176. set fxaaEnabled(enabled: boolean);
  67177. /**
  67178. * Specifies if screen space reflections are enabled.
  67179. */
  67180. get screenSpaceReflectionsEnabled(): boolean;
  67181. set screenSpaceReflectionsEnabled(enabled: boolean);
  67182. /**
  67183. * Specifies the number of steps used to calculate the volumetric lights
  67184. * Typically in interval [50, 200]
  67185. */
  67186. get volumetricLightStepsCount(): number;
  67187. set volumetricLightStepsCount(count: number);
  67188. /**
  67189. * Specifies the number of samples used for the motion blur effect
  67190. * Typically in interval [16, 64]
  67191. */
  67192. get motionBlurSamples(): number;
  67193. set motionBlurSamples(samples: number);
  67194. /**
  67195. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67196. */
  67197. get samples(): number;
  67198. set samples(sampleCount: number);
  67199. /**
  67200. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67201. * @constructor
  67202. * @param name The rendering pipeline name
  67203. * @param scene The scene linked to this pipeline
  67204. * @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)
  67205. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67206. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67207. */
  67208. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67209. private _buildPipeline;
  67210. private _createDownSampleX4PostProcess;
  67211. private _createBrightPassPostProcess;
  67212. private _createBlurPostProcesses;
  67213. private _createTextureAdderPostProcess;
  67214. private _createVolumetricLightPostProcess;
  67215. private _createLuminancePostProcesses;
  67216. private _createHdrPostProcess;
  67217. private _createLensFlarePostProcess;
  67218. private _createDepthOfFieldPostProcess;
  67219. private _createMotionBlurPostProcess;
  67220. private _getDepthTexture;
  67221. private _disposePostProcesses;
  67222. /**
  67223. * Dispose of the pipeline and stop all post processes
  67224. */
  67225. dispose(): void;
  67226. /**
  67227. * Serialize the rendering pipeline (Used when exporting)
  67228. * @returns the serialized object
  67229. */
  67230. serialize(): any;
  67231. /**
  67232. * Parse the serialized pipeline
  67233. * @param source Source pipeline.
  67234. * @param scene The scene to load the pipeline to.
  67235. * @param rootUrl The URL of the serialized pipeline.
  67236. * @returns An instantiated pipeline from the serialized object.
  67237. */
  67238. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67239. /**
  67240. * Luminance steps
  67241. */
  67242. static LuminanceSteps: number;
  67243. }
  67244. }
  67245. declare module BABYLON {
  67246. /** @hidden */
  67247. export var stereoscopicInterlacePixelShader: {
  67248. name: string;
  67249. shader: string;
  67250. };
  67251. }
  67252. declare module BABYLON {
  67253. /**
  67254. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  67255. */
  67256. export class StereoscopicInterlacePostProcessI extends PostProcess {
  67257. private _stepSize;
  67258. private _passedProcess;
  67259. /**
  67260. * Initializes a StereoscopicInterlacePostProcessI
  67261. * @param name The name of the effect.
  67262. * @param rigCameras The rig cameras to be appled to the post process
  67263. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  67264. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  67265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67266. * @param engine The engine which the post process will be applied. (default: current engine)
  67267. * @param reusable If the post process can be reused on the same frame. (default: false)
  67268. */
  67269. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67270. }
  67271. /**
  67272. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  67273. */
  67274. export class StereoscopicInterlacePostProcess extends PostProcess {
  67275. private _stepSize;
  67276. private _passedProcess;
  67277. /**
  67278. * Initializes a StereoscopicInterlacePostProcess
  67279. * @param name The name of the effect.
  67280. * @param rigCameras The rig cameras to be appled to the post process
  67281. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  67282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67283. * @param engine The engine which the post process will be applied. (default: current engine)
  67284. * @param reusable If the post process can be reused on the same frame. (default: false)
  67285. */
  67286. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67287. }
  67288. }
  67289. declare module BABYLON {
  67290. /** @hidden */
  67291. export var tonemapPixelShader: {
  67292. name: string;
  67293. shader: string;
  67294. };
  67295. }
  67296. declare module BABYLON {
  67297. /** Defines operator used for tonemapping */
  67298. export enum TonemappingOperator {
  67299. /** Hable */
  67300. Hable = 0,
  67301. /** Reinhard */
  67302. Reinhard = 1,
  67303. /** HejiDawson */
  67304. HejiDawson = 2,
  67305. /** Photographic */
  67306. Photographic = 3
  67307. }
  67308. /**
  67309. * Defines a post process to apply tone mapping
  67310. */
  67311. export class TonemapPostProcess extends PostProcess {
  67312. private _operator;
  67313. /** Defines the required exposure adjustement */
  67314. exposureAdjustment: number;
  67315. /**
  67316. * Creates a new TonemapPostProcess
  67317. * @param name defines the name of the postprocess
  67318. * @param _operator defines the operator to use
  67319. * @param exposureAdjustment defines the required exposure adjustement
  67320. * @param camera defines the camera to use (can be null)
  67321. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67322. * @param engine defines the hosting engine (can be ignore if camera is set)
  67323. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67324. */
  67325. constructor(name: string, _operator: TonemappingOperator,
  67326. /** Defines the required exposure adjustement */
  67327. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67328. }
  67329. }
  67330. declare module BABYLON {
  67331. /** @hidden */
  67332. export var volumetricLightScatteringPixelShader: {
  67333. name: string;
  67334. shader: string;
  67335. };
  67336. }
  67337. declare module BABYLON {
  67338. /** @hidden */
  67339. export var volumetricLightScatteringPassVertexShader: {
  67340. name: string;
  67341. shader: string;
  67342. };
  67343. }
  67344. declare module BABYLON {
  67345. /** @hidden */
  67346. export var volumetricLightScatteringPassPixelShader: {
  67347. name: string;
  67348. shader: string;
  67349. };
  67350. }
  67351. declare module BABYLON {
  67352. /**
  67353. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67354. */
  67355. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67356. private _volumetricLightScatteringPass;
  67357. private _volumetricLightScatteringRTT;
  67358. private _viewPort;
  67359. private _screenCoordinates;
  67360. private _cachedDefines;
  67361. /**
  67362. * If not undefined, the mesh position is computed from the attached node position
  67363. */
  67364. attachedNode: {
  67365. position: Vector3;
  67366. };
  67367. /**
  67368. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67369. */
  67370. customMeshPosition: Vector3;
  67371. /**
  67372. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67373. */
  67374. useCustomMeshPosition: boolean;
  67375. /**
  67376. * If the post-process should inverse the light scattering direction
  67377. */
  67378. invert: boolean;
  67379. /**
  67380. * The internal mesh used by the post-process
  67381. */
  67382. mesh: Mesh;
  67383. /**
  67384. * @hidden
  67385. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67386. */
  67387. get useDiffuseColor(): boolean;
  67388. set useDiffuseColor(useDiffuseColor: boolean);
  67389. /**
  67390. * Array containing the excluded meshes not rendered in the internal pass
  67391. */
  67392. excludedMeshes: AbstractMesh[];
  67393. /**
  67394. * Controls the overall intensity of the post-process
  67395. */
  67396. exposure: number;
  67397. /**
  67398. * Dissipates each sample's contribution in range [0, 1]
  67399. */
  67400. decay: number;
  67401. /**
  67402. * Controls the overall intensity of each sample
  67403. */
  67404. weight: number;
  67405. /**
  67406. * Controls the density of each sample
  67407. */
  67408. density: number;
  67409. /**
  67410. * @constructor
  67411. * @param name The post-process name
  67412. * @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)
  67413. * @param camera The camera that the post-process will be attached to
  67414. * @param mesh The mesh used to create the light scattering
  67415. * @param samples The post-process quality, default 100
  67416. * @param samplingModeThe post-process filtering mode
  67417. * @param engine The babylon engine
  67418. * @param reusable If the post-process is reusable
  67419. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67420. */
  67421. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67422. /**
  67423. * Returns the string "VolumetricLightScatteringPostProcess"
  67424. * @returns "VolumetricLightScatteringPostProcess"
  67425. */
  67426. getClassName(): string;
  67427. private _isReady;
  67428. /**
  67429. * Sets the new light position for light scattering effect
  67430. * @param position The new custom light position
  67431. */
  67432. setCustomMeshPosition(position: Vector3): void;
  67433. /**
  67434. * Returns the light position for light scattering effect
  67435. * @return Vector3 The custom light position
  67436. */
  67437. getCustomMeshPosition(): Vector3;
  67438. /**
  67439. * Disposes the internal assets and detaches the post-process from the camera
  67440. */
  67441. dispose(camera: Camera): void;
  67442. /**
  67443. * Returns the render target texture used by the post-process
  67444. * @return the render target texture used by the post-process
  67445. */
  67446. getPass(): RenderTargetTexture;
  67447. private _meshExcluded;
  67448. private _createPass;
  67449. private _updateMeshScreenCoordinates;
  67450. /**
  67451. * Creates a default mesh for the Volumeric Light Scattering post-process
  67452. * @param name The mesh name
  67453. * @param scene The scene where to create the mesh
  67454. * @return the default mesh
  67455. */
  67456. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67457. }
  67458. }
  67459. declare module BABYLON {
  67460. interface Scene {
  67461. /** @hidden (Backing field) */
  67462. _boundingBoxRenderer: BoundingBoxRenderer;
  67463. /** @hidden (Backing field) */
  67464. _forceShowBoundingBoxes: boolean;
  67465. /**
  67466. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67467. */
  67468. forceShowBoundingBoxes: boolean;
  67469. /**
  67470. * Gets the bounding box renderer associated with the scene
  67471. * @returns a BoundingBoxRenderer
  67472. */
  67473. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67474. }
  67475. interface AbstractMesh {
  67476. /** @hidden (Backing field) */
  67477. _showBoundingBox: boolean;
  67478. /**
  67479. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67480. */
  67481. showBoundingBox: boolean;
  67482. }
  67483. /**
  67484. * Component responsible of rendering the bounding box of the meshes in a scene.
  67485. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67486. */
  67487. export class BoundingBoxRenderer implements ISceneComponent {
  67488. /**
  67489. * The component name helpfull to identify the component in the list of scene components.
  67490. */
  67491. readonly name: string;
  67492. /**
  67493. * The scene the component belongs to.
  67494. */
  67495. scene: Scene;
  67496. /**
  67497. * Color of the bounding box lines placed in front of an object
  67498. */
  67499. frontColor: Color3;
  67500. /**
  67501. * Color of the bounding box lines placed behind an object
  67502. */
  67503. backColor: Color3;
  67504. /**
  67505. * Defines if the renderer should show the back lines or not
  67506. */
  67507. showBackLines: boolean;
  67508. /**
  67509. * @hidden
  67510. */
  67511. renderList: SmartArray<BoundingBox>;
  67512. private _colorShader;
  67513. private _vertexBuffers;
  67514. private _indexBuffer;
  67515. private _fillIndexBuffer;
  67516. private _fillIndexData;
  67517. /**
  67518. * Instantiates a new bounding box renderer in a scene.
  67519. * @param scene the scene the renderer renders in
  67520. */
  67521. constructor(scene: Scene);
  67522. /**
  67523. * Registers the component in a given scene
  67524. */
  67525. register(): void;
  67526. private _evaluateSubMesh;
  67527. private _activeMesh;
  67528. private _prepareRessources;
  67529. private _createIndexBuffer;
  67530. /**
  67531. * Rebuilds the elements related to this component in case of
  67532. * context lost for instance.
  67533. */
  67534. rebuild(): void;
  67535. /**
  67536. * @hidden
  67537. */
  67538. reset(): void;
  67539. /**
  67540. * Render the bounding boxes of a specific rendering group
  67541. * @param renderingGroupId defines the rendering group to render
  67542. */
  67543. render(renderingGroupId: number): void;
  67544. /**
  67545. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67546. * @param mesh Define the mesh to render the occlusion bounding box for
  67547. */
  67548. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67549. /**
  67550. * Dispose and release the resources attached to this renderer.
  67551. */
  67552. dispose(): void;
  67553. }
  67554. }
  67555. declare module BABYLON {
  67556. interface Scene {
  67557. /** @hidden (Backing field) */
  67558. _depthRenderer: {
  67559. [id: string]: DepthRenderer;
  67560. };
  67561. /**
  67562. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67563. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67564. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67565. * @returns the created depth renderer
  67566. */
  67567. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67568. /**
  67569. * Disables a depth renderer for a given camera
  67570. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67571. */
  67572. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67573. }
  67574. /**
  67575. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67576. * in several rendering techniques.
  67577. */
  67578. export class DepthRendererSceneComponent implements ISceneComponent {
  67579. /**
  67580. * The component name helpfull to identify the component in the list of scene components.
  67581. */
  67582. readonly name: string;
  67583. /**
  67584. * The scene the component belongs to.
  67585. */
  67586. scene: Scene;
  67587. /**
  67588. * Creates a new instance of the component for the given scene
  67589. * @param scene Defines the scene to register the component in
  67590. */
  67591. constructor(scene: Scene);
  67592. /**
  67593. * Registers the component in a given scene
  67594. */
  67595. register(): void;
  67596. /**
  67597. * Rebuilds the elements related to this component in case of
  67598. * context lost for instance.
  67599. */
  67600. rebuild(): void;
  67601. /**
  67602. * Disposes the component and the associated ressources
  67603. */
  67604. dispose(): void;
  67605. private _gatherRenderTargets;
  67606. private _gatherActiveCameraRenderTargets;
  67607. }
  67608. }
  67609. declare module BABYLON {
  67610. /** @hidden */
  67611. export var outlinePixelShader: {
  67612. name: string;
  67613. shader: string;
  67614. };
  67615. }
  67616. declare module BABYLON {
  67617. /** @hidden */
  67618. export var outlineVertexShader: {
  67619. name: string;
  67620. shader: string;
  67621. };
  67622. }
  67623. declare module BABYLON {
  67624. interface Scene {
  67625. /** @hidden */
  67626. _outlineRenderer: OutlineRenderer;
  67627. /**
  67628. * Gets the outline renderer associated with the scene
  67629. * @returns a OutlineRenderer
  67630. */
  67631. getOutlineRenderer(): OutlineRenderer;
  67632. }
  67633. interface AbstractMesh {
  67634. /** @hidden (Backing field) */
  67635. _renderOutline: boolean;
  67636. /**
  67637. * Gets or sets a boolean indicating if the outline must be rendered as well
  67638. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67639. */
  67640. renderOutline: boolean;
  67641. /** @hidden (Backing field) */
  67642. _renderOverlay: boolean;
  67643. /**
  67644. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67645. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67646. */
  67647. renderOverlay: boolean;
  67648. }
  67649. /**
  67650. * This class is responsible to draw bothe outline/overlay of meshes.
  67651. * It should not be used directly but through the available method on mesh.
  67652. */
  67653. export class OutlineRenderer implements ISceneComponent {
  67654. /**
  67655. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67656. */
  67657. private static _StencilReference;
  67658. /**
  67659. * The name of the component. Each component must have a unique name.
  67660. */
  67661. name: string;
  67662. /**
  67663. * The scene the component belongs to.
  67664. */
  67665. scene: Scene;
  67666. /**
  67667. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67668. */
  67669. zOffset: number;
  67670. private _engine;
  67671. private _effect;
  67672. private _cachedDefines;
  67673. private _savedDepthWrite;
  67674. /**
  67675. * Instantiates a new outline renderer. (There could be only one per scene).
  67676. * @param scene Defines the scene it belongs to
  67677. */
  67678. constructor(scene: Scene);
  67679. /**
  67680. * Register the component to one instance of a scene.
  67681. */
  67682. register(): void;
  67683. /**
  67684. * Rebuilds the elements related to this component in case of
  67685. * context lost for instance.
  67686. */
  67687. rebuild(): void;
  67688. /**
  67689. * Disposes the component and the associated ressources.
  67690. */
  67691. dispose(): void;
  67692. /**
  67693. * Renders the outline in the canvas.
  67694. * @param subMesh Defines the sumesh to render
  67695. * @param batch Defines the batch of meshes in case of instances
  67696. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67697. */
  67698. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67699. /**
  67700. * Returns whether or not the outline renderer is ready for a given submesh.
  67701. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67702. * @param subMesh Defines the submesh to check readyness for
  67703. * @param useInstances Defines wheter wee are trying to render instances or not
  67704. * @returns true if ready otherwise false
  67705. */
  67706. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67707. private _beforeRenderingMesh;
  67708. private _afterRenderingMesh;
  67709. }
  67710. }
  67711. declare module BABYLON {
  67712. /**
  67713. * Defines the basic options interface of a Sprite Frame Source Size.
  67714. */
  67715. export interface ISpriteJSONSpriteSourceSize {
  67716. /**
  67717. * number of the original width of the Frame
  67718. */
  67719. w: number;
  67720. /**
  67721. * number of the original height of the Frame
  67722. */
  67723. h: number;
  67724. }
  67725. /**
  67726. * Defines the basic options interface of a Sprite Frame Data.
  67727. */
  67728. export interface ISpriteJSONSpriteFrameData {
  67729. /**
  67730. * number of the x offset of the Frame
  67731. */
  67732. x: number;
  67733. /**
  67734. * number of the y offset of the Frame
  67735. */
  67736. y: number;
  67737. /**
  67738. * number of the width of the Frame
  67739. */
  67740. w: number;
  67741. /**
  67742. * number of the height of the Frame
  67743. */
  67744. h: number;
  67745. }
  67746. /**
  67747. * Defines the basic options interface of a JSON Sprite.
  67748. */
  67749. export interface ISpriteJSONSprite {
  67750. /**
  67751. * string name of the Frame
  67752. */
  67753. filename: string;
  67754. /**
  67755. * ISpriteJSONSpriteFrame basic object of the frame data
  67756. */
  67757. frame: ISpriteJSONSpriteFrameData;
  67758. /**
  67759. * boolean to flag is the frame was rotated.
  67760. */
  67761. rotated: boolean;
  67762. /**
  67763. * boolean to flag is the frame was trimmed.
  67764. */
  67765. trimmed: boolean;
  67766. /**
  67767. * ISpriteJSONSpriteFrame basic object of the source data
  67768. */
  67769. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67770. /**
  67771. * ISpriteJSONSpriteFrame basic object of the source data
  67772. */
  67773. sourceSize: ISpriteJSONSpriteSourceSize;
  67774. }
  67775. /**
  67776. * Defines the basic options interface of a JSON atlas.
  67777. */
  67778. export interface ISpriteJSONAtlas {
  67779. /**
  67780. * Array of objects that contain the frame data.
  67781. */
  67782. frames: Array<ISpriteJSONSprite>;
  67783. /**
  67784. * object basic object containing the sprite meta data.
  67785. */
  67786. meta?: object;
  67787. }
  67788. }
  67789. declare module BABYLON {
  67790. /** @hidden */
  67791. export var spriteMapPixelShader: {
  67792. name: string;
  67793. shader: string;
  67794. };
  67795. }
  67796. declare module BABYLON {
  67797. /** @hidden */
  67798. export var spriteMapVertexShader: {
  67799. name: string;
  67800. shader: string;
  67801. };
  67802. }
  67803. declare module BABYLON {
  67804. /**
  67805. * Defines the basic options interface of a SpriteMap
  67806. */
  67807. export interface ISpriteMapOptions {
  67808. /**
  67809. * Vector2 of the number of cells in the grid.
  67810. */
  67811. stageSize?: Vector2;
  67812. /**
  67813. * Vector2 of the size of the output plane in World Units.
  67814. */
  67815. outputSize?: Vector2;
  67816. /**
  67817. * Vector3 of the position of the output plane in World Units.
  67818. */
  67819. outputPosition?: Vector3;
  67820. /**
  67821. * Vector3 of the rotation of the output plane.
  67822. */
  67823. outputRotation?: Vector3;
  67824. /**
  67825. * number of layers that the system will reserve in resources.
  67826. */
  67827. layerCount?: number;
  67828. /**
  67829. * number of max animation frames a single cell will reserve in resources.
  67830. */
  67831. maxAnimationFrames?: number;
  67832. /**
  67833. * number cell index of the base tile when the system compiles.
  67834. */
  67835. baseTile?: number;
  67836. /**
  67837. * boolean flip the sprite after its been repositioned by the framing data.
  67838. */
  67839. flipU?: boolean;
  67840. /**
  67841. * Vector3 scalar of the global RGB values of the SpriteMap.
  67842. */
  67843. colorMultiply?: Vector3;
  67844. }
  67845. /**
  67846. * Defines the IDisposable interface in order to be cleanable from resources.
  67847. */
  67848. export interface ISpriteMap extends IDisposable {
  67849. /**
  67850. * String name of the SpriteMap.
  67851. */
  67852. name: string;
  67853. /**
  67854. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67855. */
  67856. atlasJSON: ISpriteJSONAtlas;
  67857. /**
  67858. * Texture of the SpriteMap.
  67859. */
  67860. spriteSheet: Texture;
  67861. /**
  67862. * The parameters to initialize the SpriteMap with.
  67863. */
  67864. options: ISpriteMapOptions;
  67865. }
  67866. /**
  67867. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67868. */
  67869. export class SpriteMap implements ISpriteMap {
  67870. /** The Name of the spriteMap */
  67871. name: string;
  67872. /** The JSON file with the frame and meta data */
  67873. atlasJSON: ISpriteJSONAtlas;
  67874. /** The systems Sprite Sheet Texture */
  67875. spriteSheet: Texture;
  67876. /** Arguments passed with the Constructor */
  67877. options: ISpriteMapOptions;
  67878. /** Public Sprite Storage array, parsed from atlasJSON */
  67879. sprites: Array<ISpriteJSONSprite>;
  67880. /** Returns the Number of Sprites in the System */
  67881. get spriteCount(): number;
  67882. /** Returns the Position of Output Plane*/
  67883. get position(): Vector3;
  67884. /** Returns the Position of Output Plane*/
  67885. set position(v: Vector3);
  67886. /** Returns the Rotation of Output Plane*/
  67887. get rotation(): Vector3;
  67888. /** Returns the Rotation of Output Plane*/
  67889. set rotation(v: Vector3);
  67890. /** Sets the AnimationMap*/
  67891. get animationMap(): RawTexture;
  67892. /** Sets the AnimationMap*/
  67893. set animationMap(v: RawTexture);
  67894. /** Scene that the SpriteMap was created in */
  67895. private _scene;
  67896. /** Texture Buffer of Float32 that holds tile frame data*/
  67897. private _frameMap;
  67898. /** Texture Buffers of Float32 that holds tileMap data*/
  67899. private _tileMaps;
  67900. /** Texture Buffer of Float32 that holds Animation Data*/
  67901. private _animationMap;
  67902. /** Custom ShaderMaterial Central to the System*/
  67903. private _material;
  67904. /** Custom ShaderMaterial Central to the System*/
  67905. private _output;
  67906. /** Systems Time Ticker*/
  67907. private _time;
  67908. /**
  67909. * Creates a new SpriteMap
  67910. * @param name defines the SpriteMaps Name
  67911. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67912. * @param spriteSheet is the Texture that the Sprites are on.
  67913. * @param options a basic deployment configuration
  67914. * @param scene The Scene that the map is deployed on
  67915. */
  67916. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67917. /**
  67918. * Returns tileID location
  67919. * @returns Vector2 the cell position ID
  67920. */
  67921. getTileID(): Vector2;
  67922. /**
  67923. * Gets the UV location of the mouse over the SpriteMap.
  67924. * @returns Vector2 the UV position of the mouse interaction
  67925. */
  67926. getMousePosition(): Vector2;
  67927. /**
  67928. * Creates the "frame" texture Buffer
  67929. * -------------------------------------
  67930. * Structure of frames
  67931. * "filename": "Falling-Water-2.png",
  67932. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67933. * "rotated": true,
  67934. * "trimmed": true,
  67935. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67936. * "sourceSize": {"w":32,"h":32}
  67937. * @returns RawTexture of the frameMap
  67938. */
  67939. private _createFrameBuffer;
  67940. /**
  67941. * Creates the tileMap texture Buffer
  67942. * @param buffer normally and array of numbers, or a false to generate from scratch
  67943. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67944. * @returns RawTexture of the tileMap
  67945. */
  67946. private _createTileBuffer;
  67947. /**
  67948. * Modifies the data of the tileMaps
  67949. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67950. * @param pos is the iVector2 Coordinates of the Tile
  67951. * @param tile The SpriteIndex of the new Tile
  67952. */
  67953. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67954. /**
  67955. * Creates the animationMap texture Buffer
  67956. * @param buffer normally and array of numbers, or a false to generate from scratch
  67957. * @returns RawTexture of the animationMap
  67958. */
  67959. private _createTileAnimationBuffer;
  67960. /**
  67961. * Modifies the data of the animationMap
  67962. * @param cellID is the Index of the Sprite
  67963. * @param _frame is the target Animation frame
  67964. * @param toCell is the Target Index of the next frame of the animation
  67965. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67966. * @param speed is a global scalar of the time variable on the map.
  67967. */
  67968. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67969. /**
  67970. * Exports the .tilemaps file
  67971. */
  67972. saveTileMaps(): void;
  67973. /**
  67974. * Imports the .tilemaps file
  67975. * @param url of the .tilemaps file
  67976. */
  67977. loadTileMaps(url: string): void;
  67978. /**
  67979. * Release associated resources
  67980. */
  67981. dispose(): void;
  67982. }
  67983. }
  67984. declare module BABYLON {
  67985. /**
  67986. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67987. * @see http://doc.babylonjs.com/babylon101/sprites
  67988. */
  67989. export class SpritePackedManager extends SpriteManager {
  67990. /** defines the packed manager's name */
  67991. name: string;
  67992. /**
  67993. * Creates a new sprite manager from a packed sprite sheet
  67994. * @param name defines the manager's name
  67995. * @param imgUrl defines the sprite sheet url
  67996. * @param capacity defines the maximum allowed number of sprites
  67997. * @param scene defines the hosting scene
  67998. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67999. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68000. * @param samplingMode defines the smapling mode to use with spritesheet
  68001. * @param fromPacked set to true; do not alter
  68002. */
  68003. constructor(
  68004. /** defines the packed manager's name */
  68005. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  68006. }
  68007. }
  68008. declare module BABYLON {
  68009. /**
  68010. * Defines the list of states available for a task inside a AssetsManager
  68011. */
  68012. export enum AssetTaskState {
  68013. /**
  68014. * Initialization
  68015. */
  68016. INIT = 0,
  68017. /**
  68018. * Running
  68019. */
  68020. RUNNING = 1,
  68021. /**
  68022. * Done
  68023. */
  68024. DONE = 2,
  68025. /**
  68026. * Error
  68027. */
  68028. ERROR = 3
  68029. }
  68030. /**
  68031. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  68032. */
  68033. export abstract class AbstractAssetTask {
  68034. /**
  68035. * Task name
  68036. */ name: string;
  68037. /**
  68038. * Callback called when the task is successful
  68039. */
  68040. onSuccess: (task: any) => void;
  68041. /**
  68042. * Callback called when the task is not successful
  68043. */
  68044. onError: (task: any, message?: string, exception?: any) => void;
  68045. /**
  68046. * Creates a new AssetsManager
  68047. * @param name defines the name of the task
  68048. */
  68049. constructor(
  68050. /**
  68051. * Task name
  68052. */ name: string);
  68053. private _isCompleted;
  68054. private _taskState;
  68055. private _errorObject;
  68056. /**
  68057. * Get if the task is completed
  68058. */
  68059. get isCompleted(): boolean;
  68060. /**
  68061. * Gets the current state of the task
  68062. */
  68063. get taskState(): AssetTaskState;
  68064. /**
  68065. * Gets the current error object (if task is in error)
  68066. */
  68067. get errorObject(): {
  68068. message?: string;
  68069. exception?: any;
  68070. };
  68071. /**
  68072. * Internal only
  68073. * @hidden
  68074. */
  68075. _setErrorObject(message?: string, exception?: any): void;
  68076. /**
  68077. * Execute the current task
  68078. * @param scene defines the scene where you want your assets to be loaded
  68079. * @param onSuccess is a callback called when the task is successfully executed
  68080. * @param onError is a callback called if an error occurs
  68081. */
  68082. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68083. /**
  68084. * Execute the current task
  68085. * @param scene defines the scene where you want your assets to be loaded
  68086. * @param onSuccess is a callback called when the task is successfully executed
  68087. * @param onError is a callback called if an error occurs
  68088. */
  68089. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68090. /**
  68091. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68092. * This can be used with failed tasks that have the reason for failure fixed.
  68093. */
  68094. reset(): void;
  68095. private onErrorCallback;
  68096. private onDoneCallback;
  68097. }
  68098. /**
  68099. * Define the interface used by progress events raised during assets loading
  68100. */
  68101. export interface IAssetsProgressEvent {
  68102. /**
  68103. * Defines the number of remaining tasks to process
  68104. */
  68105. remainingCount: number;
  68106. /**
  68107. * Defines the total number of tasks
  68108. */
  68109. totalCount: number;
  68110. /**
  68111. * Defines the task that was just processed
  68112. */
  68113. task: AbstractAssetTask;
  68114. }
  68115. /**
  68116. * Class used to share progress information about assets loading
  68117. */
  68118. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68119. /**
  68120. * Defines the number of remaining tasks to process
  68121. */
  68122. remainingCount: number;
  68123. /**
  68124. * Defines the total number of tasks
  68125. */
  68126. totalCount: number;
  68127. /**
  68128. * Defines the task that was just processed
  68129. */
  68130. task: AbstractAssetTask;
  68131. /**
  68132. * Creates a AssetsProgressEvent
  68133. * @param remainingCount defines the number of remaining tasks to process
  68134. * @param totalCount defines the total number of tasks
  68135. * @param task defines the task that was just processed
  68136. */
  68137. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68138. }
  68139. /**
  68140. * Define a task used by AssetsManager to load meshes
  68141. */
  68142. export class MeshAssetTask extends AbstractAssetTask {
  68143. /**
  68144. * Defines the name of the task
  68145. */
  68146. name: string;
  68147. /**
  68148. * Defines the list of mesh's names you want to load
  68149. */
  68150. meshesNames: any;
  68151. /**
  68152. * Defines the root url to use as a base to load your meshes and associated resources
  68153. */
  68154. rootUrl: string;
  68155. /**
  68156. * Defines the filename of the scene to load from
  68157. */
  68158. sceneFilename: string;
  68159. /**
  68160. * Gets the list of loaded meshes
  68161. */
  68162. loadedMeshes: Array<AbstractMesh>;
  68163. /**
  68164. * Gets the list of loaded particle systems
  68165. */
  68166. loadedParticleSystems: Array<IParticleSystem>;
  68167. /**
  68168. * Gets the list of loaded skeletons
  68169. */
  68170. loadedSkeletons: Array<Skeleton>;
  68171. /**
  68172. * Gets the list of loaded animation groups
  68173. */
  68174. loadedAnimationGroups: Array<AnimationGroup>;
  68175. /**
  68176. * Callback called when the task is successful
  68177. */
  68178. onSuccess: (task: MeshAssetTask) => void;
  68179. /**
  68180. * Callback called when the task is successful
  68181. */
  68182. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68183. /**
  68184. * Creates a new MeshAssetTask
  68185. * @param name defines the name of the task
  68186. * @param meshesNames defines the list of mesh's names you want to load
  68187. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68188. * @param sceneFilename defines the filename of the scene to load from
  68189. */
  68190. constructor(
  68191. /**
  68192. * Defines the name of the task
  68193. */
  68194. name: string,
  68195. /**
  68196. * Defines the list of mesh's names you want to load
  68197. */
  68198. meshesNames: any,
  68199. /**
  68200. * Defines the root url to use as a base to load your meshes and associated resources
  68201. */
  68202. rootUrl: string,
  68203. /**
  68204. * Defines the filename of the scene to load from
  68205. */
  68206. sceneFilename: string);
  68207. /**
  68208. * Execute the current task
  68209. * @param scene defines the scene where you want your assets to be loaded
  68210. * @param onSuccess is a callback called when the task is successfully executed
  68211. * @param onError is a callback called if an error occurs
  68212. */
  68213. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68214. }
  68215. /**
  68216. * Define a task used by AssetsManager to load text content
  68217. */
  68218. export class TextFileAssetTask extends AbstractAssetTask {
  68219. /**
  68220. * Defines the name of the task
  68221. */
  68222. name: string;
  68223. /**
  68224. * Defines the location of the file to load
  68225. */
  68226. url: string;
  68227. /**
  68228. * Gets the loaded text string
  68229. */
  68230. text: string;
  68231. /**
  68232. * Callback called when the task is successful
  68233. */
  68234. onSuccess: (task: TextFileAssetTask) => void;
  68235. /**
  68236. * Callback called when the task is successful
  68237. */
  68238. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68239. /**
  68240. * Creates a new TextFileAssetTask object
  68241. * @param name defines the name of the task
  68242. * @param url defines the location of the file to load
  68243. */
  68244. constructor(
  68245. /**
  68246. * Defines the name of the task
  68247. */
  68248. name: string,
  68249. /**
  68250. * Defines the location of the file to load
  68251. */
  68252. url: string);
  68253. /**
  68254. * Execute the current task
  68255. * @param scene defines the scene where you want your assets to be loaded
  68256. * @param onSuccess is a callback called when the task is successfully executed
  68257. * @param onError is a callback called if an error occurs
  68258. */
  68259. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68260. }
  68261. /**
  68262. * Define a task used by AssetsManager to load binary data
  68263. */
  68264. export class BinaryFileAssetTask extends AbstractAssetTask {
  68265. /**
  68266. * Defines the name of the task
  68267. */
  68268. name: string;
  68269. /**
  68270. * Defines the location of the file to load
  68271. */
  68272. url: string;
  68273. /**
  68274. * Gets the lodaded data (as an array buffer)
  68275. */
  68276. data: ArrayBuffer;
  68277. /**
  68278. * Callback called when the task is successful
  68279. */
  68280. onSuccess: (task: BinaryFileAssetTask) => void;
  68281. /**
  68282. * Callback called when the task is successful
  68283. */
  68284. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68285. /**
  68286. * Creates a new BinaryFileAssetTask object
  68287. * @param name defines the name of the new task
  68288. * @param url defines the location of the file to load
  68289. */
  68290. constructor(
  68291. /**
  68292. * Defines the name of the task
  68293. */
  68294. name: string,
  68295. /**
  68296. * Defines the location of the file to load
  68297. */
  68298. url: string);
  68299. /**
  68300. * Execute the current task
  68301. * @param scene defines the scene where you want your assets to be loaded
  68302. * @param onSuccess is a callback called when the task is successfully executed
  68303. * @param onError is a callback called if an error occurs
  68304. */
  68305. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68306. }
  68307. /**
  68308. * Define a task used by AssetsManager to load images
  68309. */
  68310. export class ImageAssetTask extends AbstractAssetTask {
  68311. /**
  68312. * Defines the name of the task
  68313. */
  68314. name: string;
  68315. /**
  68316. * Defines the location of the image to load
  68317. */
  68318. url: string;
  68319. /**
  68320. * Gets the loaded images
  68321. */
  68322. image: HTMLImageElement;
  68323. /**
  68324. * Callback called when the task is successful
  68325. */
  68326. onSuccess: (task: ImageAssetTask) => void;
  68327. /**
  68328. * Callback called when the task is successful
  68329. */
  68330. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68331. /**
  68332. * Creates a new ImageAssetTask
  68333. * @param name defines the name of the task
  68334. * @param url defines the location of the image to load
  68335. */
  68336. constructor(
  68337. /**
  68338. * Defines the name of the task
  68339. */
  68340. name: string,
  68341. /**
  68342. * Defines the location of the image to load
  68343. */
  68344. url: string);
  68345. /**
  68346. * Execute the current task
  68347. * @param scene defines the scene where you want your assets to be loaded
  68348. * @param onSuccess is a callback called when the task is successfully executed
  68349. * @param onError is a callback called if an error occurs
  68350. */
  68351. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68352. }
  68353. /**
  68354. * Defines the interface used by texture loading tasks
  68355. */
  68356. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68357. /**
  68358. * Gets the loaded texture
  68359. */
  68360. texture: TEX;
  68361. }
  68362. /**
  68363. * Define a task used by AssetsManager to load 2D textures
  68364. */
  68365. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68366. /**
  68367. * Defines the name of the task
  68368. */
  68369. name: string;
  68370. /**
  68371. * Defines the location of the file to load
  68372. */
  68373. url: string;
  68374. /**
  68375. * Defines if mipmap should not be generated (default is false)
  68376. */
  68377. noMipmap?: boolean | undefined;
  68378. /**
  68379. * Defines if texture must be inverted on Y axis (default is true)
  68380. */
  68381. invertY: boolean;
  68382. /**
  68383. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68384. */
  68385. samplingMode: number;
  68386. /**
  68387. * Gets the loaded texture
  68388. */
  68389. texture: Texture;
  68390. /**
  68391. * Callback called when the task is successful
  68392. */
  68393. onSuccess: (task: TextureAssetTask) => void;
  68394. /**
  68395. * Callback called when the task is successful
  68396. */
  68397. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68398. /**
  68399. * Creates a new TextureAssetTask object
  68400. * @param name defines the name of the task
  68401. * @param url defines the location of the file to load
  68402. * @param noMipmap defines if mipmap should not be generated (default is false)
  68403. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68404. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68405. */
  68406. constructor(
  68407. /**
  68408. * Defines the name of the task
  68409. */
  68410. name: string,
  68411. /**
  68412. * Defines the location of the file to load
  68413. */
  68414. url: string,
  68415. /**
  68416. * Defines if mipmap should not be generated (default is false)
  68417. */
  68418. noMipmap?: boolean | undefined,
  68419. /**
  68420. * Defines if texture must be inverted on Y axis (default is true)
  68421. */
  68422. invertY?: boolean,
  68423. /**
  68424. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68425. */
  68426. samplingMode?: number);
  68427. /**
  68428. * Execute the current task
  68429. * @param scene defines the scene where you want your assets to be loaded
  68430. * @param onSuccess is a callback called when the task is successfully executed
  68431. * @param onError is a callback called if an error occurs
  68432. */
  68433. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68434. }
  68435. /**
  68436. * Define a task used by AssetsManager to load cube textures
  68437. */
  68438. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68439. /**
  68440. * Defines the name of the task
  68441. */
  68442. name: string;
  68443. /**
  68444. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68445. */
  68446. url: string;
  68447. /**
  68448. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68449. */
  68450. extensions?: string[] | undefined;
  68451. /**
  68452. * Defines if mipmaps should not be generated (default is false)
  68453. */
  68454. noMipmap?: boolean | undefined;
  68455. /**
  68456. * Defines the explicit list of files (undefined by default)
  68457. */
  68458. files?: string[] | undefined;
  68459. /**
  68460. * Gets the loaded texture
  68461. */
  68462. texture: CubeTexture;
  68463. /**
  68464. * Callback called when the task is successful
  68465. */
  68466. onSuccess: (task: CubeTextureAssetTask) => void;
  68467. /**
  68468. * Callback called when the task is successful
  68469. */
  68470. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68471. /**
  68472. * Creates a new CubeTextureAssetTask
  68473. * @param name defines the name of the task
  68474. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68475. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68476. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68477. * @param files defines the explicit list of files (undefined by default)
  68478. */
  68479. constructor(
  68480. /**
  68481. * Defines the name of the task
  68482. */
  68483. name: string,
  68484. /**
  68485. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68486. */
  68487. url: string,
  68488. /**
  68489. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68490. */
  68491. extensions?: string[] | undefined,
  68492. /**
  68493. * Defines if mipmaps should not be generated (default is false)
  68494. */
  68495. noMipmap?: boolean | undefined,
  68496. /**
  68497. * Defines the explicit list of files (undefined by default)
  68498. */
  68499. files?: string[] | undefined);
  68500. /**
  68501. * Execute the current task
  68502. * @param scene defines the scene where you want your assets to be loaded
  68503. * @param onSuccess is a callback called when the task is successfully executed
  68504. * @param onError is a callback called if an error occurs
  68505. */
  68506. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68507. }
  68508. /**
  68509. * Define a task used by AssetsManager to load HDR cube textures
  68510. */
  68511. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68512. /**
  68513. * Defines the name of the task
  68514. */
  68515. name: string;
  68516. /**
  68517. * Defines the location of the file to load
  68518. */
  68519. url: string;
  68520. /**
  68521. * Defines the desired size (the more it increases the longer the generation will be)
  68522. */
  68523. size: number;
  68524. /**
  68525. * Defines if mipmaps should not be generated (default is false)
  68526. */
  68527. noMipmap: boolean;
  68528. /**
  68529. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68530. */
  68531. generateHarmonics: boolean;
  68532. /**
  68533. * 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)
  68534. */
  68535. gammaSpace: boolean;
  68536. /**
  68537. * Internal Use Only
  68538. */
  68539. reserved: boolean;
  68540. /**
  68541. * Gets the loaded texture
  68542. */
  68543. texture: HDRCubeTexture;
  68544. /**
  68545. * Callback called when the task is successful
  68546. */
  68547. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68548. /**
  68549. * Callback called when the task is successful
  68550. */
  68551. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68552. /**
  68553. * Creates a new HDRCubeTextureAssetTask object
  68554. * @param name defines the name of the task
  68555. * @param url defines the location of the file to load
  68556. * @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.
  68557. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68558. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68559. * @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)
  68560. * @param reserved Internal use only
  68561. */
  68562. constructor(
  68563. /**
  68564. * Defines the name of the task
  68565. */
  68566. name: string,
  68567. /**
  68568. * Defines the location of the file to load
  68569. */
  68570. url: string,
  68571. /**
  68572. * Defines the desired size (the more it increases the longer the generation will be)
  68573. */
  68574. size: number,
  68575. /**
  68576. * Defines if mipmaps should not be generated (default is false)
  68577. */
  68578. noMipmap?: boolean,
  68579. /**
  68580. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68581. */
  68582. generateHarmonics?: boolean,
  68583. /**
  68584. * 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)
  68585. */
  68586. gammaSpace?: boolean,
  68587. /**
  68588. * Internal Use Only
  68589. */
  68590. reserved?: boolean);
  68591. /**
  68592. * Execute the current task
  68593. * @param scene defines the scene where you want your assets to be loaded
  68594. * @param onSuccess is a callback called when the task is successfully executed
  68595. * @param onError is a callback called if an error occurs
  68596. */
  68597. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68598. }
  68599. /**
  68600. * Define a task used by AssetsManager to load Equirectangular cube textures
  68601. */
  68602. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68603. /**
  68604. * Defines the name of the task
  68605. */
  68606. name: string;
  68607. /**
  68608. * Defines the location of the file to load
  68609. */
  68610. url: string;
  68611. /**
  68612. * Defines the desired size (the more it increases the longer the generation will be)
  68613. */
  68614. size: number;
  68615. /**
  68616. * Defines if mipmaps should not be generated (default is false)
  68617. */
  68618. noMipmap: boolean;
  68619. /**
  68620. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68621. * but the standard material would require them in Gamma space) (default is true)
  68622. */
  68623. gammaSpace: boolean;
  68624. /**
  68625. * Gets the loaded texture
  68626. */
  68627. texture: EquiRectangularCubeTexture;
  68628. /**
  68629. * Callback called when the task is successful
  68630. */
  68631. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68632. /**
  68633. * Callback called when the task is successful
  68634. */
  68635. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68636. /**
  68637. * Creates a new EquiRectangularCubeTextureAssetTask object
  68638. * @param name defines the name of the task
  68639. * @param url defines the location of the file to load
  68640. * @param size defines the desired size (the more it increases the longer the generation will be)
  68641. * If the size is omitted this implies you are using a preprocessed cubemap.
  68642. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68643. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68644. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68645. * (default is true)
  68646. */
  68647. constructor(
  68648. /**
  68649. * Defines the name of the task
  68650. */
  68651. name: string,
  68652. /**
  68653. * Defines the location of the file to load
  68654. */
  68655. url: string,
  68656. /**
  68657. * Defines the desired size (the more it increases the longer the generation will be)
  68658. */
  68659. size: number,
  68660. /**
  68661. * Defines if mipmaps should not be generated (default is false)
  68662. */
  68663. noMipmap?: boolean,
  68664. /**
  68665. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68666. * but the standard material would require them in Gamma space) (default is true)
  68667. */
  68668. gammaSpace?: boolean);
  68669. /**
  68670. * Execute the current task
  68671. * @param scene defines the scene where you want your assets to be loaded
  68672. * @param onSuccess is a callback called when the task is successfully executed
  68673. * @param onError is a callback called if an error occurs
  68674. */
  68675. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68676. }
  68677. /**
  68678. * This class can be used to easily import assets into a scene
  68679. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68680. */
  68681. export class AssetsManager {
  68682. private _scene;
  68683. private _isLoading;
  68684. protected _tasks: AbstractAssetTask[];
  68685. protected _waitingTasksCount: number;
  68686. protected _totalTasksCount: number;
  68687. /**
  68688. * Callback called when all tasks are processed
  68689. */
  68690. onFinish: (tasks: AbstractAssetTask[]) => void;
  68691. /**
  68692. * Callback called when a task is successful
  68693. */
  68694. onTaskSuccess: (task: AbstractAssetTask) => void;
  68695. /**
  68696. * Callback called when a task had an error
  68697. */
  68698. onTaskError: (task: AbstractAssetTask) => void;
  68699. /**
  68700. * Callback called when a task is done (whatever the result is)
  68701. */
  68702. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68703. /**
  68704. * Observable called when all tasks are processed
  68705. */
  68706. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68707. /**
  68708. * Observable called when a task had an error
  68709. */
  68710. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68711. /**
  68712. * Observable called when all tasks were executed
  68713. */
  68714. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68715. /**
  68716. * Observable called when a task is done (whatever the result is)
  68717. */
  68718. onProgressObservable: Observable<IAssetsProgressEvent>;
  68719. /**
  68720. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68721. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68722. */
  68723. useDefaultLoadingScreen: boolean;
  68724. /**
  68725. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68726. * when all assets have been downloaded.
  68727. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68728. */
  68729. autoHideLoadingUI: boolean;
  68730. /**
  68731. * Creates a new AssetsManager
  68732. * @param scene defines the scene to work on
  68733. */
  68734. constructor(scene: Scene);
  68735. /**
  68736. * Add a MeshAssetTask to the list of active tasks
  68737. * @param taskName defines the name of the new task
  68738. * @param meshesNames defines the name of meshes to load
  68739. * @param rootUrl defines the root url to use to locate files
  68740. * @param sceneFilename defines the filename of the scene file
  68741. * @returns a new MeshAssetTask object
  68742. */
  68743. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68744. /**
  68745. * Add a TextFileAssetTask to the list of active tasks
  68746. * @param taskName defines the name of the new task
  68747. * @param url defines the url of the file to load
  68748. * @returns a new TextFileAssetTask object
  68749. */
  68750. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68751. /**
  68752. * Add a BinaryFileAssetTask to the list of active tasks
  68753. * @param taskName defines the name of the new task
  68754. * @param url defines the url of the file to load
  68755. * @returns a new BinaryFileAssetTask object
  68756. */
  68757. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68758. /**
  68759. * Add a ImageAssetTask to the list of active tasks
  68760. * @param taskName defines the name of the new task
  68761. * @param url defines the url of the file to load
  68762. * @returns a new ImageAssetTask object
  68763. */
  68764. addImageTask(taskName: string, url: string): ImageAssetTask;
  68765. /**
  68766. * Add a TextureAssetTask to the list of active tasks
  68767. * @param taskName defines the name of the new task
  68768. * @param url defines the url of the file to load
  68769. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68770. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68771. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68772. * @returns a new TextureAssetTask object
  68773. */
  68774. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68775. /**
  68776. * Add a CubeTextureAssetTask to the list of active tasks
  68777. * @param taskName defines the name of the new task
  68778. * @param url defines the url of the file to load
  68779. * @param extensions defines the extension to use to load the cube map (can be null)
  68780. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68781. * @param files defines the list of files to load (can be null)
  68782. * @returns a new CubeTextureAssetTask object
  68783. */
  68784. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68785. /**
  68786. *
  68787. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68788. * @param taskName defines the name of the new task
  68789. * @param url defines the url of the file to load
  68790. * @param size defines the size you want for the cubemap (can be null)
  68791. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68792. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68793. * @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)
  68794. * @param reserved Internal use only
  68795. * @returns a new HDRCubeTextureAssetTask object
  68796. */
  68797. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68798. /**
  68799. *
  68800. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68801. * @param taskName defines the name of the new task
  68802. * @param url defines the url of the file to load
  68803. * @param size defines the size you want for the cubemap (can be null)
  68804. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68805. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68806. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68807. * @returns a new EquiRectangularCubeTextureAssetTask object
  68808. */
  68809. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68810. /**
  68811. * Remove a task from the assets manager.
  68812. * @param task the task to remove
  68813. */
  68814. removeTask(task: AbstractAssetTask): void;
  68815. private _decreaseWaitingTasksCount;
  68816. private _runTask;
  68817. /**
  68818. * Reset the AssetsManager and remove all tasks
  68819. * @return the current instance of the AssetsManager
  68820. */
  68821. reset(): AssetsManager;
  68822. /**
  68823. * Start the loading process
  68824. * @return the current instance of the AssetsManager
  68825. */
  68826. load(): AssetsManager;
  68827. /**
  68828. * Start the loading process as an async operation
  68829. * @return a promise returning the list of failed tasks
  68830. */
  68831. loadAsync(): Promise<void>;
  68832. }
  68833. }
  68834. declare module BABYLON {
  68835. /**
  68836. * Wrapper class for promise with external resolve and reject.
  68837. */
  68838. export class Deferred<T> {
  68839. /**
  68840. * The promise associated with this deferred object.
  68841. */
  68842. readonly promise: Promise<T>;
  68843. private _resolve;
  68844. private _reject;
  68845. /**
  68846. * The resolve method of the promise associated with this deferred object.
  68847. */
  68848. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68849. /**
  68850. * The reject method of the promise associated with this deferred object.
  68851. */
  68852. get reject(): (reason?: any) => void;
  68853. /**
  68854. * Constructor for this deferred object.
  68855. */
  68856. constructor();
  68857. }
  68858. }
  68859. declare module BABYLON {
  68860. /**
  68861. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68862. */
  68863. export class MeshExploder {
  68864. private _centerMesh;
  68865. private _meshes;
  68866. private _meshesOrigins;
  68867. private _toCenterVectors;
  68868. private _scaledDirection;
  68869. private _newPosition;
  68870. private _centerPosition;
  68871. /**
  68872. * Explodes meshes from a center mesh.
  68873. * @param meshes The meshes to explode.
  68874. * @param centerMesh The mesh to be center of explosion.
  68875. */
  68876. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68877. private _setCenterMesh;
  68878. /**
  68879. * Get class name
  68880. * @returns "MeshExploder"
  68881. */
  68882. getClassName(): string;
  68883. /**
  68884. * "Exploded meshes"
  68885. * @returns Array of meshes with the centerMesh at index 0.
  68886. */
  68887. getMeshes(): Array<Mesh>;
  68888. /**
  68889. * Explodes meshes giving a specific direction
  68890. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68891. */
  68892. explode(direction?: number): void;
  68893. }
  68894. }
  68895. declare module BABYLON {
  68896. /**
  68897. * Class used to help managing file picking and drag'n'drop
  68898. */
  68899. export class FilesInput {
  68900. /**
  68901. * List of files ready to be loaded
  68902. */
  68903. static get FilesToLoad(): {
  68904. [key: string]: File;
  68905. };
  68906. /**
  68907. * Callback called when a file is processed
  68908. */
  68909. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68910. private _engine;
  68911. private _currentScene;
  68912. private _sceneLoadedCallback;
  68913. private _progressCallback;
  68914. private _additionalRenderLoopLogicCallback;
  68915. private _textureLoadingCallback;
  68916. private _startingProcessingFilesCallback;
  68917. private _onReloadCallback;
  68918. private _errorCallback;
  68919. private _elementToMonitor;
  68920. private _sceneFileToLoad;
  68921. private _filesToLoad;
  68922. /**
  68923. * Creates a new FilesInput
  68924. * @param engine defines the rendering engine
  68925. * @param scene defines the hosting scene
  68926. * @param sceneLoadedCallback callback called when scene is loaded
  68927. * @param progressCallback callback called to track progress
  68928. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68929. * @param textureLoadingCallback callback called when a texture is loading
  68930. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68931. * @param onReloadCallback callback called when a reload is requested
  68932. * @param errorCallback callback call if an error occurs
  68933. */
  68934. 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);
  68935. private _dragEnterHandler;
  68936. private _dragOverHandler;
  68937. private _dropHandler;
  68938. /**
  68939. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68940. * @param elementToMonitor defines the DOM element to track
  68941. */
  68942. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68943. /**
  68944. * Release all associated resources
  68945. */
  68946. dispose(): void;
  68947. private renderFunction;
  68948. private drag;
  68949. private drop;
  68950. private _traverseFolder;
  68951. private _processFiles;
  68952. /**
  68953. * Load files from a drop event
  68954. * @param event defines the drop event to use as source
  68955. */
  68956. loadFiles(event: any): void;
  68957. private _processReload;
  68958. /**
  68959. * Reload the current scene from the loaded files
  68960. */
  68961. reload(): void;
  68962. }
  68963. }
  68964. declare module BABYLON {
  68965. /**
  68966. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68967. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68968. */
  68969. export class SceneOptimization {
  68970. /**
  68971. * Defines the priority of this optimization (0 by default which means first in the list)
  68972. */
  68973. priority: number;
  68974. /**
  68975. * Gets a string describing the action executed by the current optimization
  68976. * @returns description string
  68977. */
  68978. getDescription(): string;
  68979. /**
  68980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68981. * @param scene defines the current scene where to apply this optimization
  68982. * @param optimizer defines the current optimizer
  68983. * @returns true if everything that can be done was applied
  68984. */
  68985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68986. /**
  68987. * Creates the SceneOptimization object
  68988. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68989. * @param desc defines the description associated with the optimization
  68990. */
  68991. constructor(
  68992. /**
  68993. * Defines the priority of this optimization (0 by default which means first in the list)
  68994. */
  68995. priority?: number);
  68996. }
  68997. /**
  68998. * Defines an optimization used to reduce the size of render target textures
  68999. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69000. */
  69001. export class TextureOptimization extends SceneOptimization {
  69002. /**
  69003. * Defines the priority of this optimization (0 by default which means first in the list)
  69004. */
  69005. priority: number;
  69006. /**
  69007. * 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
  69008. */
  69009. maximumSize: number;
  69010. /**
  69011. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69012. */
  69013. step: number;
  69014. /**
  69015. * Gets a string describing the action executed by the current optimization
  69016. * @returns description string
  69017. */
  69018. getDescription(): string;
  69019. /**
  69020. * Creates the TextureOptimization object
  69021. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69022. * @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
  69023. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69024. */
  69025. constructor(
  69026. /**
  69027. * Defines the priority of this optimization (0 by default which means first in the list)
  69028. */
  69029. priority?: number,
  69030. /**
  69031. * 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
  69032. */
  69033. maximumSize?: number,
  69034. /**
  69035. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69036. */
  69037. step?: number);
  69038. /**
  69039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69040. * @param scene defines the current scene where to apply this optimization
  69041. * @param optimizer defines the current optimizer
  69042. * @returns true if everything that can be done was applied
  69043. */
  69044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69045. }
  69046. /**
  69047. * Defines an optimization used to increase or decrease the rendering resolution
  69048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69049. */
  69050. export class HardwareScalingOptimization extends SceneOptimization {
  69051. /**
  69052. * Defines the priority of this optimization (0 by default which means first in the list)
  69053. */
  69054. priority: number;
  69055. /**
  69056. * Defines the maximum scale to use (2 by default)
  69057. */
  69058. maximumScale: number;
  69059. /**
  69060. * Defines the step to use between two passes (0.5 by default)
  69061. */
  69062. step: number;
  69063. private _currentScale;
  69064. private _directionOffset;
  69065. /**
  69066. * Gets a string describing the action executed by the current optimization
  69067. * @return description string
  69068. */
  69069. getDescription(): string;
  69070. /**
  69071. * Creates the HardwareScalingOptimization object
  69072. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69073. * @param maximumScale defines the maximum scale to use (2 by default)
  69074. * @param step defines the step to use between two passes (0.5 by default)
  69075. */
  69076. constructor(
  69077. /**
  69078. * Defines the priority of this optimization (0 by default which means first in the list)
  69079. */
  69080. priority?: number,
  69081. /**
  69082. * Defines the maximum scale to use (2 by default)
  69083. */
  69084. maximumScale?: number,
  69085. /**
  69086. * Defines the step to use between two passes (0.5 by default)
  69087. */
  69088. step?: number);
  69089. /**
  69090. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69091. * @param scene defines the current scene where to apply this optimization
  69092. * @param optimizer defines the current optimizer
  69093. * @returns true if everything that can be done was applied
  69094. */
  69095. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69096. }
  69097. /**
  69098. * Defines an optimization used to remove shadows
  69099. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69100. */
  69101. export class ShadowsOptimization extends SceneOptimization {
  69102. /**
  69103. * Gets a string describing the action executed by the current optimization
  69104. * @return description string
  69105. */
  69106. getDescription(): string;
  69107. /**
  69108. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69109. * @param scene defines the current scene where to apply this optimization
  69110. * @param optimizer defines the current optimizer
  69111. * @returns true if everything that can be done was applied
  69112. */
  69113. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69114. }
  69115. /**
  69116. * Defines an optimization used to turn post-processes off
  69117. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69118. */
  69119. export class PostProcessesOptimization extends SceneOptimization {
  69120. /**
  69121. * Gets a string describing the action executed by the current optimization
  69122. * @return description string
  69123. */
  69124. getDescription(): string;
  69125. /**
  69126. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69127. * @param scene defines the current scene where to apply this optimization
  69128. * @param optimizer defines the current optimizer
  69129. * @returns true if everything that can be done was applied
  69130. */
  69131. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69132. }
  69133. /**
  69134. * Defines an optimization used to turn lens flares off
  69135. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69136. */
  69137. export class LensFlaresOptimization extends SceneOptimization {
  69138. /**
  69139. * Gets a string describing the action executed by the current optimization
  69140. * @return description string
  69141. */
  69142. getDescription(): string;
  69143. /**
  69144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69145. * @param scene defines the current scene where to apply this optimization
  69146. * @param optimizer defines the current optimizer
  69147. * @returns true if everything that can be done was applied
  69148. */
  69149. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69150. }
  69151. /**
  69152. * Defines an optimization based on user defined callback.
  69153. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69154. */
  69155. export class CustomOptimization extends SceneOptimization {
  69156. /**
  69157. * Callback called to apply the custom optimization.
  69158. */
  69159. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69160. /**
  69161. * Callback called to get custom description
  69162. */
  69163. onGetDescription: () => string;
  69164. /**
  69165. * Gets a string describing the action executed by the current optimization
  69166. * @returns description string
  69167. */
  69168. getDescription(): string;
  69169. /**
  69170. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69171. * @param scene defines the current scene where to apply this optimization
  69172. * @param optimizer defines the current optimizer
  69173. * @returns true if everything that can be done was applied
  69174. */
  69175. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69176. }
  69177. /**
  69178. * Defines an optimization used to turn particles off
  69179. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69180. */
  69181. export class ParticlesOptimization extends SceneOptimization {
  69182. /**
  69183. * Gets a string describing the action executed by the current optimization
  69184. * @return description string
  69185. */
  69186. getDescription(): string;
  69187. /**
  69188. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69189. * @param scene defines the current scene where to apply this optimization
  69190. * @param optimizer defines the current optimizer
  69191. * @returns true if everything that can be done was applied
  69192. */
  69193. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69194. }
  69195. /**
  69196. * Defines an optimization used to turn render targets off
  69197. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69198. */
  69199. export class RenderTargetsOptimization extends SceneOptimization {
  69200. /**
  69201. * Gets a string describing the action executed by the current optimization
  69202. * @return description string
  69203. */
  69204. getDescription(): string;
  69205. /**
  69206. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69207. * @param scene defines the current scene where to apply this optimization
  69208. * @param optimizer defines the current optimizer
  69209. * @returns true if everything that can be done was applied
  69210. */
  69211. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69212. }
  69213. /**
  69214. * Defines an optimization used to merge meshes with compatible materials
  69215. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69216. */
  69217. export class MergeMeshesOptimization extends SceneOptimization {
  69218. private static _UpdateSelectionTree;
  69219. /**
  69220. * Gets or sets a boolean which defines if optimization octree has to be updated
  69221. */
  69222. static get UpdateSelectionTree(): boolean;
  69223. /**
  69224. * Gets or sets a boolean which defines if optimization octree has to be updated
  69225. */
  69226. static set UpdateSelectionTree(value: boolean);
  69227. /**
  69228. * Gets a string describing the action executed by the current optimization
  69229. * @return description string
  69230. */
  69231. getDescription(): string;
  69232. private _canBeMerged;
  69233. /**
  69234. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69235. * @param scene defines the current scene where to apply this optimization
  69236. * @param optimizer defines the current optimizer
  69237. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69238. * @returns true if everything that can be done was applied
  69239. */
  69240. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69241. }
  69242. /**
  69243. * Defines a list of options used by SceneOptimizer
  69244. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69245. */
  69246. export class SceneOptimizerOptions {
  69247. /**
  69248. * Defines the target frame rate to reach (60 by default)
  69249. */
  69250. targetFrameRate: number;
  69251. /**
  69252. * Defines the interval between two checkes (2000ms by default)
  69253. */
  69254. trackerDuration: number;
  69255. /**
  69256. * Gets the list of optimizations to apply
  69257. */
  69258. optimizations: SceneOptimization[];
  69259. /**
  69260. * Creates a new list of options used by SceneOptimizer
  69261. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69262. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69263. */
  69264. constructor(
  69265. /**
  69266. * Defines the target frame rate to reach (60 by default)
  69267. */
  69268. targetFrameRate?: number,
  69269. /**
  69270. * Defines the interval between two checkes (2000ms by default)
  69271. */
  69272. trackerDuration?: number);
  69273. /**
  69274. * Add a new optimization
  69275. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69276. * @returns the current SceneOptimizerOptions
  69277. */
  69278. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69279. /**
  69280. * Add a new custom optimization
  69281. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69282. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69283. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69284. * @returns the current SceneOptimizerOptions
  69285. */
  69286. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69287. /**
  69288. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69289. * @param targetFrameRate defines the target frame rate (60 by default)
  69290. * @returns a SceneOptimizerOptions object
  69291. */
  69292. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69293. /**
  69294. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69295. * @param targetFrameRate defines the target frame rate (60 by default)
  69296. * @returns a SceneOptimizerOptions object
  69297. */
  69298. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69299. /**
  69300. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69301. * @param targetFrameRate defines the target frame rate (60 by default)
  69302. * @returns a SceneOptimizerOptions object
  69303. */
  69304. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69305. }
  69306. /**
  69307. * Class used to run optimizations in order to reach a target frame rate
  69308. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69309. */
  69310. export class SceneOptimizer implements IDisposable {
  69311. private _isRunning;
  69312. private _options;
  69313. private _scene;
  69314. private _currentPriorityLevel;
  69315. private _targetFrameRate;
  69316. private _trackerDuration;
  69317. private _currentFrameRate;
  69318. private _sceneDisposeObserver;
  69319. private _improvementMode;
  69320. /**
  69321. * Defines an observable called when the optimizer reaches the target frame rate
  69322. */
  69323. onSuccessObservable: Observable<SceneOptimizer>;
  69324. /**
  69325. * Defines an observable called when the optimizer enables an optimization
  69326. */
  69327. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69328. /**
  69329. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69330. */
  69331. onFailureObservable: Observable<SceneOptimizer>;
  69332. /**
  69333. * Gets a boolean indicating if the optimizer is in improvement mode
  69334. */
  69335. get isInImprovementMode(): boolean;
  69336. /**
  69337. * Gets the current priority level (0 at start)
  69338. */
  69339. get currentPriorityLevel(): number;
  69340. /**
  69341. * Gets the current frame rate checked by the SceneOptimizer
  69342. */
  69343. get currentFrameRate(): number;
  69344. /**
  69345. * Gets or sets the current target frame rate (60 by default)
  69346. */
  69347. get targetFrameRate(): number;
  69348. /**
  69349. * Gets or sets the current target frame rate (60 by default)
  69350. */
  69351. set targetFrameRate(value: number);
  69352. /**
  69353. * Gets or sets the current interval between two checks (every 2000ms by default)
  69354. */
  69355. get trackerDuration(): number;
  69356. /**
  69357. * Gets or sets the current interval between two checks (every 2000ms by default)
  69358. */
  69359. set trackerDuration(value: number);
  69360. /**
  69361. * Gets the list of active optimizations
  69362. */
  69363. get optimizations(): SceneOptimization[];
  69364. /**
  69365. * Creates a new SceneOptimizer
  69366. * @param scene defines the scene to work on
  69367. * @param options defines the options to use with the SceneOptimizer
  69368. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69369. * @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)
  69370. */
  69371. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69372. /**
  69373. * Stops the current optimizer
  69374. */
  69375. stop(): void;
  69376. /**
  69377. * Reset the optimizer to initial step (current priority level = 0)
  69378. */
  69379. reset(): void;
  69380. /**
  69381. * Start the optimizer. By default it will try to reach a specific framerate
  69382. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69383. */
  69384. start(): void;
  69385. private _checkCurrentState;
  69386. /**
  69387. * Release all resources
  69388. */
  69389. dispose(): void;
  69390. /**
  69391. * Helper function to create a SceneOptimizer with one single line of code
  69392. * @param scene defines the scene to work on
  69393. * @param options defines the options to use with the SceneOptimizer
  69394. * @param onSuccess defines a callback to call on success
  69395. * @param onFailure defines a callback to call on failure
  69396. * @returns the new SceneOptimizer object
  69397. */
  69398. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69399. }
  69400. }
  69401. declare module BABYLON {
  69402. /**
  69403. * Class used to serialize a scene into a string
  69404. */
  69405. export class SceneSerializer {
  69406. /**
  69407. * Clear cache used by a previous serialization
  69408. */
  69409. static ClearCache(): void;
  69410. /**
  69411. * Serialize a scene into a JSON compatible object
  69412. * @param scene defines the scene to serialize
  69413. * @returns a JSON compatible object
  69414. */
  69415. static Serialize(scene: Scene): any;
  69416. /**
  69417. * Serialize a mesh into a JSON compatible object
  69418. * @param toSerialize defines the mesh to serialize
  69419. * @param withParents defines if parents must be serialized as well
  69420. * @param withChildren defines if children must be serialized as well
  69421. * @returns a JSON compatible object
  69422. */
  69423. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69424. }
  69425. }
  69426. declare module BABYLON {
  69427. /**
  69428. * Class used to host texture specific utilities
  69429. */
  69430. export class TextureTools {
  69431. /**
  69432. * Uses the GPU to create a copy texture rescaled at a given size
  69433. * @param texture Texture to copy from
  69434. * @param width defines the desired width
  69435. * @param height defines the desired height
  69436. * @param useBilinearMode defines if bilinear mode has to be used
  69437. * @return the generated texture
  69438. */
  69439. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69440. }
  69441. }
  69442. declare module BABYLON {
  69443. /**
  69444. * This represents the different options available for the video capture.
  69445. */
  69446. export interface VideoRecorderOptions {
  69447. /** Defines the mime type of the video. */
  69448. mimeType: string;
  69449. /** Defines the FPS the video should be recorded at. */
  69450. fps: number;
  69451. /** Defines the chunk size for the recording data. */
  69452. recordChunckSize: number;
  69453. /** The audio tracks to attach to the recording. */
  69454. audioTracks?: MediaStreamTrack[];
  69455. }
  69456. /**
  69457. * This can help with recording videos from BabylonJS.
  69458. * This is based on the available WebRTC functionalities of the browser.
  69459. *
  69460. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69461. */
  69462. export class VideoRecorder {
  69463. private static readonly _defaultOptions;
  69464. /**
  69465. * Returns whether or not the VideoRecorder is available in your browser.
  69466. * @param engine Defines the Babylon Engine.
  69467. * @returns true if supported otherwise false.
  69468. */
  69469. static IsSupported(engine: Engine): boolean;
  69470. private readonly _options;
  69471. private _canvas;
  69472. private _mediaRecorder;
  69473. private _recordedChunks;
  69474. private _fileName;
  69475. private _resolve;
  69476. private _reject;
  69477. /**
  69478. * True when a recording is already in progress.
  69479. */
  69480. get isRecording(): boolean;
  69481. /**
  69482. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69483. * @param engine Defines the BabylonJS Engine you wish to record.
  69484. * @param options Defines options that can be used to customize the capture.
  69485. */
  69486. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69487. /**
  69488. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69489. */
  69490. stopRecording(): void;
  69491. /**
  69492. * Starts recording the canvas for a max duration specified in parameters.
  69493. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69494. * If null no automatic download will start and you can rely on the promise to get the data back.
  69495. * @param maxDuration Defines the maximum recording time in seconds.
  69496. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69497. * @return A promise callback at the end of the recording with the video data in Blob.
  69498. */
  69499. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69500. /**
  69501. * Releases internal resources used during the recording.
  69502. */
  69503. dispose(): void;
  69504. private _handleDataAvailable;
  69505. private _handleError;
  69506. private _handleStop;
  69507. }
  69508. }
  69509. declare module BABYLON {
  69510. /**
  69511. * Class containing a set of static utilities functions for screenshots
  69512. */
  69513. export class ScreenshotTools {
  69514. /**
  69515. * Captures a screenshot of the current rendering
  69516. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69517. * @param engine defines the rendering engine
  69518. * @param camera defines the source camera
  69519. * @param size This parameter can be set to a single number or to an object with the
  69520. * following (optional) properties: precision, width, height. If a single number is passed,
  69521. * it will be used for both width and height. If an object is passed, the screenshot size
  69522. * will be derived from the parameters. The precision property is a multiplier allowing
  69523. * rendering at a higher or lower resolution
  69524. * @param successCallback defines the callback receives a single parameter which contains the
  69525. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69526. * src parameter of an <img> to display it
  69527. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69528. * Check your browser for supported MIME types
  69529. */
  69530. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69531. /**
  69532. * Captures a screenshot of the current rendering
  69533. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69534. * @param engine defines the rendering engine
  69535. * @param camera defines the source camera
  69536. * @param size This parameter can be set to a single number or to an object with the
  69537. * following (optional) properties: precision, width, height. If a single number is passed,
  69538. * it will be used for both width and height. If an object is passed, the screenshot size
  69539. * will be derived from the parameters. The precision property is a multiplier allowing
  69540. * rendering at a higher or lower resolution
  69541. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69542. * Check your browser for supported MIME types
  69543. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69544. * to the src parameter of an <img> to display it
  69545. */
  69546. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69547. /**
  69548. * Generates an image screenshot from the specified camera.
  69549. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69550. * @param engine The engine to use for rendering
  69551. * @param camera The camera to use for rendering
  69552. * @param size This parameter can be set to a single number or to an object with the
  69553. * following (optional) properties: precision, width, height. If a single number is passed,
  69554. * it will be used for both width and height. If an object is passed, the screenshot size
  69555. * will be derived from the parameters. The precision property is a multiplier allowing
  69556. * rendering at a higher or lower resolution
  69557. * @param successCallback The callback receives a single parameter which contains the
  69558. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69559. * src parameter of an <img> to display it
  69560. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69561. * Check your browser for supported MIME types
  69562. * @param samples Texture samples (default: 1)
  69563. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69564. * @param fileName A name for for the downloaded file.
  69565. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69566. */
  69567. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69568. /**
  69569. * Generates an image screenshot from the specified camera.
  69570. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69571. * @param engine The engine to use for rendering
  69572. * @param camera The camera to use for rendering
  69573. * @param size This parameter can be set to a single number or to an object with the
  69574. * following (optional) properties: precision, width, height. If a single number is passed,
  69575. * it will be used for both width and height. If an object is passed, the screenshot size
  69576. * will be derived from the parameters. The precision property is a multiplier allowing
  69577. * rendering at a higher or lower resolution
  69578. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69579. * Check your browser for supported MIME types
  69580. * @param samples Texture samples (default: 1)
  69581. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69582. * @param fileName A name for for the downloaded file.
  69583. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69584. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69585. * to the src parameter of an <img> to display it
  69586. */
  69587. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69588. /**
  69589. * Gets height and width for screenshot size
  69590. * @private
  69591. */
  69592. private static _getScreenshotSize;
  69593. }
  69594. }
  69595. declare module BABYLON {
  69596. /**
  69597. * Interface for a data buffer
  69598. */
  69599. export interface IDataBuffer {
  69600. /**
  69601. * Reads bytes from the data buffer.
  69602. * @param byteOffset The byte offset to read
  69603. * @param byteLength The byte length to read
  69604. * @returns A promise that resolves when the bytes are read
  69605. */
  69606. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69607. /**
  69608. * The byte length of the buffer.
  69609. */
  69610. readonly byteLength: number;
  69611. }
  69612. /**
  69613. * Utility class for reading from a data buffer
  69614. */
  69615. export class DataReader {
  69616. /**
  69617. * The data buffer associated with this data reader.
  69618. */
  69619. readonly buffer: IDataBuffer;
  69620. /**
  69621. * The current byte offset from the beginning of the data buffer.
  69622. */
  69623. byteOffset: number;
  69624. private _dataView;
  69625. private _dataByteOffset;
  69626. /**
  69627. * Constructor
  69628. * @param buffer The buffer to read
  69629. */
  69630. constructor(buffer: IDataBuffer);
  69631. /**
  69632. * Loads the given byte length.
  69633. * @param byteLength The byte length to load
  69634. * @returns A promise that resolves when the load is complete
  69635. */
  69636. loadAsync(byteLength: number): Promise<void>;
  69637. /**
  69638. * Read a unsigned 32-bit integer from the currently loaded data range.
  69639. * @returns The 32-bit integer read
  69640. */
  69641. readUint32(): number;
  69642. /**
  69643. * Read a byte array from the currently loaded data range.
  69644. * @param byteLength The byte length to read
  69645. * @returns The byte array read
  69646. */
  69647. readUint8Array(byteLength: number): Uint8Array;
  69648. /**
  69649. * Read a string from the currently loaded data range.
  69650. * @param byteLength The byte length to read
  69651. * @returns The string read
  69652. */
  69653. readString(byteLength: number): string;
  69654. /**
  69655. * Skips the given byte length the currently loaded data range.
  69656. * @param byteLength The byte length to skip
  69657. */
  69658. skipBytes(byteLength: number): void;
  69659. }
  69660. }
  69661. declare module BABYLON {
  69662. /**
  69663. * Class for storing data to local storage if available or in-memory storage otherwise
  69664. */
  69665. export class DataStorage {
  69666. private static _Storage;
  69667. private static _GetStorage;
  69668. /**
  69669. * Reads a string from the data storage
  69670. * @param key The key to read
  69671. * @param defaultValue The value if the key doesn't exist
  69672. * @returns The string value
  69673. */
  69674. static ReadString(key: string, defaultValue: string): string;
  69675. /**
  69676. * Writes a string to the data storage
  69677. * @param key The key to write
  69678. * @param value The value to write
  69679. */
  69680. static WriteString(key: string, value: string): void;
  69681. /**
  69682. * Reads a boolean from the data storage
  69683. * @param key The key to read
  69684. * @param defaultValue The value if the key doesn't exist
  69685. * @returns The boolean value
  69686. */
  69687. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69688. /**
  69689. * Writes a boolean to the data storage
  69690. * @param key The key to write
  69691. * @param value The value to write
  69692. */
  69693. static WriteBoolean(key: string, value: boolean): void;
  69694. /**
  69695. * Reads a number from the data storage
  69696. * @param key The key to read
  69697. * @param defaultValue The value if the key doesn't exist
  69698. * @returns The number value
  69699. */
  69700. static ReadNumber(key: string, defaultValue: number): number;
  69701. /**
  69702. * Writes a number to the data storage
  69703. * @param key The key to write
  69704. * @param value The value to write
  69705. */
  69706. static WriteNumber(key: string, value: number): void;
  69707. }
  69708. }
  69709. declare module BABYLON {
  69710. /**
  69711. * Options used for hit testing
  69712. */
  69713. export interface IWebXRLegacyHitTestOptions {
  69714. /**
  69715. * Only test when user interacted with the scene. Default - hit test every frame
  69716. */
  69717. testOnPointerDownOnly?: boolean;
  69718. /**
  69719. * The node to use to transform the local results to world coordinates
  69720. */
  69721. worldParentNode?: TransformNode;
  69722. }
  69723. /**
  69724. * Interface defining the babylon result of raycasting/hit-test
  69725. */
  69726. export interface IWebXRLegacyHitResult {
  69727. /**
  69728. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69729. */
  69730. transformationMatrix: Matrix;
  69731. /**
  69732. * The native hit test result
  69733. */
  69734. xrHitResult: XRHitResult | XRHitTestResult;
  69735. }
  69736. /**
  69737. * The currently-working hit-test module.
  69738. * Hit test (or Ray-casting) is used to interact with the real world.
  69739. * For further information read here - https://github.com/immersive-web/hit-test
  69740. */
  69741. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69742. /**
  69743. * options to use when constructing this feature
  69744. */
  69745. readonly options: IWebXRLegacyHitTestOptions;
  69746. private _direction;
  69747. private _mat;
  69748. private _onSelectEnabled;
  69749. private _origin;
  69750. /**
  69751. * The module's name
  69752. */
  69753. static readonly Name: string;
  69754. /**
  69755. * The (Babylon) version of this module.
  69756. * This is an integer representing the implementation version.
  69757. * This number does not correspond to the WebXR specs version
  69758. */
  69759. static readonly Version: number;
  69760. /**
  69761. * Populated with the last native XR Hit Results
  69762. */
  69763. lastNativeXRHitResults: XRHitResult[];
  69764. /**
  69765. * Triggered when new babylon (transformed) hit test results are available
  69766. */
  69767. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69768. /**
  69769. * Creates a new instance of the (legacy version) hit test feature
  69770. * @param _xrSessionManager an instance of WebXRSessionManager
  69771. * @param options options to use when constructing this feature
  69772. */
  69773. constructor(_xrSessionManager: WebXRSessionManager,
  69774. /**
  69775. * options to use when constructing this feature
  69776. */
  69777. options?: IWebXRLegacyHitTestOptions);
  69778. /**
  69779. * execute a hit test with an XR Ray
  69780. *
  69781. * @param xrSession a native xrSession that will execute this hit test
  69782. * @param xrRay the ray (position and direction) to use for ray-casting
  69783. * @param referenceSpace native XR reference space to use for the hit-test
  69784. * @param filter filter function that will filter the results
  69785. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69786. */
  69787. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69788. /**
  69789. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69790. * @param event the (select) event to use to select with
  69791. * @param referenceSpace the reference space to use for this hit test
  69792. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69793. */
  69794. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69795. /**
  69796. * attach this feature
  69797. * Will usually be called by the features manager
  69798. *
  69799. * @returns true if successful.
  69800. */
  69801. attach(): boolean;
  69802. /**
  69803. * detach this feature.
  69804. * Will usually be called by the features manager
  69805. *
  69806. * @returns true if successful.
  69807. */
  69808. detach(): boolean;
  69809. /**
  69810. * Dispose this feature and all of the resources attached
  69811. */
  69812. dispose(): void;
  69813. protected _onXRFrame(frame: XRFrame): void;
  69814. private _onHitTestResults;
  69815. private _onSelect;
  69816. }
  69817. }
  69818. declare module BABYLON {
  69819. /**
  69820. * Options used in the plane detector module
  69821. */
  69822. export interface IWebXRPlaneDetectorOptions {
  69823. /**
  69824. * The node to use to transform the local results to world coordinates
  69825. */
  69826. worldParentNode?: TransformNode;
  69827. }
  69828. /**
  69829. * A babylon interface for a WebXR plane.
  69830. * A Plane is actually a polygon, built from N points in space
  69831. *
  69832. * Supported in chrome 79, not supported in canary 81 ATM
  69833. */
  69834. export interface IWebXRPlane {
  69835. /**
  69836. * a babylon-assigned ID for this polygon
  69837. */
  69838. id: number;
  69839. /**
  69840. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69841. */
  69842. polygonDefinition: Array<Vector3>;
  69843. /**
  69844. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69845. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69846. */
  69847. transformationMatrix: Matrix;
  69848. /**
  69849. * the native xr-plane object
  69850. */
  69851. xrPlane: XRPlane;
  69852. }
  69853. /**
  69854. * The plane detector is used to detect planes in the real world when in AR
  69855. * For more information see https://github.com/immersive-web/real-world-geometry/
  69856. */
  69857. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69858. private _options;
  69859. private _detectedPlanes;
  69860. private _enabled;
  69861. private _lastFrameDetected;
  69862. /**
  69863. * The module's name
  69864. */
  69865. static readonly Name: string;
  69866. /**
  69867. * The (Babylon) version of this module.
  69868. * This is an integer representing the implementation version.
  69869. * This number does not correspond to the WebXR specs version
  69870. */
  69871. static readonly Version: number;
  69872. /**
  69873. * Observers registered here will be executed when a new plane was added to the session
  69874. */
  69875. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69876. /**
  69877. * Observers registered here will be executed when a plane is no longer detected in the session
  69878. */
  69879. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69880. /**
  69881. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69882. * This can execute N times every frame
  69883. */
  69884. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69885. /**
  69886. * construct a new Plane Detector
  69887. * @param _xrSessionManager an instance of xr Session manager
  69888. * @param _options configuration to use when constructing this feature
  69889. */
  69890. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69891. /**
  69892. * Dispose this feature and all of the resources attached
  69893. */
  69894. dispose(): void;
  69895. protected _onXRFrame(frame: XRFrame): void;
  69896. private _init;
  69897. private _updatePlaneWithXRPlane;
  69898. /**
  69899. * avoiding using Array.find for global support.
  69900. * @param xrPlane the plane to find in the array
  69901. */
  69902. private findIndexInPlaneArray;
  69903. }
  69904. }
  69905. declare module BABYLON {
  69906. /**
  69907. * Configuration options of the anchor system
  69908. */
  69909. export interface IWebXRAnchorSystemOptions {
  69910. /**
  69911. * Should a new anchor be added every time a select event is triggered
  69912. */
  69913. addAnchorOnSelect?: boolean;
  69914. /**
  69915. * should the anchor system use plane detection.
  69916. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69917. */
  69918. usePlaneDetection?: boolean;
  69919. /**
  69920. * a node that will be used to convert local to world coordinates
  69921. */
  69922. worldParentNode?: TransformNode;
  69923. }
  69924. /**
  69925. * A babylon container for an XR Anchor
  69926. */
  69927. export interface IWebXRAnchor {
  69928. /**
  69929. * A babylon-assigned ID for this anchor
  69930. */
  69931. id: number;
  69932. /**
  69933. * Transformation matrix to apply to an object attached to this anchor
  69934. */
  69935. transformationMatrix: Matrix;
  69936. /**
  69937. * The native anchor object
  69938. */
  69939. xrAnchor: XRAnchor;
  69940. }
  69941. /**
  69942. * An implementation of the anchor system of WebXR.
  69943. * Note that the current documented implementation is not available in any browser. Future implementations
  69944. * will use the frame to create an anchor and not the session or a detected plane
  69945. * For further information see https://github.com/immersive-web/anchors/
  69946. */
  69947. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69948. private _options;
  69949. private _enabled;
  69950. private _hitTestModule;
  69951. private _lastFrameDetected;
  69952. private _onSelect;
  69953. private _planeDetector;
  69954. private _trackedAnchors;
  69955. /**
  69956. * The module's name
  69957. */
  69958. static readonly Name: string;
  69959. /**
  69960. * The (Babylon) version of this module.
  69961. * This is an integer representing the implementation version.
  69962. * This number does not correspond to the WebXR specs version
  69963. */
  69964. static readonly Version: number;
  69965. /**
  69966. * Observers registered here will be executed when a new anchor was added to the session
  69967. */
  69968. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69969. /**
  69970. * Observers registered here will be executed when an anchor was removed from the session
  69971. */
  69972. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69973. /**
  69974. * Observers registered here will be executed when an existing anchor updates
  69975. * This can execute N times every frame
  69976. */
  69977. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69978. /**
  69979. * constructs a new anchor system
  69980. * @param _xrSessionManager an instance of WebXRSessionManager
  69981. * @param _options configuration object for this feature
  69982. */
  69983. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69984. /**
  69985. * Add anchor at a specific XR point.
  69986. *
  69987. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69988. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69989. * @returns a promise the fulfills when the anchor was created
  69990. */
  69991. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69992. /**
  69993. * attach this feature
  69994. * Will usually be called by the features manager
  69995. *
  69996. * @returns true if successful.
  69997. */
  69998. attach(): boolean;
  69999. /**
  70000. * detach this feature.
  70001. * Will usually be called by the features manager
  70002. *
  70003. * @returns true if successful.
  70004. */
  70005. detach(): boolean;
  70006. /**
  70007. * Dispose this feature and all of the resources attached
  70008. */
  70009. dispose(): void;
  70010. /**
  70011. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  70012. * @param hitTestModule the hit-test module to use.
  70013. */
  70014. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  70015. /**
  70016. * set the plane detector to use in order to create anchors from frames
  70017. * @param planeDetector the plane-detector module to use
  70018. * @param enable enable plane-anchors. default is true
  70019. */
  70020. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  70021. protected _onXRFrame(frame: XRFrame): void;
  70022. /**
  70023. * avoiding using Array.find for global support.
  70024. * @param xrAnchor the plane to find in the array
  70025. */
  70026. private _findIndexInAnchorArray;
  70027. private _updateAnchorWithXRFrame;
  70028. }
  70029. }
  70030. declare module BABYLON {
  70031. /**
  70032. * Options interface for the background remover plugin
  70033. */
  70034. export interface IWebXRBackgroundRemoverOptions {
  70035. /**
  70036. * Further background meshes to disable when entering AR
  70037. */
  70038. backgroundMeshes?: AbstractMesh[];
  70039. /**
  70040. * flags to configure the removal of the environment helper.
  70041. * If not set, the entire background will be removed. If set, flags should be set as well.
  70042. */
  70043. environmentHelperRemovalFlags?: {
  70044. /**
  70045. * Should the skybox be removed (default false)
  70046. */
  70047. skyBox?: boolean;
  70048. /**
  70049. * Should the ground be removed (default false)
  70050. */
  70051. ground?: boolean;
  70052. };
  70053. /**
  70054. * don't disable the environment helper
  70055. */
  70056. ignoreEnvironmentHelper?: boolean;
  70057. }
  70058. /**
  70059. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  70060. */
  70061. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  70062. /**
  70063. * read-only options to be used in this module
  70064. */
  70065. readonly options: IWebXRBackgroundRemoverOptions;
  70066. /**
  70067. * The module's name
  70068. */
  70069. static readonly Name: string;
  70070. /**
  70071. * The (Babylon) version of this module.
  70072. * This is an integer representing the implementation version.
  70073. * This number does not correspond to the WebXR specs version
  70074. */
  70075. static readonly Version: number;
  70076. /**
  70077. * registered observers will be triggered when the background state changes
  70078. */
  70079. onBackgroundStateChangedObservable: Observable<boolean>;
  70080. /**
  70081. * constructs a new background remover module
  70082. * @param _xrSessionManager the session manager for this module
  70083. * @param options read-only options to be used in this module
  70084. */
  70085. constructor(_xrSessionManager: WebXRSessionManager,
  70086. /**
  70087. * read-only options to be used in this module
  70088. */
  70089. options?: IWebXRBackgroundRemoverOptions);
  70090. /**
  70091. * attach this feature
  70092. * Will usually be called by the features manager
  70093. *
  70094. * @returns true if successful.
  70095. */
  70096. attach(): boolean;
  70097. /**
  70098. * detach this feature.
  70099. * Will usually be called by the features manager
  70100. *
  70101. * @returns true if successful.
  70102. */
  70103. detach(): boolean;
  70104. /**
  70105. * Dispose this feature and all of the resources attached
  70106. */
  70107. dispose(): void;
  70108. protected _onXRFrame(_xrFrame: XRFrame): void;
  70109. private _setBackgroundState;
  70110. }
  70111. }
  70112. declare module BABYLON {
  70113. /**
  70114. * Options for the controller physics feature
  70115. */
  70116. export class IWebXRControllerPhysicsOptions {
  70117. /**
  70118. * Should the headset get its own impostor
  70119. */
  70120. enableHeadsetImpostor?: boolean;
  70121. /**
  70122. * Optional parameters for the headset impostor
  70123. */
  70124. headsetImpostorParams?: {
  70125. /**
  70126. * The type of impostor to create. Default is sphere
  70127. */
  70128. impostorType: number;
  70129. /**
  70130. * the size of the impostor. Defaults to 10cm
  70131. */
  70132. impostorSize?: number | {
  70133. width: number;
  70134. height: number;
  70135. depth: number;
  70136. };
  70137. /**
  70138. * Friction definitions
  70139. */
  70140. friction?: number;
  70141. /**
  70142. * Restitution
  70143. */
  70144. restitution?: number;
  70145. };
  70146. /**
  70147. * The physics properties of the future impostors
  70148. */
  70149. physicsProperties?: {
  70150. /**
  70151. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  70152. * Note that this requires a physics engine that supports mesh impostors!
  70153. */
  70154. useControllerMesh?: boolean;
  70155. /**
  70156. * The type of impostor to create. Default is sphere
  70157. */
  70158. impostorType?: number;
  70159. /**
  70160. * the size of the impostor. Defaults to 10cm
  70161. */
  70162. impostorSize?: number | {
  70163. width: number;
  70164. height: number;
  70165. depth: number;
  70166. };
  70167. /**
  70168. * Friction definitions
  70169. */
  70170. friction?: number;
  70171. /**
  70172. * Restitution
  70173. */
  70174. restitution?: number;
  70175. };
  70176. /**
  70177. * the xr input to use with this pointer selection
  70178. */
  70179. xrInput: WebXRInput;
  70180. }
  70181. /**
  70182. * Add physics impostor to your webxr controllers,
  70183. * including naive calculation of their linear and angular velocity
  70184. */
  70185. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  70186. private readonly _options;
  70187. private _attachController;
  70188. private _controllers;
  70189. private _debugMode;
  70190. private _delta;
  70191. private _headsetImpostor?;
  70192. private _headsetMesh?;
  70193. private _lastTimestamp;
  70194. private _tmpQuaternion;
  70195. private _tmpVector;
  70196. /**
  70197. * The module's name
  70198. */
  70199. static readonly Name: string;
  70200. /**
  70201. * The (Babylon) version of this module.
  70202. * This is an integer representing the implementation version.
  70203. * This number does not correspond to the webxr specs version
  70204. */
  70205. static readonly Version: number;
  70206. /**
  70207. * Construct a new Controller Physics Feature
  70208. * @param _xrSessionManager the corresponding xr session manager
  70209. * @param _options options to create this feature with
  70210. */
  70211. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  70212. /**
  70213. * @hidden
  70214. * enable debugging - will show console outputs and the impostor mesh
  70215. */
  70216. _enablePhysicsDebug(): void;
  70217. /**
  70218. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  70219. * @param xrController the controller to add
  70220. */
  70221. addController(xrController: WebXRInputSource): void;
  70222. /**
  70223. * attach this feature
  70224. * Will usually be called by the features manager
  70225. *
  70226. * @returns true if successful.
  70227. */
  70228. attach(): boolean;
  70229. /**
  70230. * detach this feature.
  70231. * Will usually be called by the features manager
  70232. *
  70233. * @returns true if successful.
  70234. */
  70235. detach(): boolean;
  70236. /**
  70237. * Get the headset impostor, if enabled
  70238. * @returns the impostor
  70239. */
  70240. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70241. /**
  70242. * Get the physics impostor of a specific controller.
  70243. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70244. * @param controller the controller or the controller id of which to get the impostor
  70245. * @returns the impostor or null
  70246. */
  70247. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70248. /**
  70249. * Update the physics properties provided in the constructor
  70250. * @param newProperties the new properties object
  70251. */
  70252. setPhysicsProperties(newProperties: {
  70253. impostorType?: number;
  70254. impostorSize?: number | {
  70255. width: number;
  70256. height: number;
  70257. depth: number;
  70258. };
  70259. friction?: number;
  70260. restitution?: number;
  70261. }): void;
  70262. protected _onXRFrame(_xrFrame: any): void;
  70263. private _detachController;
  70264. }
  70265. }
  70266. declare module BABYLON {
  70267. /**
  70268. * Options used for hit testing (version 2)
  70269. */
  70270. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70271. /**
  70272. * Do not create a permanent hit test. Will usually be used when only
  70273. * transient inputs are needed.
  70274. */
  70275. disablePermanentHitTest?: boolean;
  70276. /**
  70277. * Enable transient (for example touch-based) hit test inspections
  70278. */
  70279. enableTransientHitTest?: boolean;
  70280. /**
  70281. * Offset ray for the permanent hit test
  70282. */
  70283. offsetRay?: Vector3;
  70284. /**
  70285. * Offset ray for the transient hit test
  70286. */
  70287. transientOffsetRay?: Vector3;
  70288. /**
  70289. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70290. */
  70291. useReferenceSpace?: boolean;
  70292. }
  70293. /**
  70294. * Interface defining the babylon result of hit-test
  70295. */
  70296. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70297. /**
  70298. * The input source that generated this hit test (if transient)
  70299. */
  70300. inputSource?: XRInputSource;
  70301. /**
  70302. * Is this a transient hit test
  70303. */
  70304. isTransient?: boolean;
  70305. /**
  70306. * Position of the hit test result
  70307. */
  70308. position: Vector3;
  70309. /**
  70310. * Rotation of the hit test result
  70311. */
  70312. rotationQuaternion: Quaternion;
  70313. }
  70314. /**
  70315. * The currently-working hit-test module.
  70316. * Hit test (or Ray-casting) is used to interact with the real world.
  70317. * For further information read here - https://github.com/immersive-web/hit-test
  70318. *
  70319. * Tested on chrome (mobile) 80.
  70320. */
  70321. export class WebXRHitTest extends WebXRAbstractFeature {
  70322. /**
  70323. * options to use when constructing this feature
  70324. */
  70325. readonly options: IWebXRHitTestOptions;
  70326. private _tmpMat;
  70327. private _tmpPos;
  70328. private _tmpQuat;
  70329. private _transientXrHitTestSource;
  70330. private _xrHitTestSource;
  70331. private initHitTestSource;
  70332. /**
  70333. * The module's name
  70334. */
  70335. static readonly Name: string;
  70336. /**
  70337. * The (Babylon) version of this module.
  70338. * This is an integer representing the implementation version.
  70339. * This number does not correspond to the WebXR specs version
  70340. */
  70341. static readonly Version: number;
  70342. /**
  70343. * When set to true, each hit test will have its own position/rotation objects
  70344. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70345. * the developers will clone them or copy them as they see fit.
  70346. */
  70347. autoCloneTransformation: boolean;
  70348. /**
  70349. * Populated with the last native XR Hit Results
  70350. */
  70351. lastNativeXRHitResults: XRHitResult[];
  70352. /**
  70353. * Triggered when new babylon (transformed) hit test results are available
  70354. */
  70355. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70356. /**
  70357. * Use this to temporarily pause hit test checks.
  70358. */
  70359. paused: boolean;
  70360. /**
  70361. * Creates a new instance of the hit test feature
  70362. * @param _xrSessionManager an instance of WebXRSessionManager
  70363. * @param options options to use when constructing this feature
  70364. */
  70365. constructor(_xrSessionManager: WebXRSessionManager,
  70366. /**
  70367. * options to use when constructing this feature
  70368. */
  70369. options?: IWebXRHitTestOptions);
  70370. /**
  70371. * attach this feature
  70372. * Will usually be called by the features manager
  70373. *
  70374. * @returns true if successful.
  70375. */
  70376. attach(): boolean;
  70377. /**
  70378. * detach this feature.
  70379. * Will usually be called by the features manager
  70380. *
  70381. * @returns true if successful.
  70382. */
  70383. detach(): boolean;
  70384. /**
  70385. * Dispose this feature and all of the resources attached
  70386. */
  70387. dispose(): void;
  70388. protected _onXRFrame(frame: XRFrame): void;
  70389. private _processWebXRHitTestResult;
  70390. }
  70391. }
  70392. declare module BABYLON {
  70393. /**
  70394. * The motion controller class for all microsoft mixed reality controllers
  70395. */
  70396. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70397. protected readonly _mapping: {
  70398. defaultButton: {
  70399. valueNodeName: string;
  70400. unpressedNodeName: string;
  70401. pressedNodeName: string;
  70402. };
  70403. defaultAxis: {
  70404. valueNodeName: string;
  70405. minNodeName: string;
  70406. maxNodeName: string;
  70407. };
  70408. buttons: {
  70409. "xr-standard-trigger": {
  70410. rootNodeName: string;
  70411. componentProperty: string;
  70412. states: string[];
  70413. };
  70414. "xr-standard-squeeze": {
  70415. rootNodeName: string;
  70416. componentProperty: string;
  70417. states: string[];
  70418. };
  70419. "xr-standard-touchpad": {
  70420. rootNodeName: string;
  70421. labelAnchorNodeName: string;
  70422. touchPointNodeName: string;
  70423. };
  70424. "xr-standard-thumbstick": {
  70425. rootNodeName: string;
  70426. componentProperty: string;
  70427. states: string[];
  70428. };
  70429. };
  70430. axes: {
  70431. "xr-standard-touchpad": {
  70432. "x-axis": {
  70433. rootNodeName: string;
  70434. };
  70435. "y-axis": {
  70436. rootNodeName: string;
  70437. };
  70438. };
  70439. "xr-standard-thumbstick": {
  70440. "x-axis": {
  70441. rootNodeName: string;
  70442. };
  70443. "y-axis": {
  70444. rootNodeName: string;
  70445. };
  70446. };
  70447. };
  70448. };
  70449. /**
  70450. * The base url used to load the left and right controller models
  70451. */
  70452. static MODEL_BASE_URL: string;
  70453. /**
  70454. * The name of the left controller model file
  70455. */
  70456. static MODEL_LEFT_FILENAME: string;
  70457. /**
  70458. * The name of the right controller model file
  70459. */
  70460. static MODEL_RIGHT_FILENAME: string;
  70461. profileId: string;
  70462. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70463. protected _getFilenameAndPath(): {
  70464. filename: string;
  70465. path: string;
  70466. };
  70467. protected _getModelLoadingConstraints(): boolean;
  70468. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70469. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70470. protected _updateModel(): void;
  70471. }
  70472. }
  70473. declare module BABYLON {
  70474. /**
  70475. * The motion controller class for oculus touch (quest, rift).
  70476. * This class supports legacy mapping as well the standard xr mapping
  70477. */
  70478. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70479. private _forceLegacyControllers;
  70480. private _modelRootNode;
  70481. /**
  70482. * The base url used to load the left and right controller models
  70483. */
  70484. static MODEL_BASE_URL: string;
  70485. /**
  70486. * The name of the left controller model file
  70487. */
  70488. static MODEL_LEFT_FILENAME: string;
  70489. /**
  70490. * The name of the right controller model file
  70491. */
  70492. static MODEL_RIGHT_FILENAME: string;
  70493. /**
  70494. * Base Url for the Quest controller model.
  70495. */
  70496. static QUEST_MODEL_BASE_URL: string;
  70497. profileId: string;
  70498. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70499. protected _getFilenameAndPath(): {
  70500. filename: string;
  70501. path: string;
  70502. };
  70503. protected _getModelLoadingConstraints(): boolean;
  70504. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70505. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70506. protected _updateModel(): void;
  70507. /**
  70508. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70509. * between the touch and touch 2.
  70510. */
  70511. private _isQuest;
  70512. }
  70513. }
  70514. declare module BABYLON {
  70515. /**
  70516. * The motion controller class for the standard HTC-Vive controllers
  70517. */
  70518. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70519. private _modelRootNode;
  70520. /**
  70521. * The base url used to load the left and right controller models
  70522. */
  70523. static MODEL_BASE_URL: string;
  70524. /**
  70525. * File name for the controller model.
  70526. */
  70527. static MODEL_FILENAME: string;
  70528. profileId: string;
  70529. /**
  70530. * Create a new Vive motion controller object
  70531. * @param scene the scene to use to create this controller
  70532. * @param gamepadObject the corresponding gamepad object
  70533. * @param handness the handness of the controller
  70534. */
  70535. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70536. protected _getFilenameAndPath(): {
  70537. filename: string;
  70538. path: string;
  70539. };
  70540. protected _getModelLoadingConstraints(): boolean;
  70541. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70542. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70543. protected _updateModel(): void;
  70544. }
  70545. }
  70546. declare module BABYLON {
  70547. /**
  70548. * A cursor which tracks a point on a path
  70549. */
  70550. export class PathCursor {
  70551. private path;
  70552. /**
  70553. * Stores path cursor callbacks for when an onchange event is triggered
  70554. */
  70555. private _onchange;
  70556. /**
  70557. * The value of the path cursor
  70558. */
  70559. value: number;
  70560. /**
  70561. * The animation array of the path cursor
  70562. */
  70563. animations: Animation[];
  70564. /**
  70565. * Initializes the path cursor
  70566. * @param path The path to track
  70567. */
  70568. constructor(path: Path2);
  70569. /**
  70570. * Gets the cursor point on the path
  70571. * @returns A point on the path cursor at the cursor location
  70572. */
  70573. getPoint(): Vector3;
  70574. /**
  70575. * Moves the cursor ahead by the step amount
  70576. * @param step The amount to move the cursor forward
  70577. * @returns This path cursor
  70578. */
  70579. moveAhead(step?: number): PathCursor;
  70580. /**
  70581. * Moves the cursor behind by the step amount
  70582. * @param step The amount to move the cursor back
  70583. * @returns This path cursor
  70584. */
  70585. moveBack(step?: number): PathCursor;
  70586. /**
  70587. * Moves the cursor by the step amount
  70588. * If the step amount is greater than one, an exception is thrown
  70589. * @param step The amount to move the cursor
  70590. * @returns This path cursor
  70591. */
  70592. move(step: number): PathCursor;
  70593. /**
  70594. * Ensures that the value is limited between zero and one
  70595. * @returns This path cursor
  70596. */
  70597. private ensureLimits;
  70598. /**
  70599. * Runs onchange callbacks on change (used by the animation engine)
  70600. * @returns This path cursor
  70601. */
  70602. private raiseOnChange;
  70603. /**
  70604. * Executes a function on change
  70605. * @param f A path cursor onchange callback
  70606. * @returns This path cursor
  70607. */
  70608. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70609. }
  70610. }
  70611. declare module BABYLON {
  70612. /** @hidden */
  70613. export var blurPixelShader: {
  70614. name: string;
  70615. shader: string;
  70616. };
  70617. }
  70618. declare module BABYLON {
  70619. /** @hidden */
  70620. export var pointCloudVertexDeclaration: {
  70621. name: string;
  70622. shader: string;
  70623. };
  70624. }
  70625. // Mixins
  70626. interface Window {
  70627. mozIndexedDB: IDBFactory;
  70628. webkitIndexedDB: IDBFactory;
  70629. msIndexedDB: IDBFactory;
  70630. webkitURL: typeof URL;
  70631. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70632. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70633. WebGLRenderingContext: WebGLRenderingContext;
  70634. MSGesture: MSGesture;
  70635. CANNON: any;
  70636. AudioContext: AudioContext;
  70637. webkitAudioContext: AudioContext;
  70638. PointerEvent: any;
  70639. Math: Math;
  70640. Uint8Array: Uint8ArrayConstructor;
  70641. Float32Array: Float32ArrayConstructor;
  70642. mozURL: typeof URL;
  70643. msURL: typeof URL;
  70644. VRFrameData: any; // WebVR, from specs 1.1
  70645. DracoDecoderModule: any;
  70646. setImmediate(handler: (...args: any[]) => void): number;
  70647. }
  70648. interface HTMLCanvasElement {
  70649. requestPointerLock(): void;
  70650. msRequestPointerLock?(): void;
  70651. mozRequestPointerLock?(): void;
  70652. webkitRequestPointerLock?(): void;
  70653. /** Track wether a record is in progress */
  70654. isRecording: boolean;
  70655. /** Capture Stream method defined by some browsers */
  70656. captureStream(fps?: number): MediaStream;
  70657. }
  70658. interface CanvasRenderingContext2D {
  70659. msImageSmoothingEnabled: boolean;
  70660. }
  70661. interface MouseEvent {
  70662. mozMovementX: number;
  70663. mozMovementY: number;
  70664. webkitMovementX: number;
  70665. webkitMovementY: number;
  70666. msMovementX: number;
  70667. msMovementY: number;
  70668. }
  70669. interface Navigator {
  70670. mozGetVRDevices: (any: any) => any;
  70671. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70672. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70673. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70674. webkitGetGamepads(): Gamepad[];
  70675. msGetGamepads(): Gamepad[];
  70676. webkitGamepads(): Gamepad[];
  70677. }
  70678. interface HTMLVideoElement {
  70679. mozSrcObject: any;
  70680. }
  70681. interface Math {
  70682. fround(x: number): number;
  70683. imul(a: number, b: number): number;
  70684. }
  70685. interface WebGLRenderingContext {
  70686. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70687. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70688. vertexAttribDivisor(index: number, divisor: number): void;
  70689. createVertexArray(): any;
  70690. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70691. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70692. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70693. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70694. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70695. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70696. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70697. // Queries
  70698. createQuery(): WebGLQuery;
  70699. deleteQuery(query: WebGLQuery): void;
  70700. beginQuery(target: number, query: WebGLQuery): void;
  70701. endQuery(target: number): void;
  70702. getQueryParameter(query: WebGLQuery, pname: number): any;
  70703. getQuery(target: number, pname: number): any;
  70704. MAX_SAMPLES: number;
  70705. RGBA8: number;
  70706. READ_FRAMEBUFFER: number;
  70707. DRAW_FRAMEBUFFER: number;
  70708. UNIFORM_BUFFER: number;
  70709. HALF_FLOAT_OES: number;
  70710. RGBA16F: number;
  70711. RGBA32F: number;
  70712. R32F: number;
  70713. RG32F: number;
  70714. RGB32F: number;
  70715. R16F: number;
  70716. RG16F: number;
  70717. RGB16F: number;
  70718. RED: number;
  70719. RG: number;
  70720. R8: number;
  70721. RG8: number;
  70722. UNSIGNED_INT_24_8: number;
  70723. DEPTH24_STENCIL8: number;
  70724. MIN: number;
  70725. MAX: number;
  70726. /* Multiple Render Targets */
  70727. drawBuffers(buffers: number[]): void;
  70728. readBuffer(src: number): void;
  70729. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70730. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70731. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70732. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70733. // Occlusion Query
  70734. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70735. ANY_SAMPLES_PASSED: number;
  70736. QUERY_RESULT_AVAILABLE: number;
  70737. QUERY_RESULT: number;
  70738. }
  70739. interface WebGLProgram {
  70740. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70741. }
  70742. interface EXT_disjoint_timer_query {
  70743. QUERY_COUNTER_BITS_EXT: number;
  70744. TIME_ELAPSED_EXT: number;
  70745. TIMESTAMP_EXT: number;
  70746. GPU_DISJOINT_EXT: number;
  70747. QUERY_RESULT_EXT: number;
  70748. QUERY_RESULT_AVAILABLE_EXT: number;
  70749. queryCounterEXT(query: WebGLQuery, target: number): void;
  70750. createQueryEXT(): WebGLQuery;
  70751. beginQueryEXT(target: number, query: WebGLQuery): void;
  70752. endQueryEXT(target: number): void;
  70753. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70754. deleteQueryEXT(query: WebGLQuery): void;
  70755. }
  70756. interface WebGLUniformLocation {
  70757. _currentState: any;
  70758. }
  70759. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70760. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70761. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70762. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70763. interface WebGLRenderingContext {
  70764. readonly RASTERIZER_DISCARD: number;
  70765. readonly DEPTH_COMPONENT24: number;
  70766. readonly TEXTURE_3D: number;
  70767. readonly TEXTURE_2D_ARRAY: number;
  70768. readonly TEXTURE_COMPARE_FUNC: number;
  70769. readonly TEXTURE_COMPARE_MODE: number;
  70770. readonly COMPARE_REF_TO_TEXTURE: number;
  70771. readonly TEXTURE_WRAP_R: number;
  70772. readonly HALF_FLOAT: number;
  70773. readonly RGB8: number;
  70774. readonly RED_INTEGER: number;
  70775. readonly RG_INTEGER: number;
  70776. readonly RGB_INTEGER: number;
  70777. readonly RGBA_INTEGER: number;
  70778. readonly R8_SNORM: number;
  70779. readonly RG8_SNORM: number;
  70780. readonly RGB8_SNORM: number;
  70781. readonly RGBA8_SNORM: number;
  70782. readonly R8I: number;
  70783. readonly RG8I: number;
  70784. readonly RGB8I: number;
  70785. readonly RGBA8I: number;
  70786. readonly R8UI: number;
  70787. readonly RG8UI: number;
  70788. readonly RGB8UI: number;
  70789. readonly RGBA8UI: number;
  70790. readonly R16I: number;
  70791. readonly RG16I: number;
  70792. readonly RGB16I: number;
  70793. readonly RGBA16I: number;
  70794. readonly R16UI: number;
  70795. readonly RG16UI: number;
  70796. readonly RGB16UI: number;
  70797. readonly RGBA16UI: number;
  70798. readonly R32I: number;
  70799. readonly RG32I: number;
  70800. readonly RGB32I: number;
  70801. readonly RGBA32I: number;
  70802. readonly R32UI: number;
  70803. readonly RG32UI: number;
  70804. readonly RGB32UI: number;
  70805. readonly RGBA32UI: number;
  70806. readonly RGB10_A2UI: number;
  70807. readonly R11F_G11F_B10F: number;
  70808. readonly RGB9_E5: number;
  70809. readonly RGB10_A2: number;
  70810. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70811. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70812. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70813. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70814. readonly DEPTH_COMPONENT32F: number;
  70815. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70816. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70817. 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;
  70818. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70819. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70820. readonly TRANSFORM_FEEDBACK: number;
  70821. readonly INTERLEAVED_ATTRIBS: number;
  70822. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70823. createTransformFeedback(): WebGLTransformFeedback;
  70824. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70825. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70826. beginTransformFeedback(primitiveMode: number): void;
  70827. endTransformFeedback(): void;
  70828. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70829. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70830. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70831. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70832. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70833. }
  70834. interface ImageBitmap {
  70835. readonly width: number;
  70836. readonly height: number;
  70837. close(): void;
  70838. }
  70839. interface WebGLQuery extends WebGLObject {
  70840. }
  70841. declare var WebGLQuery: {
  70842. prototype: WebGLQuery;
  70843. new(): WebGLQuery;
  70844. };
  70845. interface WebGLSampler extends WebGLObject {
  70846. }
  70847. declare var WebGLSampler: {
  70848. prototype: WebGLSampler;
  70849. new(): WebGLSampler;
  70850. };
  70851. interface WebGLSync extends WebGLObject {
  70852. }
  70853. declare var WebGLSync: {
  70854. prototype: WebGLSync;
  70855. new(): WebGLSync;
  70856. };
  70857. interface WebGLTransformFeedback extends WebGLObject {
  70858. }
  70859. declare var WebGLTransformFeedback: {
  70860. prototype: WebGLTransformFeedback;
  70861. new(): WebGLTransformFeedback;
  70862. };
  70863. interface WebGLVertexArrayObject extends WebGLObject {
  70864. }
  70865. declare var WebGLVertexArrayObject: {
  70866. prototype: WebGLVertexArrayObject;
  70867. new(): WebGLVertexArrayObject;
  70868. };
  70869. // Type definitions for WebVR API
  70870. // Project: https://w3c.github.io/webvr/
  70871. // Definitions by: six a <https://github.com/lostfictions>
  70872. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70873. interface VRDisplay extends EventTarget {
  70874. /**
  70875. * Dictionary of capabilities describing the VRDisplay.
  70876. */
  70877. readonly capabilities: VRDisplayCapabilities;
  70878. /**
  70879. * z-depth defining the far plane of the eye view frustum
  70880. * enables mapping of values in the render target depth
  70881. * attachment to scene coordinates. Initially set to 10000.0.
  70882. */
  70883. depthFar: number;
  70884. /**
  70885. * z-depth defining the near plane of the eye view frustum
  70886. * enables mapping of values in the render target depth
  70887. * attachment to scene coordinates. Initially set to 0.01.
  70888. */
  70889. depthNear: number;
  70890. /**
  70891. * An identifier for this distinct VRDisplay. Used as an
  70892. * association point in the Gamepad API.
  70893. */
  70894. readonly displayId: number;
  70895. /**
  70896. * A display name, a user-readable name identifying it.
  70897. */
  70898. readonly displayName: string;
  70899. readonly isConnected: boolean;
  70900. readonly isPresenting: boolean;
  70901. /**
  70902. * If this VRDisplay supports room-scale experiences, the optional
  70903. * stage attribute contains details on the room-scale parameters.
  70904. */
  70905. readonly stageParameters: VRStageParameters | null;
  70906. /**
  70907. * Passing the value returned by `requestAnimationFrame` to
  70908. * `cancelAnimationFrame` will unregister the callback.
  70909. * @param handle Define the hanle of the request to cancel
  70910. */
  70911. cancelAnimationFrame(handle: number): void;
  70912. /**
  70913. * Stops presenting to the VRDisplay.
  70914. * @returns a promise to know when it stopped
  70915. */
  70916. exitPresent(): Promise<void>;
  70917. /**
  70918. * Return the current VREyeParameters for the given eye.
  70919. * @param whichEye Define the eye we want the parameter for
  70920. * @returns the eye parameters
  70921. */
  70922. getEyeParameters(whichEye: string): VREyeParameters;
  70923. /**
  70924. * Populates the passed VRFrameData with the information required to render
  70925. * the current frame.
  70926. * @param frameData Define the data structure to populate
  70927. * @returns true if ok otherwise false
  70928. */
  70929. getFrameData(frameData: VRFrameData): boolean;
  70930. /**
  70931. * Get the layers currently being presented.
  70932. * @returns the list of VR layers
  70933. */
  70934. getLayers(): VRLayer[];
  70935. /**
  70936. * Return a VRPose containing the future predicted pose of the VRDisplay
  70937. * when the current frame will be presented. The value returned will not
  70938. * change until JavaScript has returned control to the browser.
  70939. *
  70940. * The VRPose will contain the position, orientation, velocity,
  70941. * and acceleration of each of these properties.
  70942. * @returns the pose object
  70943. */
  70944. getPose(): VRPose;
  70945. /**
  70946. * Return the current instantaneous pose of the VRDisplay, with no
  70947. * prediction applied.
  70948. * @returns the current instantaneous pose
  70949. */
  70950. getImmediatePose(): VRPose;
  70951. /**
  70952. * The callback passed to `requestAnimationFrame` will be called
  70953. * any time a new frame should be rendered. When the VRDisplay is
  70954. * presenting the callback will be called at the native refresh
  70955. * rate of the HMD. When not presenting this function acts
  70956. * identically to how window.requestAnimationFrame acts. Content should
  70957. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70958. * asynchronously from other displays and at differing refresh rates.
  70959. * @param callback Define the eaction to run next frame
  70960. * @returns the request handle it
  70961. */
  70962. requestAnimationFrame(callback: FrameRequestCallback): number;
  70963. /**
  70964. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70965. * Repeat calls while already presenting will update the VRLayers being displayed.
  70966. * @param layers Define the list of layer to present
  70967. * @returns a promise to know when the request has been fulfilled
  70968. */
  70969. requestPresent(layers: VRLayer[]): Promise<void>;
  70970. /**
  70971. * Reset the pose for this display, treating its current position and
  70972. * orientation as the "origin/zero" values. VRPose.position,
  70973. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70974. * updated when calling resetPose(). This should be called in only
  70975. * sitting-space experiences.
  70976. */
  70977. resetPose(): void;
  70978. /**
  70979. * The VRLayer provided to the VRDisplay will be captured and presented
  70980. * in the HMD. Calling this function has the same effect on the source
  70981. * canvas as any other operation that uses its source image, and canvases
  70982. * created without preserveDrawingBuffer set to true will be cleared.
  70983. * @param pose Define the pose to submit
  70984. */
  70985. submitFrame(pose?: VRPose): void;
  70986. }
  70987. declare var VRDisplay: {
  70988. prototype: VRDisplay;
  70989. new(): VRDisplay;
  70990. };
  70991. interface VRLayer {
  70992. leftBounds?: number[] | Float32Array | null;
  70993. rightBounds?: number[] | Float32Array | null;
  70994. source?: HTMLCanvasElement | null;
  70995. }
  70996. interface VRDisplayCapabilities {
  70997. readonly canPresent: boolean;
  70998. readonly hasExternalDisplay: boolean;
  70999. readonly hasOrientation: boolean;
  71000. readonly hasPosition: boolean;
  71001. readonly maxLayers: number;
  71002. }
  71003. interface VREyeParameters {
  71004. /** @deprecated */
  71005. readonly fieldOfView: VRFieldOfView;
  71006. readonly offset: Float32Array;
  71007. readonly renderHeight: number;
  71008. readonly renderWidth: number;
  71009. }
  71010. interface VRFieldOfView {
  71011. readonly downDegrees: number;
  71012. readonly leftDegrees: number;
  71013. readonly rightDegrees: number;
  71014. readonly upDegrees: number;
  71015. }
  71016. interface VRFrameData {
  71017. readonly leftProjectionMatrix: Float32Array;
  71018. readonly leftViewMatrix: Float32Array;
  71019. readonly pose: VRPose;
  71020. readonly rightProjectionMatrix: Float32Array;
  71021. readonly rightViewMatrix: Float32Array;
  71022. readonly timestamp: number;
  71023. }
  71024. interface VRPose {
  71025. readonly angularAcceleration: Float32Array | null;
  71026. readonly angularVelocity: Float32Array | null;
  71027. readonly linearAcceleration: Float32Array | null;
  71028. readonly linearVelocity: Float32Array | null;
  71029. readonly orientation: Float32Array | null;
  71030. readonly position: Float32Array | null;
  71031. readonly timestamp: number;
  71032. }
  71033. interface VRStageParameters {
  71034. sittingToStandingTransform?: Float32Array;
  71035. sizeX?: number;
  71036. sizeY?: number;
  71037. }
  71038. interface Navigator {
  71039. getVRDisplays(): Promise<VRDisplay[]>;
  71040. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  71041. }
  71042. interface Window {
  71043. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  71044. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  71045. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  71046. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  71047. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  71048. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  71049. }
  71050. interface Gamepad {
  71051. readonly displayId: number;
  71052. }
  71053. type XRSessionMode =
  71054. | "inline"
  71055. | "immersive-vr"
  71056. | "immersive-ar";
  71057. type XRReferenceSpaceType =
  71058. | "viewer"
  71059. | "local"
  71060. | "local-floor"
  71061. | "bounded-floor"
  71062. | "unbounded";
  71063. type XREnvironmentBlendMode =
  71064. | "opaque"
  71065. | "additive"
  71066. | "alpha-blend";
  71067. type XRVisibilityState =
  71068. | "visible"
  71069. | "visible-blurred"
  71070. | "hidden";
  71071. type XRHandedness =
  71072. | "none"
  71073. | "left"
  71074. | "right";
  71075. type XRTargetRayMode =
  71076. | "gaze"
  71077. | "tracked-pointer"
  71078. | "screen";
  71079. type XREye =
  71080. | "none"
  71081. | "left"
  71082. | "right";
  71083. type XREventType =
  71084. | "devicechange"
  71085. | "visibilitychange"
  71086. | "end"
  71087. | "inputsourceschange"
  71088. | "select"
  71089. | "selectstart"
  71090. | "selectend"
  71091. | "squeeze"
  71092. | "squeezestart"
  71093. | "squeezeend"
  71094. | "reset";
  71095. interface XRSpace extends EventTarget {
  71096. }
  71097. interface XRRenderState {
  71098. depthNear?: number;
  71099. depthFar?: number;
  71100. inlineVerticalFieldOfView?: number;
  71101. baseLayer?: XRWebGLLayer;
  71102. }
  71103. interface XRInputSource {
  71104. handedness: XRHandedness;
  71105. targetRayMode: XRTargetRayMode;
  71106. targetRaySpace: XRSpace;
  71107. gripSpace: XRSpace | undefined;
  71108. gamepad: Gamepad | undefined;
  71109. profiles: Array<string>;
  71110. }
  71111. interface XRSessionInit {
  71112. optionalFeatures?: XRReferenceSpaceType[];
  71113. requiredFeatures?: XRReferenceSpaceType[];
  71114. }
  71115. interface XRSession extends XRAnchorCreator {
  71116. addEventListener: Function;
  71117. removeEventListener: Function;
  71118. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  71119. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  71120. requestAnimationFrame: Function;
  71121. end(): Promise<void>;
  71122. renderState: XRRenderState;
  71123. inputSources: Array<XRInputSource>;
  71124. // hit test
  71125. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  71126. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  71127. // legacy AR hit test
  71128. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  71129. // legacy plane detection
  71130. updateWorldTrackingState(options: {
  71131. planeDetectionState?: { enabled: boolean; }
  71132. }): void;
  71133. }
  71134. interface XRReferenceSpace extends XRSpace {
  71135. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  71136. onreset: any;
  71137. }
  71138. type XRPlaneSet = Set<XRPlane>;
  71139. type XRAnchorSet = Set<XRAnchor>;
  71140. interface XRFrame {
  71141. session: XRSession;
  71142. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  71143. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  71144. // AR
  71145. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  71146. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  71147. // Anchors
  71148. trackedAnchors?: XRAnchorSet;
  71149. // Planes
  71150. worldInformation: {
  71151. detectedPlanes?: XRPlaneSet;
  71152. };
  71153. }
  71154. interface XRViewerPose extends XRPose {
  71155. views: Array<XRView>;
  71156. }
  71157. interface XRPose {
  71158. transform: XRRigidTransform;
  71159. emulatedPosition: boolean;
  71160. }
  71161. interface XRWebGLLayerOptions {
  71162. antialias?: boolean;
  71163. depth?: boolean;
  71164. stencil?: boolean;
  71165. alpha?: boolean;
  71166. multiview?: boolean;
  71167. framebufferScaleFactor?: number;
  71168. }
  71169. declare var XRWebGLLayer: {
  71170. prototype: XRWebGLLayer;
  71171. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  71172. };
  71173. interface XRWebGLLayer {
  71174. framebuffer: WebGLFramebuffer;
  71175. framebufferWidth: number;
  71176. framebufferHeight: number;
  71177. getViewport: Function;
  71178. }
  71179. declare class XRRigidTransform {
  71180. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  71181. position: DOMPointReadOnly;
  71182. orientation: DOMPointReadOnly;
  71183. matrix: Float32Array;
  71184. inverse: XRRigidTransform;
  71185. }
  71186. interface XRView {
  71187. eye: XREye;
  71188. projectionMatrix: Float32Array;
  71189. transform: XRRigidTransform;
  71190. }
  71191. interface XRInputSourceChangeEvent {
  71192. session: XRSession;
  71193. removed: Array<XRInputSource>;
  71194. added: Array<XRInputSource>;
  71195. }
  71196. interface XRInputSourceEvent extends Event {
  71197. readonly frame: XRFrame;
  71198. readonly inputSource: XRInputSource;
  71199. }
  71200. // Experimental(er) features
  71201. declare class XRRay {
  71202. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  71203. origin: DOMPointReadOnly;
  71204. direction: DOMPointReadOnly;
  71205. matrix: Float32Array;
  71206. }
  71207. declare enum XRHitTestTrackableType {
  71208. "point",
  71209. "plane"
  71210. }
  71211. interface XRHitResult {
  71212. hitMatrix: Float32Array;
  71213. }
  71214. interface XRTransientInputHitTestResult {
  71215. readonly inputSource: XRInputSource;
  71216. readonly results: Array<XRHitTestResult>;
  71217. }
  71218. interface XRHitTestResult {
  71219. getPose(baseSpace: XRSpace): XRPose | undefined;
  71220. }
  71221. interface XRHitTestSource {
  71222. cancel(): void;
  71223. }
  71224. interface XRTransientInputHitTestSource {
  71225. cancel(): void;
  71226. }
  71227. interface XRHitTestOptionsInit {
  71228. space: XRSpace;
  71229. entityTypes?: Array<XRHitTestTrackableType>;
  71230. offsetRay?: XRRay;
  71231. }
  71232. interface XRTransientInputHitTestOptionsInit {
  71233. profile: string;
  71234. entityTypes?: Array<XRHitTestTrackableType>;
  71235. offsetRay?: XRRay;
  71236. }
  71237. interface XRAnchor {
  71238. // remove?
  71239. id?: string;
  71240. anchorSpace: XRSpace;
  71241. lastChangedTime: number;
  71242. detach(): void;
  71243. }
  71244. interface XRPlane extends XRAnchorCreator {
  71245. orientation: "Horizontal" | "Vertical";
  71246. planeSpace: XRSpace;
  71247. polygon: Array<DOMPointReadOnly>;
  71248. lastChangedTime: number;
  71249. }
  71250. interface XRAnchorCreator {
  71251. // AR Anchors
  71252. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71253. }
  71254. /**
  71255. * @ignore
  71256. */
  71257. declare module BABYLON.GLTF2.Exporter {
  71258. }
  71259. /**
  71260. * @ignore
  71261. */
  71262. declare module BABYLON.GLTF1 {
  71263. }
  71264. declare module BABYLON.GUI {
  71265. /**
  71266. * Class used to specific a value and its associated unit
  71267. */
  71268. export class ValueAndUnit {
  71269. /** defines the unit to store */
  71270. unit: number;
  71271. /** defines a boolean indicating if the value can be negative */
  71272. negativeValueAllowed: boolean;
  71273. private _value;
  71274. private _originalUnit;
  71275. /**
  71276. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  71277. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71278. */
  71279. ignoreAdaptiveScaling: boolean;
  71280. /**
  71281. * Creates a new ValueAndUnit
  71282. * @param value defines the value to store
  71283. * @param unit defines the unit to store
  71284. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  71285. */
  71286. constructor(value: number,
  71287. /** defines the unit to store */
  71288. unit?: number,
  71289. /** defines a boolean indicating if the value can be negative */
  71290. negativeValueAllowed?: boolean);
  71291. /** Gets a boolean indicating if the value is a percentage */
  71292. get isPercentage(): boolean;
  71293. /** Gets a boolean indicating if the value is store as pixel */
  71294. get isPixel(): boolean;
  71295. /** Gets direct internal value */
  71296. get internalValue(): number;
  71297. /**
  71298. * Gets value as pixel
  71299. * @param host defines the root host
  71300. * @param refValue defines the reference value for percentages
  71301. * @returns the value as pixel
  71302. */
  71303. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  71304. /**
  71305. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  71306. * @param value defines the value to store
  71307. * @param unit defines the unit to store
  71308. * @returns the current ValueAndUnit
  71309. */
  71310. updateInPlace(value: number, unit?: number): ValueAndUnit;
  71311. /**
  71312. * Gets the value accordingly to its unit
  71313. * @param host defines the root host
  71314. * @returns the value
  71315. */
  71316. getValue(host: AdvancedDynamicTexture): number;
  71317. /**
  71318. * Gets a string representation of the value
  71319. * @param host defines the root host
  71320. * @param decimals defines an optional number of decimals to display
  71321. * @returns a string
  71322. */
  71323. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  71324. /**
  71325. * Store a value parsed from a string
  71326. * @param source defines the source string
  71327. * @returns true if the value was successfully parsed
  71328. */
  71329. fromString(source: string | number): boolean;
  71330. private static _Regex;
  71331. private static _UNITMODE_PERCENTAGE;
  71332. private static _UNITMODE_PIXEL;
  71333. /** UNITMODE_PERCENTAGE */
  71334. static get UNITMODE_PERCENTAGE(): number;
  71335. /** UNITMODE_PIXEL */
  71336. static get UNITMODE_PIXEL(): number;
  71337. }
  71338. }
  71339. declare module BABYLON.GUI {
  71340. /**
  71341. * Define a style used by control to automatically setup properties based on a template.
  71342. * Only support font related properties so far
  71343. */
  71344. export class Style implements BABYLON.IDisposable {
  71345. private _fontFamily;
  71346. private _fontStyle;
  71347. private _fontWeight;
  71348. /** @hidden */
  71349. _host: AdvancedDynamicTexture;
  71350. /** @hidden */
  71351. _fontSize: ValueAndUnit;
  71352. /**
  71353. * BABYLON.Observable raised when the style values are changed
  71354. */
  71355. onChangedObservable: BABYLON.Observable<Style>;
  71356. /**
  71357. * Creates a new style object
  71358. * @param host defines the AdvancedDynamicTexture which hosts this style
  71359. */
  71360. constructor(host: AdvancedDynamicTexture);
  71361. /**
  71362. * Gets or sets the font size
  71363. */
  71364. get fontSize(): string | number;
  71365. set fontSize(value: string | number);
  71366. /**
  71367. * Gets or sets the font family
  71368. */
  71369. get fontFamily(): string;
  71370. set fontFamily(value: string);
  71371. /**
  71372. * Gets or sets the font style
  71373. */
  71374. get fontStyle(): string;
  71375. set fontStyle(value: string);
  71376. /** Gets or sets font weight */
  71377. get fontWeight(): string;
  71378. set fontWeight(value: string);
  71379. /** Dispose all associated resources */
  71380. dispose(): void;
  71381. }
  71382. }
  71383. declare module BABYLON.GUI {
  71384. /**
  71385. * Class used to transport BABYLON.Vector2 information for pointer events
  71386. */
  71387. export class Vector2WithInfo extends BABYLON.Vector2 {
  71388. /** defines the current mouse button index */
  71389. buttonIndex: number;
  71390. /**
  71391. * Creates a new Vector2WithInfo
  71392. * @param source defines the vector2 data to transport
  71393. * @param buttonIndex defines the current mouse button index
  71394. */
  71395. constructor(source: BABYLON.Vector2,
  71396. /** defines the current mouse button index */
  71397. buttonIndex?: number);
  71398. }
  71399. /** Class used to provide 2D matrix features */
  71400. export class Matrix2D {
  71401. /** Gets the internal array of 6 floats used to store matrix data */
  71402. m: Float32Array;
  71403. /**
  71404. * Creates a new matrix
  71405. * @param m00 defines value for (0, 0)
  71406. * @param m01 defines value for (0, 1)
  71407. * @param m10 defines value for (1, 0)
  71408. * @param m11 defines value for (1, 1)
  71409. * @param m20 defines value for (2, 0)
  71410. * @param m21 defines value for (2, 1)
  71411. */
  71412. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  71413. /**
  71414. * Fills the matrix from direct values
  71415. * @param m00 defines value for (0, 0)
  71416. * @param m01 defines value for (0, 1)
  71417. * @param m10 defines value for (1, 0)
  71418. * @param m11 defines value for (1, 1)
  71419. * @param m20 defines value for (2, 0)
  71420. * @param m21 defines value for (2, 1)
  71421. * @returns the current modified matrix
  71422. */
  71423. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  71424. /**
  71425. * Gets matrix determinant
  71426. * @returns the determinant
  71427. */
  71428. determinant(): number;
  71429. /**
  71430. * Inverses the matrix and stores it in a target matrix
  71431. * @param result defines the target matrix
  71432. * @returns the current matrix
  71433. */
  71434. invertToRef(result: Matrix2D): Matrix2D;
  71435. /**
  71436. * Multiplies the current matrix with another one
  71437. * @param other defines the second operand
  71438. * @param result defines the target matrix
  71439. * @returns the current matrix
  71440. */
  71441. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71442. /**
  71443. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71444. * @param x defines the x coordinate to transform
  71445. * @param y defines the x coordinate to transform
  71446. * @param result defines the target vector2
  71447. * @returns the current matrix
  71448. */
  71449. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71450. /**
  71451. * Creates an identity matrix
  71452. * @returns a new matrix
  71453. */
  71454. static Identity(): Matrix2D;
  71455. /**
  71456. * Creates a translation matrix and stores it in a target matrix
  71457. * @param x defines the x coordinate of the translation
  71458. * @param y defines the y coordinate of the translation
  71459. * @param result defines the target matrix
  71460. */
  71461. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71462. /**
  71463. * Creates a scaling matrix and stores it in a target matrix
  71464. * @param x defines the x coordinate of the scaling
  71465. * @param y defines the y coordinate of the scaling
  71466. * @param result defines the target matrix
  71467. */
  71468. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71469. /**
  71470. * Creates a rotation matrix and stores it in a target matrix
  71471. * @param angle defines the rotation angle
  71472. * @param result defines the target matrix
  71473. */
  71474. static RotationToRef(angle: number, result: Matrix2D): void;
  71475. private static _TempPreTranslationMatrix;
  71476. private static _TempPostTranslationMatrix;
  71477. private static _TempRotationMatrix;
  71478. private static _TempScalingMatrix;
  71479. private static _TempCompose0;
  71480. private static _TempCompose1;
  71481. private static _TempCompose2;
  71482. /**
  71483. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71484. * @param tx defines the x coordinate of the translation
  71485. * @param ty defines the y coordinate of the translation
  71486. * @param angle defines the rotation angle
  71487. * @param scaleX defines the x coordinate of the scaling
  71488. * @param scaleY defines the y coordinate of the scaling
  71489. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71490. * @param result defines the target matrix
  71491. */
  71492. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71493. }
  71494. }
  71495. declare module BABYLON.GUI {
  71496. /**
  71497. * Class used to store 2D control sizes
  71498. */
  71499. export class Measure {
  71500. /** defines left coordinate */
  71501. left: number;
  71502. /** defines top coordinate */
  71503. top: number;
  71504. /** defines width dimension */
  71505. width: number;
  71506. /** defines height dimension */
  71507. height: number;
  71508. /**
  71509. * Creates a new measure
  71510. * @param left defines left coordinate
  71511. * @param top defines top coordinate
  71512. * @param width defines width dimension
  71513. * @param height defines height dimension
  71514. */
  71515. constructor(
  71516. /** defines left coordinate */
  71517. left: number,
  71518. /** defines top coordinate */
  71519. top: number,
  71520. /** defines width dimension */
  71521. width: number,
  71522. /** defines height dimension */
  71523. height: number);
  71524. /**
  71525. * Copy from another measure
  71526. * @param other defines the other measure to copy from
  71527. */
  71528. copyFrom(other: Measure): void;
  71529. /**
  71530. * Copy from a group of 4 floats
  71531. * @param left defines left coordinate
  71532. * @param top defines top coordinate
  71533. * @param width defines width dimension
  71534. * @param height defines height dimension
  71535. */
  71536. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71537. /**
  71538. * Computes the axis aligned bounding box measure for two given measures
  71539. * @param a Input measure
  71540. * @param b Input measure
  71541. * @param result the resulting bounding measure
  71542. */
  71543. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71544. /**
  71545. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71546. * @param transform the matrix to transform the measure before computing the AABB
  71547. * @param result the resulting AABB
  71548. */
  71549. transformToRef(transform: Matrix2D, result: Measure): void;
  71550. /**
  71551. * Check equality between this measure and another one
  71552. * @param other defines the other measures
  71553. * @returns true if both measures are equals
  71554. */
  71555. isEqualsTo(other: Measure): boolean;
  71556. /**
  71557. * Creates an empty measure
  71558. * @returns a new measure
  71559. */
  71560. static Empty(): Measure;
  71561. }
  71562. }
  71563. declare module BABYLON.GUI {
  71564. /**
  71565. * Interface used to define a control that can receive focus
  71566. */
  71567. export interface IFocusableControl {
  71568. /**
  71569. * Function called when the control receives the focus
  71570. */
  71571. onFocus(): void;
  71572. /**
  71573. * Function called when the control loses the focus
  71574. */
  71575. onBlur(): void;
  71576. /**
  71577. * Function called to let the control handle keyboard events
  71578. * @param evt defines the current keyboard event
  71579. */
  71580. processKeyboard(evt: KeyboardEvent): void;
  71581. /**
  71582. * Function called to get the list of controls that should not steal the focus from this control
  71583. * @returns an array of controls
  71584. */
  71585. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71586. }
  71587. /**
  71588. * Class used to create texture to support 2D GUI elements
  71589. * @see http://doc.babylonjs.com/how_to/gui
  71590. */
  71591. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71592. private _isDirty;
  71593. private _renderObserver;
  71594. private _resizeObserver;
  71595. private _preKeyboardObserver;
  71596. private _pointerMoveObserver;
  71597. private _pointerObserver;
  71598. private _canvasPointerOutObserver;
  71599. private _background;
  71600. /** @hidden */
  71601. _rootContainer: Container;
  71602. /** @hidden */
  71603. _lastPickedControl: Control;
  71604. /** @hidden */
  71605. _lastControlOver: {
  71606. [pointerId: number]: Control;
  71607. };
  71608. /** @hidden */
  71609. _lastControlDown: {
  71610. [pointerId: number]: Control;
  71611. };
  71612. /** @hidden */
  71613. _capturingControl: {
  71614. [pointerId: number]: Control;
  71615. };
  71616. /** @hidden */
  71617. _shouldBlockPointer: boolean;
  71618. /** @hidden */
  71619. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71620. /** @hidden */
  71621. _linkedControls: Control[];
  71622. private _isFullscreen;
  71623. private _fullscreenViewport;
  71624. private _idealWidth;
  71625. private _idealHeight;
  71626. private _useSmallestIdeal;
  71627. private _renderAtIdealSize;
  71628. private _focusedControl;
  71629. private _blockNextFocusCheck;
  71630. private _renderScale;
  71631. private _rootElement;
  71632. private _cursorChanged;
  71633. private _defaultMousePointerId;
  71634. /** @hidden */
  71635. _numLayoutCalls: number;
  71636. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71637. get numLayoutCalls(): number;
  71638. /** @hidden */
  71639. _numRenderCalls: number;
  71640. /** Gets the number of render calls made the last time the ADT has been rendered */
  71641. get numRenderCalls(): number;
  71642. /**
  71643. * Define type to string to ensure compatibility across browsers
  71644. * Safari doesn't support DataTransfer constructor
  71645. */
  71646. private _clipboardData;
  71647. /**
  71648. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71649. */
  71650. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71651. /**
  71652. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71653. */
  71654. onControlPickedObservable: BABYLON.Observable<Control>;
  71655. /**
  71656. * BABYLON.Observable event triggered before layout is evaluated
  71657. */
  71658. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71659. /**
  71660. * BABYLON.Observable event triggered after the layout was evaluated
  71661. */
  71662. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71663. /**
  71664. * BABYLON.Observable event triggered before the texture is rendered
  71665. */
  71666. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71667. /**
  71668. * BABYLON.Observable event triggered after the texture was rendered
  71669. */
  71670. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71671. /**
  71672. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71673. */
  71674. premulAlpha: boolean;
  71675. /**
  71676. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71677. * Useful when you want more antialiasing
  71678. */
  71679. get renderScale(): number;
  71680. set renderScale(value: number);
  71681. /** Gets or sets the background color */
  71682. get background(): string;
  71683. set background(value: string);
  71684. /**
  71685. * Gets or sets the ideal width used to design controls.
  71686. * The GUI will then rescale everything accordingly
  71687. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71688. */
  71689. get idealWidth(): number;
  71690. set idealWidth(value: number);
  71691. /**
  71692. * Gets or sets the ideal height used to design controls.
  71693. * The GUI will then rescale everything accordingly
  71694. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71695. */
  71696. get idealHeight(): number;
  71697. set idealHeight(value: number);
  71698. /**
  71699. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71700. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71701. */
  71702. get useSmallestIdeal(): boolean;
  71703. set useSmallestIdeal(value: boolean);
  71704. /**
  71705. * Gets or sets a boolean indicating if adaptive scaling must be used
  71706. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71707. */
  71708. get renderAtIdealSize(): boolean;
  71709. set renderAtIdealSize(value: boolean);
  71710. /**
  71711. * Gets the ratio used when in "ideal mode"
  71712. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71713. * */
  71714. get idealRatio(): number;
  71715. /**
  71716. * Gets the underlying layer used to render the texture when in fullscreen mode
  71717. */
  71718. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71719. /**
  71720. * Gets the root container control
  71721. */
  71722. get rootContainer(): Container;
  71723. /**
  71724. * Returns an array containing the root container.
  71725. * This is mostly used to let the Inspector introspects the ADT
  71726. * @returns an array containing the rootContainer
  71727. */
  71728. getChildren(): Array<Container>;
  71729. /**
  71730. * Will return all controls that are inside this texture
  71731. * @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
  71732. * @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
  71733. * @return all child controls
  71734. */
  71735. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71736. /**
  71737. * Gets or sets the current focused control
  71738. */
  71739. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71740. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71741. /**
  71742. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71743. */
  71744. get isForeground(): boolean;
  71745. set isForeground(value: boolean);
  71746. /**
  71747. * Gets or set information about clipboardData
  71748. */
  71749. get clipboardData(): string;
  71750. set clipboardData(value: string);
  71751. /**
  71752. * Creates a new AdvancedDynamicTexture
  71753. * @param name defines the name of the texture
  71754. * @param width defines the width of the texture
  71755. * @param height defines the height of the texture
  71756. * @param scene defines the hosting scene
  71757. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71758. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71759. */
  71760. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71761. /**
  71762. * Get the current class name of the texture useful for serialization or dynamic coding.
  71763. * @returns "AdvancedDynamicTexture"
  71764. */
  71765. getClassName(): string;
  71766. /**
  71767. * Function used to execute a function on all controls
  71768. * @param func defines the function to execute
  71769. * @param container defines the container where controls belong. If null the root container will be used
  71770. */
  71771. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71772. private _useInvalidateRectOptimization;
  71773. /**
  71774. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71775. */
  71776. get useInvalidateRectOptimization(): boolean;
  71777. set useInvalidateRectOptimization(value: boolean);
  71778. private _invalidatedRectangle;
  71779. /**
  71780. * Invalidates a rectangle area on the gui texture
  71781. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71782. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71783. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71784. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71785. */
  71786. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71787. /**
  71788. * Marks the texture as dirty forcing a complete update
  71789. */
  71790. markAsDirty(): void;
  71791. /**
  71792. * Helper function used to create a new style
  71793. * @returns a new style
  71794. * @see http://doc.babylonjs.com/how_to/gui#styles
  71795. */
  71796. createStyle(): Style;
  71797. /**
  71798. * Adds a new control to the root container
  71799. * @param control defines the control to add
  71800. * @returns the current texture
  71801. */
  71802. addControl(control: Control): AdvancedDynamicTexture;
  71803. /**
  71804. * Removes a control from the root container
  71805. * @param control defines the control to remove
  71806. * @returns the current texture
  71807. */
  71808. removeControl(control: Control): AdvancedDynamicTexture;
  71809. /**
  71810. * Release all resources
  71811. */
  71812. dispose(): void;
  71813. private _onResize;
  71814. /** @hidden */
  71815. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71816. /**
  71817. * Get screen coordinates for a vector3
  71818. * @param position defines the position to project
  71819. * @param worldMatrix defines the world matrix to use
  71820. * @returns the projected position
  71821. */
  71822. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71823. private _checkUpdate;
  71824. private _clearMeasure;
  71825. private _render;
  71826. /** @hidden */
  71827. _changeCursor(cursor: string): void;
  71828. /** @hidden */
  71829. _registerLastControlDown(control: Control, pointerId: number): void;
  71830. private _doPicking;
  71831. /** @hidden */
  71832. _cleanControlAfterRemovalFromList(list: {
  71833. [pointerId: number]: Control;
  71834. }, control: Control): void;
  71835. /** @hidden */
  71836. _cleanControlAfterRemoval(control: Control): void;
  71837. /** Attach to all scene events required to support pointer events */
  71838. attach(): void;
  71839. /** @hidden */
  71840. private onClipboardCopy;
  71841. /** @hidden */
  71842. private onClipboardCut;
  71843. /** @hidden */
  71844. private onClipboardPaste;
  71845. /**
  71846. * Register the clipboard Events onto the canvas
  71847. */
  71848. registerClipboardEvents(): void;
  71849. /**
  71850. * Unregister the clipboard Events from the canvas
  71851. */
  71852. unRegisterClipboardEvents(): void;
  71853. /**
  71854. * Connect the texture to a hosting mesh to enable interactions
  71855. * @param mesh defines the mesh to attach to
  71856. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71857. */
  71858. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71859. /**
  71860. * Move the focus to a specific control
  71861. * @param control defines the control which will receive the focus
  71862. */
  71863. moveFocusToControl(control: IFocusableControl): void;
  71864. private _manageFocus;
  71865. private _attachToOnPointerOut;
  71866. /**
  71867. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71868. * @param mesh defines the mesh which will receive the texture
  71869. * @param width defines the texture width (1024 by default)
  71870. * @param height defines the texture height (1024 by default)
  71871. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71872. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71873. * @returns a new AdvancedDynamicTexture
  71874. */
  71875. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71876. /**
  71877. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71878. * In this mode the texture will rely on a layer for its rendering.
  71879. * This allows it to be treated like any other layer.
  71880. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71881. * LayerMask is set through advancedTexture.layer.layerMask
  71882. * @param name defines name for the texture
  71883. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71884. * @param scene defines the hsoting scene
  71885. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71886. * @returns a new AdvancedDynamicTexture
  71887. */
  71888. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71889. }
  71890. }
  71891. declare module BABYLON.GUI {
  71892. /**
  71893. * Root class used for all 2D controls
  71894. * @see http://doc.babylonjs.com/how_to/gui#controls
  71895. */
  71896. export class Control {
  71897. /** defines the name of the control */
  71898. name?: string | undefined;
  71899. /**
  71900. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71901. */
  71902. static AllowAlphaInheritance: boolean;
  71903. private _alpha;
  71904. private _alphaSet;
  71905. private _zIndex;
  71906. /** @hidden */
  71907. _host: AdvancedDynamicTexture;
  71908. /** Gets or sets the control parent */
  71909. parent: BABYLON.Nullable<Container>;
  71910. /** @hidden */
  71911. _currentMeasure: Measure;
  71912. private _fontFamily;
  71913. private _fontStyle;
  71914. private _fontWeight;
  71915. private _fontSize;
  71916. private _font;
  71917. /** @hidden */
  71918. _width: ValueAndUnit;
  71919. /** @hidden */
  71920. _height: ValueAndUnit;
  71921. /** @hidden */
  71922. protected _fontOffset: {
  71923. ascent: number;
  71924. height: number;
  71925. descent: number;
  71926. };
  71927. private _color;
  71928. private _style;
  71929. private _styleObserver;
  71930. /** @hidden */
  71931. protected _horizontalAlignment: number;
  71932. /** @hidden */
  71933. protected _verticalAlignment: number;
  71934. /** @hidden */
  71935. protected _isDirty: boolean;
  71936. /** @hidden */
  71937. protected _wasDirty: boolean;
  71938. /** @hidden */
  71939. _tempParentMeasure: Measure;
  71940. /** @hidden */
  71941. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71942. /** @hidden */
  71943. protected _cachedParentMeasure: Measure;
  71944. private _paddingLeft;
  71945. private _paddingRight;
  71946. private _paddingTop;
  71947. private _paddingBottom;
  71948. /** @hidden */
  71949. _left: ValueAndUnit;
  71950. /** @hidden */
  71951. _top: ValueAndUnit;
  71952. private _scaleX;
  71953. private _scaleY;
  71954. private _rotation;
  71955. private _transformCenterX;
  71956. private _transformCenterY;
  71957. /** @hidden */
  71958. _transformMatrix: Matrix2D;
  71959. /** @hidden */
  71960. protected _invertTransformMatrix: Matrix2D;
  71961. /** @hidden */
  71962. protected _transformedPosition: BABYLON.Vector2;
  71963. private _isMatrixDirty;
  71964. private _cachedOffsetX;
  71965. private _cachedOffsetY;
  71966. private _isVisible;
  71967. private _isHighlighted;
  71968. /** @hidden */
  71969. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71970. private _fontSet;
  71971. private _dummyVector2;
  71972. private _downCount;
  71973. private _enterCount;
  71974. private _doNotRender;
  71975. private _downPointerIds;
  71976. protected _isEnabled: boolean;
  71977. protected _disabledColor: string;
  71978. protected _disabledColorItem: string;
  71979. /** @hidden */
  71980. protected _rebuildLayout: boolean;
  71981. /** @hidden */
  71982. _customData: any;
  71983. /** @hidden */
  71984. _isClipped: boolean;
  71985. /** @hidden */
  71986. _automaticSize: boolean;
  71987. /** @hidden */
  71988. _tag: any;
  71989. /**
  71990. * 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
  71991. */
  71992. uniqueId: number;
  71993. /**
  71994. * Gets or sets an object used to store user defined information for the node
  71995. */
  71996. metadata: any;
  71997. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71998. isHitTestVisible: boolean;
  71999. /** Gets or sets a boolean indicating if the control can block pointer events */
  72000. isPointerBlocker: boolean;
  72001. /** Gets or sets a boolean indicating if the control can be focusable */
  72002. isFocusInvisible: boolean;
  72003. /**
  72004. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  72005. * 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
  72006. */
  72007. clipChildren: boolean;
  72008. /**
  72009. * Gets or sets a boolean indicating that control content must be clipped
  72010. * 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
  72011. */
  72012. clipContent: boolean;
  72013. /**
  72014. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  72015. */
  72016. useBitmapCache: boolean;
  72017. private _cacheData;
  72018. private _shadowOffsetX;
  72019. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  72020. get shadowOffsetX(): number;
  72021. set shadowOffsetX(value: number);
  72022. private _shadowOffsetY;
  72023. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  72024. get shadowOffsetY(): number;
  72025. set shadowOffsetY(value: number);
  72026. private _shadowBlur;
  72027. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  72028. get shadowBlur(): number;
  72029. set shadowBlur(value: number);
  72030. private _shadowColor;
  72031. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  72032. get shadowColor(): string;
  72033. set shadowColor(value: string);
  72034. /** Gets or sets the cursor to use when the control is hovered */
  72035. hoverCursor: string;
  72036. /** @hidden */
  72037. protected _linkOffsetX: ValueAndUnit;
  72038. /** @hidden */
  72039. protected _linkOffsetY: ValueAndUnit;
  72040. /** Gets the control type name */
  72041. get typeName(): string;
  72042. /**
  72043. * Get the current class name of the control.
  72044. * @returns current class name
  72045. */
  72046. getClassName(): string;
  72047. /**
  72048. * An event triggered when pointer wheel is scrolled
  72049. */
  72050. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  72051. /**
  72052. * An event triggered when the pointer move over the control.
  72053. */
  72054. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  72055. /**
  72056. * An event triggered when the pointer move out of the control.
  72057. */
  72058. onPointerOutObservable: BABYLON.Observable<Control>;
  72059. /**
  72060. * An event triggered when the pointer taps the control
  72061. */
  72062. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  72063. /**
  72064. * An event triggered when pointer up
  72065. */
  72066. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  72067. /**
  72068. * An event triggered when a control is clicked on
  72069. */
  72070. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  72071. /**
  72072. * An event triggered when pointer enters the control
  72073. */
  72074. onPointerEnterObservable: BABYLON.Observable<Control>;
  72075. /**
  72076. * An event triggered when the control is marked as dirty
  72077. */
  72078. onDirtyObservable: BABYLON.Observable<Control>;
  72079. /**
  72080. * An event triggered before drawing the control
  72081. */
  72082. onBeforeDrawObservable: BABYLON.Observable<Control>;
  72083. /**
  72084. * An event triggered after the control was drawn
  72085. */
  72086. onAfterDrawObservable: BABYLON.Observable<Control>;
  72087. /**
  72088. * Get the hosting AdvancedDynamicTexture
  72089. */
  72090. get host(): AdvancedDynamicTexture;
  72091. /** Gets or set information about font offsets (used to render and align text) */
  72092. get fontOffset(): {
  72093. ascent: number;
  72094. height: number;
  72095. descent: number;
  72096. };
  72097. set fontOffset(offset: {
  72098. ascent: number;
  72099. height: number;
  72100. descent: number;
  72101. });
  72102. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  72103. get alpha(): number;
  72104. set alpha(value: number);
  72105. /**
  72106. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  72107. */
  72108. get isHighlighted(): boolean;
  72109. set isHighlighted(value: boolean);
  72110. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  72111. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72112. */
  72113. get scaleX(): number;
  72114. set scaleX(value: number);
  72115. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  72116. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72117. */
  72118. get scaleY(): number;
  72119. set scaleY(value: number);
  72120. /** Gets or sets the rotation angle (0 by default)
  72121. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72122. */
  72123. get rotation(): number;
  72124. set rotation(value: number);
  72125. /** Gets or sets the transformation center on Y axis (0 by default)
  72126. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72127. */
  72128. get transformCenterY(): number;
  72129. set transformCenterY(value: number);
  72130. /** Gets or sets the transformation center on X axis (0 by default)
  72131. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72132. */
  72133. get transformCenterX(): number;
  72134. set transformCenterX(value: number);
  72135. /**
  72136. * Gets or sets the horizontal alignment
  72137. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72138. */
  72139. get horizontalAlignment(): number;
  72140. set horizontalAlignment(value: number);
  72141. /**
  72142. * Gets or sets the vertical alignment
  72143. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72144. */
  72145. get verticalAlignment(): number;
  72146. set verticalAlignment(value: number);
  72147. /**
  72148. * Gets or sets control width
  72149. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72150. */
  72151. get width(): string | number;
  72152. set width(value: string | number);
  72153. /**
  72154. * Gets or sets the control width in pixel
  72155. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72156. */
  72157. get widthInPixels(): number;
  72158. set widthInPixels(value: number);
  72159. /**
  72160. * Gets or sets control height
  72161. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72162. */
  72163. get height(): string | number;
  72164. set height(value: string | number);
  72165. /**
  72166. * Gets or sets control height in pixel
  72167. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72168. */
  72169. get heightInPixels(): number;
  72170. set heightInPixels(value: number);
  72171. /** Gets or set font family */
  72172. get fontFamily(): string;
  72173. set fontFamily(value: string);
  72174. /** Gets or sets font style */
  72175. get fontStyle(): string;
  72176. set fontStyle(value: string);
  72177. /** Gets or sets font weight */
  72178. get fontWeight(): string;
  72179. set fontWeight(value: string);
  72180. /**
  72181. * Gets or sets style
  72182. * @see http://doc.babylonjs.com/how_to/gui#styles
  72183. */
  72184. get style(): BABYLON.Nullable<Style>;
  72185. set style(value: BABYLON.Nullable<Style>);
  72186. /** @hidden */
  72187. get _isFontSizeInPercentage(): boolean;
  72188. /** Gets or sets font size in pixels */
  72189. get fontSizeInPixels(): number;
  72190. set fontSizeInPixels(value: number);
  72191. /** Gets or sets font size */
  72192. get fontSize(): string | number;
  72193. set fontSize(value: string | number);
  72194. /** Gets or sets foreground color */
  72195. get color(): string;
  72196. set color(value: string);
  72197. /** Gets or sets z index which is used to reorder controls on the z axis */
  72198. get zIndex(): number;
  72199. set zIndex(value: number);
  72200. /** Gets or sets a boolean indicating if the control can be rendered */
  72201. get notRenderable(): boolean;
  72202. set notRenderable(value: boolean);
  72203. /** Gets or sets a boolean indicating if the control is visible */
  72204. get isVisible(): boolean;
  72205. set isVisible(value: boolean);
  72206. /** Gets a boolean indicating that the control needs to update its rendering */
  72207. get isDirty(): boolean;
  72208. /**
  72209. * Gets the current linked mesh (or null if none)
  72210. */
  72211. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72212. /**
  72213. * Gets or sets a value indicating the padding to use on the left of the control
  72214. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72215. */
  72216. get paddingLeft(): string | number;
  72217. set paddingLeft(value: string | number);
  72218. /**
  72219. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  72220. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72221. */
  72222. get paddingLeftInPixels(): number;
  72223. set paddingLeftInPixels(value: number);
  72224. /**
  72225. * Gets or sets a value indicating the padding to use on the right of the control
  72226. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72227. */
  72228. get paddingRight(): string | number;
  72229. set paddingRight(value: string | number);
  72230. /**
  72231. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  72232. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72233. */
  72234. get paddingRightInPixels(): number;
  72235. set paddingRightInPixels(value: number);
  72236. /**
  72237. * Gets or sets a value indicating the padding to use on the top of the control
  72238. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72239. */
  72240. get paddingTop(): string | number;
  72241. set paddingTop(value: string | number);
  72242. /**
  72243. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  72244. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72245. */
  72246. get paddingTopInPixels(): number;
  72247. set paddingTopInPixels(value: number);
  72248. /**
  72249. * Gets or sets a value indicating the padding to use on the bottom of the control
  72250. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72251. */
  72252. get paddingBottom(): string | number;
  72253. set paddingBottom(value: string | number);
  72254. /**
  72255. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  72256. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72257. */
  72258. get paddingBottomInPixels(): number;
  72259. set paddingBottomInPixels(value: number);
  72260. /**
  72261. * Gets or sets a value indicating the left coordinate of the control
  72262. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72263. */
  72264. get left(): string | number;
  72265. set left(value: string | number);
  72266. /**
  72267. * Gets or sets a value indicating the left coordinate in pixels of the control
  72268. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72269. */
  72270. get leftInPixels(): number;
  72271. set leftInPixels(value: number);
  72272. /**
  72273. * Gets or sets a value indicating the top coordinate of the control
  72274. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72275. */
  72276. get top(): string | number;
  72277. set top(value: string | number);
  72278. /**
  72279. * Gets or sets a value indicating the top coordinate in pixels of the control
  72280. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72281. */
  72282. get topInPixels(): number;
  72283. set topInPixels(value: number);
  72284. /**
  72285. * Gets or sets a value indicating the offset on X axis to the linked mesh
  72286. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72287. */
  72288. get linkOffsetX(): string | number;
  72289. set linkOffsetX(value: string | number);
  72290. /**
  72291. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  72292. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72293. */
  72294. get linkOffsetXInPixels(): number;
  72295. set linkOffsetXInPixels(value: number);
  72296. /**
  72297. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  72298. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72299. */
  72300. get linkOffsetY(): string | number;
  72301. set linkOffsetY(value: string | number);
  72302. /**
  72303. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  72304. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72305. */
  72306. get linkOffsetYInPixels(): number;
  72307. set linkOffsetYInPixels(value: number);
  72308. /** Gets the center coordinate on X axis */
  72309. get centerX(): number;
  72310. /** Gets the center coordinate on Y axis */
  72311. get centerY(): number;
  72312. /** Gets or sets if control is Enabled*/
  72313. get isEnabled(): boolean;
  72314. set isEnabled(value: boolean);
  72315. /** Gets or sets background color of control if it's disabled*/
  72316. get disabledColor(): string;
  72317. set disabledColor(value: string);
  72318. /** Gets or sets front color of control if it's disabled*/
  72319. get disabledColorItem(): string;
  72320. set disabledColorItem(value: string);
  72321. /**
  72322. * Creates a new control
  72323. * @param name defines the name of the control
  72324. */
  72325. constructor(
  72326. /** defines the name of the control */
  72327. name?: string | undefined);
  72328. /** @hidden */
  72329. protected _getTypeName(): string;
  72330. /**
  72331. * Gets the first ascendant in the hierarchy of the given type
  72332. * @param className defines the required type
  72333. * @returns the ascendant or null if not found
  72334. */
  72335. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  72336. /** @hidden */
  72337. _resetFontCache(): void;
  72338. /**
  72339. * Determines if a container is an ascendant of the current control
  72340. * @param container defines the container to look for
  72341. * @returns true if the container is one of the ascendant of the control
  72342. */
  72343. isAscendant(container: Control): boolean;
  72344. /**
  72345. * Gets coordinates in local control space
  72346. * @param globalCoordinates defines the coordinates to transform
  72347. * @returns the new coordinates in local space
  72348. */
  72349. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72350. /**
  72351. * Gets coordinates in local control space
  72352. * @param globalCoordinates defines the coordinates to transform
  72353. * @param result defines the target vector2 where to store the result
  72354. * @returns the current control
  72355. */
  72356. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  72357. /**
  72358. * Gets coordinates in parent local control space
  72359. * @param globalCoordinates defines the coordinates to transform
  72360. * @returns the new coordinates in parent local space
  72361. */
  72362. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72363. /**
  72364. * Move the current control to a vector3 position projected onto the screen.
  72365. * @param position defines the target position
  72366. * @param scene defines the hosting scene
  72367. */
  72368. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  72369. /**
  72370. * Will store all controls that have this control as ascendant in a given array
  72371. * @param results defines the array where to store the descendants
  72372. * @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
  72373. * @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
  72374. */
  72375. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72376. /**
  72377. * Will return all controls that have this control as ascendant
  72378. * @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
  72379. * @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
  72380. * @return all child controls
  72381. */
  72382. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72383. /**
  72384. * Link current control with a target mesh
  72385. * @param mesh defines the mesh to link with
  72386. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72387. */
  72388. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  72389. /** @hidden */
  72390. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  72391. /** @hidden */
  72392. _offsetLeft(offset: number): void;
  72393. /** @hidden */
  72394. _offsetTop(offset: number): void;
  72395. /** @hidden */
  72396. _markMatrixAsDirty(): void;
  72397. /** @hidden */
  72398. _flagDescendantsAsMatrixDirty(): void;
  72399. /** @hidden */
  72400. _intersectsRect(rect: Measure): boolean;
  72401. /** @hidden */
  72402. protected invalidateRect(): void;
  72403. /** @hidden */
  72404. _markAsDirty(force?: boolean): void;
  72405. /** @hidden */
  72406. _markAllAsDirty(): void;
  72407. /** @hidden */
  72408. _link(host: AdvancedDynamicTexture): void;
  72409. /** @hidden */
  72410. protected _transform(context?: CanvasRenderingContext2D): void;
  72411. /** @hidden */
  72412. _renderHighlight(context: CanvasRenderingContext2D): void;
  72413. /** @hidden */
  72414. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72415. /** @hidden */
  72416. protected _applyStates(context: CanvasRenderingContext2D): void;
  72417. /** @hidden */
  72418. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72419. /** @hidden */
  72420. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72421. protected _evaluateClippingState(parentMeasure: Measure): void;
  72422. /** @hidden */
  72423. _measure(): void;
  72424. /** @hidden */
  72425. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72426. /** @hidden */
  72427. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72428. /** @hidden */
  72429. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72430. /** @hidden */
  72431. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72432. private static _ClipMeasure;
  72433. private _tmpMeasureA;
  72434. private _clip;
  72435. /** @hidden */
  72436. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72437. /** @hidden */
  72438. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72439. /**
  72440. * Tests if a given coordinates belong to the current control
  72441. * @param x defines x coordinate to test
  72442. * @param y defines y coordinate to test
  72443. * @returns true if the coordinates are inside the control
  72444. */
  72445. contains(x: number, y: number): boolean;
  72446. /** @hidden */
  72447. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72448. /** @hidden */
  72449. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72450. /** @hidden */
  72451. _onPointerEnter(target: Control): boolean;
  72452. /** @hidden */
  72453. _onPointerOut(target: Control, force?: boolean): void;
  72454. /** @hidden */
  72455. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72456. /** @hidden */
  72457. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72458. /** @hidden */
  72459. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72460. /** @hidden */
  72461. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72462. /** @hidden */
  72463. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72464. private _prepareFont;
  72465. /** Releases associated resources */
  72466. dispose(): void;
  72467. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72468. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72469. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72470. private static _VERTICAL_ALIGNMENT_TOP;
  72471. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72472. private static _VERTICAL_ALIGNMENT_CENTER;
  72473. /** HORIZONTAL_ALIGNMENT_LEFT */
  72474. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72475. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72476. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72477. /** HORIZONTAL_ALIGNMENT_CENTER */
  72478. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72479. /** VERTICAL_ALIGNMENT_TOP */
  72480. static get VERTICAL_ALIGNMENT_TOP(): number;
  72481. /** VERTICAL_ALIGNMENT_BOTTOM */
  72482. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72483. /** VERTICAL_ALIGNMENT_CENTER */
  72484. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72485. private static _FontHeightSizes;
  72486. /** @hidden */
  72487. static _GetFontOffset(font: string): {
  72488. ascent: number;
  72489. height: number;
  72490. descent: number;
  72491. };
  72492. /**
  72493. * Creates a stack panel that can be used to render headers
  72494. * @param control defines the control to associate with the header
  72495. * @param text defines the text of the header
  72496. * @param size defines the size of the header
  72497. * @param options defines options used to configure the header
  72498. * @returns a new StackPanel
  72499. * @ignore
  72500. * @hidden
  72501. */
  72502. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72503. isHorizontal: boolean;
  72504. controlFirst: boolean;
  72505. }) => any;
  72506. /** @hidden */
  72507. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72508. }
  72509. }
  72510. declare module BABYLON.GUI {
  72511. /**
  72512. * Root class for 2D containers
  72513. * @see http://doc.babylonjs.com/how_to/gui#containers
  72514. */
  72515. export class Container extends Control {
  72516. name?: string | undefined;
  72517. /** @hidden */
  72518. _children: Control[];
  72519. /** @hidden */
  72520. protected _measureForChildren: Measure;
  72521. /** @hidden */
  72522. protected _background: string;
  72523. /** @hidden */
  72524. protected _adaptWidthToChildren: boolean;
  72525. /** @hidden */
  72526. protected _adaptHeightToChildren: boolean;
  72527. /**
  72528. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72529. */
  72530. logLayoutCycleErrors: boolean;
  72531. /**
  72532. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72533. */
  72534. maxLayoutCycle: number;
  72535. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72536. get adaptHeightToChildren(): boolean;
  72537. set adaptHeightToChildren(value: boolean);
  72538. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72539. get adaptWidthToChildren(): boolean;
  72540. set adaptWidthToChildren(value: boolean);
  72541. /** Gets or sets background color */
  72542. get background(): string;
  72543. set background(value: string);
  72544. /** Gets the list of children */
  72545. get children(): Control[];
  72546. /**
  72547. * Creates a new Container
  72548. * @param name defines the name of the container
  72549. */
  72550. constructor(name?: string | undefined);
  72551. protected _getTypeName(): string;
  72552. _flagDescendantsAsMatrixDirty(): void;
  72553. /**
  72554. * Gets a child using its name
  72555. * @param name defines the child name to look for
  72556. * @returns the child control if found
  72557. */
  72558. getChildByName(name: string): BABYLON.Nullable<Control>;
  72559. /**
  72560. * Gets a child using its type and its name
  72561. * @param name defines the child name to look for
  72562. * @param type defines the child type to look for
  72563. * @returns the child control if found
  72564. */
  72565. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72566. /**
  72567. * Search for a specific control in children
  72568. * @param control defines the control to look for
  72569. * @returns true if the control is in child list
  72570. */
  72571. containsControl(control: Control): boolean;
  72572. /**
  72573. * Adds a new control to the current container
  72574. * @param control defines the control to add
  72575. * @returns the current container
  72576. */
  72577. addControl(control: BABYLON.Nullable<Control>): Container;
  72578. /**
  72579. * Removes all controls from the current container
  72580. * @returns the current container
  72581. */
  72582. clearControls(): Container;
  72583. /**
  72584. * Removes a control from the current container
  72585. * @param control defines the control to remove
  72586. * @returns the current container
  72587. */
  72588. removeControl(control: Control): Container;
  72589. /** @hidden */
  72590. _reOrderControl(control: Control): void;
  72591. /** @hidden */
  72592. _offsetLeft(offset: number): void;
  72593. /** @hidden */
  72594. _offsetTop(offset: number): void;
  72595. /** @hidden */
  72596. _markAllAsDirty(): void;
  72597. /** @hidden */
  72598. protected _localDraw(context: CanvasRenderingContext2D): void;
  72599. /** @hidden */
  72600. _link(host: AdvancedDynamicTexture): void;
  72601. /** @hidden */
  72602. protected _beforeLayout(): void;
  72603. /** @hidden */
  72604. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72605. /** @hidden */
  72606. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72607. protected _postMeasure(): void;
  72608. /** @hidden */
  72609. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72610. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72611. /** @hidden */
  72612. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72613. /** @hidden */
  72614. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72615. /** Releases associated resources */
  72616. dispose(): void;
  72617. }
  72618. }
  72619. declare module BABYLON.GUI {
  72620. /** Class used to create rectangle container */
  72621. export class Rectangle extends Container {
  72622. name?: string | undefined;
  72623. private _thickness;
  72624. private _cornerRadius;
  72625. /** Gets or sets border thickness */
  72626. get thickness(): number;
  72627. set thickness(value: number);
  72628. /** Gets or sets the corner radius angle */
  72629. get cornerRadius(): number;
  72630. set cornerRadius(value: number);
  72631. /**
  72632. * Creates a new Rectangle
  72633. * @param name defines the control name
  72634. */
  72635. constructor(name?: string | undefined);
  72636. protected _getTypeName(): string;
  72637. protected _localDraw(context: CanvasRenderingContext2D): void;
  72638. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72639. private _drawRoundedRect;
  72640. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72641. }
  72642. }
  72643. declare module BABYLON.GUI {
  72644. /**
  72645. * Enum that determines the text-wrapping mode to use.
  72646. */
  72647. export enum TextWrapping {
  72648. /**
  72649. * Clip the text when it's larger than Control.width; this is the default mode.
  72650. */
  72651. Clip = 0,
  72652. /**
  72653. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72654. */
  72655. WordWrap = 1,
  72656. /**
  72657. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72658. */
  72659. Ellipsis = 2
  72660. }
  72661. /**
  72662. * Class used to create text block control
  72663. */
  72664. export class TextBlock extends Control {
  72665. /**
  72666. * Defines the name of the control
  72667. */
  72668. name?: string | undefined;
  72669. private _text;
  72670. private _textWrapping;
  72671. private _textHorizontalAlignment;
  72672. private _textVerticalAlignment;
  72673. private _lines;
  72674. private _resizeToFit;
  72675. private _lineSpacing;
  72676. private _outlineWidth;
  72677. private _outlineColor;
  72678. /**
  72679. * An event triggered after the text is changed
  72680. */
  72681. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72682. /**
  72683. * An event triggered after the text was broken up into lines
  72684. */
  72685. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72686. /**
  72687. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72688. */
  72689. get lines(): any[];
  72690. /**
  72691. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72692. */
  72693. get resizeToFit(): boolean;
  72694. /**
  72695. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72696. */
  72697. set resizeToFit(value: boolean);
  72698. /**
  72699. * Gets or sets a boolean indicating if text must be wrapped
  72700. */
  72701. get textWrapping(): TextWrapping | boolean;
  72702. /**
  72703. * Gets or sets a boolean indicating if text must be wrapped
  72704. */
  72705. set textWrapping(value: TextWrapping | boolean);
  72706. /**
  72707. * Gets or sets text to display
  72708. */
  72709. get text(): string;
  72710. /**
  72711. * Gets or sets text to display
  72712. */
  72713. set text(value: string);
  72714. /**
  72715. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72716. */
  72717. get textHorizontalAlignment(): number;
  72718. /**
  72719. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72720. */
  72721. set textHorizontalAlignment(value: number);
  72722. /**
  72723. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72724. */
  72725. get textVerticalAlignment(): number;
  72726. /**
  72727. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72728. */
  72729. set textVerticalAlignment(value: number);
  72730. /**
  72731. * Gets or sets line spacing value
  72732. */
  72733. set lineSpacing(value: string | number);
  72734. /**
  72735. * Gets or sets line spacing value
  72736. */
  72737. get lineSpacing(): string | number;
  72738. /**
  72739. * Gets or sets outlineWidth of the text to display
  72740. */
  72741. get outlineWidth(): number;
  72742. /**
  72743. * Gets or sets outlineWidth of the text to display
  72744. */
  72745. set outlineWidth(value: number);
  72746. /**
  72747. * Gets or sets outlineColor of the text to display
  72748. */
  72749. get outlineColor(): string;
  72750. /**
  72751. * Gets or sets outlineColor of the text to display
  72752. */
  72753. set outlineColor(value: string);
  72754. /**
  72755. * Creates a new TextBlock object
  72756. * @param name defines the name of the control
  72757. * @param text defines the text to display (emptry string by default)
  72758. */
  72759. constructor(
  72760. /**
  72761. * Defines the name of the control
  72762. */
  72763. name?: string | undefined, text?: string);
  72764. protected _getTypeName(): string;
  72765. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72766. private _drawText;
  72767. /** @hidden */
  72768. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72769. protected _applyStates(context: CanvasRenderingContext2D): void;
  72770. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72771. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72772. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72773. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72774. protected _renderLines(context: CanvasRenderingContext2D): void;
  72775. /**
  72776. * Given a width constraint applied on the text block, find the expected height
  72777. * @returns expected height
  72778. */
  72779. computeExpectedHeight(): number;
  72780. dispose(): void;
  72781. }
  72782. }
  72783. declare module BABYLON.GUI {
  72784. /**
  72785. * Class used to create 2D images
  72786. */
  72787. export class Image extends Control {
  72788. name?: string | undefined;
  72789. private _workingCanvas;
  72790. private _domImage;
  72791. private _imageWidth;
  72792. private _imageHeight;
  72793. private _loaded;
  72794. private _stretch;
  72795. private _source;
  72796. private _autoScale;
  72797. private _sourceLeft;
  72798. private _sourceTop;
  72799. private _sourceWidth;
  72800. private _sourceHeight;
  72801. private _svgAttributesComputationCompleted;
  72802. private _isSVG;
  72803. private _cellWidth;
  72804. private _cellHeight;
  72805. private _cellId;
  72806. private _populateNinePatchSlicesFromImage;
  72807. private _sliceLeft;
  72808. private _sliceRight;
  72809. private _sliceTop;
  72810. private _sliceBottom;
  72811. private _detectPointerOnOpaqueOnly;
  72812. /**
  72813. * BABYLON.Observable notified when the content is loaded
  72814. */
  72815. onImageLoadedObservable: BABYLON.Observable<Image>;
  72816. /**
  72817. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72818. */
  72819. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72820. /**
  72821. * Gets a boolean indicating that the content is loaded
  72822. */
  72823. get isLoaded(): boolean;
  72824. /**
  72825. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72826. */
  72827. get populateNinePatchSlicesFromImage(): boolean;
  72828. set populateNinePatchSlicesFromImage(value: boolean);
  72829. /**
  72830. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72831. * Beware using this as this will comsume more memory as the image has to be stored twice
  72832. */
  72833. get detectPointerOnOpaqueOnly(): boolean;
  72834. set detectPointerOnOpaqueOnly(value: boolean);
  72835. /**
  72836. * Gets or sets the left value for slicing (9-patch)
  72837. */
  72838. get sliceLeft(): number;
  72839. set sliceLeft(value: number);
  72840. /**
  72841. * Gets or sets the right value for slicing (9-patch)
  72842. */
  72843. get sliceRight(): number;
  72844. set sliceRight(value: number);
  72845. /**
  72846. * Gets or sets the top value for slicing (9-patch)
  72847. */
  72848. get sliceTop(): number;
  72849. set sliceTop(value: number);
  72850. /**
  72851. * Gets or sets the bottom value for slicing (9-patch)
  72852. */
  72853. get sliceBottom(): number;
  72854. set sliceBottom(value: number);
  72855. /**
  72856. * Gets or sets the left coordinate in the source image
  72857. */
  72858. get sourceLeft(): number;
  72859. set sourceLeft(value: number);
  72860. /**
  72861. * Gets or sets the top coordinate in the source image
  72862. */
  72863. get sourceTop(): number;
  72864. set sourceTop(value: number);
  72865. /**
  72866. * Gets or sets the width to capture in the source image
  72867. */
  72868. get sourceWidth(): number;
  72869. set sourceWidth(value: number);
  72870. /**
  72871. * Gets or sets the height to capture in the source image
  72872. */
  72873. get sourceHeight(): number;
  72874. set sourceHeight(value: number);
  72875. /** Indicates if the format of the image is SVG */
  72876. get isSVG(): boolean;
  72877. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72878. get svgAttributesComputationCompleted(): boolean;
  72879. /**
  72880. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72881. * @see http://doc.babylonjs.com/how_to/gui#image
  72882. */
  72883. get autoScale(): boolean;
  72884. set autoScale(value: boolean);
  72885. /** Gets or sets the streching mode used by the image */
  72886. get stretch(): number;
  72887. set stretch(value: number);
  72888. /** @hidden */
  72889. _rotate90(n: number, preserveProperties?: boolean): Image;
  72890. private _handleRotationForSVGImage;
  72891. private _rotate90SourceProperties;
  72892. /**
  72893. * Gets or sets the internal DOM image used to render the control
  72894. */
  72895. set domImage(value: HTMLImageElement);
  72896. get domImage(): HTMLImageElement;
  72897. private _onImageLoaded;
  72898. private _extractNinePatchSliceDataFromImage;
  72899. /**
  72900. * Gets or sets image source url
  72901. */
  72902. set source(value: BABYLON.Nullable<string>);
  72903. /**
  72904. * Checks for svg document with icon id present
  72905. */
  72906. private _svgCheck;
  72907. /**
  72908. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72909. * given external svg file and icon id
  72910. */
  72911. private _getSVGAttribs;
  72912. /**
  72913. * Gets or sets the cell width to use when animation sheet is enabled
  72914. * @see http://doc.babylonjs.com/how_to/gui#image
  72915. */
  72916. get cellWidth(): number;
  72917. set cellWidth(value: number);
  72918. /**
  72919. * Gets or sets the cell height to use when animation sheet is enabled
  72920. * @see http://doc.babylonjs.com/how_to/gui#image
  72921. */
  72922. get cellHeight(): number;
  72923. set cellHeight(value: number);
  72924. /**
  72925. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72926. * @see http://doc.babylonjs.com/how_to/gui#image
  72927. */
  72928. get cellId(): number;
  72929. set cellId(value: number);
  72930. /**
  72931. * Creates a new Image
  72932. * @param name defines the control name
  72933. * @param url defines the image url
  72934. */
  72935. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72936. /**
  72937. * Tests if a given coordinates belong to the current control
  72938. * @param x defines x coordinate to test
  72939. * @param y defines y coordinate to test
  72940. * @returns true if the coordinates are inside the control
  72941. */
  72942. contains(x: number, y: number): boolean;
  72943. protected _getTypeName(): string;
  72944. /** Force the control to synchronize with its content */
  72945. synchronizeSizeWithContent(): void;
  72946. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72947. private _prepareWorkingCanvasForOpaqueDetection;
  72948. private _drawImage;
  72949. _draw(context: CanvasRenderingContext2D): void;
  72950. private _renderCornerPatch;
  72951. private _renderNinePatch;
  72952. dispose(): void;
  72953. /** STRETCH_NONE */
  72954. static readonly STRETCH_NONE: number;
  72955. /** STRETCH_FILL */
  72956. static readonly STRETCH_FILL: number;
  72957. /** STRETCH_UNIFORM */
  72958. static readonly STRETCH_UNIFORM: number;
  72959. /** STRETCH_EXTEND */
  72960. static readonly STRETCH_EXTEND: number;
  72961. /** NINE_PATCH */
  72962. static readonly STRETCH_NINE_PATCH: number;
  72963. }
  72964. }
  72965. declare module BABYLON.GUI {
  72966. /**
  72967. * Class used to create 2D buttons
  72968. */
  72969. export class Button extends Rectangle {
  72970. name?: string | undefined;
  72971. /**
  72972. * Function called to generate a pointer enter animation
  72973. */
  72974. pointerEnterAnimation: () => void;
  72975. /**
  72976. * Function called to generate a pointer out animation
  72977. */
  72978. pointerOutAnimation: () => void;
  72979. /**
  72980. * Function called to generate a pointer down animation
  72981. */
  72982. pointerDownAnimation: () => void;
  72983. /**
  72984. * Function called to generate a pointer up animation
  72985. */
  72986. pointerUpAnimation: () => void;
  72987. /**
  72988. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72989. */
  72990. delegatePickingToChildren: boolean;
  72991. private _image;
  72992. /**
  72993. * Returns the image part of the button (if any)
  72994. */
  72995. get image(): BABYLON.Nullable<Image>;
  72996. private _textBlock;
  72997. /**
  72998. * Returns the image part of the button (if any)
  72999. */
  73000. get textBlock(): BABYLON.Nullable<TextBlock>;
  73001. /**
  73002. * Creates a new Button
  73003. * @param name defines the name of the button
  73004. */
  73005. constructor(name?: string | undefined);
  73006. protected _getTypeName(): string;
  73007. /** @hidden */
  73008. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73009. /** @hidden */
  73010. _onPointerEnter(target: Control): boolean;
  73011. /** @hidden */
  73012. _onPointerOut(target: Control, force?: boolean): void;
  73013. /** @hidden */
  73014. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73015. /** @hidden */
  73016. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73017. /**
  73018. * Creates a new button made with an image and a text
  73019. * @param name defines the name of the button
  73020. * @param text defines the text of the button
  73021. * @param imageUrl defines the url of the image
  73022. * @returns a new Button
  73023. */
  73024. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  73025. /**
  73026. * Creates a new button made with an image
  73027. * @param name defines the name of the button
  73028. * @param imageUrl defines the url of the image
  73029. * @returns a new Button
  73030. */
  73031. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  73032. /**
  73033. * Creates a new button made with a text
  73034. * @param name defines the name of the button
  73035. * @param text defines the text of the button
  73036. * @returns a new Button
  73037. */
  73038. static CreateSimpleButton(name: string, text: string): Button;
  73039. /**
  73040. * Creates a new button made with an image and a centered text
  73041. * @param name defines the name of the button
  73042. * @param text defines the text of the button
  73043. * @param imageUrl defines the url of the image
  73044. * @returns a new Button
  73045. */
  73046. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  73047. }
  73048. }
  73049. declare module BABYLON.GUI {
  73050. /**
  73051. * Class used to create a 2D stack panel container
  73052. */
  73053. export class StackPanel extends Container {
  73054. name?: string | undefined;
  73055. private _isVertical;
  73056. private _manualWidth;
  73057. private _manualHeight;
  73058. private _doNotTrackManualChanges;
  73059. /**
  73060. * Gets or sets a boolean indicating that layou warnings should be ignored
  73061. */
  73062. ignoreLayoutWarnings: boolean;
  73063. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  73064. get isVertical(): boolean;
  73065. set isVertical(value: boolean);
  73066. /**
  73067. * Gets or sets panel width.
  73068. * This value should not be set when in horizontal mode as it will be computed automatically
  73069. */
  73070. set width(value: string | number);
  73071. get width(): string | number;
  73072. /**
  73073. * Gets or sets panel height.
  73074. * This value should not be set when in vertical mode as it will be computed automatically
  73075. */
  73076. set height(value: string | number);
  73077. get height(): string | number;
  73078. /**
  73079. * Creates a new StackPanel
  73080. * @param name defines control name
  73081. */
  73082. constructor(name?: string | undefined);
  73083. protected _getTypeName(): string;
  73084. /** @hidden */
  73085. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73086. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73087. protected _postMeasure(): void;
  73088. }
  73089. }
  73090. declare module BABYLON.GUI {
  73091. /**
  73092. * Class used to represent a 2D checkbox
  73093. */
  73094. export class Checkbox extends Control {
  73095. name?: string | undefined;
  73096. private _isChecked;
  73097. private _background;
  73098. private _checkSizeRatio;
  73099. private _thickness;
  73100. /** Gets or sets border thickness */
  73101. get thickness(): number;
  73102. set thickness(value: number);
  73103. /**
  73104. * BABYLON.Observable raised when isChecked property changes
  73105. */
  73106. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73107. /** Gets or sets a value indicating the ratio between overall size and check size */
  73108. get checkSizeRatio(): number;
  73109. set checkSizeRatio(value: number);
  73110. /** Gets or sets background color */
  73111. get background(): string;
  73112. set background(value: string);
  73113. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73114. get isChecked(): boolean;
  73115. set isChecked(value: boolean);
  73116. /**
  73117. * Creates a new CheckBox
  73118. * @param name defines the control name
  73119. */
  73120. constructor(name?: string | undefined);
  73121. protected _getTypeName(): string;
  73122. /** @hidden */
  73123. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73124. /** @hidden */
  73125. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73126. /**
  73127. * Utility function to easily create a checkbox with a header
  73128. * @param title defines the label to use for the header
  73129. * @param onValueChanged defines the callback to call when value changes
  73130. * @returns a StackPanel containing the checkbox and a textBlock
  73131. */
  73132. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  73133. }
  73134. }
  73135. declare module BABYLON.GUI {
  73136. /**
  73137. * Class used to store key control properties
  73138. */
  73139. export class KeyPropertySet {
  73140. /** Width */
  73141. width?: string;
  73142. /** Height */
  73143. height?: string;
  73144. /** Left padding */
  73145. paddingLeft?: string;
  73146. /** Right padding */
  73147. paddingRight?: string;
  73148. /** Top padding */
  73149. paddingTop?: string;
  73150. /** Bottom padding */
  73151. paddingBottom?: string;
  73152. /** Foreground color */
  73153. color?: string;
  73154. /** Background color */
  73155. background?: string;
  73156. }
  73157. /**
  73158. * Class used to create virtual keyboard
  73159. */
  73160. export class VirtualKeyboard extends StackPanel {
  73161. /** BABYLON.Observable raised when a key is pressed */
  73162. onKeyPressObservable: BABYLON.Observable<string>;
  73163. /** Gets or sets default key button width */
  73164. defaultButtonWidth: string;
  73165. /** Gets or sets default key button height */
  73166. defaultButtonHeight: string;
  73167. /** Gets or sets default key button left padding */
  73168. defaultButtonPaddingLeft: string;
  73169. /** Gets or sets default key button right padding */
  73170. defaultButtonPaddingRight: string;
  73171. /** Gets or sets default key button top padding */
  73172. defaultButtonPaddingTop: string;
  73173. /** Gets or sets default key button bottom padding */
  73174. defaultButtonPaddingBottom: string;
  73175. /** Gets or sets default key button foreground color */
  73176. defaultButtonColor: string;
  73177. /** Gets or sets default key button background color */
  73178. defaultButtonBackground: string;
  73179. /** Gets or sets shift button foreground color */
  73180. shiftButtonColor: string;
  73181. /** Gets or sets shift button thickness*/
  73182. selectedShiftThickness: number;
  73183. /** Gets shift key state */
  73184. shiftState: number;
  73185. protected _getTypeName(): string;
  73186. private _createKey;
  73187. /**
  73188. * Adds a new row of keys
  73189. * @param keys defines the list of keys to add
  73190. * @param propertySets defines the associated property sets
  73191. */
  73192. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  73193. /**
  73194. * Set the shift key to a specific state
  73195. * @param shiftState defines the new shift state
  73196. */
  73197. applyShiftState(shiftState: number): void;
  73198. private _currentlyConnectedInputText;
  73199. private _connectedInputTexts;
  73200. private _onKeyPressObserver;
  73201. /** Gets the input text control currently attached to the keyboard */
  73202. get connectedInputText(): BABYLON.Nullable<InputText>;
  73203. /**
  73204. * Connects the keyboard with an input text control
  73205. *
  73206. * @param input defines the target control
  73207. */
  73208. connect(input: InputText): void;
  73209. /**
  73210. * Disconnects the keyboard from connected InputText controls
  73211. *
  73212. * @param input optionally defines a target control, otherwise all are disconnected
  73213. */
  73214. disconnect(input?: InputText): void;
  73215. private _removeConnectedInputObservables;
  73216. /**
  73217. * Release all resources
  73218. */
  73219. dispose(): void;
  73220. /**
  73221. * Creates a new keyboard using a default layout
  73222. *
  73223. * @param name defines control name
  73224. * @returns a new VirtualKeyboard
  73225. */
  73226. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  73227. }
  73228. }
  73229. declare module BABYLON.GUI {
  73230. /**
  73231. * Class used to create input text control
  73232. */
  73233. export class InputText extends Control implements IFocusableControl {
  73234. name?: string | undefined;
  73235. private _text;
  73236. private _placeholderText;
  73237. private _background;
  73238. private _focusedBackground;
  73239. private _focusedColor;
  73240. private _placeholderColor;
  73241. private _thickness;
  73242. private _margin;
  73243. private _autoStretchWidth;
  73244. private _maxWidth;
  73245. private _isFocused;
  73246. private _blinkTimeout;
  73247. private _blinkIsEven;
  73248. private _cursorOffset;
  73249. private _scrollLeft;
  73250. private _textWidth;
  73251. private _clickedCoordinate;
  73252. private _deadKey;
  73253. private _addKey;
  73254. private _currentKey;
  73255. private _isTextHighlightOn;
  73256. private _textHighlightColor;
  73257. private _highligherOpacity;
  73258. private _highlightedText;
  73259. private _startHighlightIndex;
  73260. private _endHighlightIndex;
  73261. private _cursorIndex;
  73262. private _onFocusSelectAll;
  73263. private _isPointerDown;
  73264. private _onClipboardObserver;
  73265. private _onPointerDblTapObserver;
  73266. /** @hidden */
  73267. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  73268. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  73269. promptMessage: string;
  73270. /** Force disable prompt on mobile device */
  73271. disableMobilePrompt: boolean;
  73272. /** BABYLON.Observable raised when the text changes */
  73273. onTextChangedObservable: BABYLON.Observable<InputText>;
  73274. /** BABYLON.Observable raised just before an entered character is to be added */
  73275. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  73276. /** BABYLON.Observable raised when the control gets the focus */
  73277. onFocusObservable: BABYLON.Observable<InputText>;
  73278. /** BABYLON.Observable raised when the control loses the focus */
  73279. onBlurObservable: BABYLON.Observable<InputText>;
  73280. /**Observable raised when the text is highlighted */
  73281. onTextHighlightObservable: BABYLON.Observable<InputText>;
  73282. /**Observable raised when copy event is triggered */
  73283. onTextCopyObservable: BABYLON.Observable<InputText>;
  73284. /** BABYLON.Observable raised when cut event is triggered */
  73285. onTextCutObservable: BABYLON.Observable<InputText>;
  73286. /** BABYLON.Observable raised when paste event is triggered */
  73287. onTextPasteObservable: BABYLON.Observable<InputText>;
  73288. /** BABYLON.Observable raised when a key event was processed */
  73289. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  73290. /** Gets or sets the maximum width allowed by the control */
  73291. get maxWidth(): string | number;
  73292. /** Gets the maximum width allowed by the control in pixels */
  73293. get maxWidthInPixels(): number;
  73294. set maxWidth(value: string | number);
  73295. /** Gets or sets the text highlighter transparency; default: 0.4 */
  73296. get highligherOpacity(): number;
  73297. set highligherOpacity(value: number);
  73298. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  73299. get onFocusSelectAll(): boolean;
  73300. set onFocusSelectAll(value: boolean);
  73301. /** Gets or sets the text hightlight color */
  73302. get textHighlightColor(): string;
  73303. set textHighlightColor(value: string);
  73304. /** Gets or sets control margin */
  73305. get margin(): string;
  73306. /** Gets control margin in pixels */
  73307. get marginInPixels(): number;
  73308. set margin(value: string);
  73309. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  73310. get autoStretchWidth(): boolean;
  73311. set autoStretchWidth(value: boolean);
  73312. /** Gets or sets border thickness */
  73313. get thickness(): number;
  73314. set thickness(value: number);
  73315. /** Gets or sets the background color when focused */
  73316. get focusedBackground(): string;
  73317. set focusedBackground(value: string);
  73318. /** Gets or sets the background color when focused */
  73319. get focusedColor(): string;
  73320. set focusedColor(value: string);
  73321. /** Gets or sets the background color */
  73322. get background(): string;
  73323. set background(value: string);
  73324. /** Gets or sets the placeholder color */
  73325. get placeholderColor(): string;
  73326. set placeholderColor(value: string);
  73327. /** Gets or sets the text displayed when the control is empty */
  73328. get placeholderText(): string;
  73329. set placeholderText(value: string);
  73330. /** Gets or sets the dead key flag */
  73331. get deadKey(): boolean;
  73332. set deadKey(flag: boolean);
  73333. /** Gets or sets the highlight text */
  73334. get highlightedText(): string;
  73335. set highlightedText(text: string);
  73336. /** Gets or sets if the current key should be added */
  73337. get addKey(): boolean;
  73338. set addKey(flag: boolean);
  73339. /** Gets or sets the value of the current key being entered */
  73340. get currentKey(): string;
  73341. set currentKey(key: string);
  73342. /** Gets or sets the text displayed in the control */
  73343. get text(): string;
  73344. set text(value: string);
  73345. /** Gets or sets control width */
  73346. get width(): string | number;
  73347. set width(value: string | number);
  73348. /**
  73349. * Creates a new InputText
  73350. * @param name defines the control name
  73351. * @param text defines the text of the control
  73352. */
  73353. constructor(name?: string | undefined, text?: string);
  73354. /** @hidden */
  73355. onBlur(): void;
  73356. /** @hidden */
  73357. onFocus(): void;
  73358. protected _getTypeName(): string;
  73359. /**
  73360. * Function called to get the list of controls that should not steal the focus from this control
  73361. * @returns an array of controls
  73362. */
  73363. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73364. /** @hidden */
  73365. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  73366. /** @hidden */
  73367. private _updateValueFromCursorIndex;
  73368. /** @hidden */
  73369. private _processDblClick;
  73370. /** @hidden */
  73371. private _selectAllText;
  73372. /**
  73373. * Handles the keyboard event
  73374. * @param evt Defines the KeyboardEvent
  73375. */
  73376. processKeyboard(evt: KeyboardEvent): void;
  73377. /** @hidden */
  73378. private _onCopyText;
  73379. /** @hidden */
  73380. private _onCutText;
  73381. /** @hidden */
  73382. private _onPasteText;
  73383. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73384. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73385. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73386. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73387. protected _beforeRenderText(text: string): string;
  73388. dispose(): void;
  73389. }
  73390. }
  73391. declare module BABYLON.GUI {
  73392. /**
  73393. * Class used to create a 2D grid container
  73394. */
  73395. export class Grid extends Container {
  73396. name?: string | undefined;
  73397. private _rowDefinitions;
  73398. private _columnDefinitions;
  73399. private _cells;
  73400. private _childControls;
  73401. /**
  73402. * Gets the number of columns
  73403. */
  73404. get columnCount(): number;
  73405. /**
  73406. * Gets the number of rows
  73407. */
  73408. get rowCount(): number;
  73409. /** Gets the list of children */
  73410. get children(): Control[];
  73411. /** Gets the list of cells (e.g. the containers) */
  73412. get cells(): {
  73413. [key: string]: Container;
  73414. };
  73415. /**
  73416. * Gets the definition of a specific row
  73417. * @param index defines the index of the row
  73418. * @returns the row definition
  73419. */
  73420. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73421. /**
  73422. * Gets the definition of a specific column
  73423. * @param index defines the index of the column
  73424. * @returns the column definition
  73425. */
  73426. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73427. /**
  73428. * Adds a new row to the grid
  73429. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73430. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73431. * @returns the current grid
  73432. */
  73433. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73434. /**
  73435. * Adds a new column to the grid
  73436. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73437. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73438. * @returns the current grid
  73439. */
  73440. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73441. /**
  73442. * Update a row definition
  73443. * @param index defines the index of the row to update
  73444. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73445. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73446. * @returns the current grid
  73447. */
  73448. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73449. /**
  73450. * Update a column definition
  73451. * @param index defines the index of the column to update
  73452. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73453. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73454. * @returns the current grid
  73455. */
  73456. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73457. /**
  73458. * Gets the list of children stored in a specific cell
  73459. * @param row defines the row to check
  73460. * @param column defines the column to check
  73461. * @returns the list of controls
  73462. */
  73463. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73464. /**
  73465. * Gets a string representing the child cell info (row x column)
  73466. * @param child defines the control to get info from
  73467. * @returns a string containing the child cell info (row x column)
  73468. */
  73469. getChildCellInfo(child: Control): string;
  73470. private _removeCell;
  73471. private _offsetCell;
  73472. /**
  73473. * Remove a column definition at specified index
  73474. * @param index defines the index of the column to remove
  73475. * @returns the current grid
  73476. */
  73477. removeColumnDefinition(index: number): Grid;
  73478. /**
  73479. * Remove a row definition at specified index
  73480. * @param index defines the index of the row to remove
  73481. * @returns the current grid
  73482. */
  73483. removeRowDefinition(index: number): Grid;
  73484. /**
  73485. * Adds a new control to the current grid
  73486. * @param control defines the control to add
  73487. * @param row defines the row where to add the control (0 by default)
  73488. * @param column defines the column where to add the control (0 by default)
  73489. * @returns the current grid
  73490. */
  73491. addControl(control: Control, row?: number, column?: number): Grid;
  73492. /**
  73493. * Removes a control from the current container
  73494. * @param control defines the control to remove
  73495. * @returns the current container
  73496. */
  73497. removeControl(control: Control): Container;
  73498. /**
  73499. * Creates a new Grid
  73500. * @param name defines control name
  73501. */
  73502. constructor(name?: string | undefined);
  73503. protected _getTypeName(): string;
  73504. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73505. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73506. _flagDescendantsAsMatrixDirty(): void;
  73507. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73508. /** Releases associated resources */
  73509. dispose(): void;
  73510. }
  73511. }
  73512. declare module BABYLON.GUI {
  73513. /** Class used to create color pickers */
  73514. export class ColorPicker extends Control {
  73515. name?: string | undefined;
  73516. private static _Epsilon;
  73517. private _colorWheelCanvas;
  73518. private _value;
  73519. private _tmpColor;
  73520. private _pointerStartedOnSquare;
  73521. private _pointerStartedOnWheel;
  73522. private _squareLeft;
  73523. private _squareTop;
  73524. private _squareSize;
  73525. private _h;
  73526. private _s;
  73527. private _v;
  73528. private _lastPointerDownID;
  73529. /**
  73530. * BABYLON.Observable raised when the value changes
  73531. */
  73532. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73533. /** Gets or sets the color of the color picker */
  73534. get value(): BABYLON.Color3;
  73535. set value(value: BABYLON.Color3);
  73536. /**
  73537. * Gets or sets control width
  73538. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73539. */
  73540. get width(): string | number;
  73541. set width(value: string | number);
  73542. /**
  73543. * Gets or sets control height
  73544. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73545. */
  73546. get height(): string | number;
  73547. /** Gets or sets control height */
  73548. set height(value: string | number);
  73549. /** Gets or sets control size */
  73550. get size(): string | number;
  73551. set size(value: string | number);
  73552. /**
  73553. * Creates a new ColorPicker
  73554. * @param name defines the control name
  73555. */
  73556. constructor(name?: string | undefined);
  73557. protected _getTypeName(): string;
  73558. /** @hidden */
  73559. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73560. private _updateSquareProps;
  73561. private _drawGradientSquare;
  73562. private _drawCircle;
  73563. private _createColorWheelCanvas;
  73564. /** @hidden */
  73565. _draw(context: CanvasRenderingContext2D): void;
  73566. private _pointerIsDown;
  73567. private _updateValueFromPointer;
  73568. private _isPointOnSquare;
  73569. private _isPointOnWheel;
  73570. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73571. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73572. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73573. /**
  73574. * This function expands the color picker by creating a color picker dialog with manual
  73575. * color value input and the ability to save colors into an array to be used later in
  73576. * subsequent launches of the dialogue.
  73577. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73578. * @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.
  73579. * @returns picked color as a hex string and the saved colors array as hex strings.
  73580. */
  73581. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73582. pickerWidth?: string;
  73583. pickerHeight?: string;
  73584. headerHeight?: string;
  73585. lastColor?: string;
  73586. swatchLimit?: number;
  73587. numSwatchesPerLine?: number;
  73588. savedColors?: Array<string>;
  73589. }): Promise<{
  73590. savedColors?: string[];
  73591. pickedColor: string;
  73592. }>;
  73593. }
  73594. }
  73595. declare module BABYLON.GUI {
  73596. /** Class used to create 2D ellipse containers */
  73597. export class Ellipse extends Container {
  73598. name?: string | undefined;
  73599. private _thickness;
  73600. /** Gets or sets border thickness */
  73601. get thickness(): number;
  73602. set thickness(value: number);
  73603. /**
  73604. * Creates a new Ellipse
  73605. * @param name defines the control name
  73606. */
  73607. constructor(name?: string | undefined);
  73608. protected _getTypeName(): string;
  73609. protected _localDraw(context: CanvasRenderingContext2D): void;
  73610. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73611. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73612. }
  73613. }
  73614. declare module BABYLON.GUI {
  73615. /**
  73616. * Class used to create a password control
  73617. */
  73618. export class InputPassword extends InputText {
  73619. protected _beforeRenderText(text: string): string;
  73620. }
  73621. }
  73622. declare module BABYLON.GUI {
  73623. /** Class used to render 2D lines */
  73624. export class Line extends Control {
  73625. name?: string | undefined;
  73626. private _lineWidth;
  73627. private _x1;
  73628. private _y1;
  73629. private _x2;
  73630. private _y2;
  73631. private _dash;
  73632. private _connectedControl;
  73633. private _connectedControlDirtyObserver;
  73634. /** Gets or sets the dash pattern */
  73635. get dash(): Array<number>;
  73636. set dash(value: Array<number>);
  73637. /** Gets or sets the control connected with the line end */
  73638. get connectedControl(): Control;
  73639. set connectedControl(value: Control);
  73640. /** Gets or sets start coordinates on X axis */
  73641. get x1(): string | number;
  73642. set x1(value: string | number);
  73643. /** Gets or sets start coordinates on Y axis */
  73644. get y1(): string | number;
  73645. set y1(value: string | number);
  73646. /** Gets or sets end coordinates on X axis */
  73647. get x2(): string | number;
  73648. set x2(value: string | number);
  73649. /** Gets or sets end coordinates on Y axis */
  73650. get y2(): string | number;
  73651. set y2(value: string | number);
  73652. /** Gets or sets line width */
  73653. get lineWidth(): number;
  73654. set lineWidth(value: number);
  73655. /** Gets or sets horizontal alignment */
  73656. set horizontalAlignment(value: number);
  73657. /** Gets or sets vertical alignment */
  73658. set verticalAlignment(value: number);
  73659. private get _effectiveX2();
  73660. private get _effectiveY2();
  73661. /**
  73662. * Creates a new Line
  73663. * @param name defines the control name
  73664. */
  73665. constructor(name?: string | undefined);
  73666. protected _getTypeName(): string;
  73667. _draw(context: CanvasRenderingContext2D): void;
  73668. _measure(): void;
  73669. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73670. /**
  73671. * Move one end of the line given 3D cartesian coordinates.
  73672. * @param position Targeted world position
  73673. * @param scene BABYLON.Scene
  73674. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73675. */
  73676. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73677. /**
  73678. * Move one end of the line to a position in screen absolute space.
  73679. * @param projectedPosition Position in screen absolute space (X, Y)
  73680. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73681. */
  73682. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73683. }
  73684. }
  73685. declare module BABYLON.GUI {
  73686. /**
  73687. * Class used to store a point for a MultiLine object.
  73688. * The point can be pure 2D coordinates, a mesh or a control
  73689. */
  73690. export class MultiLinePoint {
  73691. private _multiLine;
  73692. private _x;
  73693. private _y;
  73694. private _control;
  73695. private _mesh;
  73696. private _controlObserver;
  73697. private _meshObserver;
  73698. /** @hidden */
  73699. _point: BABYLON.Vector2;
  73700. /**
  73701. * Creates a new MultiLinePoint
  73702. * @param multiLine defines the source MultiLine object
  73703. */
  73704. constructor(multiLine: MultiLine);
  73705. /** Gets or sets x coordinate */
  73706. get x(): string | number;
  73707. set x(value: string | number);
  73708. /** Gets or sets y coordinate */
  73709. get y(): string | number;
  73710. set y(value: string | number);
  73711. /** Gets or sets the control associated with this point */
  73712. get control(): BABYLON.Nullable<Control>;
  73713. set control(value: BABYLON.Nullable<Control>);
  73714. /** Gets or sets the mesh associated with this point */
  73715. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73716. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73717. /** Resets links */
  73718. resetLinks(): void;
  73719. /**
  73720. * Gets a translation vector
  73721. * @returns the translation vector
  73722. */
  73723. translate(): BABYLON.Vector2;
  73724. private _translatePoint;
  73725. /** Release associated resources */
  73726. dispose(): void;
  73727. }
  73728. }
  73729. declare module BABYLON.GUI {
  73730. /**
  73731. * Class used to create multi line control
  73732. */
  73733. export class MultiLine extends Control {
  73734. name?: string | undefined;
  73735. private _lineWidth;
  73736. private _dash;
  73737. private _points;
  73738. private _minX;
  73739. private _minY;
  73740. private _maxX;
  73741. private _maxY;
  73742. /**
  73743. * Creates a new MultiLine
  73744. * @param name defines the control name
  73745. */
  73746. constructor(name?: string | undefined);
  73747. /** Gets or sets dash pattern */
  73748. get dash(): Array<number>;
  73749. set dash(value: Array<number>);
  73750. /**
  73751. * Gets point stored at specified index
  73752. * @param index defines the index to look for
  73753. * @returns the requested point if found
  73754. */
  73755. getAt(index: number): MultiLinePoint;
  73756. /** Function called when a point is updated */
  73757. onPointUpdate: () => void;
  73758. /**
  73759. * Adds new points to the point collection
  73760. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73761. * @returns the list of created MultiLinePoint
  73762. */
  73763. add(...items: (AbstractMesh | Control | {
  73764. x: string | number;
  73765. y: string | number;
  73766. })[]): MultiLinePoint[];
  73767. /**
  73768. * Adds a new point to the point collection
  73769. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73770. * @returns the created MultiLinePoint
  73771. */
  73772. push(item?: (AbstractMesh | Control | {
  73773. x: string | number;
  73774. y: string | number;
  73775. })): MultiLinePoint;
  73776. /**
  73777. * Remove a specific value or point from the active point collection
  73778. * @param value defines the value or point to remove
  73779. */
  73780. remove(value: number | MultiLinePoint): void;
  73781. /**
  73782. * Resets this object to initial state (no point)
  73783. */
  73784. reset(): void;
  73785. /**
  73786. * Resets all links
  73787. */
  73788. resetLinks(): void;
  73789. /** Gets or sets line width */
  73790. get lineWidth(): number;
  73791. set lineWidth(value: number);
  73792. set horizontalAlignment(value: number);
  73793. set verticalAlignment(value: number);
  73794. protected _getTypeName(): string;
  73795. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73796. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73797. _measure(): void;
  73798. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73799. dispose(): void;
  73800. }
  73801. }
  73802. declare module BABYLON.GUI {
  73803. /**
  73804. * Class used to create radio button controls
  73805. */
  73806. export class RadioButton extends Control {
  73807. name?: string | undefined;
  73808. private _isChecked;
  73809. private _background;
  73810. private _checkSizeRatio;
  73811. private _thickness;
  73812. /** Gets or sets border thickness */
  73813. get thickness(): number;
  73814. set thickness(value: number);
  73815. /** Gets or sets group name */
  73816. group: string;
  73817. /** BABYLON.Observable raised when isChecked is changed */
  73818. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73819. /** Gets or sets a value indicating the ratio between overall size and check size */
  73820. get checkSizeRatio(): number;
  73821. set checkSizeRatio(value: number);
  73822. /** Gets or sets background color */
  73823. get background(): string;
  73824. set background(value: string);
  73825. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73826. get isChecked(): boolean;
  73827. set isChecked(value: boolean);
  73828. /**
  73829. * Creates a new RadioButton
  73830. * @param name defines the control name
  73831. */
  73832. constructor(name?: string | undefined);
  73833. protected _getTypeName(): string;
  73834. _draw(context: CanvasRenderingContext2D): void;
  73835. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73836. /**
  73837. * Utility function to easily create a radio button with a header
  73838. * @param title defines the label to use for the header
  73839. * @param group defines the group to use for the radio button
  73840. * @param isChecked defines the initial state of the radio button
  73841. * @param onValueChanged defines the callback to call when value changes
  73842. * @returns a StackPanel containing the radio button and a textBlock
  73843. */
  73844. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73845. }
  73846. }
  73847. declare module BABYLON.GUI {
  73848. /**
  73849. * Class used to create slider controls
  73850. */
  73851. export class BaseSlider extends Control {
  73852. name?: string | undefined;
  73853. protected _thumbWidth: ValueAndUnit;
  73854. private _minimum;
  73855. private _maximum;
  73856. private _value;
  73857. private _isVertical;
  73858. protected _barOffset: ValueAndUnit;
  73859. private _isThumbClamped;
  73860. protected _displayThumb: boolean;
  73861. private _step;
  73862. private _lastPointerDownID;
  73863. protected _effectiveBarOffset: number;
  73864. protected _renderLeft: number;
  73865. protected _renderTop: number;
  73866. protected _renderWidth: number;
  73867. protected _renderHeight: number;
  73868. protected _backgroundBoxLength: number;
  73869. protected _backgroundBoxThickness: number;
  73870. protected _effectiveThumbThickness: number;
  73871. /** BABYLON.Observable raised when the sldier value changes */
  73872. onValueChangedObservable: BABYLON.Observable<number>;
  73873. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73874. get displayThumb(): boolean;
  73875. set displayThumb(value: boolean);
  73876. /** Gets or sets a step to apply to values (0 by default) */
  73877. get step(): number;
  73878. set step(value: number);
  73879. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73880. get barOffset(): string | number;
  73881. /** Gets main bar offset in pixels*/
  73882. get barOffsetInPixels(): number;
  73883. set barOffset(value: string | number);
  73884. /** Gets or sets thumb width */
  73885. get thumbWidth(): string | number;
  73886. /** Gets thumb width in pixels */
  73887. get thumbWidthInPixels(): number;
  73888. set thumbWidth(value: string | number);
  73889. /** Gets or sets minimum value */
  73890. get minimum(): number;
  73891. set minimum(value: number);
  73892. /** Gets or sets maximum value */
  73893. get maximum(): number;
  73894. set maximum(value: number);
  73895. /** Gets or sets current value */
  73896. get value(): number;
  73897. set value(value: number);
  73898. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73899. get isVertical(): boolean;
  73900. set isVertical(value: boolean);
  73901. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73902. get isThumbClamped(): boolean;
  73903. set isThumbClamped(value: boolean);
  73904. /**
  73905. * Creates a new BaseSlider
  73906. * @param name defines the control name
  73907. */
  73908. constructor(name?: string | undefined);
  73909. protected _getTypeName(): string;
  73910. protected _getThumbPosition(): number;
  73911. protected _getThumbThickness(type: string): number;
  73912. protected _prepareRenderingData(type: string): void;
  73913. private _pointerIsDown;
  73914. /** @hidden */
  73915. protected _updateValueFromPointer(x: number, y: number): void;
  73916. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73917. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73918. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73919. }
  73920. }
  73921. declare module BABYLON.GUI {
  73922. /**
  73923. * Class used to create slider controls
  73924. */
  73925. export class Slider extends BaseSlider {
  73926. name?: string | undefined;
  73927. private _background;
  73928. private _borderColor;
  73929. private _isThumbCircle;
  73930. protected _displayValueBar: boolean;
  73931. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73932. get displayValueBar(): boolean;
  73933. set displayValueBar(value: boolean);
  73934. /** Gets or sets border color */
  73935. get borderColor(): string;
  73936. set borderColor(value: string);
  73937. /** Gets or sets background color */
  73938. get background(): string;
  73939. set background(value: string);
  73940. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73941. get isThumbCircle(): boolean;
  73942. set isThumbCircle(value: boolean);
  73943. /**
  73944. * Creates a new Slider
  73945. * @param name defines the control name
  73946. */
  73947. constructor(name?: string | undefined);
  73948. protected _getTypeName(): string;
  73949. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73950. }
  73951. }
  73952. declare module BABYLON.GUI {
  73953. /** Class used to create a RadioGroup
  73954. * which contains groups of radio buttons
  73955. */
  73956. export class SelectorGroup {
  73957. /** name of SelectorGroup */
  73958. name: string;
  73959. private _groupPanel;
  73960. private _selectors;
  73961. private _groupHeader;
  73962. /**
  73963. * Creates a new SelectorGroup
  73964. * @param name of group, used as a group heading
  73965. */
  73966. constructor(
  73967. /** name of SelectorGroup */
  73968. name: string);
  73969. /** Gets the groupPanel of the SelectorGroup */
  73970. get groupPanel(): StackPanel;
  73971. /** Gets the selectors array */
  73972. get selectors(): StackPanel[];
  73973. /** Gets and sets the group header */
  73974. get header(): string;
  73975. set header(label: string);
  73976. /** @hidden */
  73977. private _addGroupHeader;
  73978. /** @hidden*/
  73979. _getSelector(selectorNb: number): StackPanel | undefined;
  73980. /** Removes the selector at the given position
  73981. * @param selectorNb the position of the selector within the group
  73982. */
  73983. removeSelector(selectorNb: number): void;
  73984. }
  73985. /** Class used to create a CheckboxGroup
  73986. * which contains groups of checkbox buttons
  73987. */
  73988. export class CheckboxGroup extends SelectorGroup {
  73989. /** Adds a checkbox as a control
  73990. * @param text is the label for the selector
  73991. * @param func is the function called when the Selector is checked
  73992. * @param checked is true when Selector is checked
  73993. */
  73994. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73995. /** @hidden */
  73996. _setSelectorLabel(selectorNb: number, label: string): void;
  73997. /** @hidden */
  73998. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73999. /** @hidden */
  74000. _setSelectorButtonColor(selectorNb: number, color: string): void;
  74001. /** @hidden */
  74002. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  74003. }
  74004. /** Class used to create a RadioGroup
  74005. * which contains groups of radio buttons
  74006. */
  74007. export class RadioGroup extends SelectorGroup {
  74008. private _selectNb;
  74009. /** Adds a radio button as a control
  74010. * @param label is the label for the selector
  74011. * @param func is the function called when the Selector is checked
  74012. * @param checked is true when Selector is checked
  74013. */
  74014. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  74015. /** @hidden */
  74016. _setSelectorLabel(selectorNb: number, label: string): void;
  74017. /** @hidden */
  74018. _setSelectorLabelColor(selectorNb: number, color: string): void;
  74019. /** @hidden */
  74020. _setSelectorButtonColor(selectorNb: number, color: string): void;
  74021. /** @hidden */
  74022. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  74023. }
  74024. /** Class used to create a SliderGroup
  74025. * which contains groups of slider buttons
  74026. */
  74027. export class SliderGroup extends SelectorGroup {
  74028. /**
  74029. * Adds a slider to the SelectorGroup
  74030. * @param label is the label for the SliderBar
  74031. * @param func is the function called when the Slider moves
  74032. * @param unit is a string describing the units used, eg degrees or metres
  74033. * @param min is the minimum value for the Slider
  74034. * @param max is the maximum value for the Slider
  74035. * @param value is the start value for the Slider between min and max
  74036. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  74037. */
  74038. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  74039. /** @hidden */
  74040. _setSelectorLabel(selectorNb: number, label: string): void;
  74041. /** @hidden */
  74042. _setSelectorLabelColor(selectorNb: number, color: string): void;
  74043. /** @hidden */
  74044. _setSelectorButtonColor(selectorNb: number, color: string): void;
  74045. /** @hidden */
  74046. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  74047. }
  74048. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  74049. * @see http://doc.babylonjs.com/how_to/selector
  74050. */
  74051. export class SelectionPanel extends Rectangle {
  74052. /** name of SelectionPanel */
  74053. name: string;
  74054. /** an array of SelectionGroups */
  74055. groups: SelectorGroup[];
  74056. private _panel;
  74057. private _buttonColor;
  74058. private _buttonBackground;
  74059. private _headerColor;
  74060. private _barColor;
  74061. private _barHeight;
  74062. private _spacerHeight;
  74063. private _labelColor;
  74064. private _groups;
  74065. private _bars;
  74066. /**
  74067. * Creates a new SelectionPanel
  74068. * @param name of SelectionPanel
  74069. * @param groups is an array of SelectionGroups
  74070. */
  74071. constructor(
  74072. /** name of SelectionPanel */
  74073. name: string,
  74074. /** an array of SelectionGroups */
  74075. groups?: SelectorGroup[]);
  74076. protected _getTypeName(): string;
  74077. /** Gets or sets the headerColor */
  74078. get headerColor(): string;
  74079. set headerColor(color: string);
  74080. private _setHeaderColor;
  74081. /** Gets or sets the button color */
  74082. get buttonColor(): string;
  74083. set buttonColor(color: string);
  74084. private _setbuttonColor;
  74085. /** Gets or sets the label color */
  74086. get labelColor(): string;
  74087. set labelColor(color: string);
  74088. private _setLabelColor;
  74089. /** Gets or sets the button background */
  74090. get buttonBackground(): string;
  74091. set buttonBackground(color: string);
  74092. private _setButtonBackground;
  74093. /** Gets or sets the color of separator bar */
  74094. get barColor(): string;
  74095. set barColor(color: string);
  74096. private _setBarColor;
  74097. /** Gets or sets the height of separator bar */
  74098. get barHeight(): string;
  74099. set barHeight(value: string);
  74100. private _setBarHeight;
  74101. /** Gets or sets the height of spacers*/
  74102. get spacerHeight(): string;
  74103. set spacerHeight(value: string);
  74104. private _setSpacerHeight;
  74105. /** Adds a bar between groups */
  74106. private _addSpacer;
  74107. /** Add a group to the selection panel
  74108. * @param group is the selector group to add
  74109. */
  74110. addGroup(group: SelectorGroup): void;
  74111. /** Remove the group from the given position
  74112. * @param groupNb is the position of the group in the list
  74113. */
  74114. removeGroup(groupNb: number): void;
  74115. /** Change a group header label
  74116. * @param label is the new group header label
  74117. * @param groupNb is the number of the group to relabel
  74118. * */
  74119. setHeaderName(label: string, groupNb: number): void;
  74120. /** Change selector label to the one given
  74121. * @param label is the new selector label
  74122. * @param groupNb is the number of the groupcontaining the selector
  74123. * @param selectorNb is the number of the selector within a group to relabel
  74124. * */
  74125. relabel(label: string, groupNb: number, selectorNb: number): void;
  74126. /** For a given group position remove the selector at the given position
  74127. * @param groupNb is the number of the group to remove the selector from
  74128. * @param selectorNb is the number of the selector within the group
  74129. */
  74130. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  74131. /** For a given group position of correct type add a checkbox button
  74132. * @param groupNb is the number of the group to remove the selector from
  74133. * @param label is the label for the selector
  74134. * @param func is the function called when the Selector is checked
  74135. * @param checked is true when Selector is checked
  74136. */
  74137. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74138. /** For a given group position of correct type add a radio button
  74139. * @param groupNb is the number of the group to remove the selector from
  74140. * @param label is the label for the selector
  74141. * @param func is the function called when the Selector is checked
  74142. * @param checked is true when Selector is checked
  74143. */
  74144. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74145. /**
  74146. * For a given slider group add a slider
  74147. * @param groupNb is the number of the group to add the slider to
  74148. * @param label is the label for the Slider
  74149. * @param func is the function called when the Slider moves
  74150. * @param unit is a string describing the units used, eg degrees or metres
  74151. * @param min is the minimum value for the Slider
  74152. * @param max is the maximum value for the Slider
  74153. * @param value is the start value for the Slider between min and max
  74154. * @param onVal is the function used to format the value displayed, eg radians to degrees
  74155. */
  74156. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  74157. }
  74158. }
  74159. declare module BABYLON.GUI {
  74160. /**
  74161. * Class used to hold a the container for ScrollViewer
  74162. * @hidden
  74163. */
  74164. export class _ScrollViewerWindow extends Container {
  74165. parentClientWidth: number;
  74166. parentClientHeight: number;
  74167. private _freezeControls;
  74168. private _parentMeasure;
  74169. private _oldLeft;
  74170. private _oldTop;
  74171. get freezeControls(): boolean;
  74172. set freezeControls(value: boolean);
  74173. private _bucketWidth;
  74174. private _bucketHeight;
  74175. private _buckets;
  74176. private _bucketLen;
  74177. get bucketWidth(): number;
  74178. get bucketHeight(): number;
  74179. setBucketSizes(width: number, height: number): void;
  74180. private _useBuckets;
  74181. private _makeBuckets;
  74182. private _dispatchInBuckets;
  74183. private _updateMeasures;
  74184. private _updateChildrenMeasures;
  74185. private _restoreMeasures;
  74186. /**
  74187. * Creates a new ScrollViewerWindow
  74188. * @param name of ScrollViewerWindow
  74189. */
  74190. constructor(name?: string);
  74191. protected _getTypeName(): string;
  74192. /** @hidden */
  74193. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74194. /** @hidden */
  74195. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74196. private _scrollChildren;
  74197. private _scrollChildrenWithBuckets;
  74198. /** @hidden */
  74199. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  74200. protected _postMeasure(): void;
  74201. }
  74202. }
  74203. declare module BABYLON.GUI {
  74204. /**
  74205. * Class used to create slider controls
  74206. */
  74207. export class ScrollBar extends BaseSlider {
  74208. name?: string | undefined;
  74209. private _background;
  74210. private _borderColor;
  74211. private _tempMeasure;
  74212. /** Gets or sets border color */
  74213. get borderColor(): string;
  74214. set borderColor(value: string);
  74215. /** Gets or sets background color */
  74216. get background(): string;
  74217. set background(value: string);
  74218. /**
  74219. * Creates a new Slider
  74220. * @param name defines the control name
  74221. */
  74222. constructor(name?: string | undefined);
  74223. protected _getTypeName(): string;
  74224. protected _getThumbThickness(): number;
  74225. _draw(context: CanvasRenderingContext2D): void;
  74226. private _first;
  74227. private _originX;
  74228. private _originY;
  74229. /** @hidden */
  74230. protected _updateValueFromPointer(x: number, y: number): void;
  74231. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74232. }
  74233. }
  74234. declare module BABYLON.GUI {
  74235. /**
  74236. * Class used to create slider controls
  74237. */
  74238. export class ImageScrollBar extends BaseSlider {
  74239. name?: string | undefined;
  74240. private _backgroundBaseImage;
  74241. private _backgroundImage;
  74242. private _thumbImage;
  74243. private _thumbBaseImage;
  74244. private _thumbLength;
  74245. private _thumbHeight;
  74246. private _barImageHeight;
  74247. private _tempMeasure;
  74248. /** Number of 90° rotation to apply on the images when in vertical mode */
  74249. num90RotationInVerticalMode: number;
  74250. /**
  74251. * Gets or sets the image used to render the background for horizontal bar
  74252. */
  74253. get backgroundImage(): Image;
  74254. set backgroundImage(value: Image);
  74255. /**
  74256. * Gets or sets the image used to render the thumb
  74257. */
  74258. get thumbImage(): Image;
  74259. set thumbImage(value: Image);
  74260. /**
  74261. * Gets or sets the length of the thumb
  74262. */
  74263. get thumbLength(): number;
  74264. set thumbLength(value: number);
  74265. /**
  74266. * Gets or sets the height of the thumb
  74267. */
  74268. get thumbHeight(): number;
  74269. set thumbHeight(value: number);
  74270. /**
  74271. * Gets or sets the height of the bar image
  74272. */
  74273. get barImageHeight(): number;
  74274. set barImageHeight(value: number);
  74275. /**
  74276. * Creates a new ImageScrollBar
  74277. * @param name defines the control name
  74278. */
  74279. constructor(name?: string | undefined);
  74280. protected _getTypeName(): string;
  74281. protected _getThumbThickness(): number;
  74282. _draw(context: CanvasRenderingContext2D): void;
  74283. private _first;
  74284. private _originX;
  74285. private _originY;
  74286. /** @hidden */
  74287. protected _updateValueFromPointer(x: number, y: number): void;
  74288. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74289. }
  74290. }
  74291. declare module BABYLON.GUI {
  74292. /**
  74293. * Class used to hold a viewer window and sliders in a grid
  74294. */
  74295. export class ScrollViewer extends Rectangle {
  74296. private _grid;
  74297. private _horizontalBarSpace;
  74298. private _verticalBarSpace;
  74299. private _dragSpace;
  74300. private _horizontalBar;
  74301. private _verticalBar;
  74302. private _barColor;
  74303. private _barBackground;
  74304. private _barImage;
  74305. private _horizontalBarImage;
  74306. private _verticalBarImage;
  74307. private _barBackgroundImage;
  74308. private _horizontalBarBackgroundImage;
  74309. private _verticalBarBackgroundImage;
  74310. private _barSize;
  74311. private _window;
  74312. private _pointerIsOver;
  74313. private _wheelPrecision;
  74314. private _onWheelObserver;
  74315. private _clientWidth;
  74316. private _clientHeight;
  74317. private _useImageBar;
  74318. private _thumbLength;
  74319. private _thumbHeight;
  74320. private _barImageHeight;
  74321. private _horizontalBarImageHeight;
  74322. private _verticalBarImageHeight;
  74323. private _oldWindowContentsWidth;
  74324. private _oldWindowContentsHeight;
  74325. /**
  74326. * Gets the horizontal scrollbar
  74327. */
  74328. get horizontalBar(): ScrollBar | ImageScrollBar;
  74329. /**
  74330. * Gets the vertical scrollbar
  74331. */
  74332. get verticalBar(): ScrollBar | ImageScrollBar;
  74333. /**
  74334. * Adds a new control to the current container
  74335. * @param control defines the control to add
  74336. * @returns the current container
  74337. */
  74338. addControl(control: BABYLON.Nullable<Control>): Container;
  74339. /**
  74340. * Removes a control from the current container
  74341. * @param control defines the control to remove
  74342. * @returns the current container
  74343. */
  74344. removeControl(control: Control): Container;
  74345. /** Gets the list of children */
  74346. get children(): Control[];
  74347. _flagDescendantsAsMatrixDirty(): void;
  74348. /**
  74349. * Freezes or unfreezes the controls in the window.
  74350. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  74351. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  74352. */
  74353. get freezeControls(): boolean;
  74354. set freezeControls(value: boolean);
  74355. /** Gets the bucket width */
  74356. get bucketWidth(): number;
  74357. /** Gets the bucket height */
  74358. get bucketHeight(): number;
  74359. /**
  74360. * Sets the bucket sizes.
  74361. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  74362. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  74363. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  74364. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  74365. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  74366. * used), that's why it is not enabled by default.
  74367. * @param width width of the bucket
  74368. * @param height height of the bucket
  74369. */
  74370. setBucketSizes(width: number, height: number): void;
  74371. private _forceHorizontalBar;
  74372. private _forceVerticalBar;
  74373. /**
  74374. * Forces the horizontal scroll bar to be displayed
  74375. */
  74376. get forceHorizontalBar(): boolean;
  74377. set forceHorizontalBar(value: boolean);
  74378. /**
  74379. * Forces the vertical scroll bar to be displayed
  74380. */
  74381. get forceVerticalBar(): boolean;
  74382. set forceVerticalBar(value: boolean);
  74383. /**
  74384. * Creates a new ScrollViewer
  74385. * @param name of ScrollViewer
  74386. */
  74387. constructor(name?: string, isImageBased?: boolean);
  74388. /** Reset the scroll viewer window to initial size */
  74389. resetWindow(): void;
  74390. protected _getTypeName(): string;
  74391. private _buildClientSizes;
  74392. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74393. protected _postMeasure(): void;
  74394. /**
  74395. * Gets or sets the mouse wheel precision
  74396. * from 0 to 1 with a default value of 0.05
  74397. * */
  74398. get wheelPrecision(): number;
  74399. set wheelPrecision(value: number);
  74400. /** Gets or sets the scroll bar container background color */
  74401. get scrollBackground(): string;
  74402. set scrollBackground(color: string);
  74403. /** Gets or sets the bar color */
  74404. get barColor(): string;
  74405. set barColor(color: string);
  74406. /** Gets or sets the bar image */
  74407. get thumbImage(): Image;
  74408. set thumbImage(value: Image);
  74409. /** Gets or sets the horizontal bar image */
  74410. get horizontalThumbImage(): Image;
  74411. set horizontalThumbImage(value: Image);
  74412. /** Gets or sets the vertical bar image */
  74413. get verticalThumbImage(): Image;
  74414. set verticalThumbImage(value: Image);
  74415. /** Gets or sets the size of the bar */
  74416. get barSize(): number;
  74417. set barSize(value: number);
  74418. /** Gets or sets the length of the thumb */
  74419. get thumbLength(): number;
  74420. set thumbLength(value: number);
  74421. /** Gets or sets the height of the thumb */
  74422. get thumbHeight(): number;
  74423. set thumbHeight(value: number);
  74424. /** Gets or sets the height of the bar image */
  74425. get barImageHeight(): number;
  74426. set barImageHeight(value: number);
  74427. /** Gets or sets the height of the horizontal bar image */
  74428. get horizontalBarImageHeight(): number;
  74429. set horizontalBarImageHeight(value: number);
  74430. /** Gets or sets the height of the vertical bar image */
  74431. get verticalBarImageHeight(): number;
  74432. set verticalBarImageHeight(value: number);
  74433. /** Gets or sets the bar background */
  74434. get barBackground(): string;
  74435. set barBackground(color: string);
  74436. /** Gets or sets the bar background image */
  74437. get barImage(): Image;
  74438. set barImage(value: Image);
  74439. /** Gets or sets the horizontal bar background image */
  74440. get horizontalBarImage(): Image;
  74441. set horizontalBarImage(value: Image);
  74442. /** Gets or sets the vertical bar background image */
  74443. get verticalBarImage(): Image;
  74444. set verticalBarImage(value: Image);
  74445. private _setWindowPosition;
  74446. /** @hidden */
  74447. private _updateScroller;
  74448. _link(host: AdvancedDynamicTexture): void;
  74449. /** @hidden */
  74450. private _addBar;
  74451. /** @hidden */
  74452. private _attachWheel;
  74453. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74454. /** Releases associated resources */
  74455. dispose(): void;
  74456. }
  74457. }
  74458. declare module BABYLON.GUI {
  74459. /** Class used to render a grid */
  74460. export class DisplayGrid extends Control {
  74461. name?: string | undefined;
  74462. private _cellWidth;
  74463. private _cellHeight;
  74464. private _minorLineTickness;
  74465. private _minorLineColor;
  74466. private _majorLineTickness;
  74467. private _majorLineColor;
  74468. private _majorLineFrequency;
  74469. private _background;
  74470. private _displayMajorLines;
  74471. private _displayMinorLines;
  74472. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74473. get displayMinorLines(): boolean;
  74474. set displayMinorLines(value: boolean);
  74475. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74476. get displayMajorLines(): boolean;
  74477. set displayMajorLines(value: boolean);
  74478. /** Gets or sets background color (Black by default) */
  74479. get background(): string;
  74480. set background(value: string);
  74481. /** Gets or sets the width of each cell (20 by default) */
  74482. get cellWidth(): number;
  74483. set cellWidth(value: number);
  74484. /** Gets or sets the height of each cell (20 by default) */
  74485. get cellHeight(): number;
  74486. set cellHeight(value: number);
  74487. /** Gets or sets the tickness of minor lines (1 by default) */
  74488. get minorLineTickness(): number;
  74489. set minorLineTickness(value: number);
  74490. /** Gets or sets the color of minor lines (DarkGray by default) */
  74491. get minorLineColor(): string;
  74492. set minorLineColor(value: string);
  74493. /** Gets or sets the tickness of major lines (2 by default) */
  74494. get majorLineTickness(): number;
  74495. set majorLineTickness(value: number);
  74496. /** Gets or sets the color of major lines (White by default) */
  74497. get majorLineColor(): string;
  74498. set majorLineColor(value: string);
  74499. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74500. get majorLineFrequency(): number;
  74501. set majorLineFrequency(value: number);
  74502. /**
  74503. * Creates a new GridDisplayRectangle
  74504. * @param name defines the control name
  74505. */
  74506. constructor(name?: string | undefined);
  74507. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74508. protected _getTypeName(): string;
  74509. }
  74510. }
  74511. declare module BABYLON.GUI {
  74512. /**
  74513. * Class used to create slider controls based on images
  74514. */
  74515. export class ImageBasedSlider extends BaseSlider {
  74516. name?: string | undefined;
  74517. private _backgroundImage;
  74518. private _thumbImage;
  74519. private _valueBarImage;
  74520. private _tempMeasure;
  74521. get displayThumb(): boolean;
  74522. set displayThumb(value: boolean);
  74523. /**
  74524. * Gets or sets the image used to render the background
  74525. */
  74526. get backgroundImage(): Image;
  74527. set backgroundImage(value: Image);
  74528. /**
  74529. * Gets or sets the image used to render the value bar
  74530. */
  74531. get valueBarImage(): Image;
  74532. set valueBarImage(value: Image);
  74533. /**
  74534. * Gets or sets the image used to render the thumb
  74535. */
  74536. get thumbImage(): Image;
  74537. set thumbImage(value: Image);
  74538. /**
  74539. * Creates a new ImageBasedSlider
  74540. * @param name defines the control name
  74541. */
  74542. constructor(name?: string | undefined);
  74543. protected _getTypeName(): string;
  74544. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74545. }
  74546. }
  74547. declare module BABYLON.GUI {
  74548. /**
  74549. * Forcing an export so that this code will execute
  74550. * @hidden
  74551. */
  74552. const name = "Statics";
  74553. }
  74554. declare module BABYLON.GUI {
  74555. /**
  74556. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74557. */
  74558. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74559. /**
  74560. * Define the instrumented AdvancedDynamicTexture.
  74561. */
  74562. texture: AdvancedDynamicTexture;
  74563. private _captureRenderTime;
  74564. private _renderTime;
  74565. private _captureLayoutTime;
  74566. private _layoutTime;
  74567. private _onBeginRenderObserver;
  74568. private _onEndRenderObserver;
  74569. private _onBeginLayoutObserver;
  74570. private _onEndLayoutObserver;
  74571. /**
  74572. * Gets the perf counter used to capture render time
  74573. */
  74574. get renderTimeCounter(): BABYLON.PerfCounter;
  74575. /**
  74576. * Gets the perf counter used to capture layout time
  74577. */
  74578. get layoutTimeCounter(): BABYLON.PerfCounter;
  74579. /**
  74580. * Enable or disable the render time capture
  74581. */
  74582. get captureRenderTime(): boolean;
  74583. set captureRenderTime(value: boolean);
  74584. /**
  74585. * Enable or disable the layout time capture
  74586. */
  74587. get captureLayoutTime(): boolean;
  74588. set captureLayoutTime(value: boolean);
  74589. /**
  74590. * Instantiates a new advanced dynamic texture instrumentation.
  74591. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74592. * @param texture Defines the AdvancedDynamicTexture to instrument
  74593. */
  74594. constructor(
  74595. /**
  74596. * Define the instrumented AdvancedDynamicTexture.
  74597. */
  74598. texture: AdvancedDynamicTexture);
  74599. /**
  74600. * Dispose and release associated resources.
  74601. */
  74602. dispose(): void;
  74603. }
  74604. }
  74605. declare module BABYLON.GUI {
  74606. /**
  74607. * Class used to load GUI via XML.
  74608. */
  74609. export class XmlLoader {
  74610. private _nodes;
  74611. private _nodeTypes;
  74612. private _isLoaded;
  74613. private _objectAttributes;
  74614. private _parentClass;
  74615. /**
  74616. * Create a new xml loader
  74617. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74618. */
  74619. constructor(parentClass?: null);
  74620. private _getChainElement;
  74621. private _getClassAttribute;
  74622. private _createGuiElement;
  74623. private _parseGrid;
  74624. private _parseElement;
  74625. private _prepareSourceElement;
  74626. private _parseElementsFromSource;
  74627. private _parseXml;
  74628. /**
  74629. * Gets if the loading has finished.
  74630. * @returns whether the loading has finished or not
  74631. */
  74632. isLoaded(): boolean;
  74633. /**
  74634. * Gets a loaded node / control by id.
  74635. * @param id the Controls id set in the xml
  74636. * @returns element of type Control
  74637. */
  74638. getNodeById(id: string): any;
  74639. /**
  74640. * Gets all loaded nodes / controls
  74641. * @returns Array of controls
  74642. */
  74643. getNodes(): any;
  74644. /**
  74645. * Initiates the xml layout loading
  74646. * @param xmlFile defines the xml layout to load
  74647. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74648. * @param callback defines the callback called on layout load.
  74649. */
  74650. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74651. }
  74652. }
  74653. declare module BABYLON.GUI {
  74654. /**
  74655. * Class used to create containers for controls
  74656. */
  74657. export class Container3D extends Control3D {
  74658. private _blockLayout;
  74659. /**
  74660. * Gets the list of child controls
  74661. */
  74662. protected _children: Control3D[];
  74663. /**
  74664. * Gets the list of child controls
  74665. */
  74666. get children(): Array<Control3D>;
  74667. /**
  74668. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74669. * This is helpful to optimize layout operation when adding multiple children in a row
  74670. */
  74671. get blockLayout(): boolean;
  74672. set blockLayout(value: boolean);
  74673. /**
  74674. * Creates a new container
  74675. * @param name defines the container name
  74676. */
  74677. constructor(name?: string);
  74678. /**
  74679. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74680. * @returns the current container
  74681. */
  74682. updateLayout(): Container3D;
  74683. /**
  74684. * Gets a boolean indicating if the given control is in the children of this control
  74685. * @param control defines the control to check
  74686. * @returns true if the control is in the child list
  74687. */
  74688. containsControl(control: Control3D): boolean;
  74689. /**
  74690. * Adds a control to the children of this control
  74691. * @param control defines the control to add
  74692. * @returns the current container
  74693. */
  74694. addControl(control: Control3D): Container3D;
  74695. /**
  74696. * This function will be called everytime a new control is added
  74697. */
  74698. protected _arrangeChildren(): void;
  74699. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74700. /**
  74701. * Removes a control from the children of this control
  74702. * @param control defines the control to remove
  74703. * @returns the current container
  74704. */
  74705. removeControl(control: Control3D): Container3D;
  74706. protected _getTypeName(): string;
  74707. /**
  74708. * Releases all associated resources
  74709. */
  74710. dispose(): void;
  74711. /** Control rotation will remain unchanged */
  74712. static readonly UNSET_ORIENTATION: number;
  74713. /** Control will rotate to make it look at sphere central axis */
  74714. static readonly FACEORIGIN_ORIENTATION: number;
  74715. /** Control will rotate to make it look back at sphere central axis */
  74716. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74717. /** Control will rotate to look at z axis (0, 0, 1) */
  74718. static readonly FACEFORWARD_ORIENTATION: number;
  74719. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74720. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74721. }
  74722. }
  74723. declare module BABYLON.GUI {
  74724. /**
  74725. * Class used to manage 3D user interface
  74726. * @see http://doc.babylonjs.com/how_to/gui3d
  74727. */
  74728. export class GUI3DManager implements BABYLON.IDisposable {
  74729. private _scene;
  74730. private _sceneDisposeObserver;
  74731. private _utilityLayer;
  74732. private _rootContainer;
  74733. private _pointerObserver;
  74734. private _pointerOutObserver;
  74735. /** @hidden */
  74736. _lastPickedControl: Control3D;
  74737. /** @hidden */
  74738. _lastControlOver: {
  74739. [pointerId: number]: Control3D;
  74740. };
  74741. /** @hidden */
  74742. _lastControlDown: {
  74743. [pointerId: number]: Control3D;
  74744. };
  74745. /**
  74746. * BABYLON.Observable raised when the point picked by the pointer events changed
  74747. */
  74748. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74749. /** @hidden */
  74750. _sharedMaterials: {
  74751. [key: string]: BABYLON.Material;
  74752. };
  74753. /** Gets the hosting scene */
  74754. get scene(): BABYLON.Scene;
  74755. /** Gets associated utility layer */
  74756. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74757. /**
  74758. * Creates a new GUI3DManager
  74759. * @param scene
  74760. */
  74761. constructor(scene?: BABYLON.Scene);
  74762. private _handlePointerOut;
  74763. private _doPicking;
  74764. /**
  74765. * Gets the root container
  74766. */
  74767. get rootContainer(): Container3D;
  74768. /**
  74769. * Gets a boolean indicating if the given control is in the root child list
  74770. * @param control defines the control to check
  74771. * @returns true if the control is in the root child list
  74772. */
  74773. containsControl(control: Control3D): boolean;
  74774. /**
  74775. * Adds a control to the root child list
  74776. * @param control defines the control to add
  74777. * @returns the current manager
  74778. */
  74779. addControl(control: Control3D): GUI3DManager;
  74780. /**
  74781. * Removes a control from the root child list
  74782. * @param control defines the control to remove
  74783. * @returns the current container
  74784. */
  74785. removeControl(control: Control3D): GUI3DManager;
  74786. /**
  74787. * Releases all associated resources
  74788. */
  74789. dispose(): void;
  74790. }
  74791. }
  74792. declare module BABYLON.GUI {
  74793. /**
  74794. * Class used to transport BABYLON.Vector3 information for pointer events
  74795. */
  74796. export class Vector3WithInfo extends BABYLON.Vector3 {
  74797. /** defines the current mouse button index */
  74798. buttonIndex: number;
  74799. /**
  74800. * Creates a new Vector3WithInfo
  74801. * @param source defines the vector3 data to transport
  74802. * @param buttonIndex defines the current mouse button index
  74803. */
  74804. constructor(source: BABYLON.Vector3,
  74805. /** defines the current mouse button index */
  74806. buttonIndex?: number);
  74807. }
  74808. }
  74809. declare module BABYLON.GUI {
  74810. /**
  74811. * Class used as base class for controls
  74812. */
  74813. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74814. /** Defines the control name */
  74815. name?: string | undefined;
  74816. /** @hidden */
  74817. _host: GUI3DManager;
  74818. private _node;
  74819. private _downCount;
  74820. private _enterCount;
  74821. private _downPointerIds;
  74822. private _isVisible;
  74823. /** Gets or sets the control position in world space */
  74824. get position(): BABYLON.Vector3;
  74825. set position(value: BABYLON.Vector3);
  74826. /** Gets or sets the control scaling in world space */
  74827. get scaling(): BABYLON.Vector3;
  74828. set scaling(value: BABYLON.Vector3);
  74829. /** Callback used to start pointer enter animation */
  74830. pointerEnterAnimation: () => void;
  74831. /** Callback used to start pointer out animation */
  74832. pointerOutAnimation: () => void;
  74833. /** Callback used to start pointer down animation */
  74834. pointerDownAnimation: () => void;
  74835. /** Callback used to start pointer up animation */
  74836. pointerUpAnimation: () => void;
  74837. /**
  74838. * An event triggered when the pointer move over the control
  74839. */
  74840. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74841. /**
  74842. * An event triggered when the pointer move out of the control
  74843. */
  74844. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74845. /**
  74846. * An event triggered when the pointer taps the control
  74847. */
  74848. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74849. /**
  74850. * An event triggered when pointer is up
  74851. */
  74852. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74853. /**
  74854. * An event triggered when a control is clicked on (with a mouse)
  74855. */
  74856. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74857. /**
  74858. * An event triggered when pointer enters the control
  74859. */
  74860. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74861. /**
  74862. * Gets or sets the parent container
  74863. */
  74864. parent: BABYLON.Nullable<Container3D>;
  74865. private _behaviors;
  74866. /**
  74867. * Gets the list of attached behaviors
  74868. * @see http://doc.babylonjs.com/features/behaviour
  74869. */
  74870. get behaviors(): BABYLON.Behavior<Control3D>[];
  74871. /**
  74872. * Attach a behavior to the control
  74873. * @see http://doc.babylonjs.com/features/behaviour
  74874. * @param behavior defines the behavior to attach
  74875. * @returns the current control
  74876. */
  74877. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74878. /**
  74879. * Remove an attached behavior
  74880. * @see http://doc.babylonjs.com/features/behaviour
  74881. * @param behavior defines the behavior to attach
  74882. * @returns the current control
  74883. */
  74884. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74885. /**
  74886. * Gets an attached behavior by name
  74887. * @param name defines the name of the behavior to look for
  74888. * @see http://doc.babylonjs.com/features/behaviour
  74889. * @returns null if behavior was not found else the requested behavior
  74890. */
  74891. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74892. /** Gets or sets a boolean indicating if the control is visible */
  74893. get isVisible(): boolean;
  74894. set isVisible(value: boolean);
  74895. /**
  74896. * Creates a new control
  74897. * @param name defines the control name
  74898. */
  74899. constructor(
  74900. /** Defines the control name */
  74901. name?: string | undefined);
  74902. /**
  74903. * Gets a string representing the class name
  74904. */
  74905. get typeName(): string;
  74906. /**
  74907. * Get the current class name of the control.
  74908. * @returns current class name
  74909. */
  74910. getClassName(): string;
  74911. protected _getTypeName(): string;
  74912. /**
  74913. * Gets the transform node used by this control
  74914. */
  74915. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74916. /**
  74917. * Gets the mesh used to render this control
  74918. */
  74919. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74920. /**
  74921. * Link the control as child of the given node
  74922. * @param node defines the node to link to. Use null to unlink the control
  74923. * @returns the current control
  74924. */
  74925. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74926. /** @hidden **/
  74927. _prepareNode(scene: BABYLON.Scene): void;
  74928. /**
  74929. * Node creation.
  74930. * Can be overriden by children
  74931. * @param scene defines the scene where the node must be attached
  74932. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74933. */
  74934. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74935. /**
  74936. * Affect a material to the given mesh
  74937. * @param mesh defines the mesh which will represent the control
  74938. */
  74939. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74940. /** @hidden */
  74941. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74942. /** @hidden */
  74943. _onPointerEnter(target: Control3D): boolean;
  74944. /** @hidden */
  74945. _onPointerOut(target: Control3D): void;
  74946. /** @hidden */
  74947. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74948. /** @hidden */
  74949. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74950. /** @hidden */
  74951. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74952. /** @hidden */
  74953. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74954. /** @hidden */
  74955. _disposeNode(): void;
  74956. /**
  74957. * Releases all associated resources
  74958. */
  74959. dispose(): void;
  74960. }
  74961. }
  74962. declare module BABYLON.GUI {
  74963. /**
  74964. * Class used as a root to all buttons
  74965. */
  74966. export class AbstractButton3D extends Control3D {
  74967. /**
  74968. * Creates a new button
  74969. * @param name defines the control name
  74970. */
  74971. constructor(name?: string);
  74972. protected _getTypeName(): string;
  74973. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74974. }
  74975. }
  74976. declare module BABYLON.GUI {
  74977. /**
  74978. * Class used to create a button in 3D
  74979. */
  74980. export class Button3D extends AbstractButton3D {
  74981. /** @hidden */
  74982. protected _currentMaterial: BABYLON.Material;
  74983. private _facadeTexture;
  74984. private _content;
  74985. private _contentResolution;
  74986. private _contentScaleRatio;
  74987. /**
  74988. * Gets or sets the texture resolution used to render content (512 by default)
  74989. */
  74990. get contentResolution(): BABYLON.int;
  74991. set contentResolution(value: BABYLON.int);
  74992. /**
  74993. * Gets or sets the texture scale ratio used to render content (2 by default)
  74994. */
  74995. get contentScaleRatio(): number;
  74996. set contentScaleRatio(value: number);
  74997. protected _disposeFacadeTexture(): void;
  74998. protected _resetContent(): void;
  74999. /**
  75000. * Creates a new button
  75001. * @param name defines the control name
  75002. */
  75003. constructor(name?: string);
  75004. /**
  75005. * Gets or sets the GUI 2D content used to display the button's facade
  75006. */
  75007. get content(): Control;
  75008. set content(value: Control);
  75009. /**
  75010. * Apply the facade texture (created from the content property).
  75011. * This function can be overloaded by child classes
  75012. * @param facadeTexture defines the AdvancedDynamicTexture to use
  75013. */
  75014. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75015. protected _getTypeName(): string;
  75016. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75017. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75018. /**
  75019. * Releases all associated resources
  75020. */
  75021. dispose(): void;
  75022. }
  75023. }
  75024. declare module BABYLON.GUI {
  75025. /**
  75026. * Abstract class used to create a container panel deployed on the surface of a volume
  75027. */
  75028. export abstract class VolumeBasedPanel extends Container3D {
  75029. private _columns;
  75030. private _rows;
  75031. private _rowThenColum;
  75032. private _orientation;
  75033. protected _cellWidth: number;
  75034. protected _cellHeight: number;
  75035. /**
  75036. * Gets or sets the distance between elements
  75037. */
  75038. margin: number;
  75039. /**
  75040. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  75041. * | Value | Type | Description |
  75042. * | ----- | ----------------------------------- | ----------- |
  75043. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  75044. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  75045. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  75046. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  75047. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  75048. */
  75049. get orientation(): number;
  75050. set orientation(value: number);
  75051. /**
  75052. * Gets or sets the number of columns requested (10 by default).
  75053. * The panel will automatically compute the number of rows based on number of child controls.
  75054. */
  75055. get columns(): BABYLON.int;
  75056. set columns(value: BABYLON.int);
  75057. /**
  75058. * Gets or sets a the number of rows requested.
  75059. * The panel will automatically compute the number of columns based on number of child controls.
  75060. */
  75061. get rows(): BABYLON.int;
  75062. set rows(value: BABYLON.int);
  75063. /**
  75064. * Creates new VolumeBasedPanel
  75065. */
  75066. constructor();
  75067. protected _arrangeChildren(): void;
  75068. /** Child classes must implement this function to provide correct control positioning */
  75069. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75070. /** Child classes can implement this function to provide additional processing */
  75071. protected _finalProcessing(): void;
  75072. }
  75073. }
  75074. declare module BABYLON.GUI {
  75075. /**
  75076. * Class used to create a container panel deployed on the surface of a cylinder
  75077. */
  75078. export class CylinderPanel extends VolumeBasedPanel {
  75079. private _radius;
  75080. /**
  75081. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  75082. */
  75083. get radius(): BABYLON.float;
  75084. set radius(value: BABYLON.float);
  75085. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75086. private _cylindricalMapping;
  75087. }
  75088. }
  75089. declare module BABYLON.GUI {
  75090. /** @hidden */
  75091. export var fluentVertexShader: {
  75092. name: string;
  75093. shader: string;
  75094. };
  75095. }
  75096. declare module BABYLON.GUI {
  75097. /** @hidden */
  75098. export var fluentPixelShader: {
  75099. name: string;
  75100. shader: string;
  75101. };
  75102. }
  75103. declare module BABYLON.GUI {
  75104. /** @hidden */
  75105. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  75106. INNERGLOW: boolean;
  75107. BORDER: boolean;
  75108. HOVERLIGHT: boolean;
  75109. TEXTURE: boolean;
  75110. constructor();
  75111. }
  75112. /**
  75113. * Class used to render controls with fluent desgin
  75114. */
  75115. export class FluentMaterial extends BABYLON.PushMaterial {
  75116. /**
  75117. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  75118. */
  75119. innerGlowColorIntensity: number;
  75120. /**
  75121. * Gets or sets the inner glow color (white by default)
  75122. */
  75123. innerGlowColor: BABYLON.Color3;
  75124. /**
  75125. * Gets or sets alpha value (default is 1.0)
  75126. */
  75127. alpha: number;
  75128. /**
  75129. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  75130. */
  75131. albedoColor: BABYLON.Color3;
  75132. /**
  75133. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  75134. */
  75135. renderBorders: boolean;
  75136. /**
  75137. * Gets or sets border width (default is 0.5)
  75138. */
  75139. borderWidth: number;
  75140. /**
  75141. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  75142. */
  75143. edgeSmoothingValue: number;
  75144. /**
  75145. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  75146. */
  75147. borderMinValue: number;
  75148. /**
  75149. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  75150. */
  75151. renderHoverLight: boolean;
  75152. /**
  75153. * Gets or sets the radius used to render the hover light (default is 1.0)
  75154. */
  75155. hoverRadius: number;
  75156. /**
  75157. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  75158. */
  75159. hoverColor: BABYLON.Color4;
  75160. /**
  75161. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  75162. */
  75163. hoverPosition: BABYLON.Vector3;
  75164. private _albedoTexture;
  75165. /** Gets or sets the texture to use for albedo color */
  75166. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75167. /**
  75168. * Creates a new Fluent material
  75169. * @param name defines the name of the material
  75170. * @param scene defines the hosting scene
  75171. */
  75172. constructor(name: string, scene: BABYLON.Scene);
  75173. needAlphaBlending(): boolean;
  75174. needAlphaTesting(): boolean;
  75175. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75176. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75177. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75178. getActiveTextures(): BABYLON.BaseTexture[];
  75179. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75180. dispose(forceDisposeEffect?: boolean): void;
  75181. clone(name: string): FluentMaterial;
  75182. serialize(): any;
  75183. getClassName(): string;
  75184. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  75185. }
  75186. }
  75187. declare module BABYLON.GUI {
  75188. /**
  75189. * Class used to create a holographic button in 3D
  75190. */
  75191. export class HolographicButton extends Button3D {
  75192. private _backPlate;
  75193. private _textPlate;
  75194. private _frontPlate;
  75195. private _text;
  75196. private _imageUrl;
  75197. private _shareMaterials;
  75198. private _frontMaterial;
  75199. private _backMaterial;
  75200. private _plateMaterial;
  75201. private _pickedPointObserver;
  75202. private _tooltipFade;
  75203. private _tooltipTextBlock;
  75204. private _tooltipTexture;
  75205. private _tooltipMesh;
  75206. private _tooltipHoverObserver;
  75207. private _tooltipOutObserver;
  75208. private _disposeTooltip;
  75209. /**
  75210. * Rendering ground id of all the mesh in the button
  75211. */
  75212. set renderingGroupId(id: number);
  75213. get renderingGroupId(): number;
  75214. /**
  75215. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  75216. */
  75217. set tooltipText(text: BABYLON.Nullable<string>);
  75218. get tooltipText(): BABYLON.Nullable<string>;
  75219. /**
  75220. * Gets or sets text for the button
  75221. */
  75222. get text(): string;
  75223. set text(value: string);
  75224. /**
  75225. * Gets or sets the image url for the button
  75226. */
  75227. get imageUrl(): string;
  75228. set imageUrl(value: string);
  75229. /**
  75230. * Gets the back material used by this button
  75231. */
  75232. get backMaterial(): FluentMaterial;
  75233. /**
  75234. * Gets the front material used by this button
  75235. */
  75236. get frontMaterial(): FluentMaterial;
  75237. /**
  75238. * Gets the plate material used by this button
  75239. */
  75240. get plateMaterial(): BABYLON.StandardMaterial;
  75241. /**
  75242. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  75243. */
  75244. get shareMaterials(): boolean;
  75245. /**
  75246. * Creates a new button
  75247. * @param name defines the control name
  75248. */
  75249. constructor(name?: string, shareMaterials?: boolean);
  75250. protected _getTypeName(): string;
  75251. private _rebuildContent;
  75252. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75253. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75254. private _createBackMaterial;
  75255. private _createFrontMaterial;
  75256. private _createPlateMaterial;
  75257. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  75258. /**
  75259. * Releases all associated resources
  75260. */
  75261. dispose(): void;
  75262. }
  75263. }
  75264. declare module BABYLON.GUI {
  75265. /**
  75266. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  75267. */
  75268. export class MeshButton3D extends Button3D {
  75269. /** @hidden */
  75270. protected _currentMesh: BABYLON.Mesh;
  75271. /**
  75272. * Creates a new 3D button based on a mesh
  75273. * @param mesh mesh to become a 3D button
  75274. * @param name defines the control name
  75275. */
  75276. constructor(mesh: BABYLON.Mesh, name?: string);
  75277. protected _getTypeName(): string;
  75278. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75279. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75280. }
  75281. }
  75282. declare module BABYLON.GUI {
  75283. /**
  75284. * Class used to create a container panel deployed on the surface of a plane
  75285. */
  75286. export class PlanePanel extends VolumeBasedPanel {
  75287. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75288. }
  75289. }
  75290. declare module BABYLON.GUI {
  75291. /**
  75292. * Class used to create a container panel where items get randomized planar mapping
  75293. */
  75294. export class ScatterPanel extends VolumeBasedPanel {
  75295. private _iteration;
  75296. /**
  75297. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  75298. */
  75299. get iteration(): BABYLON.float;
  75300. set iteration(value: BABYLON.float);
  75301. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75302. private _scatterMapping;
  75303. protected _finalProcessing(): void;
  75304. }
  75305. }
  75306. declare module BABYLON.GUI {
  75307. /**
  75308. * Class used to create a container panel deployed on the surface of a sphere
  75309. */
  75310. export class SpherePanel extends VolumeBasedPanel {
  75311. private _radius;
  75312. /**
  75313. * Gets or sets the radius of the sphere where to project controls (5 by default)
  75314. */
  75315. get radius(): BABYLON.float;
  75316. set radius(value: BABYLON.float);
  75317. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75318. private _sphericalMapping;
  75319. }
  75320. }
  75321. declare module BABYLON.GUI {
  75322. /**
  75323. * Class used to create a stack panel in 3D on XY plane
  75324. */
  75325. export class StackPanel3D extends Container3D {
  75326. private _isVertical;
  75327. /**
  75328. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  75329. */
  75330. get isVertical(): boolean;
  75331. set isVertical(value: boolean);
  75332. /**
  75333. * Gets or sets the distance between elements
  75334. */
  75335. margin: number;
  75336. /**
  75337. * Creates new StackPanel
  75338. * @param isVertical
  75339. */
  75340. constructor(isVertical?: boolean);
  75341. protected _arrangeChildren(): void;
  75342. }
  75343. }
  75344. declare module BABYLON {
  75345. /**
  75346. * Configuration for glTF validation
  75347. */
  75348. export interface IGLTFValidationConfiguration {
  75349. /**
  75350. * The url of the glTF validator.
  75351. */
  75352. url: string;
  75353. }
  75354. /**
  75355. * glTF validation
  75356. */
  75357. export class GLTFValidation {
  75358. /**
  75359. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  75360. */
  75361. static Configuration: IGLTFValidationConfiguration;
  75362. private static _LoadScriptPromise;
  75363. /**
  75364. * Validate a glTF asset using the glTF-Validator.
  75365. * @param data The JSON of a glTF or the array buffer of a binary glTF
  75366. * @param rootUrl The root url for the glTF
  75367. * @param fileName The file name for the glTF
  75368. * @param getExternalResource The callback to get external resources for the glTF validator
  75369. * @returns A promise that resolves with the glTF validation results once complete
  75370. */
  75371. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  75372. }
  75373. }
  75374. declare module BABYLON {
  75375. /**
  75376. * Mode that determines the coordinate system to use.
  75377. */
  75378. export enum GLTFLoaderCoordinateSystemMode {
  75379. /**
  75380. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  75381. */
  75382. AUTO = 0,
  75383. /**
  75384. * Sets the useRightHandedSystem flag on the scene.
  75385. */
  75386. FORCE_RIGHT_HANDED = 1
  75387. }
  75388. /**
  75389. * Mode that determines what animations will start.
  75390. */
  75391. export enum GLTFLoaderAnimationStartMode {
  75392. /**
  75393. * No animation will start.
  75394. */
  75395. NONE = 0,
  75396. /**
  75397. * The first animation will start.
  75398. */
  75399. FIRST = 1,
  75400. /**
  75401. * All animations will start.
  75402. */
  75403. ALL = 2
  75404. }
  75405. /**
  75406. * Interface that contains the data for the glTF asset.
  75407. */
  75408. export interface IGLTFLoaderData {
  75409. /**
  75410. * The object that represents the glTF JSON.
  75411. */
  75412. json: Object;
  75413. /**
  75414. * The BIN chunk of a binary glTF.
  75415. */
  75416. bin: Nullable<IDataBuffer>;
  75417. }
  75418. /**
  75419. * Interface for extending the loader.
  75420. */
  75421. export interface IGLTFLoaderExtension {
  75422. /**
  75423. * The name of this extension.
  75424. */
  75425. readonly name: string;
  75426. /**
  75427. * Defines whether this extension is enabled.
  75428. */
  75429. enabled: boolean;
  75430. /**
  75431. * Defines the order of this extension.
  75432. * The loader sorts the extensions using these values when loading.
  75433. */
  75434. order?: number;
  75435. }
  75436. /**
  75437. * Loader state.
  75438. */
  75439. export enum GLTFLoaderState {
  75440. /**
  75441. * The asset is loading.
  75442. */
  75443. LOADING = 0,
  75444. /**
  75445. * The asset is ready for rendering.
  75446. */
  75447. READY = 1,
  75448. /**
  75449. * The asset is completely loaded.
  75450. */
  75451. COMPLETE = 2
  75452. }
  75453. /** @hidden */
  75454. export interface IImportMeshAsyncOutput {
  75455. meshes: AbstractMesh[];
  75456. particleSystems: IParticleSystem[];
  75457. skeletons: Skeleton[];
  75458. animationGroups: AnimationGroup[];
  75459. lights: Light[];
  75460. transformNodes: TransformNode[];
  75461. }
  75462. /** @hidden */
  75463. export interface IGLTFLoader extends IDisposable {
  75464. readonly state: Nullable<GLTFLoaderState>;
  75465. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75466. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75467. }
  75468. /**
  75469. * File loader for loading glTF files into a scene.
  75470. */
  75471. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75472. /** @hidden */
  75473. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75474. /** @hidden */
  75475. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75476. /**
  75477. * Raised when the asset has been parsed
  75478. */
  75479. onParsedObservable: Observable<IGLTFLoaderData>;
  75480. private _onParsedObserver;
  75481. /**
  75482. * Raised when the asset has been parsed
  75483. */
  75484. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75485. /**
  75486. * 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.
  75487. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75488. * Defaults to true.
  75489. * @hidden
  75490. */
  75491. static IncrementalLoading: boolean;
  75492. /**
  75493. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75494. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75495. * @hidden
  75496. */
  75497. static HomogeneousCoordinates: boolean;
  75498. /**
  75499. * The coordinate system mode. Defaults to AUTO.
  75500. */
  75501. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75502. /**
  75503. * The animation start mode. Defaults to FIRST.
  75504. */
  75505. animationStartMode: GLTFLoaderAnimationStartMode;
  75506. /**
  75507. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75508. */
  75509. compileMaterials: boolean;
  75510. /**
  75511. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75512. */
  75513. useClipPlane: boolean;
  75514. /**
  75515. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75516. */
  75517. compileShadowGenerators: boolean;
  75518. /**
  75519. * Defines if the Alpha blended materials are only applied as coverage.
  75520. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75521. * If true, no extra effects are applied to transparent pixels.
  75522. */
  75523. transparencyAsCoverage: boolean;
  75524. /**
  75525. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75526. * Enabling will disable offline support and glTF validator.
  75527. * Defaults to false.
  75528. */
  75529. useRangeRequests: boolean;
  75530. /**
  75531. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75532. */
  75533. createInstances: boolean;
  75534. /**
  75535. * Function called before loading a url referenced by the asset.
  75536. */
  75537. preprocessUrlAsync: (url: string) => Promise<string>;
  75538. /**
  75539. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75540. */
  75541. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75542. private _onMeshLoadedObserver;
  75543. /**
  75544. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75545. */
  75546. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75547. /**
  75548. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75549. */
  75550. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75551. private _onTextureLoadedObserver;
  75552. /**
  75553. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75554. */
  75555. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75556. /**
  75557. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75558. */
  75559. readonly onMaterialLoadedObservable: Observable<Material>;
  75560. private _onMaterialLoadedObserver;
  75561. /**
  75562. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75563. */
  75564. set onMaterialLoaded(callback: (material: Material) => void);
  75565. /**
  75566. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75567. */
  75568. readonly onCameraLoadedObservable: Observable<Camera>;
  75569. private _onCameraLoadedObserver;
  75570. /**
  75571. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75572. */
  75573. set onCameraLoaded(callback: (camera: Camera) => void);
  75574. /**
  75575. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75576. * For assets with LODs, raised when all of the LODs are complete.
  75577. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75578. */
  75579. readonly onCompleteObservable: Observable<void>;
  75580. private _onCompleteObserver;
  75581. /**
  75582. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75583. * For assets with LODs, raised when all of the LODs are complete.
  75584. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75585. */
  75586. set onComplete(callback: () => void);
  75587. /**
  75588. * Observable raised when an error occurs.
  75589. */
  75590. readonly onErrorObservable: Observable<any>;
  75591. private _onErrorObserver;
  75592. /**
  75593. * Callback raised when an error occurs.
  75594. */
  75595. set onError(callback: (reason: any) => void);
  75596. /**
  75597. * Observable raised after the loader is disposed.
  75598. */
  75599. readonly onDisposeObservable: Observable<void>;
  75600. private _onDisposeObserver;
  75601. /**
  75602. * Callback raised after the loader is disposed.
  75603. */
  75604. set onDispose(callback: () => void);
  75605. /**
  75606. * Observable raised after a loader extension is created.
  75607. * Set additional options for a loader extension in this event.
  75608. */
  75609. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75610. private _onExtensionLoadedObserver;
  75611. /**
  75612. * Callback raised after a loader extension is created.
  75613. */
  75614. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75615. /**
  75616. * Defines if the loader logging is enabled.
  75617. */
  75618. get loggingEnabled(): boolean;
  75619. set loggingEnabled(value: boolean);
  75620. /**
  75621. * Defines if the loader should capture performance counters.
  75622. */
  75623. get capturePerformanceCounters(): boolean;
  75624. set capturePerformanceCounters(value: boolean);
  75625. /**
  75626. * Defines if the loader should validate the asset.
  75627. */
  75628. validate: boolean;
  75629. /**
  75630. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75631. */
  75632. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75633. private _onValidatedObserver;
  75634. /**
  75635. * Callback raised after a loader extension is created.
  75636. */
  75637. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75638. private _loader;
  75639. /**
  75640. * Name of the loader ("gltf")
  75641. */
  75642. name: string;
  75643. /** @hidden */
  75644. extensions: ISceneLoaderPluginExtensions;
  75645. /**
  75646. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75647. */
  75648. dispose(): void;
  75649. /** @hidden */
  75650. _clear(): void;
  75651. /** @hidden */
  75652. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75653. /** @hidden */
  75654. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75655. /** @hidden */
  75656. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75657. meshes: AbstractMesh[];
  75658. particleSystems: IParticleSystem[];
  75659. skeletons: Skeleton[];
  75660. animationGroups: AnimationGroup[];
  75661. }>;
  75662. /** @hidden */
  75663. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75664. /** @hidden */
  75665. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75666. /** @hidden */
  75667. canDirectLoad(data: string): boolean;
  75668. /** @hidden */
  75669. directLoad(scene: Scene, data: string): any;
  75670. /**
  75671. * The callback that allows custom handling of the root url based on the response url.
  75672. * @param rootUrl the original root url
  75673. * @param responseURL the response url if available
  75674. * @returns the new root url
  75675. */
  75676. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75677. /** @hidden */
  75678. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75679. /**
  75680. * The loader state or null if the loader is not active.
  75681. */
  75682. get loaderState(): Nullable<GLTFLoaderState>;
  75683. /**
  75684. * Returns a promise that resolves when the asset is completely loaded.
  75685. * @returns a promise that resolves when the asset is completely loaded.
  75686. */
  75687. whenCompleteAsync(): Promise<void>;
  75688. private _validate;
  75689. private _getLoader;
  75690. private _parseJson;
  75691. private _unpackBinaryAsync;
  75692. private _unpackBinaryV1Async;
  75693. private _unpackBinaryV2Async;
  75694. private static _parseVersion;
  75695. private static _compareVersion;
  75696. private static readonly _logSpaces;
  75697. private _logIndentLevel;
  75698. private _loggingEnabled;
  75699. /** @hidden */
  75700. _log: (message: string) => void;
  75701. /** @hidden */
  75702. _logOpen(message: string): void;
  75703. /** @hidden */
  75704. _logClose(): void;
  75705. private _logEnabled;
  75706. private _logDisabled;
  75707. private _capturePerformanceCounters;
  75708. /** @hidden */
  75709. _startPerformanceCounter: (counterName: string) => void;
  75710. /** @hidden */
  75711. _endPerformanceCounter: (counterName: string) => void;
  75712. private _startPerformanceCounterEnabled;
  75713. private _startPerformanceCounterDisabled;
  75714. private _endPerformanceCounterEnabled;
  75715. private _endPerformanceCounterDisabled;
  75716. }
  75717. }
  75718. declare module BABYLON.GLTF1 {
  75719. /**
  75720. * Enums
  75721. * @hidden
  75722. */
  75723. export enum EComponentType {
  75724. BYTE = 5120,
  75725. UNSIGNED_BYTE = 5121,
  75726. SHORT = 5122,
  75727. UNSIGNED_SHORT = 5123,
  75728. FLOAT = 5126
  75729. }
  75730. /** @hidden */
  75731. export enum EShaderType {
  75732. FRAGMENT = 35632,
  75733. VERTEX = 35633
  75734. }
  75735. /** @hidden */
  75736. export enum EParameterType {
  75737. BYTE = 5120,
  75738. UNSIGNED_BYTE = 5121,
  75739. SHORT = 5122,
  75740. UNSIGNED_SHORT = 5123,
  75741. INT = 5124,
  75742. UNSIGNED_INT = 5125,
  75743. FLOAT = 5126,
  75744. FLOAT_VEC2 = 35664,
  75745. FLOAT_VEC3 = 35665,
  75746. FLOAT_VEC4 = 35666,
  75747. INT_VEC2 = 35667,
  75748. INT_VEC3 = 35668,
  75749. INT_VEC4 = 35669,
  75750. BOOL = 35670,
  75751. BOOL_VEC2 = 35671,
  75752. BOOL_VEC3 = 35672,
  75753. BOOL_VEC4 = 35673,
  75754. FLOAT_MAT2 = 35674,
  75755. FLOAT_MAT3 = 35675,
  75756. FLOAT_MAT4 = 35676,
  75757. SAMPLER_2D = 35678
  75758. }
  75759. /** @hidden */
  75760. export enum ETextureWrapMode {
  75761. CLAMP_TO_EDGE = 33071,
  75762. MIRRORED_REPEAT = 33648,
  75763. REPEAT = 10497
  75764. }
  75765. /** @hidden */
  75766. export enum ETextureFilterType {
  75767. NEAREST = 9728,
  75768. LINEAR = 9728,
  75769. NEAREST_MIPMAP_NEAREST = 9984,
  75770. LINEAR_MIPMAP_NEAREST = 9985,
  75771. NEAREST_MIPMAP_LINEAR = 9986,
  75772. LINEAR_MIPMAP_LINEAR = 9987
  75773. }
  75774. /** @hidden */
  75775. export enum ETextureFormat {
  75776. ALPHA = 6406,
  75777. RGB = 6407,
  75778. RGBA = 6408,
  75779. LUMINANCE = 6409,
  75780. LUMINANCE_ALPHA = 6410
  75781. }
  75782. /** @hidden */
  75783. export enum ECullingType {
  75784. FRONT = 1028,
  75785. BACK = 1029,
  75786. FRONT_AND_BACK = 1032
  75787. }
  75788. /** @hidden */
  75789. export enum EBlendingFunction {
  75790. ZERO = 0,
  75791. ONE = 1,
  75792. SRC_COLOR = 768,
  75793. ONE_MINUS_SRC_COLOR = 769,
  75794. DST_COLOR = 774,
  75795. ONE_MINUS_DST_COLOR = 775,
  75796. SRC_ALPHA = 770,
  75797. ONE_MINUS_SRC_ALPHA = 771,
  75798. DST_ALPHA = 772,
  75799. ONE_MINUS_DST_ALPHA = 773,
  75800. CONSTANT_COLOR = 32769,
  75801. ONE_MINUS_CONSTANT_COLOR = 32770,
  75802. CONSTANT_ALPHA = 32771,
  75803. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75804. SRC_ALPHA_SATURATE = 776
  75805. }
  75806. /** @hidden */
  75807. export interface IGLTFProperty {
  75808. extensions?: {
  75809. [key: string]: any;
  75810. };
  75811. extras?: Object;
  75812. }
  75813. /** @hidden */
  75814. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75815. name?: string;
  75816. }
  75817. /** @hidden */
  75818. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75819. bufferView: string;
  75820. byteOffset: number;
  75821. byteStride: number;
  75822. count: number;
  75823. type: string;
  75824. componentType: EComponentType;
  75825. max?: number[];
  75826. min?: number[];
  75827. name?: string;
  75828. }
  75829. /** @hidden */
  75830. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75831. buffer: string;
  75832. byteOffset: number;
  75833. byteLength: number;
  75834. byteStride: number;
  75835. target?: number;
  75836. }
  75837. /** @hidden */
  75838. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75839. uri: string;
  75840. byteLength?: number;
  75841. type?: string;
  75842. }
  75843. /** @hidden */
  75844. export interface IGLTFShader extends IGLTFChildRootProperty {
  75845. uri: string;
  75846. type: EShaderType;
  75847. }
  75848. /** @hidden */
  75849. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75850. attributes: string[];
  75851. fragmentShader: string;
  75852. vertexShader: string;
  75853. }
  75854. /** @hidden */
  75855. export interface IGLTFTechniqueParameter {
  75856. type: number;
  75857. count?: number;
  75858. semantic?: string;
  75859. node?: string;
  75860. value?: number | boolean | string | Array<any>;
  75861. source?: string;
  75862. babylonValue?: any;
  75863. }
  75864. /** @hidden */
  75865. export interface IGLTFTechniqueCommonProfile {
  75866. lightingModel: string;
  75867. texcoordBindings: Object;
  75868. parameters?: Array<any>;
  75869. }
  75870. /** @hidden */
  75871. export interface IGLTFTechniqueStatesFunctions {
  75872. blendColor?: number[];
  75873. blendEquationSeparate?: number[];
  75874. blendFuncSeparate?: number[];
  75875. colorMask: boolean[];
  75876. cullFace: number[];
  75877. }
  75878. /** @hidden */
  75879. export interface IGLTFTechniqueStates {
  75880. enable: number[];
  75881. functions: IGLTFTechniqueStatesFunctions;
  75882. }
  75883. /** @hidden */
  75884. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75885. parameters: {
  75886. [key: string]: IGLTFTechniqueParameter;
  75887. };
  75888. program: string;
  75889. attributes: {
  75890. [key: string]: string;
  75891. };
  75892. uniforms: {
  75893. [key: string]: string;
  75894. };
  75895. states: IGLTFTechniqueStates;
  75896. }
  75897. /** @hidden */
  75898. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75899. technique?: string;
  75900. values: string[];
  75901. }
  75902. /** @hidden */
  75903. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75904. attributes: {
  75905. [key: string]: string;
  75906. };
  75907. indices: string;
  75908. material: string;
  75909. mode?: number;
  75910. }
  75911. /** @hidden */
  75912. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75913. primitives: IGLTFMeshPrimitive[];
  75914. }
  75915. /** @hidden */
  75916. export interface IGLTFImage extends IGLTFChildRootProperty {
  75917. uri: string;
  75918. }
  75919. /** @hidden */
  75920. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75921. magFilter?: number;
  75922. minFilter?: number;
  75923. wrapS?: number;
  75924. wrapT?: number;
  75925. }
  75926. /** @hidden */
  75927. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75928. sampler: string;
  75929. source: string;
  75930. format?: ETextureFormat;
  75931. internalFormat?: ETextureFormat;
  75932. target?: number;
  75933. type?: number;
  75934. babylonTexture?: Texture;
  75935. }
  75936. /** @hidden */
  75937. export interface IGLTFAmbienLight {
  75938. color?: number[];
  75939. }
  75940. /** @hidden */
  75941. export interface IGLTFDirectionalLight {
  75942. color?: number[];
  75943. }
  75944. /** @hidden */
  75945. export interface IGLTFPointLight {
  75946. color?: number[];
  75947. constantAttenuation?: number;
  75948. linearAttenuation?: number;
  75949. quadraticAttenuation?: number;
  75950. }
  75951. /** @hidden */
  75952. export interface IGLTFSpotLight {
  75953. color?: number[];
  75954. constantAttenuation?: number;
  75955. fallOfAngle?: number;
  75956. fallOffExponent?: number;
  75957. linearAttenuation?: number;
  75958. quadraticAttenuation?: number;
  75959. }
  75960. /** @hidden */
  75961. export interface IGLTFLight extends IGLTFChildRootProperty {
  75962. type: string;
  75963. }
  75964. /** @hidden */
  75965. export interface IGLTFCameraOrthographic {
  75966. xmag: number;
  75967. ymag: number;
  75968. zfar: number;
  75969. znear: number;
  75970. }
  75971. /** @hidden */
  75972. export interface IGLTFCameraPerspective {
  75973. aspectRatio: number;
  75974. yfov: number;
  75975. zfar: number;
  75976. znear: number;
  75977. }
  75978. /** @hidden */
  75979. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75980. type: string;
  75981. }
  75982. /** @hidden */
  75983. export interface IGLTFAnimationChannelTarget {
  75984. id: string;
  75985. path: string;
  75986. }
  75987. /** @hidden */
  75988. export interface IGLTFAnimationChannel {
  75989. sampler: string;
  75990. target: IGLTFAnimationChannelTarget;
  75991. }
  75992. /** @hidden */
  75993. export interface IGLTFAnimationSampler {
  75994. input: string;
  75995. output: string;
  75996. interpolation?: string;
  75997. }
  75998. /** @hidden */
  75999. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  76000. channels?: IGLTFAnimationChannel[];
  76001. parameters?: {
  76002. [key: string]: string;
  76003. };
  76004. samplers?: {
  76005. [key: string]: IGLTFAnimationSampler;
  76006. };
  76007. }
  76008. /** @hidden */
  76009. export interface IGLTFNodeInstanceSkin {
  76010. skeletons: string[];
  76011. skin: string;
  76012. meshes: string[];
  76013. }
  76014. /** @hidden */
  76015. export interface IGLTFSkins extends IGLTFChildRootProperty {
  76016. bindShapeMatrix: number[];
  76017. inverseBindMatrices: string;
  76018. jointNames: string[];
  76019. babylonSkeleton?: Skeleton;
  76020. }
  76021. /** @hidden */
  76022. export interface IGLTFNode extends IGLTFChildRootProperty {
  76023. camera?: string;
  76024. children: string[];
  76025. skin?: string;
  76026. jointName?: string;
  76027. light?: string;
  76028. matrix: number[];
  76029. mesh?: string;
  76030. meshes?: string[];
  76031. rotation?: number[];
  76032. scale?: number[];
  76033. translation?: number[];
  76034. babylonNode?: Node;
  76035. }
  76036. /** @hidden */
  76037. export interface IGLTFScene extends IGLTFChildRootProperty {
  76038. nodes: string[];
  76039. }
  76040. /** @hidden */
  76041. export interface IGLTFRuntime {
  76042. extensions: {
  76043. [key: string]: any;
  76044. };
  76045. accessors: {
  76046. [key: string]: IGLTFAccessor;
  76047. };
  76048. buffers: {
  76049. [key: string]: IGLTFBuffer;
  76050. };
  76051. bufferViews: {
  76052. [key: string]: IGLTFBufferView;
  76053. };
  76054. meshes: {
  76055. [key: string]: IGLTFMesh;
  76056. };
  76057. lights: {
  76058. [key: string]: IGLTFLight;
  76059. };
  76060. cameras: {
  76061. [key: string]: IGLTFCamera;
  76062. };
  76063. nodes: {
  76064. [key: string]: IGLTFNode;
  76065. };
  76066. images: {
  76067. [key: string]: IGLTFImage;
  76068. };
  76069. textures: {
  76070. [key: string]: IGLTFTexture;
  76071. };
  76072. shaders: {
  76073. [key: string]: IGLTFShader;
  76074. };
  76075. programs: {
  76076. [key: string]: IGLTFProgram;
  76077. };
  76078. samplers: {
  76079. [key: string]: IGLTFSampler;
  76080. };
  76081. techniques: {
  76082. [key: string]: IGLTFTechnique;
  76083. };
  76084. materials: {
  76085. [key: string]: IGLTFMaterial;
  76086. };
  76087. animations: {
  76088. [key: string]: IGLTFAnimation;
  76089. };
  76090. skins: {
  76091. [key: string]: IGLTFSkins;
  76092. };
  76093. currentScene?: Object;
  76094. scenes: {
  76095. [key: string]: IGLTFScene;
  76096. };
  76097. extensionsUsed: string[];
  76098. extensionsRequired?: string[];
  76099. buffersCount: number;
  76100. shaderscount: number;
  76101. scene: Scene;
  76102. rootUrl: string;
  76103. loadedBufferCount: number;
  76104. loadedBufferViews: {
  76105. [name: string]: ArrayBufferView;
  76106. };
  76107. loadedShaderCount: number;
  76108. importOnlyMeshes: boolean;
  76109. importMeshesNames?: string[];
  76110. dummyNodes: Node[];
  76111. forAssetContainer: boolean;
  76112. }
  76113. /** @hidden */
  76114. export interface INodeToRoot {
  76115. bone: Bone;
  76116. node: IGLTFNode;
  76117. id: string;
  76118. }
  76119. /** @hidden */
  76120. export interface IJointNode {
  76121. node: IGLTFNode;
  76122. id: string;
  76123. }
  76124. }
  76125. declare module BABYLON.GLTF1 {
  76126. /**
  76127. * Utils functions for GLTF
  76128. * @hidden
  76129. */
  76130. export class GLTFUtils {
  76131. /**
  76132. * Sets the given "parameter" matrix
  76133. * @param scene: the Scene object
  76134. * @param source: the source node where to pick the matrix
  76135. * @param parameter: the GLTF technique parameter
  76136. * @param uniformName: the name of the shader's uniform
  76137. * @param shaderMaterial: the shader material
  76138. */
  76139. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  76140. /**
  76141. * Sets the given "parameter" matrix
  76142. * @param shaderMaterial: the shader material
  76143. * @param uniform: the name of the shader's uniform
  76144. * @param value: the value of the uniform
  76145. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  76146. */
  76147. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  76148. /**
  76149. * Returns the wrap mode of the texture
  76150. * @param mode: the mode value
  76151. */
  76152. static GetWrapMode(mode: number): number;
  76153. /**
  76154. * Returns the byte stride giving an accessor
  76155. * @param accessor: the GLTF accessor objet
  76156. */
  76157. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  76158. /**
  76159. * Returns the texture filter mode giving a mode value
  76160. * @param mode: the filter mode value
  76161. */
  76162. static GetTextureFilterMode(mode: number): ETextureFilterType;
  76163. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  76164. /**
  76165. * Returns a buffer from its accessor
  76166. * @param gltfRuntime: the GLTF runtime
  76167. * @param accessor: the GLTF accessor
  76168. */
  76169. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  76170. /**
  76171. * Decodes a buffer view into a string
  76172. * @param view: the buffer view
  76173. */
  76174. static DecodeBufferToText(view: ArrayBufferView): string;
  76175. /**
  76176. * Returns the default material of gltf. Related to
  76177. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  76178. * @param scene: the Babylon.js scene
  76179. */
  76180. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  76181. private static _DefaultMaterial;
  76182. }
  76183. }
  76184. declare module BABYLON.GLTF1 {
  76185. /**
  76186. * Implementation of the base glTF spec
  76187. * @hidden
  76188. */
  76189. export class GLTFLoaderBase {
  76190. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  76191. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76192. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  76193. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76194. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  76195. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76196. }
  76197. /**
  76198. * glTF V1 Loader
  76199. * @hidden
  76200. */
  76201. export class GLTFLoader implements IGLTFLoader {
  76202. static Extensions: {
  76203. [name: string]: GLTFLoaderExtension;
  76204. };
  76205. static RegisterExtension(extension: GLTFLoaderExtension): void;
  76206. state: Nullable<GLTFLoaderState>;
  76207. dispose(): void;
  76208. private _importMeshAsync;
  76209. /**
  76210. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  76211. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76212. * @param scene the scene the meshes should be added to
  76213. * @param forAssetContainer defines if the entities must be stored in the scene
  76214. * @param data gltf data containing information of the meshes in a loaded file
  76215. * @param rootUrl root url to load from
  76216. * @param onProgress event that fires when loading progress has occured
  76217. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76218. */
  76219. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  76220. private _loadAsync;
  76221. /**
  76222. * Imports all objects from a loaded gltf file and adds them to the scene
  76223. * @param scene the scene the objects should be added to
  76224. * @param data gltf data containing information of the meshes in a loaded file
  76225. * @param rootUrl root url to load from
  76226. * @param onProgress event that fires when loading progress has occured
  76227. * @returns a promise which completes when objects have been loaded to the scene
  76228. */
  76229. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  76230. private _loadShadersAsync;
  76231. private _loadBuffersAsync;
  76232. private _createNodes;
  76233. }
  76234. /** @hidden */
  76235. export abstract class GLTFLoaderExtension {
  76236. private _name;
  76237. constructor(name: string);
  76238. get name(): string;
  76239. /**
  76240. * Defines an override for loading the runtime
  76241. * Return true to stop further extensions from loading the runtime
  76242. */
  76243. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  76244. /**
  76245. * Defines an onverride for creating gltf runtime
  76246. * Return true to stop further extensions from creating the runtime
  76247. */
  76248. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  76249. /**
  76250. * Defines an override for loading buffers
  76251. * Return true to stop further extensions from loading this buffer
  76252. */
  76253. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  76254. /**
  76255. * Defines an override for loading texture buffers
  76256. * Return true to stop further extensions from loading this texture data
  76257. */
  76258. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76259. /**
  76260. * Defines an override for creating textures
  76261. * Return true to stop further extensions from loading this texture
  76262. */
  76263. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  76264. /**
  76265. * Defines an override for loading shader strings
  76266. * Return true to stop further extensions from loading this shader data
  76267. */
  76268. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76269. /**
  76270. * Defines an override for loading materials
  76271. * Return true to stop further extensions from loading this material
  76272. */
  76273. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76274. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  76275. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  76276. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76277. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76278. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  76279. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76280. private static LoadTextureBufferAsync;
  76281. private static CreateTextureAsync;
  76282. private static ApplyExtensions;
  76283. }
  76284. }
  76285. declare module BABYLON.GLTF1 {
  76286. /** @hidden */
  76287. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  76288. private _bin;
  76289. constructor();
  76290. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  76291. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76292. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76293. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76294. }
  76295. }
  76296. declare module BABYLON.GLTF1 {
  76297. /** @hidden */
  76298. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  76299. constructor();
  76300. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  76301. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76302. private _loadTexture;
  76303. }
  76304. }
  76305. declare module BABYLON.GLTF2.Loader {
  76306. /**
  76307. * Loader interface with an index field.
  76308. */
  76309. export interface IArrayItem {
  76310. /**
  76311. * The index of this item in the array.
  76312. */
  76313. index: number;
  76314. }
  76315. /**
  76316. * Loader interface with additional members.
  76317. */
  76318. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  76319. /** @hidden */
  76320. _data?: Promise<ArrayBufferView>;
  76321. /** @hidden */
  76322. _babylonVertexBuffer?: Promise<VertexBuffer>;
  76323. }
  76324. /**
  76325. * Loader interface with additional members.
  76326. */
  76327. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  76328. }
  76329. /** @hidden */
  76330. export interface _IAnimationSamplerData {
  76331. input: Float32Array;
  76332. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  76333. output: Float32Array;
  76334. }
  76335. /**
  76336. * Loader interface with additional members.
  76337. */
  76338. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  76339. /** @hidden */
  76340. _data?: Promise<_IAnimationSamplerData>;
  76341. }
  76342. /**
  76343. * Loader interface with additional members.
  76344. */
  76345. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  76346. channels: IAnimationChannel[];
  76347. samplers: IAnimationSampler[];
  76348. /** @hidden */
  76349. _babylonAnimationGroup?: AnimationGroup;
  76350. }
  76351. /**
  76352. * Loader interface with additional members.
  76353. */
  76354. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  76355. /** @hidden */
  76356. _data?: Promise<ArrayBufferView>;
  76357. }
  76358. /**
  76359. * Loader interface with additional members.
  76360. */
  76361. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  76362. /** @hidden */
  76363. _data?: Promise<ArrayBufferView>;
  76364. /** @hidden */
  76365. _babylonBuffer?: Promise<Buffer>;
  76366. }
  76367. /**
  76368. * Loader interface with additional members.
  76369. */
  76370. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  76371. }
  76372. /**
  76373. * Loader interface with additional members.
  76374. */
  76375. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  76376. /** @hidden */
  76377. _data?: Promise<ArrayBufferView>;
  76378. }
  76379. /**
  76380. * Loader interface with additional members.
  76381. */
  76382. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  76383. }
  76384. /**
  76385. * Loader interface with additional members.
  76386. */
  76387. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  76388. }
  76389. /**
  76390. * Loader interface with additional members.
  76391. */
  76392. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  76393. baseColorTexture?: ITextureInfo;
  76394. metallicRoughnessTexture?: ITextureInfo;
  76395. }
  76396. /**
  76397. * Loader interface with additional members.
  76398. */
  76399. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  76400. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76401. normalTexture?: IMaterialNormalTextureInfo;
  76402. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76403. emissiveTexture?: ITextureInfo;
  76404. /** @hidden */
  76405. _data?: {
  76406. [babylonDrawMode: number]: {
  76407. babylonMaterial: Material;
  76408. babylonMeshes: AbstractMesh[];
  76409. promise: Promise<void>;
  76410. };
  76411. };
  76412. }
  76413. /**
  76414. * Loader interface with additional members.
  76415. */
  76416. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  76417. primitives: IMeshPrimitive[];
  76418. }
  76419. /**
  76420. * Loader interface with additional members.
  76421. */
  76422. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  76423. /** @hidden */
  76424. _instanceData?: {
  76425. babylonSourceMesh: Mesh;
  76426. promise: Promise<any>;
  76427. };
  76428. }
  76429. /**
  76430. * Loader interface with additional members.
  76431. */
  76432. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76433. /**
  76434. * The parent glTF node.
  76435. */
  76436. parent?: INode;
  76437. /** @hidden */
  76438. _babylonTransformNode?: TransformNode;
  76439. /** @hidden */
  76440. _primitiveBabylonMeshes?: AbstractMesh[];
  76441. /** @hidden */
  76442. _babylonBones?: Bone[];
  76443. /** @hidden */
  76444. _numMorphTargets?: number;
  76445. }
  76446. /** @hidden */
  76447. export interface _ISamplerData {
  76448. noMipMaps: boolean;
  76449. samplingMode: number;
  76450. wrapU: number;
  76451. wrapV: number;
  76452. }
  76453. /**
  76454. * Loader interface with additional members.
  76455. */
  76456. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76457. /** @hidden */
  76458. _data?: _ISamplerData;
  76459. }
  76460. /**
  76461. * Loader interface with additional members.
  76462. */
  76463. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76464. }
  76465. /**
  76466. * Loader interface with additional members.
  76467. */
  76468. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76469. /** @hidden */
  76470. _data?: {
  76471. babylonSkeleton: Skeleton;
  76472. promise: Promise<void>;
  76473. };
  76474. }
  76475. /**
  76476. * Loader interface with additional members.
  76477. */
  76478. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76479. }
  76480. /**
  76481. * Loader interface with additional members.
  76482. */
  76483. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76484. }
  76485. /**
  76486. * Loader interface with additional members.
  76487. */
  76488. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76489. accessors?: IAccessor[];
  76490. animations?: IAnimation[];
  76491. buffers?: IBuffer[];
  76492. bufferViews?: IBufferView[];
  76493. cameras?: ICamera[];
  76494. images?: IImage[];
  76495. materials?: IMaterial[];
  76496. meshes?: IMesh[];
  76497. nodes?: INode[];
  76498. samplers?: ISampler[];
  76499. scenes?: IScene[];
  76500. skins?: ISkin[];
  76501. textures?: ITexture[];
  76502. }
  76503. }
  76504. declare module BABYLON.GLTF2 {
  76505. /**
  76506. * Interface for a glTF loader extension.
  76507. */
  76508. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76509. /**
  76510. * Called after the loader state changes to LOADING.
  76511. */
  76512. onLoading?(): void;
  76513. /**
  76514. * Called after the loader state changes to READY.
  76515. */
  76516. onReady?(): void;
  76517. /**
  76518. * Define this method to modify the default behavior when loading scenes.
  76519. * @param context The context when loading the asset
  76520. * @param scene The glTF scene property
  76521. * @returns A promise that resolves when the load is complete or null if not handled
  76522. */
  76523. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76524. /**
  76525. * Define this method to modify the default behavior when loading nodes.
  76526. * @param context The context when loading the asset
  76527. * @param node The glTF node property
  76528. * @param assign A function called synchronously after parsing the glTF properties
  76529. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76530. */
  76531. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76532. /**
  76533. * Define this method to modify the default behavior when loading cameras.
  76534. * @param context The context when loading the asset
  76535. * @param camera The glTF camera property
  76536. * @param assign A function called synchronously after parsing the glTF properties
  76537. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76538. */
  76539. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76540. /**
  76541. * @hidden
  76542. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76543. * @param context The context when loading the asset
  76544. * @param primitive The glTF mesh primitive property
  76545. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76546. */
  76547. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76548. /**
  76549. * @hidden
  76550. * Define this method to modify the default behavior when loading data for mesh primitives.
  76551. * @param context The context when loading the asset
  76552. * @param name The mesh name when loading the asset
  76553. * @param node The glTF node when loading the asset
  76554. * @param mesh The glTF mesh when loading the asset
  76555. * @param primitive The glTF mesh primitive property
  76556. * @param assign A function called synchronously after parsing the glTF properties
  76557. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76558. */
  76559. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76560. /**
  76561. * @hidden
  76562. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76563. * @param context The context when loading the asset
  76564. * @param material The glTF material property
  76565. * @param assign A function called synchronously after parsing the glTF properties
  76566. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76567. */
  76568. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76569. /**
  76570. * Define this method to modify the default behavior when creating materials.
  76571. * @param context The context when loading the asset
  76572. * @param material The glTF material property
  76573. * @param babylonDrawMode The draw mode for the Babylon material
  76574. * @returns The Babylon material or null if not handled
  76575. */
  76576. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76577. /**
  76578. * Define this method to modify the default behavior when loading material properties.
  76579. * @param context The context when loading the asset
  76580. * @param material The glTF material property
  76581. * @param babylonMaterial The Babylon material
  76582. * @returns A promise that resolves when the load is complete or null if not handled
  76583. */
  76584. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76585. /**
  76586. * Define this method to modify the default behavior when loading texture infos.
  76587. * @param context The context when loading the asset
  76588. * @param textureInfo The glTF texture info property
  76589. * @param assign A function called synchronously after parsing the glTF properties
  76590. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76591. */
  76592. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76593. /**
  76594. * @hidden
  76595. * Define this method to modify the default behavior when loading textures.
  76596. * @param context The context when loading the asset
  76597. * @param texture The glTF texture property
  76598. * @param assign A function called synchronously after parsing the glTF properties
  76599. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76600. */
  76601. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76602. /**
  76603. * Define this method to modify the default behavior when loading animations.
  76604. * @param context The context when loading the asset
  76605. * @param animation The glTF animation property
  76606. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76607. */
  76608. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76609. /**
  76610. * @hidden
  76611. * Define this method to modify the default behavior when loading skins.
  76612. * @param context The context when loading the asset
  76613. * @param node The glTF node property
  76614. * @param skin The glTF skin property
  76615. * @returns A promise that resolves when the load is complete or null if not handled
  76616. */
  76617. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76618. /**
  76619. * @hidden
  76620. * Define this method to modify the default behavior when loading uris.
  76621. * @param context The context when loading the asset
  76622. * @param property The glTF property associated with the uri
  76623. * @param uri The uri to load
  76624. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76625. */
  76626. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76627. /**
  76628. * Define this method to modify the default behavior when loading buffer views.
  76629. * @param context The context when loading the asset
  76630. * @param bufferView The glTF buffer view property
  76631. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76632. */
  76633. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76634. /**
  76635. * Define this method to modify the default behavior when loading buffers.
  76636. * @param context The context when loading the asset
  76637. * @param buffer The glTF buffer property
  76638. * @param byteOffset The byte offset to load
  76639. * @param byteLength The byte length to load
  76640. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76641. */
  76642. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76643. }
  76644. }
  76645. declare module BABYLON.GLTF2 {
  76646. /**
  76647. * Helper class for working with arrays when loading the glTF asset
  76648. */
  76649. export class ArrayItem {
  76650. /**
  76651. * Gets an item from the given array.
  76652. * @param context The context when loading the asset
  76653. * @param array The array to get the item from
  76654. * @param index The index to the array
  76655. * @returns The array item
  76656. */
  76657. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76658. /**
  76659. * Assign an `index` field to each item of the given array.
  76660. * @param array The array of items
  76661. */
  76662. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76663. }
  76664. /**
  76665. * The glTF 2.0 loader
  76666. */
  76667. export class GLTFLoader implements IGLTFLoader {
  76668. /** @hidden */
  76669. _completePromises: Promise<any>[];
  76670. /** @hidden */
  76671. _forAssetContainer: boolean;
  76672. /** Storage */
  76673. _babylonLights: Light[];
  76674. private _disposed;
  76675. private _parent;
  76676. private _state;
  76677. private _extensions;
  76678. private _rootUrl;
  76679. private _fileName;
  76680. private _uniqueRootUrl;
  76681. private _gltf;
  76682. private _bin;
  76683. private _babylonScene;
  76684. private _rootBabylonMesh;
  76685. private _defaultBabylonMaterialData;
  76686. private _progressCallback?;
  76687. private _requests;
  76688. private static _RegisteredExtensions;
  76689. /**
  76690. * The default glTF sampler.
  76691. */
  76692. static readonly DefaultSampler: ISampler;
  76693. /**
  76694. * Registers a loader extension.
  76695. * @param name The name of the loader extension.
  76696. * @param factory The factory function that creates the loader extension.
  76697. */
  76698. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76699. /**
  76700. * Unregisters a loader extension.
  76701. * @param name The name of the loader extension.
  76702. * @returns A boolean indicating whether the extension has been unregistered
  76703. */
  76704. static UnregisterExtension(name: string): boolean;
  76705. /**
  76706. * The loader state.
  76707. */
  76708. get state(): Nullable<GLTFLoaderState>;
  76709. /**
  76710. * The object that represents the glTF JSON.
  76711. */
  76712. get gltf(): IGLTF;
  76713. /**
  76714. * The BIN chunk of a binary glTF.
  76715. */
  76716. get bin(): Nullable<IDataBuffer>;
  76717. /**
  76718. * The parent file loader.
  76719. */
  76720. get parent(): GLTFFileLoader;
  76721. /**
  76722. * The Babylon scene when loading the asset.
  76723. */
  76724. get babylonScene(): Scene;
  76725. /**
  76726. * The root Babylon mesh when loading the asset.
  76727. */
  76728. get rootBabylonMesh(): Mesh;
  76729. /** @hidden */
  76730. constructor(parent: GLTFFileLoader);
  76731. /** @hidden */
  76732. dispose(): void;
  76733. /** @hidden */
  76734. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76735. /** @hidden */
  76736. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76737. private _loadAsync;
  76738. private _loadData;
  76739. private _setupData;
  76740. private _loadExtensions;
  76741. private _checkExtensions;
  76742. private _setState;
  76743. private _createRootNode;
  76744. /**
  76745. * Loads a glTF scene.
  76746. * @param context The context when loading the asset
  76747. * @param scene The glTF scene property
  76748. * @returns A promise that resolves when the load is complete
  76749. */
  76750. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76751. private _forEachPrimitive;
  76752. private _getMeshes;
  76753. private _getTransformNodes;
  76754. private _getSkeletons;
  76755. private _getAnimationGroups;
  76756. private _startAnimations;
  76757. /**
  76758. * Loads a glTF node.
  76759. * @param context The context when loading the asset
  76760. * @param node The glTF node property
  76761. * @param assign A function called synchronously after parsing the glTF properties
  76762. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76763. */
  76764. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76765. private _loadMeshAsync;
  76766. /**
  76767. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76768. * @param context The context when loading the asset
  76769. * @param name The mesh name when loading the asset
  76770. * @param node The glTF node when loading the asset
  76771. * @param mesh The glTF mesh when loading the asset
  76772. * @param primitive The glTF mesh primitive property
  76773. * @param assign A function called synchronously after parsing the glTF properties
  76774. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76775. */
  76776. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76777. private _loadVertexDataAsync;
  76778. private _createMorphTargets;
  76779. private _loadMorphTargetsAsync;
  76780. private _loadMorphTargetVertexDataAsync;
  76781. private static _LoadTransform;
  76782. private _loadSkinAsync;
  76783. private _loadBones;
  76784. private _loadBone;
  76785. private _loadSkinInverseBindMatricesDataAsync;
  76786. private _updateBoneMatrices;
  76787. private _getNodeMatrix;
  76788. /**
  76789. * Loads a glTF camera.
  76790. * @param context The context when loading the asset
  76791. * @param camera The glTF camera property
  76792. * @param assign A function called synchronously after parsing the glTF properties
  76793. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76794. */
  76795. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76796. private _loadAnimationsAsync;
  76797. /**
  76798. * Loads a glTF animation.
  76799. * @param context The context when loading the asset
  76800. * @param animation The glTF animation property
  76801. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76802. */
  76803. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76804. /**
  76805. * @hidden Loads a glTF animation channel.
  76806. * @param context The context when loading the asset
  76807. * @param animationContext The context of the animation when loading the asset
  76808. * @param animation The glTF animation property
  76809. * @param channel The glTF animation channel property
  76810. * @param babylonAnimationGroup The babylon animation group property
  76811. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76812. * @returns A void promise when the channel load is complete
  76813. */
  76814. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76815. private _loadAnimationSamplerAsync;
  76816. private _loadBufferAsync;
  76817. /**
  76818. * Loads a glTF buffer view.
  76819. * @param context The context when loading the asset
  76820. * @param bufferView The glTF buffer view property
  76821. * @returns A promise that resolves with the loaded data when the load is complete
  76822. */
  76823. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76824. private _loadAccessorAsync;
  76825. /** @hidden */
  76826. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76827. private _loadIndicesAccessorAsync;
  76828. private _loadVertexBufferViewAsync;
  76829. private _loadVertexAccessorAsync;
  76830. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76831. /** @hidden */
  76832. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76833. private _createDefaultMaterial;
  76834. /**
  76835. * Creates a Babylon material from a glTF material.
  76836. * @param context The context when loading the asset
  76837. * @param material The glTF material property
  76838. * @param babylonDrawMode The draw mode for the Babylon material
  76839. * @returns The Babylon material
  76840. */
  76841. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76842. /**
  76843. * Loads properties from a glTF material into a Babylon material.
  76844. * @param context The context when loading the asset
  76845. * @param material The glTF material property
  76846. * @param babylonMaterial The Babylon material
  76847. * @returns A promise that resolves when the load is complete
  76848. */
  76849. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76850. /**
  76851. * Loads the normal, occlusion, and emissive 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. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76858. /**
  76859. * Loads the alpha properties from a glTF material into a Babylon material.
  76860. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76861. * @param context The context when loading the asset
  76862. * @param material The glTF material property
  76863. * @param babylonMaterial The Babylon material
  76864. */
  76865. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76866. /**
  76867. * Loads a glTF texture info.
  76868. * @param context The context when loading the asset
  76869. * @param textureInfo The glTF texture info property
  76870. * @param assign A function called synchronously after parsing the glTF properties
  76871. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76872. */
  76873. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76874. /** @hidden */
  76875. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76876. /** @hidden */
  76877. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76878. private _loadSampler;
  76879. /**
  76880. * Loads a glTF image.
  76881. * @param context The context when loading the asset
  76882. * @param image The glTF image property
  76883. * @returns A promise that resolves with the loaded data when the load is complete
  76884. */
  76885. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76886. /**
  76887. * Loads a glTF uri.
  76888. * @param context The context when loading the asset
  76889. * @param property The glTF property associated with the uri
  76890. * @param uri The base64 or relative uri
  76891. * @returns A promise that resolves with the loaded data when the load is complete
  76892. */
  76893. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76894. private _onProgress;
  76895. /**
  76896. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76897. * @param babylonObject the Babylon object with metadata
  76898. * @param pointer the JSON pointer
  76899. */
  76900. static AddPointerMetadata(babylonObject: {
  76901. metadata: any;
  76902. }, pointer: string): void;
  76903. private static _GetTextureWrapMode;
  76904. private static _GetTextureSamplingMode;
  76905. private static _GetTypedArrayConstructor;
  76906. private static _GetTypedArray;
  76907. private static _GetNumComponents;
  76908. private static _ValidateUri;
  76909. private static _GetDrawMode;
  76910. private _compileMaterialsAsync;
  76911. private _compileShadowGeneratorsAsync;
  76912. private _forEachExtensions;
  76913. private _applyExtensions;
  76914. private _extensionsOnLoading;
  76915. private _extensionsOnReady;
  76916. private _extensionsLoadSceneAsync;
  76917. private _extensionsLoadNodeAsync;
  76918. private _extensionsLoadCameraAsync;
  76919. private _extensionsLoadVertexDataAsync;
  76920. private _extensionsLoadMeshPrimitiveAsync;
  76921. private _extensionsLoadMaterialAsync;
  76922. private _extensionsCreateMaterial;
  76923. private _extensionsLoadMaterialPropertiesAsync;
  76924. private _extensionsLoadTextureInfoAsync;
  76925. private _extensionsLoadTextureAsync;
  76926. private _extensionsLoadAnimationAsync;
  76927. private _extensionsLoadSkinAsync;
  76928. private _extensionsLoadUriAsync;
  76929. private _extensionsLoadBufferViewAsync;
  76930. private _extensionsLoadBufferAsync;
  76931. /**
  76932. * Helper method called by a loader extension to load an glTF extension.
  76933. * @param context The context when loading the asset
  76934. * @param property The glTF property to load the extension from
  76935. * @param extensionName The name of the extension to load
  76936. * @param actionAsync The action to run
  76937. * @returns The promise returned by actionAsync or null if the extension does not exist
  76938. */
  76939. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76940. /**
  76941. * Helper method called by a loader extension to load a glTF extra.
  76942. * @param context The context when loading the asset
  76943. * @param property The glTF property to load the extra from
  76944. * @param extensionName The name of the extension to load
  76945. * @param actionAsync The action to run
  76946. * @returns The promise returned by actionAsync or null if the extra does not exist
  76947. */
  76948. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76949. /**
  76950. * Checks for presence of an extension.
  76951. * @param name The name of the extension to check
  76952. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76953. */
  76954. isExtensionUsed(name: string): boolean;
  76955. /**
  76956. * Increments the indentation level and logs a message.
  76957. * @param message The message to log
  76958. */
  76959. logOpen(message: string): void;
  76960. /**
  76961. * Decrements the indentation level.
  76962. */
  76963. logClose(): void;
  76964. /**
  76965. * Logs a message
  76966. * @param message The message to log
  76967. */
  76968. log(message: string): void;
  76969. /**
  76970. * Starts a performance counter.
  76971. * @param counterName The name of the performance counter
  76972. */
  76973. startPerformanceCounter(counterName: string): void;
  76974. /**
  76975. * Ends a performance counter.
  76976. * @param counterName The name of the performance counter
  76977. */
  76978. endPerformanceCounter(counterName: string): void;
  76979. }
  76980. }
  76981. declare module BABYLON.GLTF2.Loader.Extensions {
  76982. /**
  76983. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76984. */
  76985. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76986. /**
  76987. * The name of this extension.
  76988. */
  76989. readonly name: string;
  76990. /**
  76991. * Defines whether this extension is enabled.
  76992. */
  76993. enabled: boolean;
  76994. private _loader;
  76995. private _lights?;
  76996. /** @hidden */
  76997. constructor(loader: GLTFLoader);
  76998. /** @hidden */
  76999. dispose(): void;
  77000. /** @hidden */
  77001. onLoading(): void;
  77002. /** @hidden */
  77003. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77004. private _loadLightAsync;
  77005. }
  77006. }
  77007. declare module BABYLON.GLTF2.Loader.Extensions {
  77008. /**
  77009. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  77010. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  77011. * !!! Experimental Extension Subject to Changes !!!
  77012. */
  77013. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  77014. /**
  77015. * The name of this extension.
  77016. */
  77017. readonly name: string;
  77018. /**
  77019. * Defines whether this extension is enabled.
  77020. */
  77021. enabled: boolean;
  77022. private _loader;
  77023. /** @hidden */
  77024. constructor(loader: GLTFLoader);
  77025. /** @hidden */
  77026. dispose(): void;
  77027. /** @hidden */
  77028. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77029. }
  77030. }
  77031. declare module BABYLON.GLTF2.Loader.Extensions {
  77032. /**
  77033. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  77034. */
  77035. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  77036. /**
  77037. * The name of this extension.
  77038. */
  77039. readonly name: string;
  77040. /**
  77041. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  77042. */
  77043. dracoCompression?: DracoCompression;
  77044. /**
  77045. * Defines whether this extension is enabled.
  77046. */
  77047. enabled: boolean;
  77048. private _loader;
  77049. /** @hidden */
  77050. constructor(loader: GLTFLoader);
  77051. /** @hidden */
  77052. dispose(): void;
  77053. /** @hidden */
  77054. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  77055. }
  77056. }
  77057. declare module BABYLON.GLTF2.Loader.Extensions {
  77058. /**
  77059. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  77060. */
  77061. export class KHR_lights implements IGLTFLoaderExtension {
  77062. /**
  77063. * The name of this extension.
  77064. */
  77065. readonly name: string;
  77066. /**
  77067. * Defines whether this extension is enabled.
  77068. */
  77069. enabled: boolean;
  77070. private _loader;
  77071. private _lights?;
  77072. /** @hidden */
  77073. constructor(loader: GLTFLoader);
  77074. /** @hidden */
  77075. dispose(): void;
  77076. /** @hidden */
  77077. onLoading(): void;
  77078. /** @hidden */
  77079. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77080. }
  77081. }
  77082. declare module BABYLON.GLTF2.Loader.Extensions {
  77083. /**
  77084. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  77085. */
  77086. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  77087. /**
  77088. * The name of this extension.
  77089. */
  77090. readonly name: string;
  77091. /**
  77092. * Defines whether this extension is enabled.
  77093. */
  77094. enabled: boolean;
  77095. /**
  77096. * Defines a number that determines the order the extensions are applied.
  77097. */
  77098. order: number;
  77099. private _loader;
  77100. /** @hidden */
  77101. constructor(loader: GLTFLoader);
  77102. /** @hidden */
  77103. dispose(): void;
  77104. /** @hidden */
  77105. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77106. private _loadSpecularGlossinessPropertiesAsync;
  77107. }
  77108. }
  77109. declare module BABYLON.GLTF2.Loader.Extensions {
  77110. /**
  77111. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  77112. */
  77113. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  77114. /**
  77115. * The name of this extension.
  77116. */
  77117. readonly name: string;
  77118. /**
  77119. * Defines whether this extension is enabled.
  77120. */
  77121. enabled: boolean;
  77122. /**
  77123. * Defines a number that determines the order the extensions are applied.
  77124. */
  77125. order: number;
  77126. private _loader;
  77127. /** @hidden */
  77128. constructor(loader: GLTFLoader);
  77129. /** @hidden */
  77130. dispose(): void;
  77131. /** @hidden */
  77132. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77133. private _loadUnlitPropertiesAsync;
  77134. }
  77135. }
  77136. declare module BABYLON.GLTF2.Loader.Extensions {
  77137. /**
  77138. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77139. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  77140. * !!! Experimental Extension Subject to Changes !!!
  77141. */
  77142. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  77143. /**
  77144. * The name of this extension.
  77145. */
  77146. readonly name: string;
  77147. /**
  77148. * Defines whether this extension is enabled.
  77149. */
  77150. enabled: boolean;
  77151. /**
  77152. * Defines a number that determines the order the extensions are applied.
  77153. */
  77154. order: number;
  77155. private _loader;
  77156. /** @hidden */
  77157. constructor(loader: GLTFLoader);
  77158. /** @hidden */
  77159. dispose(): void;
  77160. /** @hidden */
  77161. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77162. private _loadClearCoatPropertiesAsync;
  77163. }
  77164. }
  77165. declare module BABYLON.GLTF2.Loader.Extensions {
  77166. /**
  77167. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  77168. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77169. * !!! Experimental Extension Subject to Changes !!!
  77170. */
  77171. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  77172. /**
  77173. * The name of this extension.
  77174. */
  77175. readonly name: string;
  77176. /**
  77177. * Defines whether this extension is enabled.
  77178. */
  77179. enabled: boolean;
  77180. /**
  77181. * Defines a number that determines the order the extensions are applied.
  77182. */
  77183. order: number;
  77184. private _loader;
  77185. /** @hidden */
  77186. constructor(loader: GLTFLoader);
  77187. /** @hidden */
  77188. dispose(): void;
  77189. /** @hidden */
  77190. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77191. private _loadSheenPropertiesAsync;
  77192. }
  77193. }
  77194. declare module BABYLON.GLTF2.Loader.Extensions {
  77195. /**
  77196. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77197. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77198. * !!! Experimental Extension Subject to Changes !!!
  77199. */
  77200. export class KHR_materials_specular implements IGLTFLoaderExtension {
  77201. /**
  77202. * The name of this extension.
  77203. */
  77204. readonly name: string;
  77205. /**
  77206. * Defines whether this extension is enabled.
  77207. */
  77208. enabled: boolean;
  77209. /**
  77210. * Defines a number that determines the order the extensions are applied.
  77211. */
  77212. order: number;
  77213. private _loader;
  77214. /** @hidden */
  77215. constructor(loader: GLTFLoader);
  77216. /** @hidden */
  77217. dispose(): void;
  77218. /** @hidden */
  77219. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77220. private _loadSpecularPropertiesAsync;
  77221. }
  77222. }
  77223. declare module BABYLON.GLTF2.Loader.Extensions {
  77224. /**
  77225. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  77226. */
  77227. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  77228. /**
  77229. * The name of this extension.
  77230. */
  77231. readonly name: string;
  77232. /**
  77233. * Defines whether this extension is enabled.
  77234. */
  77235. enabled: boolean;
  77236. /** @hidden */
  77237. constructor(loader: GLTFLoader);
  77238. /** @hidden */
  77239. dispose(): void;
  77240. }
  77241. }
  77242. declare module BABYLON.GLTF2.Loader.Extensions {
  77243. /**
  77244. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  77245. * !!! Experimental Extension Subject to Changes !!!
  77246. */
  77247. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  77248. /** The name of this extension. */
  77249. readonly name: string;
  77250. /** Defines whether this extension is enabled. */
  77251. enabled: boolean;
  77252. private _loader;
  77253. /** @hidden */
  77254. constructor(loader: GLTFLoader);
  77255. /** @hidden */
  77256. dispose(): void;
  77257. /** @hidden */
  77258. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77259. }
  77260. }
  77261. declare module BABYLON.GLTF2.Loader.Extensions {
  77262. /**
  77263. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  77264. */
  77265. export class KHR_texture_transform implements IGLTFLoaderExtension {
  77266. /**
  77267. * The name of this extension.
  77268. */
  77269. readonly name: string;
  77270. /**
  77271. * Defines whether this extension is enabled.
  77272. */
  77273. enabled: boolean;
  77274. private _loader;
  77275. /** @hidden */
  77276. constructor(loader: GLTFLoader);
  77277. /** @hidden */
  77278. dispose(): void;
  77279. /** @hidden */
  77280. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77281. }
  77282. }
  77283. declare module BABYLON.GLTF2.Loader.Extensions {
  77284. /**
  77285. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  77286. */
  77287. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  77288. /**
  77289. * The name of this extension.
  77290. */
  77291. readonly name: string;
  77292. /**
  77293. * Defines whether this extension is enabled.
  77294. */
  77295. enabled: boolean;
  77296. private _loader;
  77297. private _clips;
  77298. private _emitters;
  77299. /** @hidden */
  77300. constructor(loader: GLTFLoader);
  77301. /** @hidden */
  77302. dispose(): void;
  77303. /** @hidden */
  77304. onLoading(): void;
  77305. /** @hidden */
  77306. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77307. /** @hidden */
  77308. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77309. /** @hidden */
  77310. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77311. private _loadClipAsync;
  77312. private _loadEmitterAsync;
  77313. private _getEventAction;
  77314. private _loadAnimationEventAsync;
  77315. }
  77316. }
  77317. declare module BABYLON.GLTF2.Loader.Extensions {
  77318. /**
  77319. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  77320. */
  77321. export class MSFT_lod implements IGLTFLoaderExtension {
  77322. /**
  77323. * The name of this extension.
  77324. */
  77325. readonly name: string;
  77326. /**
  77327. * Defines whether this extension is enabled.
  77328. */
  77329. enabled: boolean;
  77330. /**
  77331. * Defines a number that determines the order the extensions are applied.
  77332. */
  77333. order: number;
  77334. /**
  77335. * Maximum number of LODs to load, starting from the lowest LOD.
  77336. */
  77337. maxLODsToLoad: number;
  77338. /**
  77339. * Observable raised when all node LODs of one level are loaded.
  77340. * The event data is the index of the loaded LOD starting from zero.
  77341. * Dispose the loader to cancel the loading of the next level of LODs.
  77342. */
  77343. onNodeLODsLoadedObservable: Observable<number>;
  77344. /**
  77345. * Observable raised when all material LODs of one level are loaded.
  77346. * The event data is the index of the loaded LOD starting from zero.
  77347. * Dispose the loader to cancel the loading of the next level of LODs.
  77348. */
  77349. onMaterialLODsLoadedObservable: Observable<number>;
  77350. private _loader;
  77351. private _nodeIndexLOD;
  77352. private _nodeSignalLODs;
  77353. private _nodePromiseLODs;
  77354. private _materialIndexLOD;
  77355. private _materialSignalLODs;
  77356. private _materialPromiseLODs;
  77357. private _indexLOD;
  77358. private _bufferLODs;
  77359. /** @hidden */
  77360. constructor(loader: GLTFLoader);
  77361. /** @hidden */
  77362. dispose(): void;
  77363. /** @hidden */
  77364. onReady(): void;
  77365. /** @hidden */
  77366. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77367. /** @hidden */
  77368. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77369. /** @hidden */
  77370. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77371. /** @hidden */
  77372. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77373. /** @hidden */
  77374. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77375. private _loadBufferLOD;
  77376. /**
  77377. * Gets an array of LOD properties from lowest to highest.
  77378. */
  77379. private _getLODs;
  77380. private _disposeTransformNode;
  77381. private _disposeMaterials;
  77382. }
  77383. }
  77384. declare module BABYLON.GLTF2.Loader.Extensions {
  77385. /** @hidden */
  77386. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  77387. readonly name: string;
  77388. enabled: boolean;
  77389. private _loader;
  77390. constructor(loader: GLTFLoader);
  77391. dispose(): void;
  77392. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77393. }
  77394. }
  77395. declare module BABYLON.GLTF2.Loader.Extensions {
  77396. /** @hidden */
  77397. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  77398. readonly name: string;
  77399. enabled: boolean;
  77400. private _loader;
  77401. constructor(loader: GLTFLoader);
  77402. dispose(): void;
  77403. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77404. }
  77405. }
  77406. declare module BABYLON.GLTF2.Loader.Extensions {
  77407. /**
  77408. * Store glTF extras (if present) in BJS objects' metadata
  77409. */
  77410. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  77411. /**
  77412. * The name of this extension.
  77413. */
  77414. readonly name: string;
  77415. /**
  77416. * Defines whether this extension is enabled.
  77417. */
  77418. enabled: boolean;
  77419. private _loader;
  77420. private _assignExtras;
  77421. /** @hidden */
  77422. constructor(loader: GLTFLoader);
  77423. /** @hidden */
  77424. dispose(): void;
  77425. /** @hidden */
  77426. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77427. /** @hidden */
  77428. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77429. /** @hidden */
  77430. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77431. }
  77432. }
  77433. declare module BABYLON {
  77434. /**
  77435. * Class reading and parsing the MTL file bundled with the obj file.
  77436. */
  77437. export class MTLFileLoader {
  77438. /**
  77439. * Invert Y-Axis of referenced textures on load
  77440. */
  77441. static INVERT_TEXTURE_Y: boolean;
  77442. /**
  77443. * All material loaded from the mtl will be set here
  77444. */
  77445. materials: StandardMaterial[];
  77446. /**
  77447. * This function will read the mtl file and create each material described inside
  77448. * This function could be improve by adding :
  77449. * -some component missing (Ni, Tf...)
  77450. * -including the specific options available
  77451. *
  77452. * @param scene defines the scene the material will be created in
  77453. * @param data defines the mtl data to parse
  77454. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77455. * @param forAssetContainer defines if the material should be registered in the scene
  77456. */
  77457. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77458. /**
  77459. * Gets the texture for the material.
  77460. *
  77461. * If the material is imported from input file,
  77462. * We sanitize the url to ensure it takes the textre from aside the material.
  77463. *
  77464. * @param rootUrl The root url to load from
  77465. * @param value The value stored in the mtl
  77466. * @return The Texture
  77467. */
  77468. private static _getTexture;
  77469. }
  77470. }
  77471. declare module BABYLON {
  77472. /**
  77473. * Options for loading OBJ/MTL files
  77474. */
  77475. type MeshLoadOptions = {
  77476. /**
  77477. * Defines if UVs are optimized by default during load.
  77478. */
  77479. OptimizeWithUV: boolean;
  77480. /**
  77481. * Defines custom scaling of UV coordinates of loaded meshes.
  77482. */
  77483. UVScaling: Vector2;
  77484. /**
  77485. * Invert model on y-axis (does a model scaling inversion)
  77486. */
  77487. InvertY: boolean;
  77488. /**
  77489. * Invert Y-Axis of referenced textures on load
  77490. */
  77491. InvertTextureY: boolean;
  77492. /**
  77493. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77494. */
  77495. ImportVertexColors: boolean;
  77496. /**
  77497. * Compute the normals for the model, even if normals are present in the file.
  77498. */
  77499. ComputeNormals: boolean;
  77500. /**
  77501. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77502. */
  77503. SkipMaterials: boolean;
  77504. /**
  77505. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77506. */
  77507. MaterialLoadingFailsSilently: boolean;
  77508. };
  77509. /**
  77510. * OBJ file type loader.
  77511. * This is a babylon scene loader plugin.
  77512. */
  77513. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77514. /**
  77515. * Defines if UVs are optimized by default during load.
  77516. */
  77517. static OPTIMIZE_WITH_UV: boolean;
  77518. /**
  77519. * Invert model on y-axis (does a model scaling inversion)
  77520. */
  77521. static INVERT_Y: boolean;
  77522. /**
  77523. * Invert Y-Axis of referenced textures on load
  77524. */
  77525. static get INVERT_TEXTURE_Y(): boolean;
  77526. static set INVERT_TEXTURE_Y(value: boolean);
  77527. /**
  77528. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77529. */
  77530. static IMPORT_VERTEX_COLORS: boolean;
  77531. /**
  77532. * Compute the normals for the model, even if normals are present in the file.
  77533. */
  77534. static COMPUTE_NORMALS: boolean;
  77535. /**
  77536. * Defines custom scaling of UV coordinates of loaded meshes.
  77537. */
  77538. static UV_SCALING: Vector2;
  77539. /**
  77540. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77541. */
  77542. static SKIP_MATERIALS: boolean;
  77543. /**
  77544. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77545. *
  77546. * Defaults to true for backwards compatibility.
  77547. */
  77548. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77549. /**
  77550. * Defines the name of the plugin.
  77551. */
  77552. name: string;
  77553. /**
  77554. * Defines the extension the plugin is able to load.
  77555. */
  77556. extensions: string;
  77557. /** @hidden */
  77558. obj: RegExp;
  77559. /** @hidden */
  77560. group: RegExp;
  77561. /** @hidden */
  77562. mtllib: RegExp;
  77563. /** @hidden */
  77564. usemtl: RegExp;
  77565. /** @hidden */
  77566. smooth: RegExp;
  77567. /** @hidden */
  77568. vertexPattern: RegExp;
  77569. /** @hidden */
  77570. normalPattern: RegExp;
  77571. /** @hidden */
  77572. uvPattern: RegExp;
  77573. /** @hidden */
  77574. facePattern1: RegExp;
  77575. /** @hidden */
  77576. facePattern2: RegExp;
  77577. /** @hidden */
  77578. facePattern3: RegExp;
  77579. /** @hidden */
  77580. facePattern4: RegExp;
  77581. /** @hidden */
  77582. facePattern5: RegExp;
  77583. private _forAssetContainer;
  77584. private _meshLoadOptions;
  77585. /**
  77586. * Creates loader for .OBJ files
  77587. *
  77588. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77589. */
  77590. constructor(meshLoadOptions?: MeshLoadOptions);
  77591. private static get currentMeshLoadOptions();
  77592. /**
  77593. * Calls synchronously the MTL file attached to this obj.
  77594. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77595. * Without this function materials are not displayed in the first frame (but displayed after).
  77596. * In consequence it is impossible to get material information in your HTML file
  77597. *
  77598. * @param url The URL of the MTL file
  77599. * @param rootUrl
  77600. * @param onSuccess Callback function to be called when the MTL file is loaded
  77601. * @private
  77602. */
  77603. private _loadMTL;
  77604. /**
  77605. * Instantiates a OBJ file loader plugin.
  77606. * @returns the created plugin
  77607. */
  77608. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77609. /**
  77610. * If the data string can be loaded directly.
  77611. *
  77612. * @param data string containing the file data
  77613. * @returns if the data can be loaded directly
  77614. */
  77615. canDirectLoad(data: string): boolean;
  77616. /**
  77617. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77618. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77619. * @param scene the scene the meshes should be added to
  77620. * @param data the OBJ data to load
  77621. * @param rootUrl root url to load from
  77622. * @param onProgress event that fires when loading progress has occured
  77623. * @param fileName Defines the name of the file to load
  77624. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77625. */
  77626. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77627. meshes: AbstractMesh[];
  77628. particleSystems: IParticleSystem[];
  77629. skeletons: Skeleton[];
  77630. animationGroups: AnimationGroup[];
  77631. }>;
  77632. /**
  77633. * Imports all objects from the loaded OBJ data and adds them to the scene
  77634. * @param scene the scene the objects should be added to
  77635. * @param data the OBJ data to load
  77636. * @param rootUrl root url to load from
  77637. * @param onProgress event that fires when loading progress has occured
  77638. * @param fileName Defines the name of the file to load
  77639. * @returns a promise which completes when objects have been loaded to the scene
  77640. */
  77641. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77642. /**
  77643. * Load into an asset container.
  77644. * @param scene The scene to load into
  77645. * @param data The data to import
  77646. * @param rootUrl The root url for scene and resources
  77647. * @param onProgress The callback when the load progresses
  77648. * @param fileName Defines the name of the file to load
  77649. * @returns The loaded asset container
  77650. */
  77651. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77652. /**
  77653. * Read the OBJ file and create an Array of meshes.
  77654. * Each mesh contains all information given by the OBJ and the MTL file.
  77655. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77656. *
  77657. * @param meshesNames
  77658. * @param scene Scene The scene where are displayed the data
  77659. * @param data String The content of the obj file
  77660. * @param rootUrl String The path to the folder
  77661. * @returns Array<AbstractMesh>
  77662. * @private
  77663. */
  77664. private _parseSolid;
  77665. }
  77666. }
  77667. declare module BABYLON {
  77668. /**
  77669. * STL file type loader.
  77670. * This is a babylon scene loader plugin.
  77671. */
  77672. export class STLFileLoader implements ISceneLoaderPlugin {
  77673. /** @hidden */
  77674. solidPattern: RegExp;
  77675. /** @hidden */
  77676. facetsPattern: RegExp;
  77677. /** @hidden */
  77678. normalPattern: RegExp;
  77679. /** @hidden */
  77680. vertexPattern: RegExp;
  77681. /**
  77682. * Defines the name of the plugin.
  77683. */
  77684. name: string;
  77685. /**
  77686. * Defines the extensions the stl loader is able to load.
  77687. * force data to come in as an ArrayBuffer
  77688. * we'll convert to string if it looks like it's an ASCII .stl
  77689. */
  77690. extensions: ISceneLoaderPluginExtensions;
  77691. /**
  77692. * Import meshes into a scene.
  77693. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77694. * @param scene The scene to import into
  77695. * @param data The data to import
  77696. * @param rootUrl The root url for scene and resources
  77697. * @param meshes The meshes array to import into
  77698. * @param particleSystems The particle systems array to import into
  77699. * @param skeletons The skeletons array to import into
  77700. * @param onError The callback when import fails
  77701. * @returns True if successful or false otherwise
  77702. */
  77703. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77704. /**
  77705. * Load into a scene.
  77706. * @param scene The scene to load into
  77707. * @param data The data to import
  77708. * @param rootUrl The root url for scene and resources
  77709. * @param onError The callback when import fails
  77710. * @returns true if successful or false otherwise
  77711. */
  77712. load(scene: Scene, data: any, rootUrl: string): boolean;
  77713. /**
  77714. * Load into an asset container.
  77715. * @param scene The scene to load into
  77716. * @param data The data to import
  77717. * @param rootUrl The root url for scene and resources
  77718. * @param onError The callback when import fails
  77719. * @returns The loaded asset container
  77720. */
  77721. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77722. private _isBinary;
  77723. private _parseBinary;
  77724. private _parseASCII;
  77725. }
  77726. }
  77727. declare module BABYLON {
  77728. /**
  77729. * Class for generating OBJ data from a Babylon scene.
  77730. */
  77731. export class OBJExport {
  77732. /**
  77733. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77734. * @param mesh defines the list of meshes to serialize
  77735. * @param materials defines if materials should be exported
  77736. * @param matlibname defines the name of the associated mtl file
  77737. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77738. * @returns the OBJ content
  77739. */
  77740. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77741. /**
  77742. * Exports the material(s) of a mesh in .MTL file format (text)
  77743. * @param mesh defines the mesh to extract the material from
  77744. * @returns the mtl content
  77745. */
  77746. static MTL(mesh: Mesh): string;
  77747. }
  77748. }
  77749. declare module BABYLON {
  77750. /** @hidden */
  77751. export var __IGLTFExporterExtension: number;
  77752. /**
  77753. * Interface for extending the exporter
  77754. * @hidden
  77755. */
  77756. export interface IGLTFExporterExtension {
  77757. /**
  77758. * The name of this extension
  77759. */
  77760. readonly name: string;
  77761. /**
  77762. * Defines whether this extension is enabled
  77763. */
  77764. enabled: boolean;
  77765. /**
  77766. * Defines whether this extension is required
  77767. */
  77768. required: boolean;
  77769. }
  77770. }
  77771. declare module BABYLON.GLTF2.Exporter {
  77772. /** @hidden */
  77773. export var __IGLTFExporterExtensionV2: number;
  77774. /**
  77775. * Interface for a glTF exporter extension
  77776. * @hidden
  77777. */
  77778. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77779. /**
  77780. * Define this method to modify the default behavior before exporting a texture
  77781. * @param context The context when loading the asset
  77782. * @param babylonTexture The Babylon.js texture
  77783. * @param mimeType The mime-type of the generated image
  77784. * @returns A promise that resolves with the exported texture
  77785. */
  77786. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77787. /**
  77788. * Define this method to get notified when a texture info is created
  77789. * @param context The context when loading the asset
  77790. * @param textureInfo The glTF texture info
  77791. * @param babylonTexture The Babylon.js texture
  77792. */
  77793. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77794. /**
  77795. * Define this method to modify the default behavior when exporting texture info
  77796. * @param context The context when loading the asset
  77797. * @param meshPrimitive glTF mesh primitive
  77798. * @param babylonSubMesh Babylon submesh
  77799. * @param binaryWriter glTF serializer binary writer instance
  77800. * @returns nullable IMeshPrimitive promise
  77801. */
  77802. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77803. /**
  77804. * Define this method to modify the default behavior when exporting a node
  77805. * @param context The context when exporting the node
  77806. * @param node glTF node
  77807. * @param babylonNode BabylonJS node
  77808. * @returns nullable INode promise
  77809. */
  77810. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77811. [key: number]: number;
  77812. }): Promise<Nullable<INode>>;
  77813. /**
  77814. * Define this method to modify the default behavior when exporting a material
  77815. * @param material glTF material
  77816. * @param babylonMaterial BabylonJS material
  77817. * @returns nullable IMaterial promise
  77818. */
  77819. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77820. /**
  77821. * Define this method to return additional textures to export from a material
  77822. * @param material glTF material
  77823. * @param babylonMaterial BabylonJS material
  77824. * @returns List of textures
  77825. */
  77826. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77827. /** Gets a boolean indicating that this extension was used */
  77828. wasUsed: boolean;
  77829. /** Gets a boolean indicating that this extension is required for the file to work */
  77830. required: boolean;
  77831. /**
  77832. * Called after the exporter state changes to EXPORTING
  77833. */
  77834. onExporting?(): void;
  77835. }
  77836. }
  77837. declare module BABYLON.GLTF2.Exporter {
  77838. /**
  77839. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77840. * @hidden
  77841. */
  77842. export class _GLTFMaterialExporter {
  77843. /**
  77844. * Represents the dielectric specular values for R, G and B
  77845. */
  77846. private static readonly _DielectricSpecular;
  77847. /**
  77848. * Allows the maximum specular power to be defined for material calculations
  77849. */
  77850. private static readonly _MaxSpecularPower;
  77851. /**
  77852. * Mapping to store textures
  77853. */
  77854. private _textureMap;
  77855. /**
  77856. * Numeric tolerance value
  77857. */
  77858. private static readonly _Epsilon;
  77859. /**
  77860. * Reference to the glTF Exporter
  77861. */
  77862. private _exporter;
  77863. constructor(exporter: _Exporter);
  77864. /**
  77865. * Specifies if two colors are approximately equal in value
  77866. * @param color1 first color to compare to
  77867. * @param color2 second color to compare to
  77868. * @param epsilon threshold value
  77869. */
  77870. private static FuzzyEquals;
  77871. /**
  77872. * Gets the materials from a Babylon scene and converts them to glTF materials
  77873. * @param scene babylonjs scene
  77874. * @param mimeType texture mime type
  77875. * @param images array of images
  77876. * @param textures array of textures
  77877. * @param materials array of materials
  77878. * @param imageData mapping of texture names to base64 textures
  77879. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77880. */
  77881. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77882. /**
  77883. * Makes a copy of the glTF material without the texture parameters
  77884. * @param originalMaterial original glTF material
  77885. * @returns glTF material without texture parameters
  77886. */
  77887. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77888. /**
  77889. * Specifies if the material has any texture parameters present
  77890. * @param material glTF Material
  77891. * @returns boolean specifying if texture parameters are present
  77892. */
  77893. _hasTexturesPresent(material: IMaterial): boolean;
  77894. /**
  77895. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77896. * @param babylonStandardMaterial
  77897. * @returns glTF Metallic Roughness Material representation
  77898. */
  77899. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77900. /**
  77901. * Computes the metallic factor
  77902. * @param diffuse diffused value
  77903. * @param specular specular value
  77904. * @param oneMinusSpecularStrength one minus the specular strength
  77905. * @returns metallic value
  77906. */
  77907. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77908. /**
  77909. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77910. * @param glTFMaterial glTF material
  77911. * @param babylonMaterial Babylon material
  77912. */
  77913. private static _SetAlphaMode;
  77914. /**
  77915. * Converts a Babylon Standard Material to a glTF Material
  77916. * @param babylonStandardMaterial BJS Standard Material
  77917. * @param mimeType mime type to use for the textures
  77918. * @param images array of glTF image interfaces
  77919. * @param textures array of glTF texture interfaces
  77920. * @param materials array of glTF material interfaces
  77921. * @param imageData map of image file name to data
  77922. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77923. */
  77924. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77925. private _finishMaterial;
  77926. /**
  77927. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77928. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77929. * @param mimeType mime type to use for the textures
  77930. * @param images array of glTF image interfaces
  77931. * @param textures array of glTF texture interfaces
  77932. * @param materials array of glTF material interfaces
  77933. * @param imageData map of image file name to data
  77934. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77935. */
  77936. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77937. /**
  77938. * Converts an image typed array buffer to a base64 image
  77939. * @param buffer typed array buffer
  77940. * @param width width of the image
  77941. * @param height height of the image
  77942. * @param mimeType mimetype of the image
  77943. * @returns base64 image string
  77944. */
  77945. private _createBase64FromCanvasAsync;
  77946. /**
  77947. * Generates a white texture based on the specified width and height
  77948. * @param width width of the texture in pixels
  77949. * @param height height of the texture in pixels
  77950. * @param scene babylonjs scene
  77951. * @returns white texture
  77952. */
  77953. private _createWhiteTexture;
  77954. /**
  77955. * 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
  77956. * @param texture1 first texture to resize
  77957. * @param texture2 second texture to resize
  77958. * @param scene babylonjs scene
  77959. * @returns resized textures or null
  77960. */
  77961. private _resizeTexturesToSameDimensions;
  77962. /**
  77963. * Converts an array of pixels to a Float32Array
  77964. * Throws an error if the pixel format is not supported
  77965. * @param pixels - array buffer containing pixel values
  77966. * @returns Float32 of pixels
  77967. */
  77968. private _convertPixelArrayToFloat32;
  77969. /**
  77970. * Convert Specular Glossiness Textures to Metallic Roughness
  77971. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77972. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77973. * @param diffuseTexture texture used to store diffuse information
  77974. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77975. * @param factors specular glossiness material factors
  77976. * @param mimeType the mime type to use for the texture
  77977. * @returns pbr metallic roughness interface or null
  77978. */
  77979. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77980. /**
  77981. * Converts specular glossiness material properties to metallic roughness
  77982. * @param specularGlossiness interface with specular glossiness material properties
  77983. * @returns interface with metallic roughness material properties
  77984. */
  77985. private _convertSpecularGlossinessToMetallicRoughness;
  77986. /**
  77987. * Calculates the surface reflectance, independent of lighting conditions
  77988. * @param color Color source to calculate brightness from
  77989. * @returns number representing the perceived brightness, or zero if color is undefined
  77990. */
  77991. private _getPerceivedBrightness;
  77992. /**
  77993. * Returns the maximum color component value
  77994. * @param color
  77995. * @returns maximum color component value, or zero if color is null or undefined
  77996. */
  77997. private _getMaxComponent;
  77998. /**
  77999. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  78000. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  78001. * @param mimeType mime type to use for the textures
  78002. * @param images array of glTF image interfaces
  78003. * @param textures array of glTF texture interfaces
  78004. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  78005. * @param imageData map of image file name to data
  78006. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  78007. * @returns glTF PBR Metallic Roughness factors
  78008. */
  78009. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  78010. private _getGLTFTextureSampler;
  78011. private _getGLTFTextureWrapMode;
  78012. private _getGLTFTextureWrapModesSampler;
  78013. /**
  78014. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  78015. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  78016. * @param mimeType mime type to use for the textures
  78017. * @param images array of glTF image interfaces
  78018. * @param textures array of glTF texture interfaces
  78019. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  78020. * @param imageData map of image file name to data
  78021. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  78022. * @returns glTF PBR Metallic Roughness factors
  78023. */
  78024. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  78025. /**
  78026. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  78027. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  78028. * @param mimeType mime type to use for the textures
  78029. * @param images array of glTF image interfaces
  78030. * @param textures array of glTF texture interfaces
  78031. * @param materials array of glTF material interfaces
  78032. * @param imageData map of image file name to data
  78033. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  78034. */
  78035. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  78036. private setMetallicRoughnessPbrMaterial;
  78037. private getPixelsFromTexture;
  78038. /**
  78039. * Extracts a texture from a Babylon texture into file data and glTF data
  78040. * @param babylonTexture Babylon texture to extract
  78041. * @param mimeType Mime Type of the babylonTexture
  78042. * @return glTF texture info, or null if the texture format is not supported
  78043. */
  78044. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  78045. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  78046. /**
  78047. * Builds a texture from base64 string
  78048. * @param base64Texture base64 texture string
  78049. * @param baseTextureName Name to use for the texture
  78050. * @param mimeType image mime type for the texture
  78051. * @param images array of images
  78052. * @param textures array of textures
  78053. * @param imageData map of image data
  78054. * @returns glTF texture info, or null if the texture format is not supported
  78055. */
  78056. private _getTextureInfoFromBase64;
  78057. }
  78058. }
  78059. declare module BABYLON {
  78060. /**
  78061. * Class for holding and downloading glTF file data
  78062. */
  78063. export class GLTFData {
  78064. /**
  78065. * Object which contains the file name as the key and its data as the value
  78066. */
  78067. glTFFiles: {
  78068. [fileName: string]: string | Blob;
  78069. };
  78070. /**
  78071. * Initializes the glTF file object
  78072. */
  78073. constructor();
  78074. /**
  78075. * Downloads the glTF data as files based on their names and data
  78076. */
  78077. downloadFiles(): void;
  78078. }
  78079. }
  78080. declare module BABYLON {
  78081. /**
  78082. * Holds a collection of exporter options and parameters
  78083. */
  78084. export interface IExportOptions {
  78085. /**
  78086. * Function which indicates whether a babylon node should be exported or not
  78087. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  78088. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  78089. */
  78090. shouldExportNode?(node: Node): boolean;
  78091. /**
  78092. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  78093. * @param metadata source metadata to read from
  78094. * @returns the data to store to glTF node extras
  78095. */
  78096. metadataSelector?(metadata: any): any;
  78097. /**
  78098. * The sample rate to bake animation curves
  78099. */
  78100. animationSampleRate?: number;
  78101. /**
  78102. * Begin serialization without waiting for the scene to be ready
  78103. */
  78104. exportWithoutWaitingForScene?: boolean;
  78105. /**
  78106. * Indicates if coordinate system swapping root nodes should be included in export
  78107. */
  78108. includeCoordinateSystemConversionNodes?: boolean;
  78109. }
  78110. /**
  78111. * Class for generating glTF data from a Babylon scene.
  78112. */
  78113. export class GLTF2Export {
  78114. /**
  78115. * Exports the geometry of the scene to .gltf file format asynchronously
  78116. * @param scene Babylon scene with scene hierarchy information
  78117. * @param filePrefix File prefix to use when generating the glTF file
  78118. * @param options Exporter options
  78119. * @returns Returns an object with a .gltf file and associates texture names
  78120. * as keys and their data and paths as values
  78121. */
  78122. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78123. private static _PreExportAsync;
  78124. private static _PostExportAsync;
  78125. /**
  78126. * Exports the geometry of the scene to .glb file format asychronously
  78127. * @param scene Babylon scene with scene hierarchy information
  78128. * @param filePrefix File prefix to use when generating glb file
  78129. * @param options Exporter options
  78130. * @returns Returns an object with a .glb filename as key and data as value
  78131. */
  78132. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78133. }
  78134. }
  78135. declare module BABYLON.GLTF2.Exporter {
  78136. /**
  78137. * @hidden
  78138. */
  78139. export class _GLTFUtilities {
  78140. /**
  78141. * Creates a buffer view based on the supplied arguments
  78142. * @param bufferIndex index value of the specified buffer
  78143. * @param byteOffset byte offset value
  78144. * @param byteLength byte length of the bufferView
  78145. * @param byteStride byte distance between conequential elements
  78146. * @param name name of the buffer view
  78147. * @returns bufferView for glTF
  78148. */
  78149. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  78150. /**
  78151. * Creates an accessor based on the supplied arguments
  78152. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  78153. * @param name The name of the accessor
  78154. * @param type The type of the accessor
  78155. * @param componentType The datatype of components in the attribute
  78156. * @param count The number of attributes referenced by this accessor
  78157. * @param byteOffset The offset relative to the start of the bufferView in bytes
  78158. * @param min Minimum value of each component in this attribute
  78159. * @param max Maximum value of each component in this attribute
  78160. * @returns accessor for glTF
  78161. */
  78162. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  78163. /**
  78164. * Calculates the minimum and maximum values of an array of position floats
  78165. * @param positions Positions array of a mesh
  78166. * @param vertexStart Starting vertex offset to calculate min and max values
  78167. * @param vertexCount Number of vertices to check for min and max values
  78168. * @returns min number array and max number array
  78169. */
  78170. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  78171. min: number[];
  78172. max: number[];
  78173. };
  78174. /**
  78175. * Converts a new right-handed Vector3
  78176. * @param vector vector3 array
  78177. * @returns right-handed Vector3
  78178. */
  78179. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  78180. /**
  78181. * Converts a Vector3 to right-handed
  78182. * @param vector Vector3 to convert to right-handed
  78183. */
  78184. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  78185. /**
  78186. * Converts a three element number array to right-handed
  78187. * @param vector number array to convert to right-handed
  78188. */
  78189. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  78190. /**
  78191. * Converts a new right-handed Vector3
  78192. * @param vector vector3 array
  78193. * @returns right-handed Vector3
  78194. */
  78195. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  78196. /**
  78197. * Converts a Vector3 to right-handed
  78198. * @param vector Vector3 to convert to right-handed
  78199. */
  78200. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  78201. /**
  78202. * Converts a three element number array to right-handed
  78203. * @param vector number array to convert to right-handed
  78204. */
  78205. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  78206. /**
  78207. * Converts a Vector4 to right-handed
  78208. * @param vector Vector4 to convert to right-handed
  78209. */
  78210. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  78211. /**
  78212. * Converts a Vector4 to right-handed
  78213. * @param vector Vector4 to convert to right-handed
  78214. */
  78215. static _GetRightHandedArray4FromRef(vector: number[]): void;
  78216. /**
  78217. * Converts a Quaternion to right-handed
  78218. * @param quaternion Source quaternion to convert to right-handed
  78219. */
  78220. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  78221. /**
  78222. * Converts a Quaternion to right-handed
  78223. * @param quaternion Source quaternion to convert to right-handed
  78224. */
  78225. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  78226. static _NormalizeTangentFromRef(tangent: Vector4): void;
  78227. }
  78228. }
  78229. declare module BABYLON.GLTF2.Exporter {
  78230. /**
  78231. * Converts Babylon Scene into glTF 2.0.
  78232. * @hidden
  78233. */
  78234. export class _Exporter {
  78235. /**
  78236. * Stores the glTF to export
  78237. */
  78238. _glTF: IGLTF;
  78239. /**
  78240. * Stores all generated buffer views, which represents views into the main glTF buffer data
  78241. */
  78242. _bufferViews: IBufferView[];
  78243. /**
  78244. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  78245. */
  78246. _accessors: IAccessor[];
  78247. /**
  78248. * Stores all the generated nodes, which contains transform and/or mesh information per node
  78249. */
  78250. _nodes: INode[];
  78251. /**
  78252. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  78253. */
  78254. private _scenes;
  78255. /**
  78256. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  78257. */
  78258. private _meshes;
  78259. /**
  78260. * Stores all the generated material information, which represents the appearance of each primitive
  78261. */
  78262. _materials: IMaterial[];
  78263. _materialMap: {
  78264. [materialID: number]: number;
  78265. };
  78266. /**
  78267. * Stores all the generated texture information, which is referenced by glTF materials
  78268. */
  78269. _textures: ITexture[];
  78270. /**
  78271. * Stores all the generated image information, which is referenced by glTF textures
  78272. */
  78273. _images: IImage[];
  78274. /**
  78275. * Stores all the texture samplers
  78276. */
  78277. _samplers: ISampler[];
  78278. /**
  78279. * Stores all the generated animation samplers, which is referenced by glTF animations
  78280. */
  78281. /**
  78282. * Stores the animations for glTF models
  78283. */
  78284. private _animations;
  78285. /**
  78286. * Stores the total amount of bytes stored in the glTF buffer
  78287. */
  78288. private _totalByteLength;
  78289. /**
  78290. * Stores a reference to the Babylon scene containing the source geometry and material information
  78291. */
  78292. _babylonScene: Scene;
  78293. /**
  78294. * Stores a map of the image data, where the key is the file name and the value
  78295. * is the image data
  78296. */
  78297. _imageData: {
  78298. [fileName: string]: {
  78299. data: Uint8Array;
  78300. mimeType: ImageMimeType;
  78301. };
  78302. };
  78303. /**
  78304. * Stores a map of the unique id of a node to its index in the node array
  78305. */
  78306. _nodeMap: {
  78307. [key: number]: number;
  78308. };
  78309. /**
  78310. * Specifies if the source Babylon scene was left handed, and needed conversion.
  78311. */
  78312. _convertToRightHandedSystem: boolean;
  78313. /**
  78314. * Specifies if a Babylon node should be converted to right-handed on export
  78315. */
  78316. _convertToRightHandedSystemMap: {
  78317. [nodeId: number]: boolean;
  78318. };
  78319. _includeCoordinateSystemConversionNodes: boolean;
  78320. /**
  78321. * Baked animation sample rate
  78322. */
  78323. private _animationSampleRate;
  78324. private _options;
  78325. private _localEngine;
  78326. _glTFMaterialExporter: _GLTFMaterialExporter;
  78327. private _extensions;
  78328. private static _ExtensionNames;
  78329. private static _ExtensionFactories;
  78330. private _applyExtension;
  78331. private _applyExtensions;
  78332. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  78333. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  78334. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78335. [key: number]: number;
  78336. }): Promise<Nullable<INode>>;
  78337. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  78338. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  78339. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78340. private _forEachExtensions;
  78341. private _extensionsOnExporting;
  78342. /**
  78343. * Load glTF serializer extensions
  78344. */
  78345. private _loadExtensions;
  78346. /**
  78347. * Creates a glTF Exporter instance, which can accept optional exporter options
  78348. * @param babylonScene Babylon scene object
  78349. * @param options Options to modify the behavior of the exporter
  78350. */
  78351. constructor(babylonScene: Scene, options?: IExportOptions);
  78352. dispose(): void;
  78353. /**
  78354. * Registers a glTF exporter extension
  78355. * @param name Name of the extension to export
  78356. * @param factory The factory function that creates the exporter extension
  78357. */
  78358. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  78359. /**
  78360. * Un-registers an exporter extension
  78361. * @param name The name fo the exporter extension
  78362. * @returns A boolean indicating whether the extension has been un-registered
  78363. */
  78364. static UnregisterExtension(name: string): boolean;
  78365. /**
  78366. * Lazy load a local engine
  78367. */
  78368. _getLocalEngine(): Engine;
  78369. private reorderIndicesBasedOnPrimitiveMode;
  78370. /**
  78371. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  78372. * clock-wise during export to glTF
  78373. * @param submesh BabylonJS submesh
  78374. * @param primitiveMode Primitive mode of the mesh
  78375. * @param sideOrientation the winding order of the submesh
  78376. * @param vertexBufferKind The type of vertex attribute
  78377. * @param meshAttributeArray The vertex attribute data
  78378. * @param byteOffset The offset to the binary data
  78379. * @param binaryWriter The binary data for the glTF file
  78380. * @param convertToRightHandedSystem Converts the values to right-handed
  78381. */
  78382. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  78383. /**
  78384. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  78385. * clock-wise during export to glTF
  78386. * @param submesh BabylonJS submesh
  78387. * @param primitiveMode Primitive mode of the mesh
  78388. * @param sideOrientation the winding order of the submesh
  78389. * @param vertexBufferKind The type of vertex attribute
  78390. * @param meshAttributeArray The vertex attribute data
  78391. * @param byteOffset The offset to the binary data
  78392. * @param binaryWriter The binary data for the glTF file
  78393. * @param convertToRightHandedSystem Converts the values to right-handed
  78394. */
  78395. private reorderTriangleFillMode;
  78396. /**
  78397. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  78398. * clock-wise during export to glTF
  78399. * @param submesh BabylonJS submesh
  78400. * @param primitiveMode Primitive mode of the mesh
  78401. * @param sideOrientation the winding order of the submesh
  78402. * @param vertexBufferKind The type of vertex attribute
  78403. * @param meshAttributeArray The vertex attribute data
  78404. * @param byteOffset The offset to the binary data
  78405. * @param binaryWriter The binary data for the glTF file
  78406. * @param convertToRightHandedSystem Converts the values to right-handed
  78407. */
  78408. private reorderTriangleStripDrawMode;
  78409. /**
  78410. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  78411. * clock-wise during export to glTF
  78412. * @param submesh BabylonJS submesh
  78413. * @param primitiveMode Primitive mode of the mesh
  78414. * @param sideOrientation the winding order of the submesh
  78415. * @param vertexBufferKind The type of vertex attribute
  78416. * @param meshAttributeArray The vertex attribute data
  78417. * @param byteOffset The offset to the binary data
  78418. * @param binaryWriter The binary data for the glTF file
  78419. * @param convertToRightHandedSystem Converts the values to right-handed
  78420. */
  78421. private reorderTriangleFanMode;
  78422. /**
  78423. * Writes the vertex attribute data to binary
  78424. * @param vertices The vertices to write to the binary writer
  78425. * @param byteOffset The offset into the binary writer to overwrite binary data
  78426. * @param vertexAttributeKind The vertex attribute type
  78427. * @param meshAttributeArray The vertex attribute data
  78428. * @param binaryWriter The writer containing the binary data
  78429. * @param convertToRightHandedSystem Converts the values to right-handed
  78430. */
  78431. private writeVertexAttributeData;
  78432. /**
  78433. * Writes mesh attribute data to a data buffer
  78434. * Returns the bytelength of the data
  78435. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78436. * @param meshAttributeArray Array containing the attribute data
  78437. * @param binaryWriter The buffer to write the binary data to
  78438. * @param indices Used to specify the order of the vertex data
  78439. * @param convertToRightHandedSystem Converts the values to right-handed
  78440. */
  78441. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78442. /**
  78443. * Generates glTF json data
  78444. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78445. * @param glTFPrefix Text to use when prefixing a glTF file
  78446. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78447. * @returns json data as string
  78448. */
  78449. private generateJSON;
  78450. /**
  78451. * Generates data for .gltf and .bin files based on the glTF prefix string
  78452. * @param glTFPrefix Text to use when prefixing a glTF file
  78453. * @param dispose Dispose the exporter
  78454. * @returns GLTFData with glTF file data
  78455. */
  78456. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78457. /**
  78458. * Creates a binary buffer for glTF
  78459. * @returns array buffer for binary data
  78460. */
  78461. private _generateBinaryAsync;
  78462. /**
  78463. * Pads the number to a multiple of 4
  78464. * @param num number to pad
  78465. * @returns padded number
  78466. */
  78467. private _getPadding;
  78468. /**
  78469. * @hidden
  78470. */
  78471. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78472. /**
  78473. * Sets the TRS for each node
  78474. * @param node glTF Node for storing the transformation data
  78475. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78476. * @param convertToRightHandedSystem Converts the values to right-handed
  78477. */
  78478. private setNodeTransformation;
  78479. private getVertexBufferFromMesh;
  78480. /**
  78481. * Creates a bufferview based on the vertices type for the Babylon mesh
  78482. * @param kind Indicates the type of vertices data
  78483. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78484. * @param binaryWriter The buffer to write the bufferview data to
  78485. * @param convertToRightHandedSystem Converts the values to right-handed
  78486. */
  78487. private createBufferViewKind;
  78488. /**
  78489. * The primitive mode of the Babylon mesh
  78490. * @param babylonMesh The BabylonJS mesh
  78491. */
  78492. private getMeshPrimitiveMode;
  78493. /**
  78494. * Sets the primitive mode of the glTF mesh primitive
  78495. * @param meshPrimitive glTF mesh primitive
  78496. * @param primitiveMode The primitive mode
  78497. */
  78498. private setPrimitiveMode;
  78499. /**
  78500. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78501. * @param meshPrimitive glTF mesh primitive
  78502. * @param attributeKind vertex attribute
  78503. * @returns boolean specifying if uv coordinates are present
  78504. */
  78505. private setAttributeKind;
  78506. /**
  78507. * Sets data for the primitive attributes of each submesh
  78508. * @param mesh glTF Mesh object to store the primitive attribute information
  78509. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78510. * @param binaryWriter Buffer to write the attribute data to
  78511. * @param convertToRightHandedSystem Converts the values to right-handed
  78512. */
  78513. private setPrimitiveAttributesAsync;
  78514. /**
  78515. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78516. * @param node The node to check
  78517. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78518. */
  78519. private isBabylonCoordinateSystemConvertingNode;
  78520. /**
  78521. * Creates a glTF scene based on the array of meshes
  78522. * Returns the the total byte offset
  78523. * @param babylonScene Babylon scene to get the mesh data from
  78524. * @param binaryWriter Buffer to write binary data to
  78525. */
  78526. private createSceneAsync;
  78527. /**
  78528. * Creates a mapping of Node unique id to node index and handles animations
  78529. * @param babylonScene Babylon Scene
  78530. * @param nodes Babylon transform nodes
  78531. * @param binaryWriter Buffer to write binary data to
  78532. * @returns Node mapping of unique id to index
  78533. */
  78534. private createNodeMapAndAnimationsAsync;
  78535. /**
  78536. * Creates a glTF node from a Babylon mesh
  78537. * @param babylonMesh Source Babylon mesh
  78538. * @param binaryWriter Buffer for storing geometry data
  78539. * @param convertToRightHandedSystem Converts the values to right-handed
  78540. * @param nodeMap Node mapping of unique id to glTF node index
  78541. * @returns glTF node
  78542. */
  78543. private createNodeAsync;
  78544. }
  78545. /**
  78546. * @hidden
  78547. *
  78548. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78549. */
  78550. export class _BinaryWriter {
  78551. /**
  78552. * Array buffer which stores all binary data
  78553. */
  78554. private _arrayBuffer;
  78555. /**
  78556. * View of the array buffer
  78557. */
  78558. private _dataView;
  78559. /**
  78560. * byte offset of data in array buffer
  78561. */
  78562. private _byteOffset;
  78563. /**
  78564. * Initialize binary writer with an initial byte length
  78565. * @param byteLength Initial byte length of the array buffer
  78566. */
  78567. constructor(byteLength: number);
  78568. /**
  78569. * Resize the array buffer to the specified byte length
  78570. * @param byteLength
  78571. */
  78572. private resizeBuffer;
  78573. /**
  78574. * Get an array buffer with the length of the byte offset
  78575. * @returns ArrayBuffer resized to the byte offset
  78576. */
  78577. getArrayBuffer(): ArrayBuffer;
  78578. /**
  78579. * Get the byte offset of the array buffer
  78580. * @returns byte offset
  78581. */
  78582. getByteOffset(): number;
  78583. /**
  78584. * Stores an UInt8 in the array buffer
  78585. * @param entry
  78586. * @param byteOffset If defined, specifies where to set the value as an offset.
  78587. */
  78588. setUInt8(entry: number, byteOffset?: number): void;
  78589. /**
  78590. * Gets an UInt32 in the array buffer
  78591. * @param entry
  78592. * @param byteOffset If defined, specifies where to set the value as an offset.
  78593. */
  78594. getUInt32(byteOffset: number): number;
  78595. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78596. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78597. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78598. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78599. /**
  78600. * Stores a Float32 in the array buffer
  78601. * @param entry
  78602. */
  78603. setFloat32(entry: number, byteOffset?: number): void;
  78604. /**
  78605. * Stores an UInt32 in the array buffer
  78606. * @param entry
  78607. * @param byteOffset If defined, specifies where to set the value as an offset.
  78608. */
  78609. setUInt32(entry: number, byteOffset?: number): void;
  78610. }
  78611. }
  78612. declare module BABYLON.GLTF2.Exporter {
  78613. /**
  78614. * @hidden
  78615. * Interface to store animation data.
  78616. */
  78617. export interface _IAnimationData {
  78618. /**
  78619. * Keyframe data.
  78620. */
  78621. inputs: number[];
  78622. /**
  78623. * Value data.
  78624. */
  78625. outputs: number[][];
  78626. /**
  78627. * Animation interpolation data.
  78628. */
  78629. samplerInterpolation: AnimationSamplerInterpolation;
  78630. /**
  78631. * Minimum keyframe value.
  78632. */
  78633. inputsMin: number;
  78634. /**
  78635. * Maximum keyframe value.
  78636. */
  78637. inputsMax: number;
  78638. }
  78639. /**
  78640. * @hidden
  78641. */
  78642. export interface _IAnimationInfo {
  78643. /**
  78644. * The target channel for the animation
  78645. */
  78646. animationChannelTargetPath: AnimationChannelTargetPath;
  78647. /**
  78648. * The glTF accessor type for the data.
  78649. */
  78650. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78651. /**
  78652. * Specifies if quaternions should be used.
  78653. */
  78654. useQuaternion: boolean;
  78655. }
  78656. /**
  78657. * @hidden
  78658. * Utility class for generating glTF animation data from BabylonJS.
  78659. */
  78660. export class _GLTFAnimation {
  78661. /**
  78662. * @ignore
  78663. *
  78664. * Creates glTF channel animation from BabylonJS animation.
  78665. * @param babylonTransformNode - BabylonJS mesh.
  78666. * @param animation - animation.
  78667. * @param animationChannelTargetPath - The target animation channel.
  78668. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78669. * @param useQuaternion - Specifies if quaternions are used.
  78670. * @returns nullable IAnimationData
  78671. */
  78672. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78673. private static _DeduceAnimationInfo;
  78674. /**
  78675. * @ignore
  78676. * Create node animations from the transform node animations
  78677. * @param babylonNode
  78678. * @param runtimeGLTFAnimation
  78679. * @param idleGLTFAnimations
  78680. * @param nodeMap
  78681. * @param nodes
  78682. * @param binaryWriter
  78683. * @param bufferViews
  78684. * @param accessors
  78685. * @param convertToRightHandedSystem
  78686. * @param animationSampleRate
  78687. */
  78688. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78689. [key: number]: number;
  78690. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78691. /**
  78692. * @ignore
  78693. * Create node animations from the animation groups
  78694. * @param babylonScene
  78695. * @param glTFAnimations
  78696. * @param nodeMap
  78697. * @param nodes
  78698. * @param binaryWriter
  78699. * @param bufferViews
  78700. * @param accessors
  78701. * @param convertToRightHandedSystemMap
  78702. * @param animationSampleRate
  78703. */
  78704. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78705. [key: number]: number;
  78706. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78707. [nodeId: number]: boolean;
  78708. }, animationSampleRate: number): void;
  78709. private static AddAnimation;
  78710. /**
  78711. * Create a baked animation
  78712. * @param babylonTransformNode BabylonJS mesh
  78713. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78714. * @param animationChannelTargetPath animation target channel
  78715. * @param minFrame minimum animation frame
  78716. * @param maxFrame maximum animation frame
  78717. * @param fps frames per second of the animation
  78718. * @param inputs input key frames of the animation
  78719. * @param outputs output key frame data of the animation
  78720. * @param convertToRightHandedSystem converts the values to right-handed
  78721. * @param useQuaternion specifies if quaternions should be used
  78722. */
  78723. private static _CreateBakedAnimation;
  78724. private static _ConvertFactorToVector3OrQuaternion;
  78725. private static _SetInterpolatedValue;
  78726. /**
  78727. * Creates linear animation from the animation key frames
  78728. * @param babylonTransformNode BabylonJS mesh
  78729. * @param animation BabylonJS animation
  78730. * @param animationChannelTargetPath The target animation channel
  78731. * @param frameDelta The difference between the last and first frame of the animation
  78732. * @param inputs Array to store the key frame times
  78733. * @param outputs Array to store the key frame data
  78734. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78735. * @param useQuaternion Specifies if quaternions are used in the animation
  78736. */
  78737. private static _CreateLinearOrStepAnimation;
  78738. /**
  78739. * Creates cubic spline animation from the animation key frames
  78740. * @param babylonTransformNode BabylonJS mesh
  78741. * @param animation BabylonJS animation
  78742. * @param animationChannelTargetPath The target animation channel
  78743. * @param frameDelta The difference between the last and first frame of the animation
  78744. * @param inputs Array to store the key frame times
  78745. * @param outputs Array to store the key frame data
  78746. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78747. * @param useQuaternion Specifies if quaternions are used in the animation
  78748. */
  78749. private static _CreateCubicSplineAnimation;
  78750. private static _GetBasePositionRotationOrScale;
  78751. /**
  78752. * Adds a key frame value
  78753. * @param keyFrame
  78754. * @param animation
  78755. * @param outputs
  78756. * @param animationChannelTargetPath
  78757. * @param basePositionRotationOrScale
  78758. * @param convertToRightHandedSystem
  78759. * @param useQuaternion
  78760. */
  78761. private static _AddKeyframeValue;
  78762. /**
  78763. * Determine the interpolation based on the key frames
  78764. * @param keyFrames
  78765. * @param animationChannelTargetPath
  78766. * @param useQuaternion
  78767. */
  78768. private static _DeduceInterpolation;
  78769. /**
  78770. * Adds an input tangent or output tangent to the output data
  78771. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78772. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78773. * @param outputs The animation data by keyframe
  78774. * @param animationChannelTargetPath The target animation channel
  78775. * @param interpolation The interpolation type
  78776. * @param keyFrame The key frame with the animation data
  78777. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78778. * @param useQuaternion Specifies if quaternions are used
  78779. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78780. */
  78781. private static AddSplineTangent;
  78782. /**
  78783. * Get the minimum and maximum key frames' frame values
  78784. * @param keyFrames animation key frames
  78785. * @returns the minimum and maximum key frame value
  78786. */
  78787. private static calculateMinMaxKeyFrames;
  78788. }
  78789. }
  78790. declare module BABYLON.GLTF2.Exporter {
  78791. /** @hidden */
  78792. export var textureTransformPixelShader: {
  78793. name: string;
  78794. shader: string;
  78795. };
  78796. }
  78797. declare module BABYLON.GLTF2.Exporter.Extensions {
  78798. /**
  78799. * @hidden
  78800. */
  78801. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78802. private _recordedTextures;
  78803. /** Name of this extension */
  78804. readonly name: string;
  78805. /** Defines whether this extension is enabled */
  78806. enabled: boolean;
  78807. /** Defines whether this extension is required */
  78808. required: boolean;
  78809. /** Reference to the glTF exporter */
  78810. private _wasUsed;
  78811. constructor(exporter: _Exporter);
  78812. dispose(): void;
  78813. /** @hidden */
  78814. get wasUsed(): boolean;
  78815. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78816. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78817. /**
  78818. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78819. * @param babylonTexture
  78820. * @param offset
  78821. * @param rotation
  78822. * @param scale
  78823. * @param scene
  78824. */
  78825. private _textureTransformTextureAsync;
  78826. }
  78827. }
  78828. declare module BABYLON.GLTF2.Exporter.Extensions {
  78829. /**
  78830. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78831. */
  78832. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78833. /** The name of this extension. */
  78834. readonly name: string;
  78835. /** Defines whether this extension is enabled. */
  78836. enabled: boolean;
  78837. /** Defines whether this extension is required */
  78838. required: boolean;
  78839. /** Reference to the glTF exporter */
  78840. private _exporter;
  78841. private _lights;
  78842. /** @hidden */
  78843. constructor(exporter: _Exporter);
  78844. /** @hidden */
  78845. dispose(): void;
  78846. /** @hidden */
  78847. get wasUsed(): boolean;
  78848. /** @hidden */
  78849. onExporting(): void;
  78850. /**
  78851. * Define this method to modify the default behavior when exporting a node
  78852. * @param context The context when exporting the node
  78853. * @param node glTF node
  78854. * @param babylonNode BabylonJS node
  78855. * @param nodeMap Node mapping of unique id to glTF node index
  78856. * @returns nullable INode promise
  78857. */
  78858. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78859. [key: number]: number;
  78860. }): Promise<Nullable<INode>>;
  78861. }
  78862. }
  78863. declare module BABYLON.GLTF2.Exporter.Extensions {
  78864. /**
  78865. * @hidden
  78866. */
  78867. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78868. /** Name of this extension */
  78869. readonly name: string;
  78870. /** Defines whether this extension is enabled */
  78871. enabled: boolean;
  78872. /** Defines whether this extension is required */
  78873. required: boolean;
  78874. /** Reference to the glTF exporter */
  78875. private _textureInfos;
  78876. private _exportedTextures;
  78877. private _wasUsed;
  78878. constructor(exporter: _Exporter);
  78879. dispose(): void;
  78880. /** @hidden */
  78881. get wasUsed(): boolean;
  78882. private _getTextureIndex;
  78883. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78884. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78885. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78886. }
  78887. }
  78888. declare module BABYLON {
  78889. /**
  78890. * Class for generating STL data from a Babylon scene.
  78891. */
  78892. export class STLExport {
  78893. /**
  78894. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78895. * @param meshes list defines the mesh to serialize
  78896. * @param download triggers the automatic download of the file.
  78897. * @param fileName changes the downloads fileName.
  78898. * @param binary changes the STL to a binary type.
  78899. * @param isLittleEndian toggle for binary type exporter.
  78900. * @returns the STL as UTF8 string
  78901. */
  78902. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78903. }
  78904. }
  78905. declare module "babylonjs-gltf2interface" {
  78906. export = BABYLON.GLTF2;
  78907. }
  78908. /**
  78909. * Module for glTF 2.0 Interface
  78910. */
  78911. declare module BABYLON.GLTF2 {
  78912. /**
  78913. * The datatype of the components in the attribute
  78914. */
  78915. const enum AccessorComponentType {
  78916. /**
  78917. * Byte
  78918. */
  78919. BYTE = 5120,
  78920. /**
  78921. * Unsigned Byte
  78922. */
  78923. UNSIGNED_BYTE = 5121,
  78924. /**
  78925. * Short
  78926. */
  78927. SHORT = 5122,
  78928. /**
  78929. * Unsigned Short
  78930. */
  78931. UNSIGNED_SHORT = 5123,
  78932. /**
  78933. * Unsigned Int
  78934. */
  78935. UNSIGNED_INT = 5125,
  78936. /**
  78937. * Float
  78938. */
  78939. FLOAT = 5126,
  78940. }
  78941. /**
  78942. * Specifies if the attirbute is a scalar, vector, or matrix
  78943. */
  78944. const enum AccessorType {
  78945. /**
  78946. * Scalar
  78947. */
  78948. SCALAR = "SCALAR",
  78949. /**
  78950. * Vector2
  78951. */
  78952. VEC2 = "VEC2",
  78953. /**
  78954. * Vector3
  78955. */
  78956. VEC3 = "VEC3",
  78957. /**
  78958. * Vector4
  78959. */
  78960. VEC4 = "VEC4",
  78961. /**
  78962. * Matrix2x2
  78963. */
  78964. MAT2 = "MAT2",
  78965. /**
  78966. * Matrix3x3
  78967. */
  78968. MAT3 = "MAT3",
  78969. /**
  78970. * Matrix4x4
  78971. */
  78972. MAT4 = "MAT4",
  78973. }
  78974. /**
  78975. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78976. */
  78977. const enum AnimationChannelTargetPath {
  78978. /**
  78979. * Translation
  78980. */
  78981. TRANSLATION = "translation",
  78982. /**
  78983. * Rotation
  78984. */
  78985. ROTATION = "rotation",
  78986. /**
  78987. * Scale
  78988. */
  78989. SCALE = "scale",
  78990. /**
  78991. * Weights
  78992. */
  78993. WEIGHTS = "weights",
  78994. }
  78995. /**
  78996. * Interpolation algorithm
  78997. */
  78998. const enum AnimationSamplerInterpolation {
  78999. /**
  79000. * The animated values are linearly interpolated between keyframes
  79001. */
  79002. LINEAR = "LINEAR",
  79003. /**
  79004. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  79005. */
  79006. STEP = "STEP",
  79007. /**
  79008. * The animation's interpolation is computed using a cubic spline with specified tangents
  79009. */
  79010. CUBICSPLINE = "CUBICSPLINE",
  79011. }
  79012. /**
  79013. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79014. */
  79015. const enum CameraType {
  79016. /**
  79017. * A perspective camera containing properties to create a perspective projection matrix
  79018. */
  79019. PERSPECTIVE = "perspective",
  79020. /**
  79021. * An orthographic camera containing properties to create an orthographic projection matrix
  79022. */
  79023. ORTHOGRAPHIC = "orthographic",
  79024. }
  79025. /**
  79026. * The mime-type of the image
  79027. */
  79028. const enum ImageMimeType {
  79029. /**
  79030. * JPEG Mime-type
  79031. */
  79032. JPEG = "image/jpeg",
  79033. /**
  79034. * PNG Mime-type
  79035. */
  79036. PNG = "image/png",
  79037. }
  79038. /**
  79039. * The alpha rendering mode of the material
  79040. */
  79041. const enum MaterialAlphaMode {
  79042. /**
  79043. * The alpha value is ignored and the rendered output is fully opaque
  79044. */
  79045. OPAQUE = "OPAQUE",
  79046. /**
  79047. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  79048. */
  79049. MASK = "MASK",
  79050. /**
  79051. * 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)
  79052. */
  79053. BLEND = "BLEND",
  79054. }
  79055. /**
  79056. * The type of the primitives to render
  79057. */
  79058. const enum MeshPrimitiveMode {
  79059. /**
  79060. * Points
  79061. */
  79062. POINTS = 0,
  79063. /**
  79064. * Lines
  79065. */
  79066. LINES = 1,
  79067. /**
  79068. * Line Loop
  79069. */
  79070. LINE_LOOP = 2,
  79071. /**
  79072. * Line Strip
  79073. */
  79074. LINE_STRIP = 3,
  79075. /**
  79076. * Triangles
  79077. */
  79078. TRIANGLES = 4,
  79079. /**
  79080. * Triangle Strip
  79081. */
  79082. TRIANGLE_STRIP = 5,
  79083. /**
  79084. * Triangle Fan
  79085. */
  79086. TRIANGLE_FAN = 6,
  79087. }
  79088. /**
  79089. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79090. */
  79091. const enum TextureMagFilter {
  79092. /**
  79093. * Nearest
  79094. */
  79095. NEAREST = 9728,
  79096. /**
  79097. * Linear
  79098. */
  79099. LINEAR = 9729,
  79100. }
  79101. /**
  79102. * Minification filter. All valid values correspond to WebGL enums
  79103. */
  79104. const enum TextureMinFilter {
  79105. /**
  79106. * Nearest
  79107. */
  79108. NEAREST = 9728,
  79109. /**
  79110. * Linear
  79111. */
  79112. LINEAR = 9729,
  79113. /**
  79114. * Nearest Mip-Map Nearest
  79115. */
  79116. NEAREST_MIPMAP_NEAREST = 9984,
  79117. /**
  79118. * Linear Mipmap Nearest
  79119. */
  79120. LINEAR_MIPMAP_NEAREST = 9985,
  79121. /**
  79122. * Nearest Mipmap Linear
  79123. */
  79124. NEAREST_MIPMAP_LINEAR = 9986,
  79125. /**
  79126. * Linear Mipmap Linear
  79127. */
  79128. LINEAR_MIPMAP_LINEAR = 9987,
  79129. }
  79130. /**
  79131. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79132. */
  79133. const enum TextureWrapMode {
  79134. /**
  79135. * Clamp to Edge
  79136. */
  79137. CLAMP_TO_EDGE = 33071,
  79138. /**
  79139. * Mirrored Repeat
  79140. */
  79141. MIRRORED_REPEAT = 33648,
  79142. /**
  79143. * Repeat
  79144. */
  79145. REPEAT = 10497,
  79146. }
  79147. /**
  79148. * glTF Property
  79149. */
  79150. interface IProperty {
  79151. /**
  79152. * Dictionary object with extension-specific objects
  79153. */
  79154. extensions?: {
  79155. [key: string]: any;
  79156. };
  79157. /**
  79158. * Application-Specific data
  79159. */
  79160. extras?: any;
  79161. }
  79162. /**
  79163. * glTF Child of Root Property
  79164. */
  79165. interface IChildRootProperty extends IProperty {
  79166. /**
  79167. * The user-defined name of this object
  79168. */
  79169. name?: string;
  79170. }
  79171. /**
  79172. * Indices of those attributes that deviate from their initialization value
  79173. */
  79174. interface IAccessorSparseIndices extends IProperty {
  79175. /**
  79176. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79177. */
  79178. bufferView: number;
  79179. /**
  79180. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79181. */
  79182. byteOffset?: number;
  79183. /**
  79184. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  79185. */
  79186. componentType: AccessorComponentType;
  79187. }
  79188. /**
  79189. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  79190. */
  79191. interface IAccessorSparseValues extends IProperty {
  79192. /**
  79193. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79194. */
  79195. bufferView: number;
  79196. /**
  79197. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79198. */
  79199. byteOffset?: number;
  79200. }
  79201. /**
  79202. * Sparse storage of attributes that deviate from their initialization value
  79203. */
  79204. interface IAccessorSparse extends IProperty {
  79205. /**
  79206. * The number of attributes encoded in this sparse accessor
  79207. */
  79208. count: number;
  79209. /**
  79210. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  79211. */
  79212. indices: IAccessorSparseIndices;
  79213. /**
  79214. * 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
  79215. */
  79216. values: IAccessorSparseValues;
  79217. }
  79218. /**
  79219. * 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
  79220. */
  79221. interface IAccessor extends IChildRootProperty {
  79222. /**
  79223. * The index of the bufferview
  79224. */
  79225. bufferView?: number;
  79226. /**
  79227. * The offset relative to the start of the bufferView in bytes
  79228. */
  79229. byteOffset?: number;
  79230. /**
  79231. * The datatype of components in the attribute
  79232. */
  79233. componentType: AccessorComponentType;
  79234. /**
  79235. * Specifies whether integer data values should be normalized
  79236. */
  79237. normalized?: boolean;
  79238. /**
  79239. * The number of attributes referenced by this accessor
  79240. */
  79241. count: number;
  79242. /**
  79243. * Specifies if the attribute is a scalar, vector, or matrix
  79244. */
  79245. type: AccessorType;
  79246. /**
  79247. * Maximum value of each component in this attribute
  79248. */
  79249. max?: number[];
  79250. /**
  79251. * Minimum value of each component in this attribute
  79252. */
  79253. min?: number[];
  79254. /**
  79255. * Sparse storage of attributes that deviate from their initialization value
  79256. */
  79257. sparse?: IAccessorSparse;
  79258. }
  79259. /**
  79260. * Targets an animation's sampler at a node's property
  79261. */
  79262. interface IAnimationChannel extends IProperty {
  79263. /**
  79264. * The index of a sampler in this animation used to compute the value for the target
  79265. */
  79266. sampler: number;
  79267. /**
  79268. * The index of the node and TRS property to target
  79269. */
  79270. target: IAnimationChannelTarget;
  79271. }
  79272. /**
  79273. * The index of the node and TRS property that an animation channel targets
  79274. */
  79275. interface IAnimationChannelTarget extends IProperty {
  79276. /**
  79277. * The index of the node to target
  79278. */
  79279. node: number;
  79280. /**
  79281. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  79282. */
  79283. path: AnimationChannelTargetPath;
  79284. }
  79285. /**
  79286. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79287. */
  79288. interface IAnimationSampler extends IProperty {
  79289. /**
  79290. * The index of an accessor containing keyframe input values, e.g., time
  79291. */
  79292. input: number;
  79293. /**
  79294. * Interpolation algorithm
  79295. */
  79296. interpolation?: AnimationSamplerInterpolation;
  79297. /**
  79298. * The index of an accessor, containing keyframe output values
  79299. */
  79300. output: number;
  79301. }
  79302. /**
  79303. * A keyframe animation
  79304. */
  79305. interface IAnimation extends IChildRootProperty {
  79306. /**
  79307. * An array of channels, each of which targets an animation's sampler at a node's property
  79308. */
  79309. channels: IAnimationChannel[];
  79310. /**
  79311. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79312. */
  79313. samplers: IAnimationSampler[];
  79314. }
  79315. /**
  79316. * Metadata about the glTF asset
  79317. */
  79318. interface IAsset extends IChildRootProperty {
  79319. /**
  79320. * A copyright message suitable for display to credit the content creator
  79321. */
  79322. copyright?: string;
  79323. /**
  79324. * Tool that generated this glTF model. Useful for debugging
  79325. */
  79326. generator?: string;
  79327. /**
  79328. * The glTF version that this asset targets
  79329. */
  79330. version: string;
  79331. /**
  79332. * The minimum glTF version that this asset targets
  79333. */
  79334. minVersion?: string;
  79335. }
  79336. /**
  79337. * A buffer points to binary geometry, animation, or skins
  79338. */
  79339. interface IBuffer extends IChildRootProperty {
  79340. /**
  79341. * 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
  79342. */
  79343. uri?: string;
  79344. /**
  79345. * The length of the buffer in bytes
  79346. */
  79347. byteLength: number;
  79348. }
  79349. /**
  79350. * A view into a buffer generally representing a subset of the buffer
  79351. */
  79352. interface IBufferView extends IChildRootProperty {
  79353. /**
  79354. * The index of the buffer
  79355. */
  79356. buffer: number;
  79357. /**
  79358. * The offset into the buffer in bytes
  79359. */
  79360. byteOffset?: number;
  79361. /**
  79362. * The lenth of the bufferView in bytes
  79363. */
  79364. byteLength: number;
  79365. /**
  79366. * The stride, in bytes
  79367. */
  79368. byteStride?: number;
  79369. }
  79370. /**
  79371. * An orthographic camera containing properties to create an orthographic projection matrix
  79372. */
  79373. interface ICameraOrthographic extends IProperty {
  79374. /**
  79375. * The floating-point horizontal magnification of the view. Must not be zero
  79376. */
  79377. xmag: number;
  79378. /**
  79379. * The floating-point vertical magnification of the view. Must not be zero
  79380. */
  79381. ymag: number;
  79382. /**
  79383. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  79384. */
  79385. zfar: number;
  79386. /**
  79387. * The floating-point distance to the near clipping plane
  79388. */
  79389. znear: number;
  79390. }
  79391. /**
  79392. * A perspective camera containing properties to create a perspective projection matrix
  79393. */
  79394. interface ICameraPerspective extends IProperty {
  79395. /**
  79396. * The floating-point aspect ratio of the field of view
  79397. */
  79398. aspectRatio?: number;
  79399. /**
  79400. * The floating-point vertical field of view in radians
  79401. */
  79402. yfov: number;
  79403. /**
  79404. * The floating-point distance to the far clipping plane
  79405. */
  79406. zfar?: number;
  79407. /**
  79408. * The floating-point distance to the near clipping plane
  79409. */
  79410. znear: number;
  79411. }
  79412. /**
  79413. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79414. */
  79415. interface ICamera extends IChildRootProperty {
  79416. /**
  79417. * An orthographic camera containing properties to create an orthographic projection matrix
  79418. */
  79419. orthographic?: ICameraOrthographic;
  79420. /**
  79421. * A perspective camera containing properties to create a perspective projection matrix
  79422. */
  79423. perspective?: ICameraPerspective;
  79424. /**
  79425. * Specifies if the camera uses a perspective or orthographic projection
  79426. */
  79427. type: CameraType;
  79428. }
  79429. /**
  79430. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79431. */
  79432. interface IImage extends IChildRootProperty {
  79433. /**
  79434. * 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
  79435. */
  79436. uri?: string;
  79437. /**
  79438. * The image's MIME type
  79439. */
  79440. mimeType?: ImageMimeType;
  79441. /**
  79442. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79443. */
  79444. bufferView?: number;
  79445. }
  79446. /**
  79447. * Material Normal Texture Info
  79448. */
  79449. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79450. /**
  79451. * The scalar multiplier applied to each normal vector of the normal texture
  79452. */
  79453. scale?: number;
  79454. }
  79455. /**
  79456. * Material Occlusion Texture Info
  79457. */
  79458. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79459. /**
  79460. * A scalar multiplier controlling the amount of occlusion applied
  79461. */
  79462. strength?: number;
  79463. }
  79464. /**
  79465. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79466. */
  79467. interface IMaterialPbrMetallicRoughness {
  79468. /**
  79469. * The material's base color factor
  79470. */
  79471. baseColorFactor?: number[];
  79472. /**
  79473. * The base color texture
  79474. */
  79475. baseColorTexture?: ITextureInfo;
  79476. /**
  79477. * The metalness of the material
  79478. */
  79479. metallicFactor?: number;
  79480. /**
  79481. * The roughness of the material
  79482. */
  79483. roughnessFactor?: number;
  79484. /**
  79485. * The metallic-roughness texture
  79486. */
  79487. metallicRoughnessTexture?: ITextureInfo;
  79488. }
  79489. /**
  79490. * The material appearance of a primitive
  79491. */
  79492. interface IMaterial extends IChildRootProperty {
  79493. /**
  79494. * 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
  79495. */
  79496. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79497. /**
  79498. * The normal map texture
  79499. */
  79500. normalTexture?: IMaterialNormalTextureInfo;
  79501. /**
  79502. * The occlusion map texture
  79503. */
  79504. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79505. /**
  79506. * The emissive map texture
  79507. */
  79508. emissiveTexture?: ITextureInfo;
  79509. /**
  79510. * 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
  79511. */
  79512. emissiveFactor?: number[];
  79513. /**
  79514. * The alpha rendering mode of the material
  79515. */
  79516. alphaMode?: MaterialAlphaMode;
  79517. /**
  79518. * The alpha cutoff value of the material
  79519. */
  79520. alphaCutoff?: number;
  79521. /**
  79522. * Specifies whether the material is double sided
  79523. */
  79524. doubleSided?: boolean;
  79525. }
  79526. /**
  79527. * Geometry to be rendered with the given material
  79528. */
  79529. interface IMeshPrimitive extends IProperty {
  79530. /**
  79531. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79532. */
  79533. attributes: {
  79534. [name: string]: number;
  79535. };
  79536. /**
  79537. * The index of the accessor that contains the indices
  79538. */
  79539. indices?: number;
  79540. /**
  79541. * The index of the material to apply to this primitive when rendering
  79542. */
  79543. material?: number;
  79544. /**
  79545. * The type of primitives to render. All valid values correspond to WebGL enums
  79546. */
  79547. mode?: MeshPrimitiveMode;
  79548. /**
  79549. * 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
  79550. */
  79551. targets?: {
  79552. [name: string]: number;
  79553. }[];
  79554. }
  79555. /**
  79556. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79557. */
  79558. interface IMesh extends IChildRootProperty {
  79559. /**
  79560. * An array of primitives, each defining geometry to be rendered with a material
  79561. */
  79562. primitives: IMeshPrimitive[];
  79563. /**
  79564. * Array of weights to be applied to the Morph Targets
  79565. */
  79566. weights?: number[];
  79567. }
  79568. /**
  79569. * A node in the node hierarchy
  79570. */
  79571. interface INode extends IChildRootProperty {
  79572. /**
  79573. * The index of the camera referenced by this node
  79574. */
  79575. camera?: number;
  79576. /**
  79577. * The indices of this node's children
  79578. */
  79579. children?: number[];
  79580. /**
  79581. * The index of the skin referenced by this node
  79582. */
  79583. skin?: number;
  79584. /**
  79585. * A floating-point 4x4 transformation matrix stored in column-major order
  79586. */
  79587. matrix?: number[];
  79588. /**
  79589. * The index of the mesh in this node
  79590. */
  79591. mesh?: number;
  79592. /**
  79593. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79594. */
  79595. rotation?: number[];
  79596. /**
  79597. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79598. */
  79599. scale?: number[];
  79600. /**
  79601. * The node's translation along the x, y, and z axes
  79602. */
  79603. translation?: number[];
  79604. /**
  79605. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79606. */
  79607. weights?: number[];
  79608. }
  79609. /**
  79610. * Texture sampler properties for filtering and wrapping modes
  79611. */
  79612. interface ISampler extends IChildRootProperty {
  79613. /**
  79614. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79615. */
  79616. magFilter?: TextureMagFilter;
  79617. /**
  79618. * Minification filter. All valid values correspond to WebGL enums
  79619. */
  79620. minFilter?: TextureMinFilter;
  79621. /**
  79622. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79623. */
  79624. wrapS?: TextureWrapMode;
  79625. /**
  79626. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79627. */
  79628. wrapT?: TextureWrapMode;
  79629. }
  79630. /**
  79631. * The root nodes of a scene
  79632. */
  79633. interface IScene extends IChildRootProperty {
  79634. /**
  79635. * The indices of each root node
  79636. */
  79637. nodes: number[];
  79638. }
  79639. /**
  79640. * Joints and matrices defining a skin
  79641. */
  79642. interface ISkin extends IChildRootProperty {
  79643. /**
  79644. * 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
  79645. */
  79646. inverseBindMatrices?: number;
  79647. /**
  79648. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79649. */
  79650. skeleton?: number;
  79651. /**
  79652. * 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)
  79653. */
  79654. joints: number[];
  79655. }
  79656. /**
  79657. * A texture and its sampler
  79658. */
  79659. interface ITexture extends IChildRootProperty {
  79660. /**
  79661. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79662. */
  79663. sampler?: number;
  79664. /**
  79665. * The index of the image used by this texture
  79666. */
  79667. source: number;
  79668. }
  79669. /**
  79670. * Reference to a texture
  79671. */
  79672. interface ITextureInfo extends IProperty {
  79673. /**
  79674. * The index of the texture
  79675. */
  79676. index: number;
  79677. /**
  79678. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79679. */
  79680. texCoord?: number;
  79681. }
  79682. /**
  79683. * The root object for a glTF asset
  79684. */
  79685. interface IGLTF extends IProperty {
  79686. /**
  79687. * An array of accessors. An accessor is a typed view into a bufferView
  79688. */
  79689. accessors?: IAccessor[];
  79690. /**
  79691. * An array of keyframe animations
  79692. */
  79693. animations?: IAnimation[];
  79694. /**
  79695. * Metadata about the glTF asset
  79696. */
  79697. asset: IAsset;
  79698. /**
  79699. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79700. */
  79701. buffers?: IBuffer[];
  79702. /**
  79703. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79704. */
  79705. bufferViews?: IBufferView[];
  79706. /**
  79707. * An array of cameras
  79708. */
  79709. cameras?: ICamera[];
  79710. /**
  79711. * Names of glTF extensions used somewhere in this asset
  79712. */
  79713. extensionsUsed?: string[];
  79714. /**
  79715. * Names of glTF extensions required to properly load this asset
  79716. */
  79717. extensionsRequired?: string[];
  79718. /**
  79719. * An array of images. An image defines data used to create a texture
  79720. */
  79721. images?: IImage[];
  79722. /**
  79723. * An array of materials. A material defines the appearance of a primitive
  79724. */
  79725. materials?: IMaterial[];
  79726. /**
  79727. * An array of meshes. A mesh is a set of primitives to be rendered
  79728. */
  79729. meshes?: IMesh[];
  79730. /**
  79731. * An array of nodes
  79732. */
  79733. nodes?: INode[];
  79734. /**
  79735. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79736. */
  79737. samplers?: ISampler[];
  79738. /**
  79739. * The index of the default scene
  79740. */
  79741. scene?: number;
  79742. /**
  79743. * An array of scenes
  79744. */
  79745. scenes?: IScene[];
  79746. /**
  79747. * An array of skins. A skin is defined by joints and matrices
  79748. */
  79749. skins?: ISkin[];
  79750. /**
  79751. * An array of textures
  79752. */
  79753. textures?: ITexture[];
  79754. }
  79755. /**
  79756. * The glTF validation results
  79757. * @ignore
  79758. */
  79759. interface IGLTFValidationResults {
  79760. info: {
  79761. generator: string;
  79762. hasAnimations: boolean;
  79763. hasDefaultScene: boolean;
  79764. hasMaterials: boolean;
  79765. hasMorphTargets: boolean;
  79766. hasSkins: boolean;
  79767. hasTextures: boolean;
  79768. maxAttributesUsed: number;
  79769. primitivesCount: number
  79770. };
  79771. issues: {
  79772. messages: Array<string>;
  79773. numErrors: number;
  79774. numHints: number;
  79775. numInfos: number;
  79776. numWarnings: number;
  79777. truncated: boolean
  79778. };
  79779. mimeType: string;
  79780. uri: string;
  79781. validatedAt: string;
  79782. validatorVersion: string;
  79783. }
  79784. /**
  79785. * The glTF validation options
  79786. */
  79787. interface IGLTFValidationOptions {
  79788. /** Uri to use */
  79789. uri?: string;
  79790. /** Function used to load external resources */
  79791. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79792. /** Boolean indicating that we need to validate accessor data */
  79793. validateAccessorData?: boolean;
  79794. /** max number of issues allowed */
  79795. maxIssues?: number;
  79796. /** Ignored issues */
  79797. ignoredIssues?: Array<string>;
  79798. /** Value to override severy settings */
  79799. severityOverrides?: Object;
  79800. }
  79801. /**
  79802. * The glTF validator object
  79803. * @ignore
  79804. */
  79805. interface IGLTFValidator {
  79806. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79807. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79808. }
  79809. }
  79810. declare module BABYLON {
  79811. /** @hidden */
  79812. export var cellPixelShader: {
  79813. name: string;
  79814. shader: string;
  79815. };
  79816. }
  79817. declare module BABYLON {
  79818. /** @hidden */
  79819. export var cellVertexShader: {
  79820. name: string;
  79821. shader: string;
  79822. };
  79823. }
  79824. declare module BABYLON {
  79825. export class CellMaterial extends BABYLON.PushMaterial {
  79826. private _diffuseTexture;
  79827. diffuseTexture: BABYLON.BaseTexture;
  79828. diffuseColor: BABYLON.Color3;
  79829. _computeHighLevel: boolean;
  79830. computeHighLevel: boolean;
  79831. private _disableLighting;
  79832. disableLighting: boolean;
  79833. private _maxSimultaneousLights;
  79834. maxSimultaneousLights: number;
  79835. constructor(name: string, scene: BABYLON.Scene);
  79836. needAlphaBlending(): boolean;
  79837. needAlphaTesting(): boolean;
  79838. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79839. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79840. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79841. getAnimatables(): BABYLON.IAnimatable[];
  79842. getActiveTextures(): BABYLON.BaseTexture[];
  79843. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79844. dispose(forceDisposeEffect?: boolean): void;
  79845. getClassName(): string;
  79846. clone(name: string): CellMaterial;
  79847. serialize(): any;
  79848. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79849. }
  79850. }
  79851. declare module BABYLON {
  79852. export class CustomShaderStructure {
  79853. FragmentStore: string;
  79854. VertexStore: string;
  79855. constructor();
  79856. }
  79857. export class ShaderSpecialParts {
  79858. constructor();
  79859. Fragment_Begin: string;
  79860. Fragment_Definitions: string;
  79861. Fragment_MainBegin: string;
  79862. Fragment_Custom_Diffuse: string;
  79863. Fragment_Before_Lights: string;
  79864. Fragment_Before_Fog: string;
  79865. Fragment_Custom_Alpha: string;
  79866. Fragment_Before_FragColor: string;
  79867. Vertex_Begin: string;
  79868. Vertex_Definitions: string;
  79869. Vertex_MainBegin: string;
  79870. Vertex_Before_PositionUpdated: string;
  79871. Vertex_Before_NormalUpdated: string;
  79872. Vertex_After_WorldPosComputed: string;
  79873. Vertex_MainEnd: string;
  79874. }
  79875. export class CustomMaterial extends BABYLON.StandardMaterial {
  79876. static ShaderIndexer: number;
  79877. CustomParts: ShaderSpecialParts;
  79878. _isCreatedShader: boolean;
  79879. _createdShaderName: string;
  79880. _customUniform: string[];
  79881. _newUniforms: string[];
  79882. _newUniformInstances: {
  79883. [name: string]: any;
  79884. };
  79885. _newSamplerInstances: {
  79886. [name: string]: BABYLON.Texture;
  79887. };
  79888. _customAttributes: string[];
  79889. FragmentShader: string;
  79890. VertexShader: string;
  79891. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79892. ReviewUniform(name: string, arr: string[]): string[];
  79893. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79894. constructor(name: string, scene: BABYLON.Scene);
  79895. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79896. AddAttribute(name: string): CustomMaterial;
  79897. Fragment_Begin(shaderPart: string): CustomMaterial;
  79898. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79899. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79900. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79901. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79902. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79903. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79904. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79905. Vertex_Begin(shaderPart: string): CustomMaterial;
  79906. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79907. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79908. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79909. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79910. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  79911. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79912. }
  79913. }
  79914. declare module BABYLON {
  79915. export class ShaderAlebdoParts {
  79916. constructor();
  79917. Fragment_Begin: string;
  79918. Fragment_Definitions: string;
  79919. Fragment_MainBegin: string;
  79920. Fragment_Custom_Albedo: string;
  79921. Fragment_Before_Lights: string;
  79922. Fragment_Custom_MetallicRoughness: string;
  79923. Fragment_Custom_MicroSurface: string;
  79924. Fragment_Before_Fog: string;
  79925. Fragment_Custom_Alpha: string;
  79926. Fragment_Before_FragColor: string;
  79927. Vertex_Begin: string;
  79928. Vertex_Definitions: string;
  79929. Vertex_MainBegin: string;
  79930. Vertex_Before_PositionUpdated: string;
  79931. Vertex_Before_NormalUpdated: string;
  79932. Vertex_After_WorldPosComputed: string;
  79933. Vertex_MainEnd: string;
  79934. }
  79935. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79936. static ShaderIndexer: number;
  79937. CustomParts: ShaderAlebdoParts;
  79938. _isCreatedShader: boolean;
  79939. _createdShaderName: string;
  79940. _customUniform: string[];
  79941. _newUniforms: string[];
  79942. _newUniformInstances: {
  79943. [name: string]: any;
  79944. };
  79945. _newSamplerInstances: {
  79946. [name: string]: BABYLON.Texture;
  79947. };
  79948. _customAttributes: string[];
  79949. FragmentShader: string;
  79950. VertexShader: string;
  79951. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79952. ReviewUniform(name: string, arr: string[]): string[];
  79953. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79954. constructor(name: string, scene: BABYLON.Scene);
  79955. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79956. AddAttribute(name: string): PBRCustomMaterial;
  79957. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79958. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79959. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79960. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79961. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79962. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79963. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79964. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79965. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79966. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79967. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79968. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79969. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79970. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79971. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79972. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  79973. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79974. }
  79975. }
  79976. declare module BABYLON {
  79977. /** @hidden */
  79978. export var firePixelShader: {
  79979. name: string;
  79980. shader: string;
  79981. };
  79982. }
  79983. declare module BABYLON {
  79984. /** @hidden */
  79985. export var fireVertexShader: {
  79986. name: string;
  79987. shader: string;
  79988. };
  79989. }
  79990. declare module BABYLON {
  79991. export class FireMaterial extends BABYLON.PushMaterial {
  79992. private _diffuseTexture;
  79993. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79994. private _distortionTexture;
  79995. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79996. private _opacityTexture;
  79997. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79998. diffuseColor: BABYLON.Color3;
  79999. speed: number;
  80000. private _scaledDiffuse;
  80001. private _lastTime;
  80002. constructor(name: string, scene: BABYLON.Scene);
  80003. needAlphaBlending(): boolean;
  80004. needAlphaTesting(): boolean;
  80005. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80006. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80007. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80008. getAnimatables(): BABYLON.IAnimatable[];
  80009. getActiveTextures(): BABYLON.BaseTexture[];
  80010. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80011. getClassName(): string;
  80012. dispose(forceDisposeEffect?: boolean): void;
  80013. clone(name: string): FireMaterial;
  80014. serialize(): any;
  80015. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  80016. }
  80017. }
  80018. declare module BABYLON {
  80019. /** @hidden */
  80020. export var furPixelShader: {
  80021. name: string;
  80022. shader: string;
  80023. };
  80024. }
  80025. declare module BABYLON {
  80026. /** @hidden */
  80027. export var furVertexShader: {
  80028. name: string;
  80029. shader: string;
  80030. };
  80031. }
  80032. declare module BABYLON {
  80033. export class FurMaterial extends BABYLON.PushMaterial {
  80034. private _diffuseTexture;
  80035. diffuseTexture: BABYLON.BaseTexture;
  80036. private _heightTexture;
  80037. heightTexture: BABYLON.BaseTexture;
  80038. diffuseColor: BABYLON.Color3;
  80039. furLength: number;
  80040. furAngle: number;
  80041. furColor: BABYLON.Color3;
  80042. furOffset: number;
  80043. furSpacing: number;
  80044. furGravity: BABYLON.Vector3;
  80045. furSpeed: number;
  80046. furDensity: number;
  80047. furOcclusion: number;
  80048. furTexture: BABYLON.DynamicTexture;
  80049. private _disableLighting;
  80050. disableLighting: boolean;
  80051. private _maxSimultaneousLights;
  80052. maxSimultaneousLights: number;
  80053. highLevelFur: boolean;
  80054. _meshes: BABYLON.AbstractMesh[];
  80055. private _furTime;
  80056. constructor(name: string, scene: BABYLON.Scene);
  80057. get furTime(): number;
  80058. set furTime(furTime: number);
  80059. needAlphaBlending(): boolean;
  80060. needAlphaTesting(): boolean;
  80061. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80062. updateFur(): void;
  80063. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80064. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80065. getAnimatables(): BABYLON.IAnimatable[];
  80066. getActiveTextures(): BABYLON.BaseTexture[];
  80067. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80068. dispose(forceDisposeEffect?: boolean): void;
  80069. clone(name: string): FurMaterial;
  80070. serialize(): any;
  80071. getClassName(): string;
  80072. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  80073. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  80074. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  80075. }
  80076. }
  80077. declare module BABYLON {
  80078. /** @hidden */
  80079. export var gradientPixelShader: {
  80080. name: string;
  80081. shader: string;
  80082. };
  80083. }
  80084. declare module BABYLON {
  80085. /** @hidden */
  80086. export var gradientVertexShader: {
  80087. name: string;
  80088. shader: string;
  80089. };
  80090. }
  80091. declare module BABYLON {
  80092. export class GradientMaterial extends BABYLON.PushMaterial {
  80093. private _maxSimultaneousLights;
  80094. maxSimultaneousLights: number;
  80095. topColor: BABYLON.Color3;
  80096. topColorAlpha: number;
  80097. bottomColor: BABYLON.Color3;
  80098. bottomColorAlpha: number;
  80099. offset: number;
  80100. scale: number;
  80101. smoothness: number;
  80102. private _disableLighting;
  80103. disableLighting: boolean;
  80104. constructor(name: string, scene: BABYLON.Scene);
  80105. needAlphaBlending(): boolean;
  80106. needAlphaTesting(): boolean;
  80107. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80108. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80109. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80110. getAnimatables(): BABYLON.IAnimatable[];
  80111. dispose(forceDisposeEffect?: boolean): void;
  80112. clone(name: string): GradientMaterial;
  80113. serialize(): any;
  80114. getClassName(): string;
  80115. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  80116. }
  80117. }
  80118. declare module BABYLON {
  80119. /** @hidden */
  80120. export var gridPixelShader: {
  80121. name: string;
  80122. shader: string;
  80123. };
  80124. }
  80125. declare module BABYLON {
  80126. /** @hidden */
  80127. export var gridVertexShader: {
  80128. name: string;
  80129. shader: string;
  80130. };
  80131. }
  80132. declare module BABYLON {
  80133. /**
  80134. * The grid materials allows you to wrap any shape with a grid.
  80135. * Colors are customizable.
  80136. */
  80137. export class GridMaterial extends BABYLON.PushMaterial {
  80138. /**
  80139. * Main color of the grid (e.g. between lines)
  80140. */
  80141. mainColor: BABYLON.Color3;
  80142. /**
  80143. * Color of the grid lines.
  80144. */
  80145. lineColor: BABYLON.Color3;
  80146. /**
  80147. * The scale of the grid compared to unit.
  80148. */
  80149. gridRatio: number;
  80150. /**
  80151. * Allows setting an offset for the grid lines.
  80152. */
  80153. gridOffset: BABYLON.Vector3;
  80154. /**
  80155. * The frequency of thicker lines.
  80156. */
  80157. majorUnitFrequency: number;
  80158. /**
  80159. * The visibility of minor units in the grid.
  80160. */
  80161. minorUnitVisibility: number;
  80162. /**
  80163. * The grid opacity outside of the lines.
  80164. */
  80165. opacity: number;
  80166. /**
  80167. * Determine RBG output is premultiplied by alpha value.
  80168. */
  80169. preMultiplyAlpha: boolean;
  80170. private _opacityTexture;
  80171. opacityTexture: BABYLON.BaseTexture;
  80172. private _gridControl;
  80173. /**
  80174. * constructor
  80175. * @param name The name given to the material in order to identify it afterwards.
  80176. * @param scene The scene the material is used in.
  80177. */
  80178. constructor(name: string, scene: BABYLON.Scene);
  80179. /**
  80180. * Returns wehter or not the grid requires alpha blending.
  80181. */
  80182. needAlphaBlending(): boolean;
  80183. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80184. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80185. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80186. /**
  80187. * Dispose the material and its associated resources.
  80188. * @param forceDisposeEffect will also dispose the used effect when true
  80189. */
  80190. dispose(forceDisposeEffect?: boolean): void;
  80191. clone(name: string): GridMaterial;
  80192. serialize(): any;
  80193. getClassName(): string;
  80194. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  80195. }
  80196. }
  80197. declare module BABYLON {
  80198. /** @hidden */
  80199. export var lavaPixelShader: {
  80200. name: string;
  80201. shader: string;
  80202. };
  80203. }
  80204. declare module BABYLON {
  80205. /** @hidden */
  80206. export var lavaVertexShader: {
  80207. name: string;
  80208. shader: string;
  80209. };
  80210. }
  80211. declare module BABYLON {
  80212. export class LavaMaterial extends BABYLON.PushMaterial {
  80213. private _diffuseTexture;
  80214. diffuseTexture: BABYLON.BaseTexture;
  80215. noiseTexture: BABYLON.BaseTexture;
  80216. fogColor: BABYLON.Color3;
  80217. speed: number;
  80218. movingSpeed: number;
  80219. lowFrequencySpeed: number;
  80220. fogDensity: number;
  80221. private _lastTime;
  80222. diffuseColor: BABYLON.Color3;
  80223. private _disableLighting;
  80224. disableLighting: boolean;
  80225. private _unlit;
  80226. unlit: boolean;
  80227. private _maxSimultaneousLights;
  80228. maxSimultaneousLights: number;
  80229. private _scaledDiffuse;
  80230. constructor(name: string, scene: BABYLON.Scene);
  80231. needAlphaBlending(): boolean;
  80232. needAlphaTesting(): boolean;
  80233. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80234. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80235. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80236. getAnimatables(): BABYLON.IAnimatable[];
  80237. getActiveTextures(): BABYLON.BaseTexture[];
  80238. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80239. dispose(forceDisposeEffect?: boolean): void;
  80240. clone(name: string): LavaMaterial;
  80241. serialize(): any;
  80242. getClassName(): string;
  80243. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  80244. }
  80245. }
  80246. declare module BABYLON {
  80247. /** @hidden */
  80248. export var mixPixelShader: {
  80249. name: string;
  80250. shader: string;
  80251. };
  80252. }
  80253. declare module BABYLON {
  80254. /** @hidden */
  80255. export var mixVertexShader: {
  80256. name: string;
  80257. shader: string;
  80258. };
  80259. }
  80260. declare module BABYLON {
  80261. export class MixMaterial extends BABYLON.PushMaterial {
  80262. /**
  80263. * Mix textures
  80264. */
  80265. private _mixTexture1;
  80266. mixTexture1: BABYLON.BaseTexture;
  80267. private _mixTexture2;
  80268. mixTexture2: BABYLON.BaseTexture;
  80269. /**
  80270. * Diffuse textures
  80271. */
  80272. private _diffuseTexture1;
  80273. diffuseTexture1: BABYLON.Texture;
  80274. private _diffuseTexture2;
  80275. diffuseTexture2: BABYLON.Texture;
  80276. private _diffuseTexture3;
  80277. diffuseTexture3: BABYLON.Texture;
  80278. private _diffuseTexture4;
  80279. diffuseTexture4: BABYLON.Texture;
  80280. private _diffuseTexture5;
  80281. diffuseTexture5: BABYLON.Texture;
  80282. private _diffuseTexture6;
  80283. diffuseTexture6: BABYLON.Texture;
  80284. private _diffuseTexture7;
  80285. diffuseTexture7: BABYLON.Texture;
  80286. private _diffuseTexture8;
  80287. diffuseTexture8: BABYLON.Texture;
  80288. /**
  80289. * Uniforms
  80290. */
  80291. diffuseColor: BABYLON.Color3;
  80292. specularColor: BABYLON.Color3;
  80293. specularPower: number;
  80294. private _disableLighting;
  80295. disableLighting: boolean;
  80296. private _maxSimultaneousLights;
  80297. maxSimultaneousLights: number;
  80298. constructor(name: string, scene: BABYLON.Scene);
  80299. needAlphaBlending(): boolean;
  80300. needAlphaTesting(): boolean;
  80301. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80302. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80303. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80304. getAnimatables(): BABYLON.IAnimatable[];
  80305. getActiveTextures(): BABYLON.BaseTexture[];
  80306. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80307. dispose(forceDisposeEffect?: boolean): void;
  80308. clone(name: string): MixMaterial;
  80309. serialize(): any;
  80310. getClassName(): string;
  80311. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  80312. }
  80313. }
  80314. declare module BABYLON {
  80315. /** @hidden */
  80316. export var normalPixelShader: {
  80317. name: string;
  80318. shader: string;
  80319. };
  80320. }
  80321. declare module BABYLON {
  80322. /** @hidden */
  80323. export var normalVertexShader: {
  80324. name: string;
  80325. shader: string;
  80326. };
  80327. }
  80328. declare module BABYLON {
  80329. export class NormalMaterial extends BABYLON.PushMaterial {
  80330. private _diffuseTexture;
  80331. diffuseTexture: BABYLON.BaseTexture;
  80332. diffuseColor: BABYLON.Color3;
  80333. private _disableLighting;
  80334. disableLighting: boolean;
  80335. private _maxSimultaneousLights;
  80336. maxSimultaneousLights: number;
  80337. constructor(name: string, scene: BABYLON.Scene);
  80338. needAlphaBlending(): boolean;
  80339. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80340. needAlphaTesting(): boolean;
  80341. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80342. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80343. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80344. getAnimatables(): BABYLON.IAnimatable[];
  80345. getActiveTextures(): BABYLON.BaseTexture[];
  80346. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80347. dispose(forceDisposeEffect?: boolean): void;
  80348. clone(name: string): NormalMaterial;
  80349. serialize(): any;
  80350. getClassName(): string;
  80351. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  80352. }
  80353. }
  80354. declare module BABYLON {
  80355. /** @hidden */
  80356. export var shadowOnlyPixelShader: {
  80357. name: string;
  80358. shader: string;
  80359. };
  80360. }
  80361. declare module BABYLON {
  80362. /** @hidden */
  80363. export var shadowOnlyVertexShader: {
  80364. name: string;
  80365. shader: string;
  80366. };
  80367. }
  80368. declare module BABYLON {
  80369. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  80370. private _activeLight;
  80371. constructor(name: string, scene: BABYLON.Scene);
  80372. shadowColor: BABYLON.Color3;
  80373. needAlphaBlending(): boolean;
  80374. needAlphaTesting(): boolean;
  80375. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80376. get activeLight(): BABYLON.IShadowLight;
  80377. set activeLight(light: BABYLON.IShadowLight);
  80378. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80379. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80380. clone(name: string): ShadowOnlyMaterial;
  80381. serialize(): any;
  80382. getClassName(): string;
  80383. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  80384. }
  80385. }
  80386. declare module BABYLON {
  80387. /** @hidden */
  80388. export var simplePixelShader: {
  80389. name: string;
  80390. shader: string;
  80391. };
  80392. }
  80393. declare module BABYLON {
  80394. /** @hidden */
  80395. export var simpleVertexShader: {
  80396. name: string;
  80397. shader: string;
  80398. };
  80399. }
  80400. declare module BABYLON {
  80401. export class SimpleMaterial extends BABYLON.PushMaterial {
  80402. private _diffuseTexture;
  80403. diffuseTexture: BABYLON.BaseTexture;
  80404. diffuseColor: BABYLON.Color3;
  80405. private _disableLighting;
  80406. disableLighting: boolean;
  80407. private _maxSimultaneousLights;
  80408. maxSimultaneousLights: number;
  80409. constructor(name: string, scene: BABYLON.Scene);
  80410. needAlphaBlending(): boolean;
  80411. needAlphaTesting(): boolean;
  80412. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80413. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80414. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80415. getAnimatables(): BABYLON.IAnimatable[];
  80416. getActiveTextures(): BABYLON.BaseTexture[];
  80417. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80418. dispose(forceDisposeEffect?: boolean): void;
  80419. clone(name: string): SimpleMaterial;
  80420. serialize(): any;
  80421. getClassName(): string;
  80422. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  80423. }
  80424. }
  80425. declare module BABYLON {
  80426. /** @hidden */
  80427. export var skyPixelShader: {
  80428. name: string;
  80429. shader: string;
  80430. };
  80431. }
  80432. declare module BABYLON {
  80433. /** @hidden */
  80434. export var skyVertexShader: {
  80435. name: string;
  80436. shader: string;
  80437. };
  80438. }
  80439. declare module BABYLON {
  80440. /**
  80441. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80442. * @see https://doc.babylonjs.com/extensions/sky
  80443. */
  80444. export class SkyMaterial extends BABYLON.PushMaterial {
  80445. /**
  80446. * Defines the overall luminance of sky in interval ]0, 1[.
  80447. */
  80448. luminance: number;
  80449. /**
  80450. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80451. */
  80452. turbidity: number;
  80453. /**
  80454. * Defines the sky appearance (light intensity).
  80455. */
  80456. rayleigh: number;
  80457. /**
  80458. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80459. */
  80460. mieCoefficient: number;
  80461. /**
  80462. * Defines the amount of haze particles following the Mie scattering theory.
  80463. */
  80464. mieDirectionalG: number;
  80465. /**
  80466. * Defines the distance of the sun according to the active scene camera.
  80467. */
  80468. distance: number;
  80469. /**
  80470. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80471. * "inclined".
  80472. */
  80473. inclination: number;
  80474. /**
  80475. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80476. * an object direction and a reference direction.
  80477. */
  80478. azimuth: number;
  80479. /**
  80480. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80481. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80482. */
  80483. sunPosition: BABYLON.Vector3;
  80484. /**
  80485. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80486. * .sunPosition property.
  80487. */
  80488. useSunPosition: boolean;
  80489. /**
  80490. * Defines an offset vector used to get a horizon offset.
  80491. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80492. */
  80493. cameraOffset: BABYLON.Vector3;
  80494. private _cameraPosition;
  80495. /**
  80496. * Instantiates a new sky material.
  80497. * This material allows to create dynamic and texture free
  80498. * effects for skyboxes by taking care of the atmosphere state.
  80499. * @see https://doc.babylonjs.com/extensions/sky
  80500. * @param name Define the name of the material in the scene
  80501. * @param scene Define the scene the material belong to
  80502. */
  80503. constructor(name: string, scene: BABYLON.Scene);
  80504. /**
  80505. * Specifies if the material will require alpha blending
  80506. * @returns a boolean specifying if alpha blending is needed
  80507. */
  80508. needAlphaBlending(): boolean;
  80509. /**
  80510. * Specifies if this material should be rendered in alpha test mode
  80511. * @returns false as the sky material doesn't need alpha testing.
  80512. */
  80513. needAlphaTesting(): boolean;
  80514. /**
  80515. * Get the texture used for alpha test purpose.
  80516. * @returns null as the sky material has no texture.
  80517. */
  80518. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80519. /**
  80520. * Get if the submesh is ready to be used and all its information available.
  80521. * Child classes can use it to update shaders
  80522. * @param mesh defines the mesh to check
  80523. * @param subMesh defines which submesh to check
  80524. * @param useInstances specifies that instances should be used
  80525. * @returns a boolean indicating that the submesh is ready or not
  80526. */
  80527. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80528. /**
  80529. * Binds the submesh to this material by preparing the effect and shader to draw
  80530. * @param world defines the world transformation matrix
  80531. * @param mesh defines the mesh containing the submesh
  80532. * @param subMesh defines the submesh to bind the material to
  80533. */
  80534. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80535. /**
  80536. * Get the list of animatables in the material.
  80537. * @returns the list of animatables object used in the material
  80538. */
  80539. getAnimatables(): BABYLON.IAnimatable[];
  80540. /**
  80541. * Disposes the material
  80542. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80543. */
  80544. dispose(forceDisposeEffect?: boolean): void;
  80545. /**
  80546. * Makes a duplicate of the material, and gives it a new name
  80547. * @param name defines the new name for the duplicated material
  80548. * @returns the cloned material
  80549. */
  80550. clone(name: string): SkyMaterial;
  80551. /**
  80552. * Serializes this material in a JSON representation
  80553. * @returns the serialized material object
  80554. */
  80555. serialize(): any;
  80556. /**
  80557. * Gets the current class name of the material e.g. "SkyMaterial"
  80558. * Mainly use in serialization.
  80559. * @returns the class name
  80560. */
  80561. getClassName(): string;
  80562. /**
  80563. * Creates a sky material from parsed material data
  80564. * @param source defines the JSON representation of the material
  80565. * @param scene defines the hosting scene
  80566. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80567. * @returns a new sky material
  80568. */
  80569. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80570. }
  80571. }
  80572. declare module BABYLON {
  80573. /** @hidden */
  80574. export var terrainPixelShader: {
  80575. name: string;
  80576. shader: string;
  80577. };
  80578. }
  80579. declare module BABYLON {
  80580. /** @hidden */
  80581. export var terrainVertexShader: {
  80582. name: string;
  80583. shader: string;
  80584. };
  80585. }
  80586. declare module BABYLON {
  80587. export class TerrainMaterial extends BABYLON.PushMaterial {
  80588. private _mixTexture;
  80589. mixTexture: BABYLON.BaseTexture;
  80590. private _diffuseTexture1;
  80591. diffuseTexture1: BABYLON.Texture;
  80592. private _diffuseTexture2;
  80593. diffuseTexture2: BABYLON.Texture;
  80594. private _diffuseTexture3;
  80595. diffuseTexture3: BABYLON.Texture;
  80596. private _bumpTexture1;
  80597. bumpTexture1: BABYLON.Texture;
  80598. private _bumpTexture2;
  80599. bumpTexture2: BABYLON.Texture;
  80600. private _bumpTexture3;
  80601. bumpTexture3: BABYLON.Texture;
  80602. diffuseColor: BABYLON.Color3;
  80603. specularColor: BABYLON.Color3;
  80604. specularPower: number;
  80605. private _disableLighting;
  80606. disableLighting: boolean;
  80607. private _maxSimultaneousLights;
  80608. maxSimultaneousLights: number;
  80609. constructor(name: string, scene: BABYLON.Scene);
  80610. needAlphaBlending(): boolean;
  80611. needAlphaTesting(): boolean;
  80612. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80613. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80614. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80615. getAnimatables(): BABYLON.IAnimatable[];
  80616. getActiveTextures(): BABYLON.BaseTexture[];
  80617. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80618. dispose(forceDisposeEffect?: boolean): void;
  80619. clone(name: string): TerrainMaterial;
  80620. serialize(): any;
  80621. getClassName(): string;
  80622. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80623. }
  80624. }
  80625. declare module BABYLON {
  80626. /** @hidden */
  80627. export var triplanarPixelShader: {
  80628. name: string;
  80629. shader: string;
  80630. };
  80631. }
  80632. declare module BABYLON {
  80633. /** @hidden */
  80634. export var triplanarVertexShader: {
  80635. name: string;
  80636. shader: string;
  80637. };
  80638. }
  80639. declare module BABYLON {
  80640. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80641. mixTexture: BABYLON.BaseTexture;
  80642. private _diffuseTextureX;
  80643. diffuseTextureX: BABYLON.BaseTexture;
  80644. private _diffuseTextureY;
  80645. diffuseTextureY: BABYLON.BaseTexture;
  80646. private _diffuseTextureZ;
  80647. diffuseTextureZ: BABYLON.BaseTexture;
  80648. private _normalTextureX;
  80649. normalTextureX: BABYLON.BaseTexture;
  80650. private _normalTextureY;
  80651. normalTextureY: BABYLON.BaseTexture;
  80652. private _normalTextureZ;
  80653. normalTextureZ: BABYLON.BaseTexture;
  80654. tileSize: number;
  80655. diffuseColor: BABYLON.Color3;
  80656. specularColor: BABYLON.Color3;
  80657. specularPower: number;
  80658. private _disableLighting;
  80659. disableLighting: boolean;
  80660. private _maxSimultaneousLights;
  80661. maxSimultaneousLights: number;
  80662. constructor(name: string, scene: BABYLON.Scene);
  80663. needAlphaBlending(): boolean;
  80664. needAlphaTesting(): boolean;
  80665. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80666. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80667. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80668. getAnimatables(): BABYLON.IAnimatable[];
  80669. getActiveTextures(): BABYLON.BaseTexture[];
  80670. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80671. dispose(forceDisposeEffect?: boolean): void;
  80672. clone(name: string): TriPlanarMaterial;
  80673. serialize(): any;
  80674. getClassName(): string;
  80675. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80676. }
  80677. }
  80678. declare module BABYLON {
  80679. /** @hidden */
  80680. export var waterPixelShader: {
  80681. name: string;
  80682. shader: string;
  80683. };
  80684. }
  80685. declare module BABYLON {
  80686. /** @hidden */
  80687. export var waterVertexShader: {
  80688. name: string;
  80689. shader: string;
  80690. };
  80691. }
  80692. declare module BABYLON {
  80693. export class WaterMaterial extends BABYLON.PushMaterial {
  80694. renderTargetSize: BABYLON.Vector2;
  80695. private _bumpTexture;
  80696. bumpTexture: BABYLON.BaseTexture;
  80697. diffuseColor: BABYLON.Color3;
  80698. specularColor: BABYLON.Color3;
  80699. specularPower: number;
  80700. private _disableLighting;
  80701. disableLighting: boolean;
  80702. private _maxSimultaneousLights;
  80703. maxSimultaneousLights: number;
  80704. /**
  80705. * @param {number}: Represents the wind force
  80706. */
  80707. windForce: number;
  80708. /**
  80709. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80710. */
  80711. windDirection: BABYLON.Vector2;
  80712. /**
  80713. * @param {number}: Wave height, represents the height of the waves
  80714. */
  80715. waveHeight: number;
  80716. /**
  80717. * @param {number}: Bump height, represents the bump height related to the bump map
  80718. */
  80719. bumpHeight: number;
  80720. /**
  80721. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80722. */
  80723. private _bumpSuperimpose;
  80724. bumpSuperimpose: boolean;
  80725. /**
  80726. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80727. */
  80728. private _fresnelSeparate;
  80729. fresnelSeparate: boolean;
  80730. /**
  80731. * @param {boolean}: bump Waves modify the reflection.
  80732. */
  80733. private _bumpAffectsReflection;
  80734. bumpAffectsReflection: boolean;
  80735. /**
  80736. * @param {number}: The water color blended with the refraction (near)
  80737. */
  80738. waterColor: BABYLON.Color3;
  80739. /**
  80740. * @param {number}: The blend factor related to the water color
  80741. */
  80742. colorBlendFactor: number;
  80743. /**
  80744. * @param {number}: The water color blended with the reflection (far)
  80745. */
  80746. waterColor2: BABYLON.Color3;
  80747. /**
  80748. * @param {number}: The blend factor related to the water color (reflection, far)
  80749. */
  80750. colorBlendFactor2: number;
  80751. /**
  80752. * @param {number}: Represents the maximum length of a wave
  80753. */
  80754. waveLength: number;
  80755. /**
  80756. * @param {number}: Defines the waves speed
  80757. */
  80758. waveSpeed: number;
  80759. /**
  80760. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80761. * will avoid calculating useless pixels in the pixel shader of the water material.
  80762. */
  80763. disableClipPlane: boolean;
  80764. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80765. private _mesh;
  80766. private _refractionRTT;
  80767. private _reflectionRTT;
  80768. private _reflectionTransform;
  80769. private _lastTime;
  80770. private _lastDeltaTime;
  80771. private _useLogarithmicDepth;
  80772. private _waitingRenderList;
  80773. private _imageProcessingConfiguration;
  80774. private _imageProcessingObserver;
  80775. /**
  80776. * Gets a boolean indicating that current material needs to register RTT
  80777. */
  80778. get hasRenderTargetTextures(): boolean;
  80779. /**
  80780. * Constructor
  80781. */
  80782. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80783. get useLogarithmicDepth(): boolean;
  80784. set useLogarithmicDepth(value: boolean);
  80785. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80786. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80787. addToRenderList(node: any): void;
  80788. enableRenderTargets(enable: boolean): void;
  80789. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80790. get renderTargetsEnabled(): boolean;
  80791. needAlphaBlending(): boolean;
  80792. needAlphaTesting(): boolean;
  80793. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80794. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80795. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80796. private _createRenderTargets;
  80797. getAnimatables(): BABYLON.IAnimatable[];
  80798. getActiveTextures(): BABYLON.BaseTexture[];
  80799. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80800. dispose(forceDisposeEffect?: boolean): void;
  80801. clone(name: string): WaterMaterial;
  80802. serialize(): any;
  80803. getClassName(): string;
  80804. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80805. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80806. }
  80807. }
  80808. declare module BABYLON {
  80809. /** @hidden */
  80810. export var asciiartPixelShader: {
  80811. name: string;
  80812. shader: string;
  80813. };
  80814. }
  80815. declare module BABYLON {
  80816. /**
  80817. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80818. *
  80819. * It basically takes care rendering the font front the given font size to a texture.
  80820. * This is used later on in the postprocess.
  80821. */
  80822. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80823. private _font;
  80824. private _text;
  80825. private _charSize;
  80826. /**
  80827. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80828. */
  80829. get charSize(): number;
  80830. /**
  80831. * Create a new instance of the Ascii Art FontTexture class
  80832. * @param name the name of the texture
  80833. * @param font the font to use, use the W3C CSS notation
  80834. * @param text the caracter set to use in the rendering.
  80835. * @param scene the scene that owns the texture
  80836. */
  80837. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80838. /**
  80839. * Gets the max char width of a font.
  80840. * @param font the font to use, use the W3C CSS notation
  80841. * @return the max char width
  80842. */
  80843. private getFontWidth;
  80844. /**
  80845. * Gets the max char height of a font.
  80846. * @param font the font to use, use the W3C CSS notation
  80847. * @return the max char height
  80848. */
  80849. private getFontHeight;
  80850. /**
  80851. * Clones the current AsciiArtTexture.
  80852. * @return the clone of the texture.
  80853. */
  80854. clone(): AsciiArtFontTexture;
  80855. /**
  80856. * Parses a json object representing the texture and returns an instance of it.
  80857. * @param source the source JSON representation
  80858. * @param scene the scene to create the texture for
  80859. * @return the parsed texture
  80860. */
  80861. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80862. }
  80863. /**
  80864. * Option available in the Ascii Art Post Process.
  80865. */
  80866. export interface IAsciiArtPostProcessOptions {
  80867. /**
  80868. * The font to use following the w3c font definition.
  80869. */
  80870. font?: string;
  80871. /**
  80872. * The character set to use in the postprocess.
  80873. */
  80874. characterSet?: string;
  80875. /**
  80876. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80877. * This number is defined between 0 and 1;
  80878. */
  80879. mixToTile?: number;
  80880. /**
  80881. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80882. * This number is defined between 0 and 1;
  80883. */
  80884. mixToNormal?: number;
  80885. }
  80886. /**
  80887. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80888. *
  80889. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80890. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80891. */
  80892. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80893. /**
  80894. * The font texture used to render the char in the post process.
  80895. */
  80896. private _asciiArtFontTexture;
  80897. /**
  80898. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80899. * This number is defined between 0 and 1;
  80900. */
  80901. mixToTile: number;
  80902. /**
  80903. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80904. * This number is defined between 0 and 1;
  80905. */
  80906. mixToNormal: number;
  80907. /**
  80908. * Instantiates a new Ascii Art Post Process.
  80909. * @param name the name to give to the postprocess
  80910. * @camera the camera to apply the post process to.
  80911. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80912. */
  80913. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80914. }
  80915. }
  80916. declare module BABYLON {
  80917. /** @hidden */
  80918. export var digitalrainPixelShader: {
  80919. name: string;
  80920. shader: string;
  80921. };
  80922. }
  80923. declare module BABYLON {
  80924. /**
  80925. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80926. *
  80927. * It basically takes care rendering the font front the given font size to a texture.
  80928. * This is used later on in the postprocess.
  80929. */
  80930. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80931. private _font;
  80932. private _text;
  80933. private _charSize;
  80934. /**
  80935. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80936. */
  80937. get charSize(): number;
  80938. /**
  80939. * Create a new instance of the Digital Rain FontTexture class
  80940. * @param name the name of the texture
  80941. * @param font the font to use, use the W3C CSS notation
  80942. * @param text the caracter set to use in the rendering.
  80943. * @param scene the scene that owns the texture
  80944. */
  80945. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80946. /**
  80947. * Gets the max char width of a font.
  80948. * @param font the font to use, use the W3C CSS notation
  80949. * @return the max char width
  80950. */
  80951. private getFontWidth;
  80952. /**
  80953. * Gets the max char height of a font.
  80954. * @param font the font to use, use the W3C CSS notation
  80955. * @return the max char height
  80956. */
  80957. private getFontHeight;
  80958. /**
  80959. * Clones the current DigitalRainFontTexture.
  80960. * @return the clone of the texture.
  80961. */
  80962. clone(): DigitalRainFontTexture;
  80963. /**
  80964. * Parses a json object representing the texture and returns an instance of it.
  80965. * @param source the source JSON representation
  80966. * @param scene the scene to create the texture for
  80967. * @return the parsed texture
  80968. */
  80969. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80970. }
  80971. /**
  80972. * Option available in the Digital Rain Post Process.
  80973. */
  80974. export interface IDigitalRainPostProcessOptions {
  80975. /**
  80976. * The font to use following the w3c font definition.
  80977. */
  80978. font?: string;
  80979. /**
  80980. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80981. * This number is defined between 0 and 1;
  80982. */
  80983. mixToTile?: number;
  80984. /**
  80985. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80986. * This number is defined between 0 and 1;
  80987. */
  80988. mixToNormal?: number;
  80989. }
  80990. /**
  80991. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80992. *
  80993. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80994. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80995. */
  80996. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80997. /**
  80998. * The font texture used to render the char in the post process.
  80999. */
  81000. private _digitalRainFontTexture;
  81001. /**
  81002. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  81003. * This number is defined between 0 and 1;
  81004. */
  81005. mixToTile: number;
  81006. /**
  81007. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  81008. * This number is defined between 0 and 1;
  81009. */
  81010. mixToNormal: number;
  81011. /**
  81012. * Instantiates a new Digital Rain Post Process.
  81013. * @param name the name to give to the postprocess
  81014. * @camera the camera to apply the post process to.
  81015. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  81016. */
  81017. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  81018. }
  81019. }
  81020. declare module BABYLON {
  81021. /** @hidden */
  81022. export var brickProceduralTexturePixelShader: {
  81023. name: string;
  81024. shader: string;
  81025. };
  81026. }
  81027. declare module BABYLON {
  81028. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  81029. private _numberOfBricksHeight;
  81030. private _numberOfBricksWidth;
  81031. private _jointColor;
  81032. private _brickColor;
  81033. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81034. updateShaderUniforms(): void;
  81035. get numberOfBricksHeight(): number;
  81036. set numberOfBricksHeight(value: number);
  81037. get numberOfBricksWidth(): number;
  81038. set numberOfBricksWidth(value: number);
  81039. get jointColor(): BABYLON.Color3;
  81040. set jointColor(value: BABYLON.Color3);
  81041. get brickColor(): BABYLON.Color3;
  81042. set brickColor(value: BABYLON.Color3);
  81043. /**
  81044. * Serializes this brick procedural texture
  81045. * @returns a serialized brick procedural texture object
  81046. */
  81047. serialize(): any;
  81048. /**
  81049. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  81050. * @param parsedTexture defines parsed texture data
  81051. * @param scene defines the current scene
  81052. * @param rootUrl defines the root URL containing brick procedural texture information
  81053. * @returns a parsed Brick Procedural BABYLON.Texture
  81054. */
  81055. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  81056. }
  81057. }
  81058. declare module BABYLON {
  81059. /** @hidden */
  81060. export var cloudProceduralTexturePixelShader: {
  81061. name: string;
  81062. shader: string;
  81063. };
  81064. }
  81065. declare module BABYLON {
  81066. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  81067. private _skyColor;
  81068. private _cloudColor;
  81069. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81070. updateShaderUniforms(): void;
  81071. get skyColor(): BABYLON.Color4;
  81072. set skyColor(value: BABYLON.Color4);
  81073. get cloudColor(): BABYLON.Color4;
  81074. set cloudColor(value: BABYLON.Color4);
  81075. /**
  81076. * Serializes this cloud procedural texture
  81077. * @returns a serialized cloud procedural texture object
  81078. */
  81079. serialize(): any;
  81080. /**
  81081. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  81082. * @param parsedTexture defines parsed texture data
  81083. * @param scene defines the current scene
  81084. * @param rootUrl defines the root URL containing cloud procedural texture information
  81085. * @returns a parsed Cloud Procedural BABYLON.Texture
  81086. */
  81087. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  81088. }
  81089. }
  81090. declare module BABYLON {
  81091. /** @hidden */
  81092. export var fireProceduralTexturePixelShader: {
  81093. name: string;
  81094. shader: string;
  81095. };
  81096. }
  81097. declare module BABYLON {
  81098. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  81099. private _time;
  81100. private _speed;
  81101. private _autoGenerateTime;
  81102. private _fireColors;
  81103. private _alphaThreshold;
  81104. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81105. updateShaderUniforms(): void;
  81106. render(useCameraPostProcess?: boolean): void;
  81107. static get PurpleFireColors(): BABYLON.Color3[];
  81108. static get GreenFireColors(): BABYLON.Color3[];
  81109. static get RedFireColors(): BABYLON.Color3[];
  81110. static get BlueFireColors(): BABYLON.Color3[];
  81111. get autoGenerateTime(): boolean;
  81112. set autoGenerateTime(value: boolean);
  81113. get fireColors(): BABYLON.Color3[];
  81114. set fireColors(value: BABYLON.Color3[]);
  81115. get time(): number;
  81116. set time(value: number);
  81117. get speed(): BABYLON.Vector2;
  81118. set speed(value: BABYLON.Vector2);
  81119. get alphaThreshold(): number;
  81120. set alphaThreshold(value: number);
  81121. /**
  81122. * Serializes this fire procedural texture
  81123. * @returns a serialized fire procedural texture object
  81124. */
  81125. serialize(): any;
  81126. /**
  81127. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  81128. * @param parsedTexture defines parsed texture data
  81129. * @param scene defines the current scene
  81130. * @param rootUrl defines the root URL containing fire procedural texture information
  81131. * @returns a parsed Fire Procedural BABYLON.Texture
  81132. */
  81133. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  81134. }
  81135. }
  81136. declare module BABYLON {
  81137. /** @hidden */
  81138. export var grassProceduralTexturePixelShader: {
  81139. name: string;
  81140. shader: string;
  81141. };
  81142. }
  81143. declare module BABYLON {
  81144. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  81145. private _grassColors;
  81146. private _groundColor;
  81147. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81148. updateShaderUniforms(): void;
  81149. get grassColors(): BABYLON.Color3[];
  81150. set grassColors(value: BABYLON.Color3[]);
  81151. get groundColor(): BABYLON.Color3;
  81152. set groundColor(value: BABYLON.Color3);
  81153. /**
  81154. * Serializes this grass procedural texture
  81155. * @returns a serialized grass procedural texture object
  81156. */
  81157. serialize(): any;
  81158. /**
  81159. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  81160. * @param parsedTexture defines parsed texture data
  81161. * @param scene defines the current scene
  81162. * @param rootUrl defines the root URL containing grass procedural texture information
  81163. * @returns a parsed Grass Procedural BABYLON.Texture
  81164. */
  81165. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  81166. }
  81167. }
  81168. declare module BABYLON {
  81169. /** @hidden */
  81170. export var marbleProceduralTexturePixelShader: {
  81171. name: string;
  81172. shader: string;
  81173. };
  81174. }
  81175. declare module BABYLON {
  81176. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  81177. private _numberOfTilesHeight;
  81178. private _numberOfTilesWidth;
  81179. private _amplitude;
  81180. private _jointColor;
  81181. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81182. updateShaderUniforms(): void;
  81183. get numberOfTilesHeight(): number;
  81184. set numberOfTilesHeight(value: number);
  81185. get amplitude(): number;
  81186. set amplitude(value: number);
  81187. get numberOfTilesWidth(): number;
  81188. set numberOfTilesWidth(value: number);
  81189. get jointColor(): BABYLON.Color3;
  81190. set jointColor(value: BABYLON.Color3);
  81191. /**
  81192. * Serializes this marble procedural texture
  81193. * @returns a serialized marble procedural texture object
  81194. */
  81195. serialize(): any;
  81196. /**
  81197. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  81198. * @param parsedTexture defines parsed texture data
  81199. * @param scene defines the current scene
  81200. * @param rootUrl defines the root URL containing marble procedural texture information
  81201. * @returns a parsed Marble Procedural BABYLON.Texture
  81202. */
  81203. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  81204. }
  81205. }
  81206. declare module BABYLON {
  81207. /** @hidden */
  81208. export var normalMapProceduralTexturePixelShader: {
  81209. name: string;
  81210. shader: string;
  81211. };
  81212. }
  81213. declare module BABYLON {
  81214. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  81215. private _baseTexture;
  81216. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81217. updateShaderUniforms(): void;
  81218. render(useCameraPostProcess?: boolean): void;
  81219. resize(size: any, generateMipMaps: any): void;
  81220. get baseTexture(): BABYLON.Texture;
  81221. set baseTexture(texture: BABYLON.Texture);
  81222. /**
  81223. * Serializes this normal map procedural texture
  81224. * @returns a serialized normal map procedural texture object
  81225. */
  81226. serialize(): any;
  81227. /**
  81228. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  81229. * @param parsedTexture defines parsed texture data
  81230. * @param scene defines the current scene
  81231. * @param rootUrl defines the root URL containing normal map procedural texture information
  81232. * @returns a parsed Normal Map Procedural BABYLON.Texture
  81233. */
  81234. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  81235. }
  81236. }
  81237. declare module BABYLON {
  81238. /** @hidden */
  81239. export var perlinNoiseProceduralTexturePixelShader: {
  81240. name: string;
  81241. shader: string;
  81242. };
  81243. }
  81244. declare module BABYLON {
  81245. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  81246. time: number;
  81247. timeScale: number;
  81248. translationSpeed: number;
  81249. private _currentTranslation;
  81250. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81251. updateShaderUniforms(): void;
  81252. render(useCameraPostProcess?: boolean): void;
  81253. resize(size: any, generateMipMaps: any): void;
  81254. /**
  81255. * Serializes this perlin noise procedural texture
  81256. * @returns a serialized perlin noise procedural texture object
  81257. */
  81258. serialize(): any;
  81259. /**
  81260. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  81261. * @param parsedTexture defines parsed texture data
  81262. * @param scene defines the current scene
  81263. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  81264. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  81265. */
  81266. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  81267. }
  81268. }
  81269. declare module BABYLON {
  81270. /** @hidden */
  81271. export var roadProceduralTexturePixelShader: {
  81272. name: string;
  81273. shader: string;
  81274. };
  81275. }
  81276. declare module BABYLON {
  81277. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  81278. private _roadColor;
  81279. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81280. updateShaderUniforms(): void;
  81281. get roadColor(): BABYLON.Color3;
  81282. set roadColor(value: BABYLON.Color3);
  81283. /**
  81284. * Serializes this road procedural texture
  81285. * @returns a serialized road procedural texture object
  81286. */
  81287. serialize(): any;
  81288. /**
  81289. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  81290. * @param parsedTexture defines parsed texture data
  81291. * @param scene defines the current scene
  81292. * @param rootUrl defines the root URL containing road procedural texture information
  81293. * @returns a parsed Road Procedural BABYLON.Texture
  81294. */
  81295. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  81296. }
  81297. }
  81298. declare module BABYLON {
  81299. /** @hidden */
  81300. export var starfieldProceduralTexturePixelShader: {
  81301. name: string;
  81302. shader: string;
  81303. };
  81304. }
  81305. declare module BABYLON {
  81306. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  81307. private _time;
  81308. private _alpha;
  81309. private _beta;
  81310. private _zoom;
  81311. private _formuparam;
  81312. private _stepsize;
  81313. private _tile;
  81314. private _brightness;
  81315. private _darkmatter;
  81316. private _distfading;
  81317. private _saturation;
  81318. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81319. updateShaderUniforms(): void;
  81320. get time(): number;
  81321. set time(value: number);
  81322. get alpha(): number;
  81323. set alpha(value: number);
  81324. get beta(): number;
  81325. set beta(value: number);
  81326. get formuparam(): number;
  81327. set formuparam(value: number);
  81328. get stepsize(): number;
  81329. set stepsize(value: number);
  81330. get zoom(): number;
  81331. set zoom(value: number);
  81332. get tile(): number;
  81333. set tile(value: number);
  81334. get brightness(): number;
  81335. set brightness(value: number);
  81336. get darkmatter(): number;
  81337. set darkmatter(value: number);
  81338. get distfading(): number;
  81339. set distfading(value: number);
  81340. get saturation(): number;
  81341. set saturation(value: number);
  81342. /**
  81343. * Serializes this starfield procedural texture
  81344. * @returns a serialized starfield procedural texture object
  81345. */
  81346. serialize(): any;
  81347. /**
  81348. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  81349. * @param parsedTexture defines parsed texture data
  81350. * @param scene defines the current scene
  81351. * @param rootUrl defines the root URL containing startfield procedural texture information
  81352. * @returns a parsed Starfield Procedural BABYLON.Texture
  81353. */
  81354. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  81355. }
  81356. }
  81357. declare module BABYLON {
  81358. /** @hidden */
  81359. export var woodProceduralTexturePixelShader: {
  81360. name: string;
  81361. shader: string;
  81362. };
  81363. }
  81364. declare module BABYLON {
  81365. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  81366. private _ampScale;
  81367. private _woodColor;
  81368. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81369. updateShaderUniforms(): void;
  81370. get ampScale(): number;
  81371. set ampScale(value: number);
  81372. get woodColor(): BABYLON.Color3;
  81373. set woodColor(value: BABYLON.Color3);
  81374. /**
  81375. * Serializes this wood procedural texture
  81376. * @returns a serialized wood procedural texture object
  81377. */
  81378. serialize(): any;
  81379. /**
  81380. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  81381. * @param parsedTexture defines parsed texture data
  81382. * @param scene defines the current scene
  81383. * @param rootUrl defines the root URL containing wood procedural texture information
  81384. * @returns a parsed Wood Procedural BABYLON.Texture
  81385. */
  81386. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  81387. }
  81388. }